On 2016-12-19 21:09, Br. Samuel Springuel wrote:
Is there a way to get lyric extenders to appear automatically when
lyrics have been applied to a voice using `\lyricsto`? I know how to
manually get them to appear (with `__`), but I'm wondering if there is a
simple setting that can be changed in an included style file that would
allow me to make the change universally for all file in a particular
project.
Hi Samuel,
you asked at the right time. This will be a major change in one of the
upcoming Lilypond versions: automatic extenders per default.
Unfortunately, the idea is merely two weeks old, and programming is
(almost?) done, but the interface is not yet entirely polished. For the
time being, you might want to use some "testing" code and include the
attached file and prefix all your \lyricmode code with \autoextenders:
\include "autoextenders.ily"
...
words = \autoextenders \lyricmode { ... }
Once the new functionality will arrive in the official Lilypond
distribution, you can simply remove the include, delete all calls of
autoextenders and you should be good to go.
If you find any annoyances, please make sure to let us know on this list
- most likely, any "unexpected behavior" will also pop up with the new
code, and we are eager to find out as soon as possible.
HTH,
Alexander
\version "2.17.11"
#(define (conditional-kill-lyric-extender-callback . args)
(lambda (grob)
(let* ((orig (ly:grob-original grob))
(siblings (ly:spanner-broken-into orig))
(minimum-length
(if (null? args)
(ly:grob-property grob 'minimum-length 0)
(car args)))
(X-extent (ly:stencil-extent (ly:grob-property grob 'stencil
empty-stencil) X))
(natural-length (- (cdr X-extent) (car X-extent))))
(if (and (> minimum-length natural-length)
(<= (length siblings) 1)) ;; never kill a broken extender
(ly:grob-suicide! grob)))))
\layout {
\context {
\Lyrics
\override LyricExtender.minimum-length = #1.5
\override LyricExtender.after-line-breaking =
#(conditional-kill-lyric-extender-callback)
}
}
autoextenders =
#(define-music-function (lyrics) (ly:music?)
(let* ((has-hyphen?
(lambda (event)
(let* ((art (ly:music-property event 'articulations))
(is-hyphen? (lambda (ev) (eq? (ly:music-property ev 'name)
'HyphenEvent))))
(find is-hyphen? art))))
(has-extender?
(lambda (event)
(let* ((art (ly:music-property event 'articulations))
(is-hyphen? (lambda (ev) (eq? (ly:music-property ev 'name)
'ExtenderEvent))))
(find is-hyphen? art))))
(add-extender!
(lambda (event)
(ly:music-set-property! event 'articulations
(append (ly:music-property event 'articulations) (list
(make-music 'ExtenderEvent))))
event)))
(music-map
(lambda (event)
(if (and (eq? (ly:music-property event 'name) 'LyricEvent)
; do not add extenders below hyphens
(not (has-hyphen? event))
; do not duplicate extenders
(not (has-extender? event))
; do not add additional extenders after _ (internally
equivalent to " ")
; to avoid killed extenders
(not (equal? (ly:music-property event 'text) " "))
; do not add extenders after "" to allow ending extenders
; within _ _ _ _ skip sequences with _ _ "" _ _
(not (equal? (ly:music-property event 'text) ""))
; ditto, with _ _ \markup{|null} _ _
(not (equal? (ly:music-property event 'text) (markup #:null)))
)
(add-extender! event))
event)
lyrics)))
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user