summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorEric Ludlam <zappo@gnu.org>2021-01-10 10:54:49 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2021-01-11 16:20:57 -0500
commit002f9dc091ecaabbed38917a13748dd0d893fffd (patch)
treeec8697f4cee2e43fe90eea5d9c1c52ee9bb3f739 /lisp/emacs-lisp
parentfcf8ad610d43ba9b96d9ad1cc67185144c819006 (diff)
downloademacs-002f9dc091ecaabbed38917a13748dd0d893fffd.tar.gz
eieio-base.el:
(eieio-persistent-make-instance): Save the backward compatible 'name' of objects saved in the file, and if the newly loaded class inherits from 'eieio-named', restore the name of the object. Author: Eric Ludlam <zappo@gnu.org>
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/eieio-base.el29
1 files changed, 22 insertions, 7 deletions
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el
index 4ba72aea56d..19809265ff0 100644
--- a/lisp/emacs-lisp/eieio-base.el
+++ b/lisp/emacs-lisp/eieio-base.el
@@ -264,12 +264,17 @@ objects found there."
(:method
((objclass (subclass eieio-default-superclass)) inputlist)
- (let ((slots (if (stringp (car inputlist))
- ;; Earlier versions of `object-write' added a
- ;; string name for the object, now obsolete.
- (cdr inputlist)
- inputlist))
- (createslots nil))
+ (let* ((name nil)
+ (slots (if (stringp (car inputlist))
+ (progn
+ ;; Earlier versions of `object-write' added a
+ ;; string name for the object, now obsolete.
+ ;; Save as 'name' in case this object is subclass
+ ;; of eieio-named with no :object-name slot specified.
+ (setq name (car inputlist))
+ (cdr inputlist))
+ inputlist))
+ (createslots nil))
;; If OBJCLASS is an eieio autoload object, then we need to
;; load it (we don't need the return value).
(eieio--full-class-object objclass)
@@ -286,7 +291,17 @@ objects found there."
(setq slots (cdr (cdr slots))))
- (apply #'make-instance objclass (nreverse createslots)))))
+ (let ((newobj (apply #'make-instance objclass (nreverse createslots))))
+
+ ;; Check for special case of subclass of `eieio-named', and do
+ ;; name assignment.
+ (when (and eieio-backward-compatibility
+ (object-of-class-p newobj eieio-named)
+ (not (oref newobj object-name))
+ name)
+ (oset newobj object-name name))
+
+ newobj))))
(defun eieio-persistent-fix-value (proposed-value)
"Fix PROPOSED-VALUE.