]> git.donarmstrong.com Git - lilypond.git/commitdiff
Add remove-grace-property code
authorCarl Sorensen <c_sorensen@byu.edu>
Mon, 11 Aug 2008 18:47:30 +0000 (12:47 -0600)
committerCarl Sorensen <c_sorensen@byu.edu>
Mon, 11 Aug 2008 18:47:30 +0000 (12:47 -0600)
scm/music-functions.scm

index 5ca4d309afd66e9b3335713bf06720a9bc10065f..7b2cc3404f6d27e5b90e1821b98381b24fa5db9e 100644 (file)
@@ -689,7 +689,6 @@ SkipEvent. Useful for extracting parts from crowded scores"
       ((< i 0))
     (f (vector-ref v i))))
 
-;; TODO:  make a remove-grace-property too.
 (define-public (add-grace-property context-name grob sym val)
   "Set SYM=VAL for GROB in CONTEXT-NAME. "
   (define (set-prop context)
@@ -700,6 +699,25 @@ SkipEvent. Useful for extracting parts from crowded scores"
       (ly:context-set-property! where 'graceSettings new-settings)))
   (ly:export (context-spec-music (make-apply-context set-prop) 'Voice)))
 
+(define-public (remove-grace-property context-name grob sym)
+  "Remove all SYM for GROB in CONTEXT-NAME. "
+  (define (sym-grob-context? property sym grob context-name)
+    (and (eq? (car property) context-name)
+         (eq? (cadr property) grob)
+         (eq? (caddr property) sym)))
+  (define (delete-prop context)
+    (let* ((where (ly:context-property-where-defined context 'graceSettings))
+          (current (ly:context-property where 'graceSettings))
+           (prop-settings (filter 
+                            (lambda(x) (sym-grob-context? x sym grob context-name))
+                            current)) 
+          (new-settings current))
+      (for-each (lambda(x) 
+                 (set! new-settings (delete x new-settings)))
+               prop-settings)
+      (ly:context-set-property! where 'graceSettings new-settings)))
+  (ly:export (context-spec-music (make-apply-context delete-prop) 'Voice)))
+
 
 
 (defmacro-public def-grace-function (start stop)