diff options
author | Eric Abrahamsen <eric@ericabrahamsen.net> | 2017-12-05 14:41:50 -0800 |
---|---|---|
committer | Eric Abrahamsen <eric@ericabrahamsen.net> | 2017-12-09 08:55:58 -0800 |
commit | e1cc2037a9183bab9440b7b981a233c95d896aac (patch) | |
tree | b7b5345cdbfdaa1df6bfb6fbdd031cc8d278a4c2 /lisp/emacs-lisp/eieio.el | |
parent | cda219c3df688cb54b20bf8d061dac56b8f754be (diff) | |
download | emacs-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.el')
-rw-r--r-- | lisp/emacs-lisp/eieio.el | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index 75f1097acf1..c73b7a8c3f1 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -913,6 +913,25 @@ this object." (object-write thing)) ((consp thing) (eieio-list-prin1 thing)) + ((hash-table-p thing) + (let ((copy (copy-hash-table thing))) + (maphash + (lambda (key val) + (setf (gethash key copy) + (read + (with-output-to-string + (eieio-override-prin1 val))))) + copy) + (prin1 copy))) + ((vectorp thing) + (let ((copy (copy-sequence thing))) + (dotimes (i (length copy)) + (aset copy i + (read + (with-output-to-string + (eieio-override-prin1 + (aref copy i)))))) + (prin1 copy))) ((eieio--class-p thing) (princ (eieio--class-print-name thing))) (t (prin1 thing)))) |