Re: conditional parenthesis
Thomas Morley <[email protected]> Sat, 4 Jul 2026 09:28:43 +0200
| Newsgroups | gmane.comp.gnu.lilypond.general |
|---|---|
| Message-ID | <CABsfGyWVqGnwFWUXy525-7Abe-E4cFkjtvbakKFL33kipu1coQ@mail.gmail.com> |
Am Sa., 4. Juli 2026 um 07:50 Uhr schrieb Walt North <[email protected]>: > > I have a case where I need to put parenthesis around some notes (not all notes) for a given instrument to emphasize a specific thing at certain points. > > I thought this might be a case where tags would come in handy. > > But the following doesn't add the parenthesis. What am I missing? Is the problem related to having tags within a function? Or would there be a better way to do this. > > \version "2.26.0" > > par = #(define-music-function (note) (ly:music?) > #{ > \tag #'(piano) { #note } > \tag #'(guitar) { \parenthesize #note } > #}) > > music = {c'1} > > \score { > { > \keepWithTag #'piano {\par \music} > } > } > \score { > { > \keepWithTag #'guitar {\par \music} > } > } > > Two issues: a) \parenthesize works on a single note or event-chord. Your `music` is sequential music, though. Thus { \parenthesize { c'1 } } does not work. b) In the function you do #note. This _changes_ `note` for all instances of the function. Use a copy instead, i.e. $note As long as you only want to parenthesize single notes below works here: par = #(define-music-function (note) (ly:music?) #{ \tag #'(piano) { $note } \tag #'(guitar) { \parenthesize $note } #}) music = c'1 \score { { \keepWithTag #'piano {\par \music} } } \score { { \keepWithTag #'guitar {\par \music} } } Cheers, Harm