-#(define-public (default-repeat-chord previous-chord location duration articulations)
- "Copy the previous chord, filter out events which are not notes, set
-the chord duration, add articulations."
- ;; If previous-chord has an length property, then it means that it
- ;; has been processed by a music iterator. In other words, the chord
- ;; has been memorized in an other music block, which is certainly not
- ;; what the user has intended. In that case, raise a warning.
- (if (not (and (ly:music? previous-chord)
- (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))
+chordRepeats =
+#(define-music-function (parser location event-types music)
+ ((list? '()) ly:music?)
+ "Walk through @var{music} putting the notes of the previous chord
+into repeat chords, as well as an optional list of @var{event-types}
+such as @code{#'(string-number-event)}."
+ (expand-repeat-chords! (cons 'rhythmic-event event-types) music))
+
+tabChordRepeats =
+#(define-music-function (parser location event-types music)
+ ((list? '()) ly:music?)
+ "Walk through @var{music} putting the notes, fingerings and string
+numbers of the previous chord into repeat chords, as well as an
+optional list of @var{event-types} such as @code{#'(articulation-event)}."
+ #{ \chordRepeats
+ #(append '(string-number-event fingering-event) event-types)
+ #music
+ #})