[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:12:57 +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. The problem
with the code is that
{ c'8-\parenthesize-1 [ f'8] }
will no longer compile.
Ah, I see.
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.
Of course.
So I discarded the "optional argument" idea and went for \lparenthesize
and \rparenthesize in combination with tweak.
Now I got
\version "2.19.20"
lparenthesize =
#(define-music-function (arg) (ly:music?)
(_i "Tag @var{arg} to be left parenthesized.)
(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))
#{ \tweak ParenthesesItem.stencils #(lambda (grob)
(let ((par-list (parentheses-item::calc-parenthesis-stencils
grob)))
(list (car par-list) point-stencil))) #arg #})
{ \parenthesize c }
which results in an error message that I don't understand:
Lilypond parenthesize.ly
GNU LilyPond 2.19.23
»parenthesize.ly« wird verarbeitet
Analysieren...
parenthesize.ly:4:2: Fehler: GUILE signalisierte einen Fehler für den
hier beginnenden Ausdruck
#
(define-music-function (arg) (ly:music?)
parenthesize.ly:23:5: illegal character in escape sequence: #\p
parenthesize.ly:4:2: Fehler: syntax error, unexpected EVENT_IDENTIFIER
#
(define-music-function (arg) (ly:music?)
parenthesize.ly:23:4: Fehler: EOF innerhalb einer Zeichenkette gefunden
{ \
parenthesize c }
schwerer Fehler: gescheiterte Dateien: "parenthesize.ly"
I remember getting such error messages in combination with some
unbalanced parentheses, but my editor tells me that this is not the case
here :-(
Marc