lilypond-user
[Top][All Lists]
Advanced

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

Re: Getting the name of the context a scheme function was called from


From: David Kastrup
Subject: Re: Getting the name of the context a scheme function was called from
Date: Fri, 11 Jan 2013 18:40:52 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Paul Morris <address@hidden> writes:

> given custom staff context, but do nothing when it is called from a
> standard staff context.  Then I could put the music, with calls to the
> function, into a variable, and use that variable in both custom and
> standard staves.  When called from the custom staff the function would
> make changes, but when called from the standard staff it would do
> nothing.
>
> I've tried to do this by using ly:context-name:
>
>   Function: ly:context-name context
>   Return the name of context, i.e., for \context Voice = "one" … return the 
> symbol Voice.
>
> and maybe getting the "context" argument by using ly:translator-context:
>
>   Function: ly:translator-context trans
>   Return the context of the translator object trans.
>
> http://www.lilypond.org/doc/v2.16/Documentation/internals/scheme-functions
>
> But to do that I need the "translator object" (which seems to be an
> engraver?), and I'm not sure how to do that.  Maybe there is a way to
> get to it from the grob?

A grob can be announced in multiple contexts, so no.

> displaceHeads =
> #(define-music-function (parser location offsets) (list?)
> "
>  Moves the NoteHeads, using (shift offsets)
> "
>  #{
>    \once \override NoteColumn #'before-line-breaking = #(shift offsets)
>  #})

At the time this is called, there are no live contexts.  You might want
to try fiddling with the context grob properties (huh, do we even have
functions for that?) directly in a function called via \applyContext.

-- 
David Kastrup




reply via email to

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