From: David Kastrup Date: Tue, 4 Aug 2015 08:44:49 +0000 (+0200) Subject: Add check-music-path function X-Git-Tag: release/2.19.26-1~57 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=473dbe8c4e0af73fe7fb341484d1071965d5f3b4;p=lilypond.git Add check-music-path function --- diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 8b3647923d..4e7e8aea1f 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -513,6 +513,29 @@ error (using optionally @code{location})." location) #f)))) +(define-safe-public (check-music-path path #:optional location #:key default) + "Check a music 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 'music-type?)) + (define (unspecial? s) + (not (property? s))) + (or (case (length path) + ((1) (and (property? (car path)) (cons default path))) + ((2) (and (unspecial? (car path)) (property? (cadr path)) path)) + (else #f)) + (begin + (ly:parser-error + (format #f (_ "bad music 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."