* bug#70063: [PATCH] fix warning-suppress for list type "warning type"
@ 2024-03-29 1:07 Xuan Wang
2024-03-31 9:10 ` Eli Zaretskii
0 siblings, 1 reply; 2+ messages in thread
From: Xuan Wang @ 2024-03-29 1:07 UTC (permalink / raw)
To: 70063
[-- Attachment #1: Type: text/plain, Size: 1602 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-fix-warning-suppress-for-list-type-warning-type.patch --]
[-- Type: text/patch, Size: 2006 bytes --]
From 57084c8de073c8ca1e74b98ca67e08b88813c42e Mon Sep 17 00:00:00 2001
From: Xuan Wang <code@wangxuan.name>
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#70063: [PATCH] fix warning-suppress for list type "warning type"
2024-03-29 1:07 bug#70063: [PATCH] fix warning-suppress for list type "warning type" Xuan Wang
@ 2024-03-31 9:10 ` Eli Zaretskii
0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2024-03-31 9:10 UTC (permalink / raw)
To: Xuan Wang; +Cc: 70063-done
> From: Xuan Wang <code@wangxuan.name>
> 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-31 9:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-29 1:07 bug#70063: [PATCH] fix warning-suppress for list type "warning type" Xuan Wang
2024-03-31 9:10 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).