From 604d785b55a3a1c536fc537e877253f0c4eaea6c Mon Sep 17 00:00:00 2001 From: Nicolas Sceaux Date: Fri, 29 Jan 2010 19:46:46 +0100 Subject: [PATCH] Fix #1003: chord repetition: copy nothing from previous chord but pitches --- input/regression/chord-repetition.ly | 7 ++--- 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' { - 8\p( q) q4-| q8.\(^"text" q16 q4-|\) + 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) -- 2.39.2