all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: pierre.techoueyres@free.fr (Pierre Téchoueyres)
Cc: 29220@debbugs.gnu.org, Stefan Monnier <monnier@iro.umontreal.ca>,
	Noam Postavsky <npostavs@users.sourceforge.net>
Subject: bug#29220: 26.0.90; eieio-persistent-read fail to restore saved object.
Date: Mon, 04 Dec 2017 17:27:04 -0800	[thread overview]
Message-ID: <87h8t69d7b.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <87zi6zmzh7.fsf@killashandra.ballybran.fr> ("Pierre Téchoueyres"'s message of "Sun, 03 Dec 2017 19:35:16 +0100")

[-- Attachment #1: Type: text/plain, Size: 846 bytes --]


On 12/03/17 19:35 PM, Pierre Téchoueyres wrote:
> Eric Abrahamsen <eric@ericabrahamsen.net> writes:
>
>> On 12/01/17 12:55 PM, Stefan Monnier wrote:
>>>>> So I think the real fix here is to extend eieio-persistent with support
>>>>> for hash-tables.
>>>> Just hash tables?
>>>
>>> For the problem at hand, IIUC, hash-tables is what's needed, yes.
>>>
>>>> How about vectors?
>>>
>>> Sure, add that too.
>>
>> Before I do that, I just opened #29541 with a proposal for tweaking the
>> restore process -- maybe that could be done first?
>>
>
> I wishes it would, but this is a blocker bug for emacs 26, isn't it ?

Could be! If so, let's fix this part first.

Here's a diff that seems to work. The read->with-output-to-string stuff
seems awful to me, and I'm hoping someone has something more elegant on
hand.

Eric


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: persistent-stuff.diff --]
[-- Type: text/x-patch, Size: 2364 bytes --]

diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el
index 58dcd09d7e..840f7223c4 100644
--- a/lisp/emacs-lisp/eieio-base.el
+++ b/lisp/emacs-lisp/eieio-base.el
@@ -354,15 +354,34 @@ eieio-persistent-validate/fix-slot-value
 		   proposed-value))
 		 (t
 		  proposed-value))))
+	((stringp proposed-value)
+	 ;; Remove string properties.
+	 (substring-no-properties 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.
-	  (substring-no-properties proposed-value))
-
-	 (t
-	  ;; Else, just return whatever the constant was.
-	  proposed-value))
-  )
+	(t
+	 ;; Else, just return whatever the constant was.
+	 proposed-value)))
 
 (defun eieio-persistent-slot-type-is-class-p (type)
   "Return the class referred to in TYPE.
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index d0d2ff5145..11637c8072 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -926,6 +926,23 @@ eieio-override-prin1
 	 (object-write thing))
 	((consp thing)
 	 (eieio-list-prin1 thing))
+	((hash-table-p thing)
+	 (maphash
+	  (lambda (key val)
+	    (setf (gethash key thing)
+		  (read
+		   (with-output-to-string
+		     (temp-eieio-override-prin1 val)))))
+	  thing)
+	 (prin1 thing))
+	((vectorp thing)
+	 (dotimes (i (length thing))
+	   (aset thing i
+		 (read
+		  (with-output-to-string
+		    (temp-eieio-override-prin1
+		     (aref thing i))))))
+	 (prin1 thing))
 	((eieio--class-p thing)
 	 (princ (eieio--class-print-name thing)))
 	(t (prin1 thing))))

  reply	other threads:[~2017-12-05  1:27 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 22:04 bug#29220: 26.0.90; eieio-persistent-read fail to restore saved object Pierre Téchoueyres
2017-11-08 22:48 ` Eric Abrahamsen
2017-11-10 17:31   ` Pierre Téchoueyres
2017-11-10 18:12     ` Eric Abrahamsen
2017-11-10 18:32       ` Pierre Téchoueyres
2017-11-12 19:10       ` Noam Postavsky
2017-11-14 22:30         ` Pierre Téchoueyres
2017-11-15  2:02           ` Noam Postavsky
2017-11-15 15:29             ` Stefan Monnier
2017-11-17 19:56               ` Pierre Téchoueyres
2017-11-18  3:40             ` Noam Postavsky
2017-11-18  4:39               ` Eric Abrahamsen
2017-11-18 13:24                 ` Noam Postavsky
2017-11-18 18:14                   ` Eric Abrahamsen
2017-11-19  3:17                     ` Noam Postavsky
2017-11-19  5:57                       ` Eric Abrahamsen
2017-11-23 23:20                       ` Pierre Téchoueyres
2017-11-24  0:09                         ` Noam Postavsky
2017-11-28 21:39                           ` Pierre Téchoueyres
2017-11-28 21:52                             ` Noam Postavsky
2017-11-28 22:18                               ` Pierre Téchoueyres
2017-11-29  1:09                                 ` Noam Postavsky
2017-11-29 15:18                                   ` Stefan Monnier
2017-11-28 22:10                             ` Eric Abrahamsen
2017-11-29 15:15                               ` Stefan Monnier
2017-12-01 17:25                                 ` Eric Abrahamsen
2017-12-01 17:55                                   ` Stefan Monnier
2017-12-03  0:17                                     ` Eric Abrahamsen
2017-12-03 18:35                                       ` Pierre Téchoueyres
2017-12-05  1:27                                         ` Eric Abrahamsen [this message]
2017-12-05  2:08                                           ` Stefan Monnier
2017-12-05 17:47                                             ` Eric Abrahamsen
2017-12-05 19:02                                               ` Stefan Monnier
2017-12-05 20:56                                                 ` Eric Abrahamsen
2017-12-05 22:14                                                   ` Stefan Monnier
2017-12-05 22:58                                                     ` Eric Abrahamsen
2017-12-08 10:41                                                       ` Eli Zaretskii
2017-12-09 16:59                                                         ` Eric Abrahamsen
2017-12-12 23:21                                                           ` Noam Postavsky
2017-12-15 20:26                                                             ` Pierre Téchoueyres
2017-12-15 22:26                                                               ` Pierre Téchoueyres
2017-12-16 23:42                                                                 ` Eric Abrahamsen
2018-02-20 19:50                                                                   ` Pierre Téchoueyres
2018-02-24 21:23                                                                     ` Eric Abrahamsen
2018-02-24 23:21                                                                       ` Pierre Téchoueyres
2018-02-24 23:40                                                                         ` Eric Abrahamsen
2018-02-25  0:34                                                                           ` Pierre Téchoueyres
2018-02-25 18:59                                                                             ` Eric Abrahamsen
2019-05-27 23:36                                                                               ` Noam Postavsky
2019-05-28 21:17                                                                                 ` Eric Abrahamsen
2019-05-30 22:50                                                                                 ` Noam Postavsky
2017-12-18 19:52                                                                 ` Eric Abrahamsen
2017-12-18 21:38                                                                   ` Stefan Monnier
2017-12-20 18:29                                                                     ` Eric Abrahamsen
2017-12-20 20:54                                                                       ` Stefan Monnier
2017-12-21  2:21                                                                         ` Eric Abrahamsen
2017-12-24  2:18                                                                           ` Eric Ludlam
2017-12-28 18:44                                                                             ` Eric Abrahamsen
2017-12-05 22:20                                                   ` Pierre Téchoueyres
2018-01-24 19:17                                                     ` Pierre Téchoueyres
2018-01-25  3:09                                                       ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h8t69d7b.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=29220@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=npostavs@users.sourceforge.net \
    --cc=pierre.techoueyres@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.