lilypond-user
[Top][All Lists]
Advanced

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

Re: [bounty] context generating function - how to get context def from i


From: David Kastrup
Subject: Re: [bounty] context generating function - how to get context def from its name?
Date: Fri, 25 Jul 2014 21:34:58 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Janek Warchoł <address@hidden> writes:

> newInstrument =
> #(define-scheme-function
>   (parser location instrName parentName settings)(string? ly:context-mod?)
>   ;; ...
>     #{
>       \layout {
>         \context {
            $(module-ref (current-module) (string->symbol parentName))
>           ;; create "instrNameStaff" context, derived from "parentNameStaff",
>           ;; with default child "instrNameVoice", and modifications specified
>           ;; in "settings" argument
            \name #instrName
            \defaultchild #instrNameVoice
            #settings
>         }
>         \context {
>           ;; create "instrNameVoice" context, derived from "parentNameVoice",
>         }
>       }
>     #})
>
> I managed to write a function that does something like this, but I
> have two problems:
> 1) inside the function, i don't know how to get a context definition
> from its name (i.e. from a string).  Right now i have to pass parent
> contexts' definitions as separate arguments, but this means that i
> have three arguments instead of one.
> 2) i didn't manage to get midi stuff done inside the same function as
> the layout stuff - but i think that i'll be able to solve that if i
> have a solution to 1).

You basically need to collect just the context definitions and apply
those (a context definition is applied by looking up its \name and
overwriting the variable with that name).

Frankly, I am tempted to create something like
#{
   \output {
     \context ...
     xxx = 3\cm
   }
#}

that will either execute a number of assignments or alternatively return
an anonymous lambda or define-void-function doing the same so that you
can easily splice it into different output definitions.

Something like that would apparently serve a need.

-- 
David Kastrup



reply via email to

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