]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4561/1: \inherit-acceptability for inheriting accepts for a context-def
authorDavid Kastrup <dak@gnu.org>
Fri, 14 Aug 2015 12:47:26 +0000 (14:47 +0200)
committerDavid Kastrup <dak@gnu.org>
Mon, 24 Aug 2015 08:33:03 +0000 (10:33 +0200)
ly/context-mods-init.ly

index e8b96025773683aab20fbf3e2d4f42b914105e5b..24b8ce055845e3d730475b64da9c94e6a9e46b46 100644 (file)
@@ -23,3 +23,26 @@ RemoveEmptyStaves = \with {
   \description "Remove staves which are considered to be empty according
 to the list of interfaces set by @code{keepAliveInterfaces}."
 }
+
+inherit-acceptability =
+#(define-void-function (to from)
+   (symbol? symbol?)
+   (_i "When used in an output definition, will modify all context
+definitions such that context @var{to} is accepted as a child by all
+contexts that also accept @var{from}.")
+   (let* ((module (current-module))
+         (cmod (ly:make-context-mod)))
+     (ly:add-context-mod cmod (list 'accepts to))
+     (if (output-module? module)
+        (module-map
+         (lambda (_sym var)
+           (if (variable-bound? var)
+               (let ((cdef (variable-ref var)))
+                 (if (ly:context-def? cdef)
+                     (let ((accepts (ly:context-def-lookup cdef 'accepts)))
+                       (if (and (memq from accepts)
+                                (not (memq to accepts)))
+                           (variable-set! var
+                                          (ly:context-def-modify cdef cmod))))))))
+         module)
+        (ly:parser-error (_ "Not in an output definition")))))