diff options
author | Zhu Zihao <all_but_last@163.com> | 2020-05-08 17:01:56 +0800 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2020-05-08 11:08:02 -0400 |
commit | 39b2a598d27809c524a123fd53db71783693071e (patch) | |
tree | c159e6f6855ee9f54e6ed62905b7e514e976c530 /lisp/emacs-lisp | |
parent | 958ddc9526aa7bb1d165d45be43efc4d68589b1e (diff) | |
download | emacs-39b2a598d27809c524a123fd53db71783693071e.tar.gz emacs-39b2a598d27809c524a123fd53db71783693071e.tar.bz2 emacs-39b2a598d27809c524a123fd53db71783693071e.zip |
Make pcase pattern 'eieio' respect slot access related functions.
* lisp/emacs-lisp/eieio.el: Make pcase pattern respect slot-missing and
slot-unbound
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/eieio.el | 17 |
1 files changed, 7 insertions, 10 deletions
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. |