From: Zhu Zihao Date: Fri, 8 May 2020 09:01:56 +0000 (+0800) Subject: Make pcase pattern 'eieio' respect slot access related functions. X-Git-Tag: emacs-28.0.90~7411 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=39b2a598d27809c524a123fd53db71783693071e;p=emacs.git Make pcase pattern 'eieio' respect slot access related functions. * lisp/emacs-lisp/eieio.el: Make pcase pattern respect slot-missing and slot-unbound --- diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index fe2b80be01e..999d75f79e9 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -359,16 +359,13 @@ contents of field NAME is matched against PAT, or they can be of ;; FIXME: `pcase' does not do a good job here of sharing tests&code among ;; various branches. `(and (pred eieio-object-p) - (app eieio-pcase-slot-index-table ,is) - ,@(mapcar (lambda (field) - (let* ((name (if (consp field) (car field) field)) - (pat (if (consp field) (cadr field) field)) - (i (make-symbol "index"))) - `(and (let (and ,i (pred natnump)) - (eieio-pcase-slot-index-from-index-table - ,is ',name)) - (app (pcase--flip aref ,i) ,pat)))) - fields)))) + ,@(mapcar (lambda (field) + (pcase-exhaustive field + (`(,name ,pat) + `(app (pcase--flip eieio-oref ',name) ,pat)) + ((pred symbolp) + `(app (pcase--flip eieio-oref ',field) ,field)))) + fields)))) ;;; Simple generators, and query functions. None of these would do ;; well embedded into an object.