]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp/emacs-lisp/eieio-base.el (eieio-persistent-read): Simplify.
authorStefan Kangas <stefan@marxist.se>
Sun, 31 Jul 2022 10:01:01 +0000 (12:01 +0200)
committerStefan Kangas <stefan@marxist.se>
Sun, 31 Jul 2022 10:04:17 +0000 (12:04 +0200)
lisp/emacs-lisp/eieio-base.el

index 4c702deaa952cd05d5ebb48d87c59d1ee2f36897..ef02216411d80ca50dd460faa2756fe5a18d3f0c 100644 (file)
@@ -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)