]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4507/1: Let \applyOutput take an optional grob spec
authorDavid Kastrup <dak@gnu.org>
Thu, 16 Jul 2015 13:54:33 +0000 (15:54 +0200)
committerDavid Kastrup <dak@gnu.org>
Tue, 21 Jul 2015 05:07:35 +0000 (07:07 +0200)
lily/output-property-engraver.cc
ly/music-functions-init.ly
python/convertrules.py

index 7efe061304ad1c467068bb6a900af24c895fb2f1..c14a6ee563b11c3e1f09cd6210ed7f7fa8eb1255 100644 (file)
@@ -56,6 +56,10 @@ Output_property_engraver::acknowledge_grob (Grob_info inf)
     {
       Stream_event *o = props_[i];
       Context *d = inf.context ();
+      SCM grob = o->get_property ("symbol");
+      if (scm_is_symbol (grob)
+          && ly_symbol2string (grob) != inf.grob ()->name ())
+        continue;
       SCM proc = o->get_property ("procedure");
       scm_call_3 (proc,
                  inf.grob ()->self_scm (),
index 98e6203630dedd13dabc1b4aaa3ee02a06218674..8e6483184f5d7753421b3b5942fc976008986c5e 100644 (file)
@@ -152,11 +152,18 @@ applyMusic =
    (func music))
 
 applyOutput =
-#(define-music-function (ctx proc) (symbol? procedure?)
-   (_i "Apply function @code{proc} to every layout object in context @code{ctx}")
-   (make-music 'ApplyOutputEvent
-               'procedure proc
-               'context-type ctx))
+#(define-music-function (target proc) (symbol-list-or-symbol? procedure?)
+   (_i "Apply function @code{proc} to every layout object matched by
+@var{target} which takes the form @code{Context} or @code{Context.Grob}.")
+   (let ((p (check-grob-path target (*location*) #:max 2)))
+     (if p
+         (make-music 'ApplyOutputEvent
+                     'procedure proc
+                     'context-type (car p)
+                     (if (pair? (cdr p))
+                         (list (cons 'symbol (cadr p)))
+                         '()))
+         (make-music 'Music))))
 
 appoggiatura =
 #(def-grace-function startAppoggiaturaMusic stopAppoggiaturaMusic
index a824fcbd5a83651ff57f36c9c11c194da611f2c7..fd33dce1d162e6b3a0f0f12e59dd22398e8749ce 100644 (file)
@@ -3826,10 +3826,12 @@ def conv(str):
         return str
     return inner (str)
 
-@rule ((2, 19, 24), "music-has-type -> music-is-of-type?")
+@rule ((2, 19, 24), r"""music-has-type -> music-is-of-type?
+\applyOutput #'Context -> \applyOutput Context""")
 def conv (str):
     str = re.sub (r'(?<=\s|["\\()])' + "music-has-type" + r'(?=\s|["\\()])',
                   "music-is-of-type?", str)
+    str = re.sub (r"(\\applyOutput\s+)#'([a-zA-Z])", r"\1\2", str)
     return str
 
 # Guidelines to write rules (please keep this at the end of this file)