]> git.donarmstrong.com Git - lilypond.git/commitdiff
Compatibility function event-chord-wrap!, used in \eventChords
authorDavid Kastrup <dak@gnu.org>
Tue, 14 Feb 2012 20:40:30 +0000 (21:40 +0100)
committerDavid Kastrup <dak@gnu.org>
Wed, 15 Feb 2012 05:45:30 +0000 (06:45 +0100)
ly/music-functions-init.ly
scm/music-functions.scm

index 5afd8e44acaef03cb6e0e68d160e9090868aea6b..4082ea9aec31c76d39422c0e6d8a9ad5a8604186 100644 (file)
@@ -315,7 +315,12 @@ without the need of a specific end spanner.")
         (ly:input-message location (_ "argument endSpanners is not an EventChord: ~a") music)
         music)))
 
-
+eventChords =
+#(define-music-function (parser location music) (ly:music?)
+   (_i "Compatibility function wrapping @code{EventChord} around
+isolated rhythmic events occuring since version 2.15.28, after
+expanding repeat chords @samp{q}.")
+   (event-chord-wrap! music parser))
 
 featherDurations=
 #(define-music-function (parser location factor argument) (ly:moment? ly:music?)
index 361dc92b95617607b3e7eae63982a07f69598cea..9ff13189d22b089586d192d86a33c701abae7577 100644 (file)
@@ -1650,6 +1650,34 @@ recursing into matches themselves."
         (any (lambda (t) (music-is-of-type? m t)) type))
        (lambda (m) (music-is-of-type? m type)))))
 
+(define*-public (event-chord-wrap! music #:optional parser)
+  "Wrap isolated rhythmic events and non-postevent events in
+@var{music} inside of an @code{EventChord}.  If the optional
+@var{parser} argument is given, chord repeats @samp{q} are expanded
+using the default settings.  Otherwise, you need to cater for them
+yourself."
+  (map-some-music
+   (lambda (m)
+     (cond ((music-is-of-type? m 'event-chord)
+           (if (pair? (ly:music-property m 'articulations))
+               (begin
+                 (set! (ly:music-property m 'elements)
+                       (append (ly:music-property m 'elements)
+                               (ly:music-property m 'articulations)))
+                 (set! (ly:music-property m 'articulations) '())))
+           m)
+          ((music-is-of-type? m 'rhythmic-event)
+           (let ((arts (ly:music-property m 'articulations)))
+             (if (pair? arts)
+                 (set! (ly:music-property m 'articulations) '()))
+             (make-event-chord (cons m arts))))
+          (else #f)))
+   (if parser
+       (expand-repeat-chords!
+       (cons 'rhythmic-event
+             (ly:parser-lookup parser '$chord-repeat-events))
+       music)
+       music)))
 
 (define-public (event-chord-notes event-chord)
   "Return a list of all notes from @var{event-chord}."