Hi Jean,
I never understood the whole thing fully (and it is at the heart of
the problem that led to disabling LilyPond on WikiMedia), but output
definitions have their own scope, which is implemented as a Guile
module. pretty-print is defined by another Guile module, (ice-9
pretty-print), which is generally available in LilyPond code because
it is loaded upon initialization of LilyPond (see init.ly). last is in
(srfi srfi-1), which is also loaded by default.
If you want these functions in a \layout, you have to load the
corresponding module by hand:
\layout {
#(use-modules (ice-9 pretty-print))
\override NoteHead.after-line-breaking =
#(lambda (grob) (pretty-print "I explode."))
}
{
a4
}
Thanks much for the explanation and the pointers to workarounds!
That's the kind of pitfall that lets you start doubting your sanity: You
create and test a scheme \override, and when it finally works, you copy
it into a general-purpose definition of a new context ... and it stops
working (with the strange error message that "last" is an unknown
variable). :-)
At least now I understand why I sometimes see (car (last-pair
some-list)) in examples where I'd usually expect (last some-list).
Lukas