GNU bug report logs - #78303
31.0.50; Allow nil as valid value for url-cookie-save-interval per doc and type

Previous Next

Package: emacs;

Reported by: Jens Schmidt <jschmidt4gnu <at> vodafonemail.de>

Date: Wed, 7 May 2025 21:01:02 UTC

Severity: normal

Found in version 31.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 78303 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jens Schmidt <jschmidt4gnu <at> vodafonemail.de>
Cc: 78303 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#78303: 31.0.50;
 Allow nil as valid value for url-cookie-save-interval per doc and type
Date: Thu, 08 May 2025 12:40:48 +0300
> Cc: stefan monnier <monnier <at> iro.umontreal.ca>
> Date: Wed, 7 May 2025 22:59:47 +0200
> From:  Jens Schmidt via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> [ CC to Stefan, who seems to be the original author of that cookie
>   handling thingy ... apologies if that does not really concern you ]
> 
> Variable `url-cookie-save-interval' can be perfectly well configured to
> nil, as one can see in function `url-cookie-setup-save-timer' (which
> seems to be the only function referencing that variable):
> 
>   (defun url-cookie-setup-save-timer ()
>     "Reset the cookie saver timer."
>     (interactive)
>     (ignore-errors (cancel-timer url-cookie-timer))
>     (setq url-cookie-timer nil)
>     (if url-cookie-save-interval
>         (setq url-cookie-timer (run-at-time url-cookie-save-interval
>                                             url-cookie-save-interval
>                                             #'url-cookie-write-file))))
> 
> However, the docstring and the :type of the defcustom do not
> document/allow for nil as a valid value.
> 
> The attached patch fixes that, please check.

Thanks, my alternative suggestion is below.  Now Stefan gets to choose ;-)

diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el
index bb7364e..7ec90fd 100644
--- a/lisp/url/url-cookie.el
+++ b/lisp/url/url-cookie.el
@@ -350,21 +350,23 @@ url-cookie-timer
 
 (defcustom url-cookie-save-interval 3600
   "The number of seconds between automatic saves of cookies.
-Default is 1 hour.  Note that if you change this variable outside of
+Default is 1 hour; set to nil to disable automatic saving.
+Note that if you change this variable outside of
 the `customize' interface after `url-do-setup' has been run, you need
 to run the `url-cookie-setup-save-timer' function manually."
   :set (lambda (var val)
          (set-default var val)
          (if (bound-and-true-p url-setup-done)
              (url-cookie-setup-save-timer)))
-  :type 'natnum)
+  :type '(choice (const :tag "Disable automatic saving" :value nil)
+                 (natnum :tag "Auto-save interval in seconds")))
 
 (defun url-cookie-setup-save-timer ()
   "Reset the cookie saver timer."
   (interactive)
   (ignore-errors (cancel-timer url-cookie-timer))
   (setq url-cookie-timer nil)
-  (if url-cookie-save-interval
+  (if (natnump url-cookie-save-interval)
       (setq url-cookie-timer (run-at-time url-cookie-save-interval
 					  url-cookie-save-interval
 					  #'url-cookie-write-file))))




This bug report was last modified 2 days ago.

Previous Next


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