On Sat, 2016-11-19 at 19:58 +0100, David Kastrup wrote: > David Sumbler <da...@aeolia.co.uk> writes: > > > > > On Sat, 2016-11-19 at 00:27 +0100, Simon Albrecht wrote: > > > > > > On 18.11.2016 22:41, David Sumbler wrote: > > > > > > > > > > > > I need to study this (and the previous answer) to see if I can > > > > fathom > > > > out the logic of it all. > > > \tweak is a music function (which means it returns music) and it > > > also > > > takes music as its third argument. The dash turns a markup into > > > a > > > post-event, which is music. > > > > > > HTH, Simon > > I find this very confusing. > > > > \tweak returns music, yet it requires a hyphen in front of it. > Music comes in two flavors: post events, and "proper" music > expressions. > Post events are what you can tack onto single notes or chords: most > articulations, subscripts, superscripts. > > A \tweak can return either. Unfortunately LilyPond's syntax for > parsing > music function arguments differs depending on which it is, so > LilyPond > needs to know whether the result of a \tweak will be a post event. > > This means you need to put a - in front of it. The frustrating thing > is > that this resolution is only needed for the call itself when in a > larger > music expression but not for assignments. So all of > > redf = \tweak color #red \f > greenf = -\tweak color #green \f > > { c1\redf c1\greenf } > > is fine while > > { c1\tweak color #red \f } > > does not work but > > { c1-\tweak color #green \f } > > does. It might be more consistent if > > redf = \tweak color #red \f > > also raised an error. But I think that ship has sailed. The long- > term > goal should be that > > c1\tweak color #red \f > > works fine. However, it is quite different from > > c1 \tweak color #red d1 > > And the real clincher actually is > > \displayMusic c1 \tweak \color #red \f > > \displayMusic has to wait for \tweak to return a value before it can > decide whether the returned value is a post-event belonging to c1 or > a > separate music expression. > > > > > And markup is not music, but a hyphen turns it into music. > Not just any old music but a post-event. > > > > > This seems to indicate that \tweak itself is not music, > It is always music, but whether this music is a post-event or not > needs > to be established early enough for LilyPond to parse the rest. > > > > > but merely returns music - but with the hyphen the \tweak itself > > becomes music. Or perhaps not! > > > > What constitutes music, so far as Lilypond is concerned? > Markups cannot occur in music expressions in isolation (well, in > \notemode. They are fine for \lyricmode). But -\markup ... is a > text > script in \notemode, and text scripts are music expressions and post > events. > > - introduces _any_ post-event actually but it is often > redundant. You > can write c1-\f-(-3 and it is only the 3 that actually needs the - > (in > order to identify it as a fingering rather than a note length, > incidentally an invalid one). > > So - is needed to turn numbers into post-events, or for turning > markups > into post-events, or for giving LilyPond advance notice that a music > function call is going to return a post-event (LilyPond will mess up > in > music expressions if its expectation of post-event or not turns out > to > be wrong when the music function call returns something other than > expected).
This is very, very useful. OK, I had to read it and think about it 3 or 4 times before I got it my head around it all, but it was defintely worth the effort. Thank you so much for taking the time to explain it. David _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user