aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Ludlam2021-01-10 10:54:49 -0500
committerStefan Monnier2021-01-11 16:20:57 -0500
commit002f9dc091ecaabbed38917a13748dd0d893fffd (patch)
treeec8697f4cee2e43fe90eea5d9c1c52ee9bb3f739
parentfcf8ad610d43ba9b96d9ad1cc67185144c819006 (diff)
downloademacs-002f9dc091ecaabbed38917a13748dd0d893fffd.tar.gz
emacs-002f9dc091ecaabbed38917a13748dd0d893fffd.zip
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>
-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."
264 (:method 264 (:method
265 ((objclass (subclass eieio-default-superclass)) inputlist) 265 ((objclass (subclass eieio-default-superclass)) inputlist)
266 266
267 (let ((slots (if (stringp (car inputlist)) 267 (let* ((name nil)
268 ;; Earlier versions of `object-write' added a 268 (slots (if (stringp (car inputlist))
269 ;; string name for the object, now obsolete. 269 (progn
270 (cdr inputlist) 270 ;; Earlier versions of `object-write' added a
271 inputlist)) 271 ;; string name for the object, now obsolete.
272 (createslots nil)) 272 ;; Save as 'name' in case this object is subclass
273 ;; of eieio-named with no :object-name slot specified.
274 (setq name (car inputlist))
275 (cdr inputlist))
276 inputlist))
277 (createslots nil))
273 ;; If OBJCLASS is an eieio autoload object, then we need to 278 ;; If OBJCLASS is an eieio autoload object, then we need to
274 ;; load it (we don't need the return value). 279 ;; load it (we don't need the return value).
275 (eieio--full-class-object objclass) 280 (eieio--full-class-object objclass)
@@ -286,7 +291,17 @@ objects found there."
286 291
287 (setq slots (cdr (cdr slots)))) 292 (setq slots (cdr (cdr slots))))
288 293
289 (apply #'make-instance objclass (nreverse createslots))))) 294 (let ((newobj (apply #'make-instance objclass (nreverse createslots))))
295
296 ;; Check for special case of subclass of `eieio-named', and do
297 ;; name assignment.
298 (when (and eieio-backward-compatibility
299 (object-of-class-p newobj eieio-named)
300 (not (oref newobj object-name))
301 name)
302 (oset newobj object-name name))
303
304 newobj))))
290 305
291(defun eieio-persistent-fix-value (proposed-value) 306(defun eieio-persistent-fix-value (proposed-value)
292 "Fix PROPOSED-VALUE. 307 "Fix PROPOSED-VALUE.