]> git.donarmstrong.com Git - lilypond.git/commitdiff
Implement \once as music function able to operate on complex stuff.
authorDavid Kastrup <dak@gnu.org>
Tue, 1 Nov 2011 17:51:40 +0000 (18:51 +0100)
committerDavid Kastrup <dak@gnu.org>
Sun, 6 Nov 2011 23:04:29 +0000 (00:04 +0100)
lily/lily-lexer.cc
lily/parser.yy
ly/music-functions-init.ly
scm/ly-syntax-constructors.scm

index 1298604f12f704bccbf48299bc5caa3a366164a2..b19639b579d81941a4fec8d2541e0acaf36f002f 100644 (file)
@@ -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 0adb95c2f55667155309e9025d0afd60ad8a635c..1e693c89c04a7988e3fe22dd9c6d2209553dee9c 100644 (file)
@@ -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 185ee7be382af797b8ebe2e432f6e6b18fa4d3d6..5dad573ac071c348d0d948d718f4110faf03f8fd 100644 (file)
@@ -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 (_ "Cannot apply \\once to timed music"))))
+      m)
+    music))
+
 ottava =
 #(define-music-function (parser location octave) (integer?)
    (_i "Set the octavation.")
index 841ad92e97f203717bfaf9181b9795f0546cc1b2..ee6140ab1fc9e932d5196b62ec89b43d4c80a7cc 100644 (file)
@@ -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