[Top][All Lists]

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

Re: \parenthesize and optional arguments

From: David Kastrup
Subject: Re: \parenthesize and optional arguments
Date: Sat, 04 Jul 2015 10:08:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Marc Hohl <address@hidden> writes:

> \version "2.19.20"
> parenthesize =
> #(define-music-function (dir arg) ((number? 0) ly:music?)
>    (_i "Tag @var{arg} to be parenthesized. @arg{dir} is optional and may be
>    set to @code{#LEFT} or @code{#RIGHT} for left/right parentheses only.")
>    (if (memq 'event-chord (ly:music-property arg 'types))
>        ;; 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))
>    (case dir
>          ((-1) #{ \once\override ParenthesesItem.stencils =
>                     #(lambda (grob)
>                        (let ((par-list
> (parentheses-item::calc-parenthesis-stencils grob)))
>                        (list (car par-list) point-stencil ))) #arg #})
>          ((1) #{ \once \override ParenthesesItem.stencils =
>                    #(lambda (grob)
>                       (let ((par-list
> (parentheses-item::calc-parenthesis-stencils grob)))
>                       (list point-stencil (cadr par-list)))) #arg #})
>          (else #{ #arg #})))
> { \parenthesize c \parenthesize #LEFT d \parenthesize #RIGHT e}
> Would it make sense to enhance the parenthesize function like this, i.e.
> create a patch for this?

Well, I'm not enthusiastic about both code and interface.  The problem
with the code is that

{ c'8-\parenthesize-1 [ f'8] }

will no longer compile.  The first reason for that is that one-paren
parenthesize will not work for any articulation and/or post-event.  You
really should try to turn this into tweaks rather than an override.
Otherwise it will be impossible anyway to parenthesize more than one
thing differently at one time step.

And of course the second reason is that -1 is no longer interpreted as a
fingering here but rather as a direction indicator.  Which changes the
entire meaning.

David Kastrup

reply via email to

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