Am Mittwoch, 6. Dezember 2023, 23:10:11 CET schrieb Jean Abou Samra:
> \version "2.24.2"
> 
> #(define-markup-command (foo layout props loc-provider) (ly:music?)
>    (display (ly:input-file-line-char-column (ly:music-property loc-provider
> 'origin))) empty-stencil)
> 
> \markup \foo {{}}

Maybe a bit less esoteric:

\version "2.24.2"

locationOf =
#(define-scheme-function (which) (ly:music?)
   (apply format #f "~a:~a:~a:~a" (ly:input-file-line-char-column 
(ly:music-property which 
'origin))))


\markup { \locationOf {} }

> OK, thanks.  But what about accessing the `input-file-name` variable?
> Shouldn't this work within `delay-stencil-evaluation`?

That should not work. A markup function is evaluated at a delayed point, at 
which `input-
file-name` might have changed. Try this:

B.ly:
{
  \override NoteHead.stencil = #(grob-transformer 'stencil (lambda (grob orig) 
(display 
input-file-name) orig))
  c
}

A.ly:
\include B.ly

This will display A.ly (as `input-file-name` is only "B.ly" while that part is 
parsed.

Cheers,
Valentin

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to