lilypond-user
[Top][All Lists]
Advanced

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

Re: \tweak-like function


From: David Kastrup
Subject: Re: \tweak-like function
Date: Sat, 21 Sep 2019 11:15:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Werner LEMBERG <address@hidden> writes:

>>>   moveDynTweak =
>>>     #(define-music-function (X Y) (number? number?)
>>>       #{ \tweak DynamicLineSpanner.outside-staff-priority ##f
>>>          \tweak DynamicText.X-offset #X
>>>          \offset DynamicLineSpanner.Y-offset #Y
>>>          \etc #})
>> 
>> Should have worked when using -\moveDynTweak ...  Since you are not
>> using this for anything other dynamic expressions, it would be
>> likely better to use define-event-function here, obviating the need
>> to write - before \moveDynTweak .
>
> Thanks!  Please check whether
>
>   moveDyn =
>     #(define-event-function (X Y etc) (number? number? ly:music?)
>       #{ \tweak DynamicLineSpanner.outside-staff-priority ##f
>          \tweak DynamicText.X-offset #X
>          \offset DynamicLineSpanner.Y-offset #Y
>          etc #})
>
>   {
>     g'2
>     g'\moveDyn #-1 #5 -\f
>   }
>
> is really correct; I will then add this to the documentation.

I think all of your argument names are a bad idea.  #X and #Y are
usually fixed constants (namely axes) in their uppercase form.  There is
absolutely no conceivable reason for using this form instead of
lowercase letters and/or something more descriptive like xoff/yoff .

"etc" is so close to "\etc" that people will tend to "autocorrect".  Why
not use "event" or "dyn" ?  And by the way, the predicate should be the
more specific ly:event? , or otherwise construction of a post-event will
fail at an unexpected place when a non-postevent is given as argument.

It also seems writing -\f rather than \f suggests that it would not work
otherwise while it does.

-- 
David Kastrup



reply via email to

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