From: Gulshan Singh <gsingh2011@gmail.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Phillip Lord <phillip.lord@russet.org.uk>, 54346@debbugs.gnu.org
Subject: bug#54346: persist-save doesn't persist variables when the value is set to the default
Date: Tue, 21 Jun 2022 17:55:42 -0700 [thread overview]
Message-ID: <CANEZYrf8EqB=6wN=0UH0p+Nw2cE_ARMcX3ibOaLPh8kHgq93pQ@mail.gmail.com> (raw)
In-Reply-To: <87y1xqz3xs.fsf@gnus.org>
[-- Attachment #1.1: Type: text/plain, Size: 739 bytes --]
Sure, the attached patch should work on the ELPA version.
On Tue, Jun 21, 2022 at 3:50 AM Lars Ingebrigtsen <larsi@gnus.org> wrote:
> Gulshan Singh <gsingh2011@gmail.com> writes:
>
> > Do you know what's normally done in cases like this? Even if
> > persist.el is maintained externally, should we just merge my patch and
> > close this bug if we can't get a response from the maintainer?
>
> Yes, we can merge the patch. However, it doesn't seem to apply to the
> version we have in ELPA -- the upstream and the ELPA version have
> already diverged, apparently.
>
> Can you respin the patch against the version in GNU ELPA?
>
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
>
[-- Attachment #1.2: Type: text/html, Size: 1224 bytes --]
[-- Attachment #2: 0001-Delete-persist-file-when-symbol-is-set-to-default-va.patch --]
[-- Type: application/octet-stream, Size: 2688 bytes --]
From 4f27733c326c5f24768fb09fd8be4742fd19e3bc Mon Sep 17 00:00:00 2001
From: Gulshan Singh <gsingh2011@gmail.com>
Date: Tue, 21 Jun 2022 17:38:58 -0700
Subject: [PATCH] Delete persist file when symbol is set to default value
---
persist.el | 38 ++++++++++++++++++++------------------
test/persist-tests.el | 3 +++
2 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/persist.el b/persist.el
index 3d8d1af..950de3a 100644
--- a/persist.el
+++ b/persist.el
@@ -132,24 +132,26 @@ variables persist automatically when Emacs exits."
(unless (persist--persistant-p symbol)
(error (format
"Symbol %s is not persistant" symbol)))
- (unless (equal (symbol-value symbol)
- (persist-default symbol))
- (let ((dir-loc
- (file-name-directory
- (persist--file-location symbol))))
- (unless (file-exists-p dir-loc)
- (mkdir dir-loc)))
- (with-temp-buffer
- (let (print-level
- print-length
- print-quoted
- (print-escape-control-characters t)
- (print-escape-nonascii t)
- (print-circle t))
- (print (symbol-value symbol) (current-buffer)))
- (write-region (point-min) (point-max)
- (persist--file-location symbol)
- nil 'quiet))))
+ (let ((symbol-file-loc (persist--file-location symbol)))
+ (if (equal (symbol-value symbol)
+ (persist-default symbol))
+ (when (file-exists-p symbol-file-loc)
+ (delete-file symbol-file-loc))
+ (let ((dir-loc
+ (file-name-directory symbol-file-loc)))
+ (unless (file-exists-p dir-loc)
+ (mkdir dir-loc))
+ (with-temp-buffer
+ (let (print-level
+ print-length
+ print-quoted
+ (print-escape-control-characters t)
+ (print-escape-nonascii t)
+ (print-circle t))
+ (print (symbol-value symbol) (current-buffer)))
+ (write-region (point-min) (point-max)
+ symbol-file-loc
+ nil 'quiet))))))
(defun persist-default (symbol)
"Return the default value for SYMBOL."
diff --git a/test/persist-tests.el b/test/persist-tests.el
index 9fa406f..b6645a9 100644
--- a/test/persist-tests.el
+++ b/test/persist-tests.el
@@ -44,6 +44,9 @@
(with-temp-buffer
(insert-file-contents (persist--file-location sym))
(buffer-string))))
+ (set sym 10)
+ (persist-save sym)
+ (should-not (file-exists-p (persist--file-location sym)))
(should-error
(persist-save 'fred)))))
--
2.37.0.rc0.104.g0611611a94-goog
next prev parent reply other threads:[~2022-06-22 0:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-12 1:15 bug#54346: persist-save doesn't persist variables when the value is set to the default Gulshan Singh
2022-03-12 17:44 ` Lars Ingebrigtsen
2022-04-09 21:45 ` Gulshan Singh
2022-04-10 12:17 ` Lars Ingebrigtsen
2022-04-10 19:36 ` Gulshan Singh
2022-04-11 10:18 ` Lars Ingebrigtsen
2022-06-21 2:14 ` Gulshan Singh
2022-06-21 10:49 ` Lars Ingebrigtsen
2022-06-22 0:55 ` Gulshan Singh [this message]
2022-06-22 4:21 ` Lars Ingebrigtsen
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='CANEZYrf8EqB=6wN=0UH0p+Nw2cE_ARMcX3ibOaLPh8kHgq93pQ@mail.gmail.com' \
--to=gsingh2011@gmail.com \
--cc=54346@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=phillip.lord@russet.org.uk \
/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.