]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/cl-generic.el (cl--generic-typeof-types): Add `atom'
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 22 Feb 2017 02:44:32 +0000 (21:44 -0500)
committerStefan Monnier <monnier@iro.umontreal.ca>
Wed, 22 Feb 2017 02:47:10 +0000 (21:47 -0500)
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.

lisp/emacs-lisp/cl-generic.el

index b7695af32f6f97f834f6e3fdee16a52ce59c9f58..8517e1ee6431c49dddd73e002e76dd768e52502d 100644 (file)
@@ -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.