summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2021-08-09 19:03:01 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2021-08-09 19:03:42 -0400
commit75de09b9de2c800d074e2b65a03483d0d44ce3de (patch)
treec23c7142550670371fd7847556e4776725204325 /lisp/emacs-lisp
parent0509f3921b52feb6b1916e4ba64c91a603991bfe (diff)
downloademacs-75de09b9de2c800d074e2b65a03483d0d44ce3de.tar.gz
emacs-75de09b9de2c800d074e2b65a03483d0d44ce3de.tar.bz2
emacs-75de09b9de2c800d074e2b65a03483d0d44ce3de.zip
* lisp/emacs-lisp/cl-generic.el: Try and fix bug#49866
(cl-generic-generalizers): Remember the specializers that match a given value. (cl--generic-eql-generalizer): Adjust accordingly. * test/lisp/emacs-lisp/cl-generic-tests.el (cl-generic-test-01-eql): Add corresponding test.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/cl-generic.el29
1 files changed, 17 insertions, 12 deletions
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index db5a5a0c89a..4a69df15bc8 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -1153,22 +1153,27 @@ These match if the argument is a cons cell whose car is `eql' to VAL."
(cl-generic-define-generalizer cl--generic-eql-generalizer
100 (lambda (name &rest _) `(gethash ,name cl--generic-eql-used))
- (lambda (tag &rest _) (if (eq (car-safe tag) 'eql) (list tag))))
+ (lambda (tag &rest _) (if (eq (car-safe tag) 'eql) (cdr tag))))
(cl-defmethod cl-generic-generalizers ((specializer (head eql)))
"Support for (eql VAL) specializers.
These match if the argument is `eql' to VAL."
- (let ((form (cadr specializer)))
- (puthash (if (or (not (symbolp form)) (macroexp-const-p form))
- (eval form t)
- ;; FIXME: Compatibility with Emacs<28. For now emitting
- ;; a warning would be annoying for third party packages
- ;; which can't use the new form without breaking compatibility
- ;; with older Emacsen, but in the future we should emit
- ;; a warning.
- ;; (message "Quoting obsolete `eql' form: %S" specializer)
- form)
- specializer cl--generic-eql-used))
+ (let* ((form (cadr specializer))
+ (val (if (or (not (symbolp form)) (macroexp-const-p form))
+ (eval form t)
+ ;; FIXME: Compatibility with Emacs<28. For now emitting
+ ;; a warning would be annoying for third party packages
+ ;; which can't use the new form without breaking compatibility
+ ;; with older Emacsen, but in the future we should emit
+ ;; a warning.
+ ;; (message "Quoting obsolete `eql' form: %S" specializer)
+ form))
+ (specializers (cdr (gethash val cl--generic-eql-used))))
+ ;; The `specializers-function' needs to return all the (eql EXP) that
+ ;; were used for the same VALue (bug#49866).
+ ;; So we keep this info in `cl--generic-eql-used'.
+ (cl-pushnew specializer specializers :test #'equal)
+ (puthash val `(eql . ,specializers) cl--generic-eql-used))
(list cl--generic-eql-generalizer))
(cl--generic-prefill-dispatchers 0 (eql nil))