Re: Where was my music-function called?

Graham King <[email protected]> Sun, 26 Jul 2026 10:00:03 +0100
Newsgroups gmane.comp.gnu.lilypond.general
Message-ID <[email protected]>
On Sun, 2026-07-26 at 00:35 +0200, David Kastrup wrote:
> Graham King <[email protected]> writes:
>=20
> > I'm trying to debug some Scheme code, and it would be really
> > helpful to
> > be able to make a music-function display the lilypond source-code-
> > line-
> > number where the music-function was called.
> >=20
> > Is this possible?
> >=20
> > In other words, how can I make this code display "8" rather than
> > "foo"?
> >=20
> > (the message is the point; inserting a note is just random
> > functionality to illustrate the problem)
> >=20
> > \version "2.27.1"
> >=20
> > insertC =3D #(define-music-function ()()
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (ly:=
message "insertC called at line ~a" "foo")
> > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #{ c=
'1 #} )
> >=20
> > { \repeat unfold 3 { c' d' e' f' }
> > =C2=A0 \insertC
> > }
>=20
> I'd use ly:input-message:
>=20
>=20
> This formats the output in a manner that you can use any IDE (like
> Frescobaldi) to click on the message and get to the point in the
> source.
>=20

Thanks David,
that's very helpful.