lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get Staff context-id from a grob?


From: Jan-Peter Voigt
Subject: Re: How to get Staff context-id from a grob?
Date: Fri, 11 Oct 2013 10:49:02 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0

Hi Jan,

AFAICS its not possible to get the context from a grob. It only points to the originating music-_expression_, which might be used in several contexts.
You can get the current context-id, whenever you have a context, like in an engraver or in an applyContext statement:

--snip--
% find a context-id
#(define (ctxid context)
   ; find the
   (let ((id (ly:context-id context))
         (pc (ly:context-parent context)))
     (cond
      ((and (string? id)(> (string-length id) 0)) id)
      ((ly:context? pc) (ctxid pc))
      (else "?")
      )))
% use applyContext to display the context id
\new Staff = foobar \relative c'' {
  bes4 a \applyContext #(lambda (context) (display (ctxid context))) c b
}
--snip--

One might think of an engraver, which modifies grobs according to the current context-id - that should be possible.

Best, Jan-Peter

Am 11.10.2013 10:22, schrieb Jan Rosseel:

I have a problem that I’ve been trying to crack, but I’m failing.

In my backend, I am processing grobs, and I would need to get the context-id of the StaffSymbol that a certain grob belongs to.

Here’s the bigger picture:

\new Staff = foobar { 

… << some music>>>

}

For all grobs that orginate from notes in “some music” I need to be able to get to the “foobar” string.

Is this possible from scheme code?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]