diff options
author | David Kastrup <dak@gnu.org> | 2015-07-12 20:44:39 +0200 |
---|---|---|
committer | David Kastrup <dak@gnu.org> | 2015-07-18 06:42:13 +0200 |
commit | fb54b6968c3b70c102bcb89c54bc9b1f15a71327 (patch) | |
tree | c8ecdbaf5891544211587aeca2d9f4f192956367 /scm | |
parent | f4bbf51329c0594b55ae7fa28a831ec700c9d2e7 (diff) |
Provide check-context-path function
Diffstat (limited to 'scm')
-rw-r--r-- | scm/music-functions.scm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/scm/music-functions.scm b/scm/music-functions.scm index b75709bf0c..97bb8c4f67 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -481,6 +481,30 @@ respectively." location) #f))))) +(define-safe-public (check-context-path path #:optional location) + "Check a context property path specification @var{path}, a symbol +list (or a single symbol), for validity and possibly complete it. +Returns the completed specification, or @code{#f} when rising an +error (using optionally @code{location})." + (let* ((path (if (symbol? path) (list path) path))) + ;; A Guile 1.x bug specific to optargs precludes moving the + ;; defines out of the let + (define (property? s) + (object-property s 'translation-type?)) + (define (unspecial? s) + (not (property? s))) + (define (check c p) (c p)) + (or (case (length path) + ((1) (and (property? (car path)) (cons 'Bottom path))) + ((2) (and (unspecial? (car path)) (property? (cadr path)) path)) + (else #f)) + (begin + (ly:parser-error + (format #f (_ "bad context property ~a") + path) + location) + #f)))) + (define-public (make-grob-property-set grob gprop val) "Make a @code{Music} expression that sets @var{gprop} to @var{val} in @var{grob}. Does a pop first, i.e., this is not an override." |