diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 58dcd09d7e..0241f27395 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el @@ -354,6 +354,26 @@ eieio-persistent-validate/fix-slot-value 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. diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el index d0d2ff5145..ab96547f93 100644 --- a/lisp/emacs-lisp/eieio.el +++ b/lisp/emacs-lisp/eieio.el @@ -926,6 +926,25 @@ eieio-override-prin1 (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))))