diff options
author | David Kastrup <dak@gnu.org> | 2016-02-12 18:02:10 +0100 |
---|---|---|
committer | David Kastrup <dak@gnu.org> | 2016-03-19 14:20:03 +0100 |
commit | a2f0f4f890e4dbc3062a86f4d6e1e9bf65dcac98 (patch) | |
tree | eb742a7b7a113cefdb3ae2446017c08eeea2ea74 /scm | |
parent | 17440eeed8ec9fc6714d5b418387fb162d232003 (diff) |
Issue 4798/3: Define key?, key-list?, key-list-or-music?, key-list-or-symbol?
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.
Diffstat (limited to 'scm')
-rw-r--r-- | scm/c++.scm | 16 | ||||
-rw-r--r-- | scm/lily.scm | 4 |
2 files changed, 20 insertions, 0 deletions
diff --git a/scm/c++.scm b/scm/c++.scm index badac67e5c..a455afdd78 100644 --- a/scm/c++.scm +++ b/scm/c++.scm @@ -60,6 +60,22 @@ (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))) diff --git a/scm/lily.scm b/scm/lily.scm index 3d7a326c64..5ead4e6c9c 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -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") |