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

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

Reply via email to