summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2019-05-08 07:51:48 -0700
committerGlenn Morris <rgm@gnu.org>2019-05-08 07:51:48 -0700
commit8b789755b45e6e10ed2809d7a7b89146b28452fc (patch)
tree044d0e819072fe86fddd064ce6b11a975072902b /lisp/emacs-lisp
parent6734f2168c5f4f68a15325215c2054e7006f0e82 (diff)
parent1c6484e975e8b0e50d22980d02a3be6c9bf93b49 (diff)
downloademacs-8b789755b45e6e10ed2809d7a7b89146b28452fc.tar.gz
emacs-8b789755b45e6e10ed2809d7a7b89146b28452fc.tar.bz2
emacs-8b789755b45e6e10ed2809d7a7b89146b28452fc.zip
Merge from origin/emacs-26
1c6484e (origin/emacs-26) Fix incorrect cloning of eieio-instance-inh... 37436fe Fix cloning of eieio-named objects (Bug#22840) fb65a36 Fix ibuffer-unmark-backward synopsis (bug#35572) f77bd2b ; * src/lisp.h (DEFSYM): Fix inaccurate comment. 3b86e0b Clarify handling of long options (Bug#24949) 04340a8 Improve documentation of the daemon and emacsclient 3e29de2 * etc/NEWS.24: Belatedly announce delete-consecutive-dups.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/eieio-base.el32
1 files changed, 21 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el
index 3a0109877e7..7214f8aff72 100644
--- a/lisp/emacs-lisp/eieio-base.el
+++ b/lisp/emacs-lisp/eieio-base.el
@@ -64,10 +64,18 @@ SLOT-NAME is the offending slot. FN is the function signaling the error."
;; Throw the regular signal.
(cl-call-next-method)))
-(cl-defmethod clone ((obj eieio-instance-inheritor) &rest _params)
+(cl-defmethod clone ((obj eieio-instance-inheritor) &rest params)
"Clone OBJ, initializing `:parent' to OBJ.
All slots are unbound, except those initialized with PARAMS."
- (let ((nobj (cl-call-next-method)))
+ ;; call next method without params as we makeunbound slots anyhow
+ (let ((nobj (if (stringp (car params))
+ (cl-call-next-method obj (pop params))
+ (cl-call-next-method obj))))
+ (dolist (descriptor (eieio-class-slots (class-of nobj)))
+ (let ((slot (eieio-slot-descriptor-name descriptor)))
+ (slot-makeunbound nobj slot)))
+ (when params
+ (shared-initialize nobj params))
(oset nobj parent-instance obj)
nobj))
@@ -510,16 +518,18 @@ instance."
All slots are unbound, except those initialized with PARAMS."
(let* ((newname (and (stringp (car params)) (pop params)))
(nobj (apply #'cl-call-next-method obj params))
- (nm (slot-value obj 'object-name)))
- (eieio-oset obj 'object-name
+ (nm (slot-value nobj 'object-name)))
+ (eieio-oset nobj 'object-name
(or newname
- (save-match-data
- (if (and nm (string-match "-\\([0-9]+\\)" nm))
- (let ((num (1+ (string-to-number
- (match-string 1 nm)))))
- (concat (substring nm 0 (match-beginning 0))
- "-" (int-to-string num)))
- (concat nm "-1")))))
+ (if (equal nm (slot-value obj 'object-name))
+ (save-match-data
+ (if (and nm (string-match "-\\([0-9]+\\)" nm))
+ (let ((num (1+ (string-to-number
+ (match-string 1 nm)))))
+ (concat (substring nm 0 (match-beginning 0))
+ "-" (int-to-string num)))
+ (concat nm "-1")))
+ nm)))
nobj))
(cl-defmethod make-instance ((class (subclass eieio-named)) &rest args)