Reviewers: Reinhold,
Message:
On 2011/11/03 10:47:59, Reinhold wrote:
LGTM, although regtests are missing (for \once applied to multiple
settings at
one, stored in a variable).
There you are.
Description:
Implement \once as music function able to operate on complex stuff.
Please review this at http://codereview.appspot.com/5322065/
Affected files:
A input/regression/complex-once.ly
M lily/lily-lexer.cc
M lily/parser.yy
M ly/music-functions-init.ly
M scm/ly-syntax-constructors.scm
Index: input/regression/complex-once.ly
diff --git a/input/regression/complex-once.ly
b/input/regression/complex-once.ly
new file mode 100644
index
0000000000000000000000000000000000000000..4fb2448c02e2d9cd078978243ffe56909e971493
--- /dev/null
+++ b/input/regression/complex-once.ly
@@ -0,0 +1,12 @@
+\version "2.15.17"
+
+\header{
+ texidoc= "This tests @code{\once} applied to multiple property
operations."
+}
+
+\layout { ragged-right = ##t }
+
+\relative c' {
+ c4 d \hideNotes e4 f |
+ \unHideNotes g a \once\hideNotes b c |
+}
Index: lily/lily-lexer.cc
diff --git a/lily/lily-lexer.cc b/lily/lily-lexer.cc
index
1298604f12f704bccbf48299bc5caa3a366164a2..b19639b579d81941a4fec8d2541e0acaf36f002f
100644
--- a/lily/lily-lexer.cc
+++ b/lily/lily-lexer.cc
@@ -72,7 +72,6 @@ static Keyword_ent the_key_tab[]
{"name", NAME},
{"new", NEWCONTEXT},
{"notemode", NOTEMODE},
- {"once", ONCE},
{"override", OVERRIDE},
{"paper", PAPER},
{"remove", REMOVE},
Index: lily/parser.yy
diff --git a/lily/parser.yy b/lily/parser.yy
index
0adb95c2f55667155309e9025d0afd60ad8a635c..1e693c89c04a7988e3fe22dd9c6d2209553dee9c
100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -229,7 +229,6 @@ void set_music_properties (Music *p, SCM a);
%token MIDI "\\midi"
%token NAME "\\name"
%token NOTEMODE "\\notemode"
-%token ONCE "\\once"
%token OVERRIDE "\\override"
%token PAPER "\\paper"
%token REMOVE "\\remove"
@@ -1614,10 +1613,7 @@ simple_music_property_def:
music_property_def:
simple_music_property_def {
- $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant
("property-operation"), scm_cons (PARSER->self_scm (), scm_cons2
(make_input (@$), SCM_BOOL_F, $1)));
- }
- | ONCE simple_music_property_def {
- $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant
("property-operation"), scm_cons (PARSER->self_scm (), scm_cons2
(make_input (@$), SCM_BOOL_T, $2)));
+ $$ = LOWLEVEL_MAKE_SYNTAX (ly_lily_module_constant
("property-operation"), scm_cons2 (PARSER->self_scm (), make_input (@$),
$1));
}
;
Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index
185ee7be382af797b8ebe2e432f6e6b18fa4d3d6..aca7963b6246cfda5cb5eaa2367cdcf89e0585e1
100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -578,6 +578,18 @@ octaveCheck =
(make-music 'RelativeOctaveCheck
'pitch pitch))
+once =
+#(define-music-function (parser location music) (ly:music?)
+ (_i "Set @code{once} to @code{#t} on all layout instruction events in
@var{music}")
+ (music-map
+ (lambda (m)
+ (cond ((music-is-of-type? m 'layout-instruction-event)
+ (set! (ly:music-property m 'once) #t))
+ ((ly:duration? (ly:music-property m 'duration))
+ (ly:music-warning m (_ "Can't apply \\once to timed music"))))
+ m)
+ music))
+
ottava =
#(define-music-function (parser location octave) (integer?)
(_i "Set the octavation.")
Index: scm/ly-syntax-constructors.scm
diff --git a/scm/ly-syntax-constructors.scm b/scm/ly-syntax-constructors.scm
index
841ad92e97f203717bfaf9181b9795f0546cc1b2..ee6140ab1fc9e932d5196b62ec89b43d4c80a7cc
100644
--- a/scm/ly-syntax-constructors.scm
+++ b/scm/ly-syntax-constructors.scm
@@ -177,7 +177,7 @@ into a @code{MultiMeasureTextEvent}."
(if create-new (set! (ly:music-property csm 'create-new) #t))
csm))
-(define-ly-syntax (property-operation parser location once ctx music-type
symbol . args)
+(define-ly-syntax (property-operation parser location ctx music-type
symbol . args)
(let* ((props (case music-type
((PropertySet) (list 'value (car args)))
((PropertyUnset) '())
@@ -191,11 +191,10 @@ into a @code{MultiMeasureTextEvent}."
(list 'grob-property-path (car args))
(list 'grob-property-path args)))
(else (ly:error (_ "Invalid property operation ~a")
music-type))))
- (oprops (if once (cons* 'once once props) props))
(m (apply make-music music-type
'symbol symbol
'origin location
- oprops)))
+ props)))
(make-music 'ContextSpeccedMusic
'element m
'context-type ctx
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel