[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: \parenthesize and optional arguments
From: |
Marc Hohl |
Subject: |
Re: \parenthesize and optional arguments |
Date: |
Sat, 04 Jul 2015 11:29:38 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 |
Am 04.07.2015 um 10:08 schrieb David Kastrup:
[...]
Well, I'm not enthusiastic about both code and interface.
What about
\version "2.19.20"
#(define (set-paren-property arg)
(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)))
lparenthesize =
#(define-music-function (arg) (ly:music?)
(_i "Tag @var{arg} to be left parenthesized.")
(set-paren-property arg)
#{ \tweak ParenthesesItem.stencils #(lambda (grob)
(let ((par-list (parentheses-item::calc-parenthesis-stencils
grob)))
(list (car par-list) point-stencil))) #arg #})
rparenthesize =
#(define-music-function (arg) (ly:music?)
(_i "Tag @var{arg} to be right parenthesized.")
(set-paren-property arg)
#{ \tweak ParenthesesItem.stencils #(lambda (grob)
(let ((par-list (parentheses-item::calc-parenthesis-stencils
grob)))
(list point-stencil (cadr par-list)))) #arg #})
{ \parenthesize c \lparenthesize d \rparenthesize e
c-\parenthesize-1 d-\lparenthesize-2 e-\rparenthesize-3}
I'd define set-paren-property globally at a appropriate place, rewrite
the definition of \parenthesize using set-paren-property and add
\[l|r]parenthesize.
Would that warrant a patch?
Cheers,
Marc