Am So., 18. Nov. 2018 um 18:23 Uhr schrieb Thomas Morley
<thomasmorle...@gmail.com>:
>
> Hi,
>
> consider the code below. I'd like to restrict usage to Staff-like
> contexts, i.e. Staff, Tab- and DrumStaff, etc would be ok, but
> container-contexts like StaffGroup, etc should lead to return '().
>
> Pseudo-code:
>
> \new Staff(Group)
>   \with {
>     \applyContext
>      #(lambda (context)
>        (if <condition>
>            ;; Do something, if we are in a Staff-like context
>            ;;   Multiple Bottom-contexts may happen
>            (lambda (x) ...)
>            ;; Do nothing if we are are in container-contexts like ChoirStaff,
>            ;; StaffGroup, etc
>            '()
>        )
>   }
> { c''1 }
>
> I thought the <condition> could be "Do I have the Staff_symbol_engraver?"
> Though, how to code?
>     \applyContext
>      #(lambda (context)
>        (ly:context-def-lookup context 'consists))
> does not work, because 'context' is not a context-definition.
>
> Any hint how to proceed would be great.
>
>
> Thanks,
>   Harm

To answer my own question
(ly:output-find-context-def $defaultlayout (ly:context-name context))
will return an alist of context-defs for current context and all the aliases.

To checking for the engraver in the relevant context-def is trivial now.

Cheers,
  Harm

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

Reply via email to