]> git.donarmstrong.com Git - lilypond.git/commitdiff
Fix #1003: chord repetition: copy nothing from previous chord but pitches
authorNicolas Sceaux <nicolas.sceaux@free.fr>
Fri, 29 Jan 2010 18:46:46 +0000 (19:46 +0100)
committerNicolas Sceaux <nicolas.sceaux@free.fr>
Fri, 29 Jan 2010 18:46:46 +0000 (19:46 +0100)
input/regression/chord-repetition.ly
ly/chord-repetition-init.ly

index f84f2807f17bfa821b1f0cdfbde8084fc903b08c..904cbeeeabd924de17ff060719987d2e89d99fde 100644 (file)
@@ -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-|\)
 }
index bea929f4c658a5a8ce6f2682c8abfb4261b4da26..f19e3a10b50d5433168ed4c92bafedf90526599d 100644 (file)
@@ -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)