]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4798/3: Define key?, key-list?, key-list-or-music?, key-list-or-symbol?
authorDavid Kastrup <dak@gnu.org>
Fri, 12 Feb 2016 17:02:10 +0000 (18:02 +0100)
committerDavid Kastrup <dak@gnu.org>
Sat, 19 Mar 2016 13:20:03 +0000 (14:20 +0100)
A key (previously a symbol) can be either a non-negative
integer (obeying the predicate index?) or a symbol.  When used for
overrides/reverts, the first elements of a path may not actually be
numbers but they are flagged as an error by other means: since a full
override path can be the concatenation of several key lists, the leading
elements are not treated differently by the list predicates.

Strictly speaking this should not be the case for key-list-or-music? or
key-list-or-symbol? predicates, but making them behave differently seems
unwarranted.  Arguably key-list-or-symbol? should possibly be
key-list-or-key? instead.

scm/c++.scm
scm/lily.scm

index badac67e5ca6f3a5ba3613edf46747b191ecbc38..a455afdd78a4cf69116dd7809bc2f227cf9b0bd1 100644 (file)
 (define-public (boolean-or-symbol? x)
   (or (boolean? x) (symbol? x)))
 
+(define-public (key? x)
+  (or (symbol? x) (index? x)))
+
+(define-public (key-list? x)
+  (and (list? x) (every key? x)))
+
+(define-public (key-list-or-music? x)
+  (if (list? x)
+      (every key? x)
+      (ly:music? x)))
+
+(define-public (key-list-or-symbol? x)
+  (if (list? x)
+      (every key? x)
+      (symbol? x)))
+
 (define-public (symbol-list? x)
   (and (list? x) (every symbol? x)))
 
index 3d7a326c64b6cbc9a98e64b4808bca3fe2a714bc..5ead4e6c9cf9da25e8f12bcf08cdfa145692f613 100644 (file)
@@ -678,6 +678,10 @@ messages into errors.")
     (,fraction? . "fraction, as pair")
     (,grob-list? . "list of grobs")
     (,index? . "non-negative integer")
+    (,key? . "index or symbol")
+    (,key-list? . "list of indexes or symbols")
+    (,key-list-or-music? . "key list or music")
+    (,key-list-or-symbol? . "key list or symbol")
     (,markup? . "markup")
     (,markup-command-list? . "markup command list")
     (,markup-list? . "markup list")