\version "2.11.43" \header { title="Redefining parenthesize for rests, single notes, chords" } parenthesize = #(define-music-function (parser loc arg) (ly:music?) (_i "Tag @var{arg} to be parenthesized.") (if (memq 'event-chord (ly:music-property arg 'types)) ; arg is an EventChord -> set the parenthesize property on all child notes and rests (map (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) \relative c'' { % parentheses on single notes (with articulations), inside chord and articulation \parenthesize c \parenthesize c-. <\parenthesize c> c-\parenthesize-. | % parenthesized rests and whole chords \parenthesize 4-> \parenthesize r \parenthesize r2^"rest" | % parenthesizing other music expressions does nothing \parenthesize {c4 c-. r} }