summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/eieio-base.el
diff options
context:
space:
mode:
authorEric Abrahamsen <eric@ericabrahamsen.net>2017-12-05 14:41:50 -0800
committerEric Abrahamsen <eric@ericabrahamsen.net>2017-12-09 08:55:58 -0800
commite1cc2037a9183bab9440b7b981a233c95d896aac (patch)
treeb7b5345cdbfdaa1df6bfb6fbdd031cc8d278a4c2 /lisp/emacs-lisp/eieio-base.el
parentcda219c3df688cb54b20bf8d061dac56b8f754be (diff)
downloademacs-e1cc2037a9183bab9440b7b981a233c95d896aac.tar.gz
emacs-e1cc2037a9183bab9440b7b981a233c95d896aac.tar.bz2
emacs-e1cc2037a9183bab9440b7b981a233c95d896aac.zip
Handle hash tables and vectors when reading/writing EIEIO objects
* lisp/emacs-lisp/eieio.el (eieio-override-prin1): EIEIO objects printed with `prin1' can no longer be read with `read'. Make sure they are printed with object-write instead, even when they're inside hash tables and vectors. * lisp/emacs-lisp/eieio-base.el (eieio-persistent-validate/fix-slot-value): Check for written representations of objects inside hash tables and vectors, and reconstruct them.
Diffstat (limited to 'lisp/emacs-lisp/eieio-base.el')
-rw-r--r--lisp/emacs-lisp/eieio-base.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el
index f11056faecc..a07e1f13acf 100644
--- a/lisp/emacs-lisp/eieio-base.el
+++ b/lisp/emacs-lisp/eieio-base.el
@@ -354,6 +354,26 @@ Second, any text properties will be stripped from strings."
proposed-value))
(t
proposed-value))))
+ ;; For hash-tables and vectors, the top-level `read' will not
+ ;; "look inside" member values, so we need to do that
+ ;; explicitly.
+ ((hash-table-p proposed-value)
+ (maphash
+ (lambda (key value)
+ (when (class-p (car-safe value))
+ (setf (gethash key proposed-value)
+ (eieio-persistent-convert-list-to-object
+ value))))
+ proposed-value)
+ proposed-value)
+
+ ((vectorp proposed-value)
+ (dotimes (i (length proposed-value))
+ (when (class-p (car-safe (aref proposed-value i)))
+ (aset proposed-value i
+ (eieio-persistent-convert-list-to-object
+ (aref proposed-value i)))))
+ proposed-value)
((stringp proposed-value)
;; Else, check for strings, remove properties.