Paul Morris <p...@paulwmorris.com> writes:

> Paul Morris wrote
>> (The only possible down side I see is that users may find it strange to
>> supply an output definition as a function argument, but I don't know of a
>> way around that.)
>
> Well, here's one possible way.
> -Paul
>
> \version "2.19.16"
>
> accept-like =
> #(define-scheme-function (parser location old new out)
>    (symbol? symbol? ly:output-def?)
>    (for-each
>     (lambda (p)
>       (let* ((sym (car p))
>              (def (cdr p))
>              (acc (ly:context-def-lookup def 'accepts)))
>         (if (and (memq old acc) (not (memq new acc)))
>             (ly:output-def-set-variable! out sym
>               (ly:context-def-modify
>                def
>                (ly:make-context-mod
>                 `((accepts ,new))))))))
>     (ly:output-find-context-def out))
>    out)
>
> accept-like-layout =
> #(define-scheme-function (parser location old new)
>    (symbol? symbol?)
>    #{ \accept-like $old $new \layout { } #})
>
> accept-like-midi =
> #(define-scheme-function (parser location old new)
>    (symbol? symbol?)
>    #{ \accept-like $old $new \midi { } #})
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%
>
> \layout {
>   \context {
>     \Voice
>     \name myVoice
>     \alias Voice
>     \override NoteHead.color = #blue
>   }
> }
>
> \accept-like-layout Voice myVoice

An extra command seems like bikeshedding when you can just write

\accept-like Voice myVoice \layout { }

instead.

-- 
David Kastrup

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

Reply via email to