From 71eebe83138ead38e2e6383f6a9f145985e30b08 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Wed, 3 Oct 2012 13:38:24 +0200 Subject: [PATCH] Issue 2874: Provide an \undo function for turning overrides and sets into reverts and unsets \undo\hideNotes is equivalent to \unHideNotes, \undo\easyHeadsOn to \easyHeadsOff. While this can't undo reverts, it is useful for a lot of overriding commands defined in ly/property-init.ly, and is also useful in combination with \hide/\omit. --- ly/music-functions-init.ly | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 2180b895e1..4fa31929d4 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -1321,6 +1321,50 @@ are affected.") (ly:music-property music 'tweaks))) music) +undo = +#(define-music-function (parser location music) + (ly:music?) + (_i "Convert @code{\\override} and @code{\\set} in @var{music} to +@code{\\revert} and @code{\\unset}, respectively. Any reverts and +unsets already in @var{music} are ignored and not converted.") + (let loop + ((music music)) + (let + ((lst + (fold-some-music + (lambda (m) (or (music-is-of-type? m 'layout-instruction-event) + (music-is-of-type? m 'context-specification))) + (lambda (m overrides) + (case (ly:music-property m 'name) + ((OverrideProperty) + (cons + (make-music 'RevertProperty + 'symbol (ly:music-property m 'symbol) + 'grob-property-path + (cond + ((ly:music-property m 'grob-property #f) => list) + (else + (ly:music-property m 'grob-property-path)))) + overrides)) + ((PropertySet) + (cons + (make-music 'PropertyUnset + 'symbol (ly:music-property m 'symbol)) + overrides)) + ((ContextSpeccedMusic) + (cons + (make-music 'ContextSpeccedMusic + 'element (loop (ly:music-property m 'element)) + 'context-type (ly:music-property m 'context-type)) + overrides)) + (else overrides))) + '() + music))) + (cond + ((null? lst) (make-music 'Music)) + ((null? (cdr lst)) (car lst)) + (else (make-sequential-music lst)))))) + unfoldRepeats = #(define-music-function (parser location music) (ly:music?) (_i "Force any @code{\\repeat volta}, @code{\\repeat tremolo} or -- 2.39.5