catching layout-content

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

catching layout-content

Thomas Morley-2
Hi all,
how can I see from inside a procedure that there is indeed an
\override in \layout ?
Below returns a long list, but nothing like the \override

\layout { \override NoteHead.color = #red }

#(pretty-print
  (sort
    (ly:module->alist (ly:output-def-scope $defaultlayout))
      (lambda (p q)
        (symbol<? (car p) (car q)))))

I'm aware using
\layout { \context { \Voice \override NoteHead.color = #red } }
will return a different result, indicating the layout is indeed changed.

Ideally I would love to catch both cases.


Thanks,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: catching layout-content

David Kastrup
Thomas Morley <[hidden email]> writes:

> Hi all,
> how can I see from inside a procedure that there is indeed an
> \override in \layout ?
> Below returns a long list, but nothing like the \override
>
> \layout { \override NoteHead.color = #red }
>
> #(pretty-print
>   (sort
>     (ly:module->alist (ly:output-def-scope $defaultlayout))
>       (lambda (p q)
>         (symbol<? (car p) (car q)))))
>
> I'm aware using
> \layout { \context { \Voice \override NoteHead.color = #red } }
> will return a different result, indicating the layout is indeed changed.
>
> Ideally I would love to catch both cases.
Well, you have to look closer: such an override is turned into an
override for every context definition matching the given context alias
(in this case the default "Bottom", so every context def without a
default child).  Try


\layout { \override NoteHead.color = #red }

#(pretty-print
  (map
   (lambda (x)
    (if (ly:context-def? (cdr x))
     (cons (car x) (ly:context-def-lookup (cdr x) 'property-ops))
     x))
   (sort
    (ly:module->alist (ly:output-def-scope $defaultlayout))
    (lambda (p q)
     (symbol<? (car p) (car q))))))


By the way: the DOC string of ly:context-def-lookup is complete and
utter crap and has nothing whatsoever to do with what the function
actually does.  Must have been some copy&paste job.

--
David Kastrup

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: catching layout-content

Thomas Morley-2
2018-05-25 12:26 GMT+02:00 David Kastrup <[hidden email]>:

> Thomas Morley <[hidden email]> writes:
>
>> Hi all,
>> how can I see from inside a procedure that there is indeed an
>> \override in \layout ?
>> Below returns a long list, but nothing like the \override
>>
>> \layout { \override NoteHead.color = #red }
>>
>> #(pretty-print
>>   (sort
>>     (ly:module->alist (ly:output-def-scope $defaultlayout))
>>       (lambda (p q)
>>         (symbol<? (car p) (car q)))))
>>
>> I'm aware using
>> \layout { \context { \Voice \override NoteHead.color = #red } }
>> will return a different result, indicating the layout is indeed changed.
>>
>> Ideally I would love to catch both cases.
>
> Well, you have to look closer: such an override is turned into an
> override for every context definition matching the given context alias
> (in this case the default "Bottom", so every context def without a
> default child).  Try
>
>
>
> By the way: the DOC string of ly:context-def-lookup is complete and
> utter crap and has nothing whatsoever to do with what the function
> actually does.  Must have been some copy&paste job.
>
> --
> David Kastrup
>


That's it!


Many thanks,
  Harm

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user