Aaron Hill <[email protected]> writes: > On 2020-02-02 2:26 am, David Kastrup wrote: >> Aaron Hill <[email protected]> writes: >> >>> Music functions certainly give you the most flexibility, although >>> there are simple cases where you can use 2.19's \etc keyword as a >>> shorthand to defining the function yourself: >>> %%%% >>> \version "2.19" >>> stemColor = \override Stem.color = \etc >>> { d'8 \stemColor #red e' f' \undo \stemColor ##f g' } >>> %%%% >>> Note the \undo command above is less ideal as one needs to provide >>> a >>> dummy argument to the function. >> Why not \undo \stemColor #red here ? ##f makes no sense. > > I did not want to give the impression that the arguments *had* to > match. One could just as easily say \undo \stemColor #blue and get > the same outcome. \undo only seems to care about which properties are > \overridden, not the specific values. So the argument to the music > function in this case does not matter. My choice of "false" was > purely arbitrary, but I guess it was too confusing. > > A scenario where the mismatch would make sense is using the function > several times in a row: > > %%%% > { d \stemColor #red e f \stemColor #blue g a > \stemColor #green f c \undo \stemColor #'() d } > %%%% > > This pattern reinforces that it is not required to \undo each > application of the function.
That's just because you have not been using \temporary \stemColor here. Non-\temporary overrides implicitly cancel the last existing override at that level, so \undo \stemColor #green would be "correct" here. The principal purpose of \undo is that it works even if you don't know the details involved, so it seems self-defeating to use it in a manner relying on knowing the details. > If \undo \stemColor #'() proves to be undesirable, nothing stops a > user just doing the \undo by hand with a manual \revert Stem.color or > a suitably-defined \noStemColor. Again, \undo is for those occasions where you are not really interested in the details. It's always equivalent to something explicit, of course. If you write stemColor = \override Stem.color = \etc \void \displayLilyMusic \undo \stemColor #red you get the output lilypond /tmp/baba.ly GNU LilyPond 2.21.0 Processing `/tmp/baba.ly' Parsing... \revert Stem.color And there is nothing wrong with that. -- David Kastrup
