> On 23 Mar 2025, at 15:59, Hans Aikema <hans.aik...@aikebah.net> wrote:
>
>
>
>> On 21 Mar 2025, at 17:00, Valentin Petzel <valen...@petzel.at> wrote:
>>
>> Hello Ad,
>>
>> what you want is
>>
>> \paper {
>> ragged-right = ##t
>> }
>>
>> the issue with this is that it will shorten the staff. So use
>>
>> \layout {
>> \context {
>> \Staff \override StaffSymbol.width =
>> #(lambda (grob)
>> (ly:output-def-lookup (ly:grob-layout grob) 'line-width))
>> }
>> }
>>
>> to enforce the staff having full length.
>>
>> Cheers,
>> Valentin
>
> Works great and got me into trying to apply it on my use-case (display of
> hymns including melody in presentation slides), but I end up with visual
> ugliness it triggers for end-of-line barlines which then appear in the middle
> of the staff at the end of the music. I’d like to know whether that can be
> solved as well.
>
> For the regular measure bars I don’t mind it that much, I’m fine with
> overriding the default measure bar with an overrride that does not print
> end-of-line for my purposes as in
>
>
> \defineBarLine "|-noeol" #'(#f #f #f)
>
> and
>
> \layout {
> \context { \Staff
> \override StaffSymbol.width = #(lambda (grob) (ly:output-def-lookup
> (ly:grob-layout grob) 'line-width))
> measureBarType = "|-noeol"
> }
> }
>
>
> However for the typical closing barline at the end of a piece ( \bar “|.” ) I
> would like to keep it visible, but have it appear at the end of the
> staff-line rather than the end of the music.
Answering on my own question with a hidden gem I managed to dig up from the
archives of this list (thanks Wilbert for posting this in the distant past):
https://lists.gnu.org/archive/html//lilypond-user/2013-03/msg00963.html
Updated for 2.24.0 with convert-ly that would nowadays be
\version "2.24.0"
endbar = {
\overrideProperty Staff.BarLine.after-line-breaking
#(lambda (grob)
(let* ((sys (ly:grob-system grob))
(staff (ly:grob-object grob 'staff-symbol))
(half-thickness (/ (ly:staff-symbol-line-thickness staff) 2))
(cur-x (cdr (ly:grob-extent grob sys X)))
(new-x (cdr (ly:grob-extent staff sys X)))
(xoff (+ half-thickness (- new-x cur-x))))
(ly:grob-set-property! grob 'extra-offset (cons xoff 0))))
}
allowing you to code an end-of-staff barline on left-aligned notes and lyrics
(the typical ending-barline in this case) like:
\endbar \bar “|.”