lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Provide an \un function for turning overrides and sets into reverts


From: dak
Subject: Re: Provide an \un function for turning overrides and sets into reverts and unsets (issue 6588067)
Date: Sat, 06 Oct 2012 07:10:39 +0000

Reviewers: janek,

Message:
On 2012/10/05 14:46:09, janek wrote:
please provide usage example(s).  I suppose i like this idea, but
without
examples i don't know what exactly will be possible, and what won't be
possible.

Is it enough to say that after

unHideNotes = \un\hideNotes
oneVoice = \un\voiceOne

you would not notice a difference? \un\omit StringNumber will revert the
effect of \omit StringNumber.

Description:
Provide an \un function for turning overrides and sets into reverts and
unsets

Please review this at http://codereview.appspot.com/6588067/

Affected files:
  M ly/music-functions-init.ly


Index: ly/music-functions-init.ly
diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly
index 26db17c5ede8ce07e9b72f78fa7d05c0f82a7cbf..d946ab54919b7236948a1a4a3ac7227c6958616b 100644
--- a/ly/music-functions-init.ly
+++ b/ly/music-functions-init.ly
@@ -1290,6 +1290,50 @@ are affected.")
           (ly:music-property music 'tweaks)))
    music)

+un =
+#(define-music-function (parser location music)
+   (ly:music?)
+   (_i "Convert @code{\\override} and @code{\\set} in @var{music} to
address@hidden 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]