lilypond-user
[Top][All Lists]
Advanced

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

Re: How to return markup conditionally?


From: David Kastrup
Subject: Re: How to return markup conditionally?
Date: Thu, 20 Jul 2023 20:25:33 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Trevor Bača <trevorbaca@gmail.com> writes:

> %%% BEGIN %%%
>
> \version "2.25.6"
> \paper { indent = 0 tagline = ##f }
>
> \markuplist \column-lines {
>     "TextSpanner.bound-details.text.left = \"red\" when spanner color is
> red;"
>     "TextSpanner.bound-details.text.left = \"other\" when spanner color is
> not red:"
>     " "
> }
>
> {
>   \override TextSpanner.bound-details =
>     #(grob-transformer
>       'bound-details
>       (lambda (grob orig)
>         (assoc-set! (alist-copy orig)
>                     'left
>                     (assoc-set! (alist-copy (assoc-ref orig 'left))
>                                 'text
>                                 (if (equal? red (ly:grob-property grob
> 'color))
>                                     "red" "other")))))
>   c'1
>   - \tweak color #red
>   \startTextSpan
>   d'1
>   e'1
>   \stopTextSpan
>   f'1
>   - \tweak color #blue
>   \startTextSpan
>   g'1
>   a'1
>   \stopTextSpan
> }
>
> %%% END %%%
>
> But because successive calls to grob-transformer effectively overwrite
> earlier calls to grob-transformer, we can't use this pattern to (say)
> override bound-details.left.text and bound-details.left-broken.text at the
> same time:

Your analysis is wrong.  Successive calls to grob-transformer work just
fine.  Your problem is that successive \override incantations revert
previous incantations in the same context _unless_ you use \temporary
\override .

If you do your second grob-transformer invocation (or both) with a
\temporary \override, it will leave the first call in place.  Of course
you'll need a double \revert then if you want to get rid of both calls.

-- 
David Kastrup



reply via email to

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