diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2017-02-21 21:44:32 -0500 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2017-02-21 21:47:10 -0500 |
commit | fb997d30af28da4712ca64876feddbd07db20e13 (patch) | |
tree | f25bd97212a2f0b5355e3dc3f4a9ee9164ce60b9 /lisp/emacs-lisp/cl-generic.el | |
parent | 907bad07f25ca91e72ebb29a468c6b1b8b91fa49 (diff) | |
download | emacs-fb997d30af28da4712ca64876feddbd07db20e13.tar.gz |
* 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.
Diffstat (limited to 'lisp/emacs-lisp/cl-generic.el')
-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." (defconst cl--generic-typeof-types ;; Hand made from the source code of `type-of'. - '((integer number) (symbol) (string array sequence) (cons list sequence) + '((integer number number-or-marker atom) + (symbol atom) (string array sequence atom) + (cons list sequence) ;; Markers aren't `numberp', yet they are accepted wherever integers are ;; accepted, pretty much. - (marker) (overlay) (float number) (window-configuration) - (process) (window) (subr) (compiled-function) (buffer) - (char-table array sequence) - (bool-vector array sequence) - (frame) (hash-table) (font-spec) (font-entity) (font-object) - (vector array sequence) - ;; Plus, hand made: - (null symbol list sequence) - (list sequence) - (array sequence) - (sequence) - (number))) + (marker number-or-marker atom) + (overlay atom) (float number atom) (window-configuration atom) + (process atom) (window atom) (subr atom) (compiled-function function atom) + (buffer atom) (char-table array sequence atom) + (bool-vector array sequence atom) + (frame atom) (hash-table atom) + (font-spec atom) (font-entity atom) (font-object atom) + (vector array sequence atom) + ;; Plus, really hand made: + (null symbol list sequence atom)) + "Alist of supertypes. +Each element has the form (TYPE . SUPERTYPES) where TYPE is one of +the symbols returned by `type-of', and SUPERTYPES is the list of its +supertypes from the most specific to least specific.") + +(defconst cl--generic-all-builtin-types + (delete-dups (copy-sequence (apply #'append cl--generic-typeof-types)))) (cl-generic-define-generalizer cl--generic-typeof-generalizer ;; 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." "Support for dispatch on builtin types. See the full list and their hierarchy in `cl--generic-typeof-types'." ;; FIXME: Add support for other types accepted by `cl-typep' such - ;; as `character', `atom', `face', `function', ... + ;; as `character', `face', `function', ... (or - (and (assq type cl--generic-typeof-types) + (and (memq type cl--generic-all-builtin-types) (progn ;; FIXME: While this wrinkle in the semantics can be occasionally ;; problematic, this warning is more often annoying than helpful. |