From: David Kastrup Date: Thu, 16 Jul 2015 13:54:33 +0000 (+0200) Subject: Issue 4507/1: Let \applyOutput take an optional grob spec X-Git-Tag: release/2.19.24-1~5^2~25 X-Git-Url: https://git.donarmstrong.com/?p=lilypond.git;a=commitdiff_plain;h=579cc91ea384517d2c6b85e224074ffdfaa1f5ba Issue 4507/1: Let \applyOutput take an optional grob spec --- diff --git a/lily/output-property-engraver.cc b/lily/output-property-engraver.cc index 7efe061304..c14a6ee563 100644 --- a/lily/output-property-engraver.cc +++ b/lily/output-property-engraver.cc @@ -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 (), diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 98e6203630..8e6483184f 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -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 diff --git a/python/convertrules.py b/python/convertrules.py index a824fcbd5a..fd33dce1d1 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -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)