Urs Liska <u...@openlilylib.org> writes:

> is it possible to take a music expression and print out its literal
> input?

Sort of.

> In other words: Could I write a function "\example" that takes a music
> expression as an argument and that first outputs the input code as
> text and then as a score?
>
> So that
>
> \example {
>   \relative c' {
>     c8 d e
>   }
> }

Well, if you write

example =
#(make-scheme-function (parser location music) (ly:music)
...
then (ly:input-both-locations location)
will return

-- Function: ly:input-both-locations sip
     Return input location in SIP as ‘(file-name first-line first-column
     last-line last-column)’.

So you'll be able to take the input location information and read the
corresponding source from the file.

It is sort of annoying that LilyPond does not offer something already
doing that since it _does_ have the information available (as you can
see when it produces error messages).

-- 
David Kastrup

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to