X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fdefine-music-types.scm;h=184b4e54850ad3eb911120d05a40fc71c60ffd5a;hb=9675132431ef8b44d24e8c03f1a846c9620ac5da;hp=a39ad23002b9bf1d4edbd26bf08d7210dc11812b;hpb=3eb0d21c7cac9360c37c3376c8771e6e29c1a588;p=lilypond.git diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index a39ad23002..184b4e5485 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -712,8 +712,8 @@ brackets start and stop.") )) (UnfoldedRepeatedMusic - . ((description . "Repeated music which is fully written -(and played) out.") + . ((description . "Repeated music which is fully written (and +played) out.") (iterator-ctor . ,ly:unfolded-repeat-iterator::constructor) (start-callback . ,ly:repeated-music::first-start) (types . (general-music repeated-music unfolded-repeated-music)) @@ -775,22 +775,44 @@ Syntax: @code{\\\\}") "Create a music object of given name, and set its properties according to @code{music-properties}, a list of alternating property symbols and values. E.g: +@example (make-music 'OverrideProperty 'symbol 'Stem 'grob-property 'thickness - 'grob-value (* 2 1.5))" + 'grob-value (* 2 1.5)) +@end example +Instead of a successive symbol and value, an entry in the list may +also be an alist or a music object in which case its elements, +respectively its @emph{mutable} property list (properties not inherent +to the type of the music object) will get taken. + +The argument list will be interpreted left-to-right, so later entries +override earlier ones." (if (not (symbol? name)) (ly:error (_ "symbol expected: ~S") name)) (let ((props (hashq-ref music-name-to-property-table name '()))) (if (not (pair? props)) (ly:error (_ "cannot find music object: ~S") name)) (let ((m (ly:make-music props))) + (define (alist-set-props lst) + (for-each (lambda (e) + (set! (ly:music-property m (car e)) (cdr e))) + (reverse lst))) (define (set-props mus-props) - (if (and (not (null? mus-props)) - (not (null? (cdr mus-props)))) - (begin - (set! (ly:music-property m (car mus-props)) (cadr mus-props)) - (set-props (cddr mus-props))))) + (if (pair? mus-props) + (let ((e (car mus-props)) + (mus-props (cdr mus-props))) + (cond ((symbol? e) + (set! (ly:music-property m e) (car mus-props)) + (set-props (cdr mus-props))) + ((ly:music? e) + (alist-set-props (ly:music-mutable-properties e)) + (set-props mus-props)) + ((cheap-list? e) + (alist-set-props e) + (set-props mus-props)) + (else + (ly:error (_ "bad make-music argument: ~S") e)))))) (set-props music-properties) m)))