On Tue, 2023-12-05 at 11:23 +0100, Jean Abou Samra wrote:
> Is this the sort of thing you're looking for?
>
> #(define (dump-system-info sys)
> (let* ((right (ly:spanner-bound sys RIGHT))
> (time (ly:grob-property right 'when 0)))
> (format #t "\nline break at ~f" (ly:moment-main time))))
>
> \layout {
> \context {
> \Score
> \override System.after-line-breaking = #dump-system-info
> }
> }
> It should work on LilyPond 2.23.7 or later (current stable is 2.24).
It doesn't work on 2.20 which is what I have installed (Ubuntu 20.04).
It also doesn't work on 2.24.3. Doesn't work means I don't see any
"line break" prints.
> This:
>
> > \layout {
> > \context {
> > \Staff
> > \override System.after-line-breaking = #printPage
> > }
> > }
> > should work. And it doesn't. I tried \Score context,
> >
>
> probably means you're running an older version.
The after-line-breaking callback appears to be in stable/2.20 from git.
At least in system.cc.
<
https://github.com/lilypond/lilypond/blob/2a3a1ed05c3129a76e6531d3bc8b9d4f717a0175/lily/system.cc#L191C1-L191C58
>
I assume that get_property is used to evaluate a scheme expression? Or
am I not looking at the right thing?
> Listening to page-break-event in an engraver is not what you're
> looking for — these are only emitted for explicit \break commands.
As I suspected, thanks for confirming.
> Another way would be
>
> #(define (dump-col-info col)
> (when (eqv? LEFT (ly:item-break-dir col))
> (let ((time (ly:grob-property col 'when 0)))
> (format #t "\nline break at ~f" (ly:moment-main time)))))
>
> \layout {
> \context {
> \Score
> \override NonMusicalPaperColumn.after-line-breaking = #dump-col-
> info
> }
> }
It doesn't work on my version.
Drawing systems...mwe.ly:36:4: In expression (when (eqv? LEFT #) (let #
#)):
mwe.ly:36:4: Unbound variable: when
Unless there is a syntax error I don't see.
I tried it in 2.24.3 and it didn't work there either. Same error.
There might be an extra parens in there, but I don't understand all
the syntax.
For fun I also tried:
\layout {
\context {
\Score
\override System.after-line-breaking = #dump-col-info
}
}
to see if that error would trigger on System.after-line-breaking and
the error didn't occur on 2.24.3. This implies that the after-line-
breaking callback is broken for the System object.
> which prints the time of all NonMusicalPaperColumn grobs that are
> just before a line break. Note the difference between a PaperColumn,
> which is on a vertical alignment of notes, and a
> NonMusicalPaperColumn, which is between two PaperColumns (or at one
> extreme end of the system). There is a diagram here about ly:item-
> break-dir.
>
> Both of these methods will print at each line break, but since you
> have just one system per page, that's equivalent to printing page
> breaks in your case.
Right, that's the workaround I had in mind.