From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Xuan Wang Newsgroups: gmane.emacs.bugs Subject: bug#70063: [PATCH] fix warning-suppress for list type "warning type" Date: Thu, 28 Mar 2024 21:07:34 -0400 Message-ID: <87zfuhu9pl.fsf@WX-Desktop.mail-host-address-is-not-set> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21572"; mail-complaints-to="usenet@ciao.gmane.io" To: 70063@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 29 05:08:35 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rq3Xd-0005MD-8q for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 29 Mar 2024 05:08:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rq3XA-0002pe-8n; Fri, 29 Mar 2024 00:08:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rq3X8-0002o5-PJ for bug-gnu-emacs@gnu.org; Fri, 29 Mar 2024 00:08:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rq3X8-0002JX-Hh for bug-gnu-emacs@gnu.org; Fri, 29 Mar 2024 00:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rq3X9-0000H6-JB for bug-gnu-emacs@gnu.org; Fri, 29 Mar 2024 00:08:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Xuan Wang Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 29 Mar 2024 04:08:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70063 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1711685259945 (code B ref -1); Fri, 29 Mar 2024 04:08:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Mar 2024 04:07:39 +0000 Original-Received: from localhost ([127.0.0.1]:41393 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rq3Wl-0000F6-1H for submit@debbugs.gnu.org; Fri, 29 Mar 2024 00:07:39 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:48784) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rq0il-0007YZ-Kn for submit@debbugs.gnu.org; Thu, 28 Mar 2024 21:07:53 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rq0ie-0007Xv-R6 for bug-gnu-emacs@gnu.org; Thu, 28 Mar 2024 21:07:44 -0400 Original-Received: from mail-ot1-f46.google.com ([209.85.210.46]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rq0ic-0004FL-Q2 for bug-gnu-emacs@gnu.org; Thu, 28 Mar 2024 21:07:44 -0400 Original-Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6e67d42422aso983104a34.0 for ; Thu, 28 Mar 2024 18:07:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711674460; x=1712279260; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=D+LB4EpXGxaDerNphIwn1MLNQsYR0HYR0y1RqfawQ3U=; b=dCk1iIsvODeWEz9AaP4fn3TGpFPeENinCvq6wKYEtla0Il4wsgsEDx0O55f7nnzUvi Y7IGP3h2ZUVUfCTi5ww6ZTLLMnEGTpK7sormbaHRb8ZT3a9yGqTbJfKem5EN7xzaCan1 HeUcMP4TupOlRNFr4IpHjVsVKN6+Lkc78SN4+lAyDPs5PeHKnm2C5XA7VM/Cs7CLcR2C tqrnjhbgG2fRtVzmLApDAsx6AJTUBz4dOT2Uh8LrJ/CMOyvWOh+uIx5q0GebHXYjoIY+ D7LGXYeeQ/cN+LJOiZJgpI+bdYRpiRtv8Kw+gxOYAQDq+rGmJjfdAQSTBg2pQKcK/iNk Wq5g== X-Gm-Message-State: AOJu0YxG81Aq4vyaU2QOsNRQQwZKp039vlZRrjQL3Bl+cQgGlO3AaPnO drhcMgmf1pjaenPPEgZLBL2LH/5T8phPQg1P3lbBNBUD8Pd9Sf81fYDXXjnc X-Google-Smtp-Source: AGHT+IFllylQhpczpwsimCFaG3/x68GRYemgF/srgrVZrodGivxGqs+HblYdMPxdG3JgydB15cKesg== X-Received: by 2002:a9d:7a9a:0:b0:6e7:b67c:1940 with SMTP id l26-20020a9d7a9a000000b006e7b67c1940mr557460otn.23.1711674460187; Thu, 28 Mar 2024 18:07:40 -0700 (PDT) Original-Received: from WX-Desktop (074-065-109-118.res.spectrum.com. [74.65.109.118]) by smtp.gmail.com with ESMTPSA id z4-20020ae9f444000000b00787fd080d28sm992932qkl.74.2024.03.28.18.07.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 18:07:39 -0700 (PDT) Received-SPF: pass client-ip=209.85.210.46; envelope-from=xuan.public@gmail.com; helo=mail-ot1-f46.google.com X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 29 Mar 2024 00:07:26 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:282265 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-fix-warning-suppress-for-list-type-warning-type.patch >From 57084c8de073c8ca1e74b98ca67e08b88813c42e Mon Sep 17 00:00:00 2001 From: Xuan Wang 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 --=-=-=--