diff options
| author | Stefan Monnier | 2017-02-21 21:44:32 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2017-02-21 21:47:10 -0500 |
| commit | fb997d30af28da4712ca64876feddbd07db20e13 (patch) | |
| tree | f25bd97212a2f0b5355e3dc3f4a9ee9164ce60b9 | |
| parent | 907bad07f25ca91e72ebb29a468c6b1b8b91fa49 (diff) | |
| download | emacs-fb997d30af28da4712ca64876feddbd07db20e13.tar.gz emacs-fb997d30af28da4712ca64876feddbd07db20e13.zip | |
* lisp/emacs-lisp/cl-generic.el (cl--generic-typeof-types): Add `atom'
remove entries whose car can't be returned by type-of.
(cl--generic-all-builtin-types): New var.
(cl-generic-generalizers): Use it to avoid requiring
extra entries in cl--generic-typeof-types.
| -rw-r--r-- | lisp/emacs-lisp/cl-generic.el | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el index b7695af32f6..8517e1ee643 100644 --- a/lisp/emacs-lisp/cl-generic.el +++ b/lisp/emacs-lisp/cl-generic.el | |||
| @@ -1144,21 +1144,28 @@ These match if the argument is `eql' to VAL." | |||
| 1144 | 1144 | ||
| 1145 | (defconst cl--generic-typeof-types | 1145 | (defconst cl--generic-typeof-types |
| 1146 | ;; Hand made from the source code of `type-of'. | 1146 | ;; Hand made from the source code of `type-of'. |
| 1147 | '((integer number) (symbol) (string array sequence) (cons list sequence) | 1147 | '((integer number number-or-marker atom) |
| 1148 | (symbol atom) (string array sequence atom) | ||
| 1149 | (cons list sequence) | ||
| 1148 | ;; Markers aren't `numberp', yet they are accepted wherever integers are | 1150 | ;; Markers aren't `numberp', yet they are accepted wherever integers are |
| 1149 | ;; accepted, pretty much. | 1151 | ;; accepted, pretty much. |
| 1150 | (marker) (overlay) (float number) (window-configuration) | 1152 | (marker number-or-marker atom) |
| 1151 | (process) (window) (subr) (compiled-function) (buffer) | 1153 | (overlay atom) (float number atom) (window-configuration atom) |
| 1152 | (char-table array sequence) | 1154 | (process atom) (window atom) (subr atom) (compiled-function function atom) |
| 1153 | (bool-vector array sequence) | 1155 | (buffer atom) (char-table array sequence atom) |
| 1154 | (frame) (hash-table) (font-spec) (font-entity) (font-object) | 1156 | (bool-vector array sequence atom) |
| 1155 | (vector array sequence) | 1157 | (frame atom) (hash-table atom) |
| 1156 | ;; Plus, hand made: | 1158 | (font-spec atom) (font-entity atom) (font-object atom) |
| 1157 | (null symbol list sequence) | 1159 | (vector array sequence atom) |
| 1158 | (list sequence) | 1160 | ;; Plus, really hand made: |
| 1159 | (array sequence) | 1161 | (null symbol list sequence atom)) |
| 1160 | (sequence) | 1162 | "Alist of supertypes. |
| 1161 | (number))) | 1163 | Each element has the form (TYPE . SUPERTYPES) where TYPE is one of |
| 1164 | the symbols returned by `type-of', and SUPERTYPES is the list of its | ||
| 1165 | supertypes from the most specific to least specific.") | ||
| 1166 | |||
| 1167 | (defconst cl--generic-all-builtin-types | ||
| 1168 | (delete-dups (copy-sequence (apply #'append cl--generic-typeof-types)))) | ||
| 1162 | 1169 | ||
| 1163 | (cl-generic-define-generalizer cl--generic-typeof-generalizer | 1170 | (cl-generic-define-generalizer cl--generic-typeof-generalizer |
| 1164 | ;; FIXME: We could also change `type-of' to return `null' for nil. | 1171 | ;; FIXME: We could also change `type-of' to return `null' for nil. |
| @@ -1170,9 +1177,9 @@ These match if the argument is `eql' to VAL." | |||
| 1170 | "Support for dispatch on builtin types. | 1177 | "Support for dispatch on builtin types. |
| 1171 | See the full list and their hierarchy in `cl--generic-typeof-types'." | 1178 | See the full list and their hierarchy in `cl--generic-typeof-types'." |
| 1172 | ;; FIXME: Add support for other types accepted by `cl-typep' such | 1179 | ;; FIXME: Add support for other types accepted by `cl-typep' such |
| 1173 | ;; as `character', `atom', `face', `function', ... | 1180 | ;; as `character', `face', `function', ... |
| 1174 | (or | 1181 | (or |
| 1175 | (and (assq type cl--generic-typeof-types) | 1182 | (and (memq type cl--generic-all-builtin-types) |
| 1176 | (progn | 1183 | (progn |
| 1177 | ;; FIXME: While this wrinkle in the semantics can be occasionally | 1184 | ;; FIXME: While this wrinkle in the semantics can be occasionally |
| 1178 | ;; problematic, this warning is more often annoying than helpful. | 1185 | ;; problematic, this warning is more often annoying than helpful. |