Hi, for some reason I wanted a music-function which should end a TextSpanner automagically at the next event which starts a new TextSpanner or the last possible event at all.
Although it needs further testing I already found a glitch I really can't explain or cope with: Sometimes, when the TextSpanner is attached to skip-events, ending them gets confused. It sometimes can be cured, if the skips are devided, i.e. s2 becomes s4 s4. So why???? And how to fix the function, which is inspired by our endSpanners-function. Here the code: \version "2.19.82" endTextSpanners = #(define-music-function (music) (ly:music?) (_i "Terminate a TextSpanner at the last rhythmic-event or at the next rhythmic-event which starts a new TextSpanner, without the need to use @code{\\stopTextSpan}.") (let ((counter 0) (last-rhythmic-ev #f) (end-span-ev-chrd (make-event-chord (list (make-music 'TextSpanEvent 'span-direction 1))))) (map-some-music (lambda (m) (and (or (music-is-of-type? m 'rhythmic-event) (music-is-of-type? m 'skip-event)) (let* ((mus (ly:music-deep-copy m))) (set! last-rhythmic-ev mus) (cond ((and (zero? counter) (pair? (extract-typed-music mus 'text-span-event))) (begin (set! counter (1+ counter)) mus)) ((pair? (extract-typed-music mus 'text-span-event)) (make-sequential-music (list end-span-ev-chrd mus))) (else mus))))) music) (map-some-music (lambda (mc) (and (equal? mc last-rhythmic-ev) (make-sequential-music (list end-span-ev-chrd mc)))) music) (set! counter 0) (set! last-rhythmic-ev #f) music)) %% Only for better viewing \layout { \override TextSpanner.style = #'solid \override TextSpanner.bound-details.left.text = "X" } %% This returns: %% warning: cannot find start of text spanner \endTextSpanners { s2 -\startTextSpan s2 s2 } %% This one works !! \endTextSpanners { s2 -\startTextSpan s4 s s2 } %% This one as well \endTextSpanners { c'2 -\startTextSpan d'2 e'2 } Thanks, Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user