Subject: bug#78303: closed (Re: bug#78303: 31.0.50; Allow nil as valid value for url-cookie-save-interval per doc and type)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 17 May 2025 08:29:02 +0000

Your bug report

#78303: 31.0.50; Allow nil as valid value for url-cookie-save-interval per doc and type

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 [email-masked].

-- 
78303: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=78303
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#78303: 31.0.50; Allow nil as valid value for url-cookie-save-interval per doc and type
From: Eli Zaretskii <[email-masked]>
To: Stefan Monnier <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Sat, 17 May 2025 11:28:09 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Stefan Monnier <[email-masked]>
> Cc: Jens Schmidt <[email-masked]>,  [email-masked]
> Date: Thu, 08 May 2025 09:28:49 -0400
> 
> >> [ CC to Stefan, who seems to be the original author of that cookie
> >>   handling thingy ... apologies if that does not really concern you ]
> 
> [ Hmm... Git indeed claims that I added this file back in 2003, but
>   I have no recollection of doing so.  Apparently that applies to all
>   the URL package, so I guess I was the one who added that package to
>   Emacs, tho I can't remember doing that either.
>   FWIW, that package started its life as part of the W3 browser and was
>   written mostly by W3's author, William Perry.
>   You can see that package's earlier history in the `externals/w3`
>   branch of the `elpa.git `repository where the files were named
>   `lisp/url-*.el`.  ]
> 
> > Thanks, my alternative suggestion is below.  Now Stefan gets to choose ;-)
> 
> I'll let you fight it out.  🙂

I've now installed on the master branch a version that merges both
suggestions, and I'm therefore closing this bug.

Subject: 31.0.50; Allow nil as valid value for url-cookie-save-interval per doc and type
From: Jens Schmidt <[email-masked]>
To: [email-masked]
Date: Wed, 7 May 2025 22:59:47 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

X-Debbugs-Cc: Stefan Monnier <[email-masked]>

[ 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!
From f26e0f8fcf5a886079c4f2f6eb74030349b41aa1 Mon Sep 17 00:00:00 2001
From: Jens Schmidt <[email-masked]>
Date: Wed, 7 May 2025 22:48:45 +0200
Subject: [PATCH] Allow nil as valid value for `url-cookie-save-interval'

* lisp/url/url-cookie.el (url-cookie-save-interval): Allow nil as valid
value for `url-cookie-save-interval': Mention that value in the
docstring and change the custom type accordingly.  (Bug#XXXXX)
---
 lisp/url/url-cookie.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el
index bb7364ef06e..3092c5a7d79 100644
--- a/lisp/url/url-cookie.el
+++ b/lisp/url/url-cookie.el
@@ -349,15 +349,18 @@ url-cookie-handle-set-cookie
 (defvar url-cookie-timer nil)
 
 (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
-the `customize' interface after `url-do-setup' has been run, you need
-to run the `url-cookie-setup-save-timer' function manually."
+  "If non-nil, the number of seconds between automatic saves of cookies.
+If nil, don't automatically save cookies.
+Default save interval is 1 hour.
+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 (natnum :tag "Number of seconds")
+                 (const :tag "Don't automatically save cookies" nil)))
 
 (defun url-cookie-setup-save-timer ()
   "Reset the cookie saver timer."
-- 
2.39.5