lilypond-user
[Top][All Lists]
Advanced

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

Consist engraver within loop


From: Urs Liska
Subject: Consist engraver within loop
Date: Wed, 9 Mar 2016 01:53:18 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1

Hi all,

I want to write a wrapper function to "install" an engraver in a number
of contexts. It works pretty well, but I want to make it better.

This is what I have so far.

\version "2.19.38"

install =
#(define-scheme-function (contexts)(symbol-list?)
  
   (if (member 'Score contexts)
       #{
         \layout {
           \context {
             \Score
             \consists "Clef_engraver"
           }
         }
       #})
   (if (member 'Staff contexts)
       #{
         \layout {
           \context {
             \Staff
             \consists "Clef_engraver"
           }
         }
       #})
   (if (member 'Voice contexts)
       #{
         \layout {
           \context {
             \Voice
             \consists "Clef_engraver"
           }
         }
       #}))

\install Staff

{
  c'
}

Clef_engraver doesn't make real sense, it's just there to have something
compilable.
In order to complete that I would have to repeat the conditional for all
existing context - and wouldn't even catch custom contexts. So I would
like to iterate over the symbol list to consist the engraver in a
non-redundant manner. The problem is, I don't know how to get from the
symbols like 'Score to the \Score incantation. I think it should go
something like this:

   (for-each
    (lambda (ctx)
      #{
        \layout {
          \context {
            % specify context from ctx
            \consists "Clef_engraver"
          }
        }
      #}
      )
    contexts)

This should work once I can "resolve" the comment

Any pointers or solution would be appreciated
Urs



reply via email to

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