From fea33b81da974ff0627843dfc88a00b49cd2323c Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sun, 6 May 2012 17:53:39 +0200 Subject: [PATCH] Let display-music work more consistently with command events and empty chords --- scm/define-music-display-methods.scm | 75 +++++++++++++++++----------- 1 file changed, 45 insertions(+), 30 deletions(-) diff --git a/scm/define-music-display-methods.scm b/scm/define-music-display-methods.scm index 5c7ec677de..6089e25392 100644 --- a/scm/define-music-display-methods.scm +++ b/scm/define-music-display-methods.scm @@ -428,37 +428,52 @@ Otherwise, return #f." (let* ((elements (append (ly:music-property chord 'elements) (ly:music-property chord 'articulations))) - (chord-elements (filter (lambda (m) - (music-is-of-type? m 'rhythmic-event)) - elements)) - (post-events (filter post-event? elements)) (chord-repeat (ly:music-property chord 'duration))) - (cond ((ly:duration? chord-repeat) - (let ((duration (duration->lily-string chord-repeat #:remember #t))) - (format #f "q~a~{~a~^ ~}" - duration - (map-in-order (lambda (music) - (music->lily-string music parser)) - post-events)))) - ((pair? chord-elements) - ;; note_chord_element : '<' (notepitch | drumpitch)* '>" duration post_events - (let ((duration (duration->lily-string (ly:music-property - (car chord-elements) - 'duration) #:remember #t))) - ;; Format duration first so that it does not appear on chord elements - (format #f "< ~{~a ~}>~a~{~a~^ ~}" - (map-in-order (lambda (music) - (music->lily-string music parser)) - chord-elements) - duration - (map-in-order (lambda (music) - (music->lily-string music parser)) - post-events)))) - (else - ;; command_element - (format #f "~{~a~^ ~}" (map-in-order (lambda (music) - (music->lily-string music parser)) - elements)))))) + (call-with-values + (lambda () + (partition (lambda (m) (music-is-of-type? m 'rhythmic-event)) + elements)) + (lambda (chord-elements other-elements) + (cond ((pair? chord-elements) + ;; note_chord_element : + ;; '<' (notepitch | drumpitch)* '>" duration post_events + (let ((duration (duration->lily-string (ly:music-property + (car chord-elements) + 'duration) + #:remember #t))) + ;; Format duration first so that it does not appear on + ;; chord elements + (format #f "< ~{~a ~}>~a~:{~:[-~;~]~a~^ ~}" + (map-in-order (lambda (music) + (music->lily-string music parser)) + chord-elements) + duration + (map-in-order (lambda (music) + (list + (post-event? music) + (music->lily-string music parser))) + other-elements)))) + ((ly:duration? chord-repeat) + (let ((duration (duration->lily-string chord-repeat + #:remember #t))) + (format #f "q~a~:{~:[-~;~]~a~^ ~}" + duration + (map-in-order (lambda (music) + (list + (post-event? music) + (music->lily-string music parser))) + other-elements)))) + + ((and (= 1 (length other-elements)) + (not (post-event? (car other-elements)))) + (format #f (music->lily-string (car other-elements) parser))) + (else + (format #f "< >~:{~:[-~;~]~a~^ ~}" + (map-in-order (lambda (music) + (list + (post-event? music) + (music->lily-string music parser))) + other-elements)))))))) (define-display-method MultiMeasureRestMusic (mmrest parser) (format #f "R~a~{~a~^ ~}" -- 2.39.2