lilypond-devel
[Top][All Lists]
Advanced

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

Re: Syntax-question about nested functions/procedures


From: Thomas Morley
Subject: Re: Syntax-question about nested functions/procedures
Date: Wed, 1 Aug 2012 10:59:38 +0200

2012/8/1 David Kastrup <address@hidden>:
> Thomas Morley <address@hidden> writes:
>
>> Hi,
>>
>> fiddling around with a new patch for issue 2646 I tried to integrate
>> default-parenthesize into another function.
>> The following returns an error when uncommenting \override
>> Score.ParenthesesItem #'font-size = #0 and applying it to an
>> articulation.
>>
>> \version "2.15.42"
>>
>> parenthesizeII =
>> #(define-music-function (parser location mus) (ly:music?)
>>
>> (define (proc arg)
>> ;; from music-functions-init.ly
>>     (if (memq 'event-chord (ly:music-property arg 'types))
>       (if (music-is-of-type? arg 'event-chord)
>
> is a bit more readable.
>>        ;; arg is an EventChord -> set the parenthesize property
>>        ;; on all child notes and rests
>>        (for-each
>>       (lambda (ev)
>>         (if (or (memq 'note-event (ly:music-property ev 'types))
>>                 (memq 'rest-event (ly:music-property ev 'types)))
>>             (set! (ly:music-property ev 'parenthesize) #t)))
>>       (ly:music-property arg 'elements))
>>        ;; No chord, simply set property for this expression:
>>        (set! (ly:music-property arg 'parenthesize) #t))
>>    arg)
>> #{
>>
>>         %\override Score.ParenthesesItem #'font-size = #0
>>         $(proc mus)
>> #})
>
> Without override, it is a single music expression.  With override, it is
> sequential music containing an override as first element and the input
> as second element, and sequential music can't be a post-event.
>
> An override has permanent effect, and even \once\override affects
> everything at a given timestep.  More likely than not, you want a tweak.

It's so obvious, I hardly can believe not having seen it myself.

>
>>
>> \relative c' {
>>       % works
>>       \parenthesizeII a'4-1
>>
>>       % returns an error when uncommenting the
>>       % font-size-override above
>>         a4-\parenthesizeII-1
>> }
>>
>> What's wrong and how to do it better?
>
> Well, here is an only slightly tongue-in-cheek version which first lets
> \parenthesize to the job and then tweaks everything it finds
> parenthesized.  If you copy the core of \parenthesize, as you did above,
> you would likely manipulate the 'tweak music property yourself,
> prepending an appropriate tweak.
>
> \version "2.15.42"
>
> parenthesizeII =
> #(define-music-function (parser location mus) (ly:music?)
>   (map-some-music
>     (lambda (m)
>       (and (ly:music-property m 'parenthesize #f)
>            #{ \tweak ParenthesesItem #'font-size #0 #m #}))
>     #{ \parenthesize #mus #}))
>
> \relative c' {
>         % works
>         \parenthesizeII a'4-1
>         a4-\parenthesizeII-1
> }
>
> --
> David Kastrup
>
>
> _______________________________________________
> lilypond-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-devel

Thanks,
  Harm



reply via email to

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