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

From: Jens Schmidt <[email-masked]>
Date: Wed, 7 May 2025 22:59:47 +0200

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