[Top][All Lists]

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

Re: Getting context-definiton, while being in applyContext

From: Thomas Morley
Subject: Re: Getting context-definiton, while being in applyContext
Date: Sun, 18 Nov 2018 21:07:04 +0100

Am So., 18. Nov. 2018 um 20:40 Uhr schrieb David Kastrup <address@hidden>:

> Just do
> (eq? ctx (ly:context-find ctx 'Staff))
> --
> David Kastrup

I did not even consider to use ly:context-find. The description says:
Find a _parent_ of context that has name or alias name. Return #f if not found.
So I expected it could return
Staff as parent of Voice
StaffGroup as parent of Staff
Score as parent of StaffGroup

Similar to
Function: ly:context-parent context
    Return the parent of context, #f if none.
Although this one returns a tree of contexts not even a single parent.
At least for me this was a surprise.

Is my understanding of parents with contexts entirely wrong ...?

Anyway, the following works very nicely:

foo =
    #(lambda (ctx)
       (let* ((ctx-name (ly:context-name ctx)))
         (if (eq? ctx (ly:context-find ctx 'Staff))
             (format #t "\n\tI'm in a staff-like context: ~a" ctx-name)
             (format #t "\n\tWrong here in: ~a" ctx-name))))

\score {
    \new StaffGroup R1
    \new Staff R1
    \new TabStaff R1
    \new DrumStaff R1
    \new ChoirStaff R1
  \layout {
      \context Staff \foo
    \context {
    \context {


reply via email to

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