emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master ca2d3ed74c 2/2: * lisp/emacs-lisp/eieio-base.el (eieio-persistent


From: Stefan Kangas
Subject: master ca2d3ed74c 2/2: * lisp/emacs-lisp/eieio-base.el (eieio-persistent-read): Simplify.
Date: Sun, 31 Jul 2022 06:06:51 -0400 (EDT)

branch: master
commit ca2d3ed74c63167c7d8378482016efea9756dd17
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>

    * lisp/emacs-lisp/eieio-base.el (eieio-persistent-read): Simplify.
---
 lisp/emacs-lisp/eieio-base.el | 46 +++++++++++++++++++------------------------
 1 file changed, 20 insertions(+), 26 deletions(-)

diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el
index 4c702deaa9..ef02216411 100644
--- a/lisp/emacs-lisp/eieio-base.el
+++ b/lisp/emacs-lisp/eieio-base.el
@@ -281,32 +281,26 @@ being pedantic."
   (unless class
     (warn "`eieio-persistent-read' called without specifying a class"))
   (when class (cl-check-type class class))
-  (let ((ret nil)
-       (buffstr nil))
-    (unwind-protect
-       (progn
-         (with-current-buffer (get-buffer-create " *tmp eieio read*")
-           (insert-file-contents filename nil nil nil t)
-           (goto-char (point-min))
-           (setq buffstr (buffer-string)))
-         ;; Do the read in the buffer the read was initialized from
-         ;; so that any initialize-instance calls that depend on
-         ;; the current buffer will work.
-         (setq ret (read buffstr))
-         (when (not (child-of-class-p (car ret) 'eieio-persistent))
-           (error
-             "Invalid object: %s is not a subclass of `eieio-persistent'"
-             (car ret)))
-         (when (and class
-                    (not (or (eq (car ret) class) ; same class
-                             (and allow-subclass  ; subclass
-                                  (child-of-class-p (car ret) class)))))
-           (error
-             "Invalid object: %s is not an object of class %s nor a subclass"
-             (car ret) class))
-          (setq ret (eieio-persistent-make-instance (car ret) (cdr ret)))
-         (oset ret file filename))
-      (kill-buffer " *tmp eieio read*"))
+  (let* ((buffstr (with-temp-buffer
+                    (insert-file-contents filename)
+                    (buffer-string)))
+         ;; Do the read in the buffer the read was initialized from
+         ;; so that any initialize-instance calls that depend on
+         ;; the current buffer will work.
+         (ret (read buffstr)))
+    (when (not (child-of-class-p (car ret) 'eieio-persistent))
+      (error
+       "Invalid object: %s is not a subclass of `eieio-persistent'"
+       (car ret)))
+    (when (and class
+              (not (or (eq (car ret) class) ; same class
+                       (and allow-subclass  ; subclass
+                            (child-of-class-p (car ret) class)))))
+      (error
+       "Invalid object: %s is not an object of class %s nor a subclass"
+       (car ret) class))
+    (setq ret (eieio-persistent-make-instance (car ret) (cdr ret)))
+    (oset ret file filename)
     ret))
 
 (cl-defgeneric eieio-persistent-make-instance (objclass inputlist)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]