GNU bug report logs - #63513
[PATCH] Make persist-defvar work with records and hash tables

Previous Next

Package: emacs;

Reported by: Joseph Turner <joseph <at> breatheoutbreathe.in>

Date: Mon, 15 May 2023 06:22:02 UTC

Severity: wishlist

Tags: patch

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Subject: bug#63513: closed (Re: bug#63513: [PATCH] Make persist-defvar
 work with records and hash tables)
Date: Tue, 05 Sep 2023 21:08:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#63513: [PATCH] Make persist-defvar work with records and hash tables

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 63513 <at> debbugs.gnu.org.

-- 
63513: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63513
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Joseph Turner <joseph <at> breatheoutbreathe.in>
Cc: Adam Porter <adam <at> alphapapa.net>, Eli Zaretskii <eliz <at> gnu.org>,
 phillip.lord <at> russet.org.uk, 63513-done <at> debbugs.gnu.org
Subject: Re: bug#63513: [PATCH] Make persist-defvar work with records and
 hash tables
Date: Tue, 05 Sep 2023 17:06:17 -0400
> Here you go!

Thanks, pushed!


        Stefan


[Message part 3 (message/rfc822, inline)]
From: Joseph Turner <joseph <at> breatheoutbreathe.in>
To: bug-gnu-emacs <at> gnu.org
Cc: Adam Porter <adam <at> alphapapa.net>
Subject: [PATCH] Make persist-defvar work with records and hash tables
Date: Sun, 14 May 2023 22:56:20 -0700
[Message part 4 (text/plain, inline)]
Hello!

persist-defvar does not persist records or hash tables correctly.

Here's a minimal example with a hash table:

(progn
  (persist-defvar foo (make-hash-table :test #'equal) "docstring")
  (puthash 'bar t foo)
  (persist-save 'foo)
  (gethash 'bar (persist-default 'foo))) ;; Expected nil, got t

This patch fixes persisting records by using copy-tree. Currently,
copy-tree does not work with records (see
<https://lists.gnu.org/archive/html/bug-gnu-emacs/2023-05/msg00875.html>).
The following snippet will return the expected value only when both this
patch and the above-linked patch are applied:

(progn
  (cl-defstruct baz a)
  (persist-defvar quux (make-baz :a nil) "docstring")
  (setf (baz-a quux) t)
  (persist-save 'quux)
  (baz-a (persist-default 'quux))) ;; Expected nil, got t

Before applying this patch, the updated values in both cases are not
persisted to disk. With the patch, the updated values are persisted as
expected.

Best,

Joseph

[0001-Make-persist-defvar-work-with-records-and-hash-table.patch (text/x-diff, attachment)]

This bug report was last modified 1 year and 334 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.