Subject: bug#70063: closed (Re: bug#70063: [PATCH] fix warning-suppress for list type "warning type")

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 31 Mar 2024 09:12:02 +0000

Your bug report

#70063: [PATCH] fix warning-suppress for list type "warning 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].

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

Subject: Re: bug#70063: [PATCH] fix warning-suppress for list type "warning type"
From: Eli Zaretskii <[email-masked]>
To: Xuan Wang <[email-masked]>
Cc: [email-masked]
Date: Sun, 31 Mar 2024 12:10:50 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Xuan Wang <[email-masked]>
> Date: Thu, 28 Mar 2024 21:07:34 -0400
> 
> Bug report:
> 
> In warnings.el, the function warning-suppress is supposed to save the
> user's choice into variable warning-suppress-types or
> warning-suppress-log-types.
> 
> The type of a warning can be a simple symbol, or a list of symbols in
> the format of '(warning-type subtype subsubtype).
> 
> The change introduced by commit d5ee49c25c8f59ab17c40eebdf38a769c2f5588b
> fixes the problem in situations where the warning type is a simple
> symbol, but this commit's code saves wrong data if the warning type is a
> list.

Thanks, installed on the emacs-29 branch, and closing the bug.

Subject: [PATCH] fix warning-suppress for list type "warning type"
From: Xuan Wang <[email-masked]>
To: [email-masked]
Date: Thu, 28 Mar 2024 21:07:34 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

Tags: patch

Bug report:

In warnings.el, the function warning-suppress is supposed to save the
user's choice into variable warning-suppress-types or
warning-suppress-log-types.

The type of a warning can be a simple symbol, or a list of symbols in
the format of '(warning-type subtype subsubtype).

The change introduced by commit d5ee49c25c8f59ab17c40eebdf38a769c2f5588b
fixes the problem in situations where the warning type is a simple
symbol, but this commit's code saves wrong data if the warning type is a
list.

old behavior:
type              warning-suppress-types
pkg           ->    '((pkg))                  Correct
(pkg subtype) ->    '(((pkg subtype)))        Incorrect

Refer to the implementation of warning-suppress-p, an element in
warning-suppress-types must be a list of symbols, must not be a simple
symbol, and must not be a list of lists (if this is the case, nothing is
going to be matched).

How to reproduce the bug:

Use any script that can emit a warning type that is a list. Press the
button on the warning buffer to suppress the warning. Run the script and
emit the warning again; you will see the warning buffer pop up, so the
warning is not suppressed.

How this patch fix the bug:

Check if the "warning type" is a list using "consp" first. If the
warning type is a list, add it directly to warning-suppress-types.
Otherwise, use the old behavior, wrap it in a list, then add it to
warning-suppress-types.

new behavior:
type              warning-suppress-types
pkg           ->    '((pkg))                Correct
(pkg subtype) ->    '((pkg subtype))        Correct

>From 57084c8de073c8ca1e74b98ca67e08b88813c42e Mon Sep 17 00:00:00 2001
From: Xuan Wang <[email-masked]>
Date: Thu, 28 Mar 2024 20:34:23 -0400
Subject: [PATCH] fix warning-suppress for list type "warning type"

Per the document of warning-suppress-types and the implementation of
warning-suppress-p, a warning type can be either a symbol or a list of
symbols. The old implementation can generate wrong
warning-suppress-types.

old behavior:
type              warning-suppress-types
pkg           ->    '((pkg))                  Correct
(pkg subtype) ->    '(((pkg subtype)))        Incorrect

Now we check whether type is a cons cell first. (Should not use listp
here as listp returns t for nil)

new behavior:
type              warning-suppress-types
pkg           ->    '((pkg))                Correct
(pkg subtype) ->    '((pkg subtype))        Correct
---
 lisp/emacs-lisp/warnings.el | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el
index 6c62a56e99c..8b43c6a8726 100644
--- a/lisp/emacs-lisp/warnings.el
+++ b/lisp/emacs-lisp/warnings.el
@@ -225,10 +225,14 @@ SUPPRESS-LIST is the list of kinds of warnings to suppress."
              (?q "quit and do nothing"))))
     (?y
      (customize-save-variable 'warning-suppress-log-types
-                              (cons (list type) warning-suppress-log-types)))
+                              (if (consp type)
+                                  (cons type warning-suppress-log-types)
+                                (cons (list type) warning-suppress-log-types))))
     (?n
      (customize-save-variable 'warning-suppress-types
-                              (cons (list type) warning-suppress-types)))
+                              (if (consp type)
+                                  (cons type warning-suppress-types)
+                                (cons (list type) warning-suppress-types))))
     (_ (message "Exiting"))))
 
 ;;;###autoload
-- 
2.34.1