diff options
author | Nicolas Sceaux <nicolas.sceaux@free.fr> | 2010-01-29 19:46:46 +0100 |
---|---|---|
committer | Nicolas Sceaux <nicolas.sceaux@free.fr> | 2010-01-29 19:46:46 +0100 |
commit | 604d785b55a3a1c536fc537e877253f0c4eaea6c (patch) | |
tree | 3c954b9d65b628763c201331fa8103b382234991 | |
parent | 549bf8cf0149565b312a41f5c7b13e8bb6e53b43 (diff) |
Fix #1003: chord repetition: copy nothing from previous chord but pitches
-rw-r--r-- | input/regression/chord-repetition.ly | 7 | ||||
-rw-r--r-- | ly/chord-repetition-init.ly | 40 |
2 files changed, 21 insertions, 26 deletions
diff --git a/input/regression/chord-repetition.ly b/input/regression/chord-repetition.ly index f84f2807f1..904cbeeeab 100644 --- a/input/regression/chord-repetition.ly +++ b/input/regression/chord-repetition.ly @@ -2,11 +2,12 @@ \header { texidoc = " -A repetition symbol can be used to repeat the previous chord -and save typing. Only note events are copied. +A repetition symbol can be used to repeat the previous chord and save +typing. Only note events are copied: articulations, text scripts, +fingerings, etc are not repeated. " } \relative c' { - <c e g>8\p( q) q4-| q8.\(^"text" q16 q4-|\) + <c-1 e-3 g-5>8\p( q) q4-| q8.\(^"text" q16 q4-|\) } diff --git a/ly/chord-repetition-init.ly b/ly/chord-repetition-init.ly index bea929f4c6..f19e3a10b5 100644 --- a/ly/chord-repetition-init.ly +++ b/ly/chord-repetition-init.ly @@ -29,29 +29,23 @@ the chord duration, add articulations." (null? (ly:music-property previous-chord 'length)))) (ly:input-message location (_ "No memorized chord in music block before chord repetition"))) - (let* ((new-chord (ly:music-deep-copy previous-chord)) - (notes (filter (lambda (event) - (eqv? (ly:music-property event 'name) 'NoteEvent)) - (ly:music-property new-chord 'elements)))) - ;; remove possible cautionary/forced accidentals from notes - (for-each (lambda (note) - (if (eqv? (ly:music-property note 'cautionary) #t) - (set! (ly:music-property note 'cautionary) #f)) - (if (eqv? (ly:music-property note 'force-accidental) #t) - (set! (ly:music-property note 'force-accidental) #f))) - notes) - ;; Add articulations and notes to the new event chord - (set! (ly:music-property new-chord 'elements) - (append! notes articulations)) - ;; Set the duration of each event - (for-each (lambda (event) - (if (ly:duration? (ly:music-property event 'duration)) - (set! (ly:music-property event 'duration) duration))) - (ly:music-property new-chord 'elements)) - ;; Set the new chord origin - (set! (ly:music-property new-chord 'origin) location) - ;; return the new chord - new-chord)) + ;; Instead of copying the previous chord, then removing the + ;; undesired elements (like articulations), a new empty chord is + ;; built. Then, the pitch found in the previous chord are added to + ;; the new chord, without any "decoration" (e.g. cautionary + ;; accidentals, fingerings, text scripts, articulations). + (make-music + 'EventChord + 'origin location + 'elements (append! (filter identity + (map (lambda (event) + (and (eqv? (ly:music-property event 'name) 'NoteEvent) + (make-music + 'NoteEvent + 'pitch (ly:music-property event 'pitch) + 'duration duration))) + (ly:music-property previous-chord 'elements))) + articulations))) #(ly:parser-set-repetition-symbol parser 'q) #(ly:parser-set-repetition-function parser default-repeat-chord) |