X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=ly%2Fcontext-mods-init.ly;h=24b8ce055845e3d730475b64da9c94e6a9e46b46;hb=d10e0de7dceb7393a0f08dcb0672979b1e53cf57;hp=d3ae2129fac6c0c04fc5d844d0e152d9267e225a;hpb=0b544cfb7332615ef809b71b57ab656741311ae1;p=lilypond.git diff --git a/ly/context-mods-init.ly b/ly/context-mods-init.ly index d3ae2129fa..24b8ce0558 100644 --- a/ly/context-mods-init.ly +++ b/ly/context-mods-init.ly @@ -1,6 +1,6 @@ %%%% This file is part of LilyPond, the GNU music typesetter. %%%% -%%%% Copyright (C) 2011--2014 Han-Wen Nienhuys +%%%% Copyright (C) 2011--2015 Han-Wen Nienhuys %%%% Jan Nieuwenhuizen %%%% %%%% LilyPond is free software: you can redistribute it and/or modify @@ -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")))))