Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Stefan Kangas <stefankangas@HIDDEN>
to control <at> debbugs.gnu.org
.
Full text available.Received: (at 66326) by debbugs.gnu.org; 4 Oct 2023 12:21:15 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 04 08:21:15 2023 Received: from localhost ([127.0.0.1]:41767 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qo0sM-0004OX-F1 for submit <at> debbugs.gnu.org; Wed, 04 Oct 2023 08:21:14 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:32837) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1qo0sL-0004OI-1w for 66326 <at> debbugs.gnu.org; Wed, 04 Oct 2023 08:21:13 -0400 From: Spencer Baugh <sbaugh@HIDDEN> To: Eli Zaretskii <eliz@HIDDEN> Subject: Re: bug#66326: 29.1.50; There should be a way to promote warnings to errors In-Reply-To: <83wmw353ny.fsf@HIDDEN> (Eli Zaretskii's message of "Wed, 04 Oct 2023 08:59:13 +0300") References: <ierr0mbveyt.fsf@HIDDEN> <iero7hfv9dl.fsf@HIDDEN> <83y1gj5ya9.fsf@HIDDEN> <87wmw3zfd3.fsf@HIDDEN> <83wmw353ny.fsf@HIDDEN> Date: Wed, 04 Oct 2023 08:20:49 -0400 Message-ID: <ierlecivase.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66326 Cc: sbaugh@HIDDEN, 66326 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Eli Zaretskii <eliz@HIDDEN> writes: > And in this case, duplication is a lesser evil than reordering of > logic, since the chances of unintended consequences would be lower in > the former case. OK, how about this version then? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Support-turning-warnings-into-errors.patch From 11fdd0cdd2d0da28848ad42d8087ebb1a4e05430 Mon Sep 17 00:00:00 2001 From: Spencer Baugh <sbaugh@HIDDEN> Date: Tue, 3 Oct 2023 14:36:25 -0400 Subject: [PATCH] Support turning warnings into errors Support turning warnings into errors in a user-configurable way. This is especially useful in combination with (setq debug-on-error t) to drop to the debugger when a warning happens. * lisp/emacs-lisp/warnings.el (warning-suppress-types): Improve docstring. (warning-to-error-types, warning-to-error): Add. (display-warning): Check warning-to-error-types. --- lisp/emacs-lisp/warnings.el | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el index 31b840d6c83..0e8464c4455 100644 --- a/lisp/emacs-lisp/warnings.el +++ b/lisp/emacs-lisp/warnings.el @@ -114,11 +114,20 @@ warning-suppress-types The element must match an initial segment of the list TYPE. Thus, (foo bar) as an element matches (foo bar) or (foo bar ANYTHING...) as TYPE. +An empty list as an element matches any TYPE. If TYPE is a symbol FOO, that is equivalent to the list (FOO), so only the element (FOO) will match it. See also `warning-suppress-log-types'." :type '(repeat (repeat symbol)) :version "22.1") + +(defcustom warning-to-error-types nil + "List of warning types to signal as an error instead. +If any element of this list matches the TYPE argument to `display-warning', +`display-warning' signals an error instead of logging a warning. +See `warning-suppress-types' for the format of elements in this list." + :type '(repeat (repeat symbol)) + :version "30.1") ;; The autoload cookie is so that programs can bind this variable ;; safely, testing the existing value, before they call one of the @@ -230,6 +239,14 @@ warnings-suppress (cons (list type) warning-suppress-types))) (_ (message "Exiting")))) +(defun warning-to-error (type message level) + (unless level + (setq level :warning)) + (let* ((typename (if (consp type) (car type) type)) + (level-info (assq level warning-levels))) + (error (nth 1 level-info) + (format warning-type-format typename)))) + ;;;###autoload (defun display-warning (type message &optional level buffer-name) "Display a warning message, MESSAGE. @@ -263,6 +280,11 @@ display-warning disable automatic display of the warning or disable the warning entirely by setting `warning-suppress-types' or `warning-suppress-log-types' on their behalf." + (when (and (> (warning-numeric-level (or level :warning)) + (warning-numeric-level warning-minimum-log-level)) + (not (warning-suppress-p type warning-suppress-log-types)) + (warning-suppress-p type warning-to-error-types)) + (warning-to-error type message level)) (if (not (or after-init-time noninteractive (daemonp))) ;; Ensure warnings that happen early in the startup sequence ;; are visible when startup completes (bug#20792). -- 2.39.3 --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#66326
; Package emacs
.
Full text available.Received: (at 66326) by debbugs.gnu.org; 4 Oct 2023 05:59:37 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 04 01:59:37 2023 Received: from localhost ([127.0.0.1]:41260 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qnuv3-0002Kn-74 for submit <at> debbugs.gnu.org; Wed, 04 Oct 2023 01:59:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58192) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1qnuv0-0002Ka-Q2 for 66326 <at> debbugs.gnu.org; Wed, 04 Oct 2023 01:59:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1qnuuc-0001kx-Th; Wed, 04 Oct 2023 01:59:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=2tWzHFTk66VD76R+9cbjzPJQEHEfbRj/6CoQ8Q3046c=; b=RMVFmawBk0MA vTawNpaYTkFR1s9JWR8aFbRofyvgZ2utord1rELLbo/66J1uV9eqjOBgbuHY2yJ8+M6WcOYEAI3UT g82Qvw2gRlLNKkvej5rJt2BPBcL80EFZDosv41a3dvoxh/1jjhQ8yVaMO814KiMcNJyz7kJ/P8cHx vEoPuzWW+T7C0p3o04hMfeDVDfZeJwGEBNbAcJkptrlAXBhTgZ6KLrbWTAZ+mYraC/YAY+SOeWFOp bh454Xmhvrkm46g/zjFmGpHVg09GYs9ZPFOS8wxULm4YjFOJY+rfwg0O49Mcax+NJwRQMlOAMk4n2 S2u8sxe1PgKMisYOMGVSFw==; Date: Wed, 04 Oct 2023 08:59:13 +0300 Message-Id: <83wmw353ny.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: sbaugh@HIDDEN In-Reply-To: <87wmw3zfd3.fsf@HIDDEN> (sbaugh@HIDDEN) Subject: Re: bug#66326: 29.1.50; There should be a way to promote warnings to errors References: <ierr0mbveyt.fsf@HIDDEN> <iero7hfv9dl.fsf@HIDDEN> <83y1gj5ya9.fsf@HIDDEN> <87wmw3zfd3.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 66326 Cc: sbaugh@HIDDEN, 66326 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: sbaugh@HIDDEN > Date: Tue, 03 Oct 2023 19:16:09 +0000 (UTC) > Cc: Spencer Baugh <sbaugh@HIDDEN>, 66326 <at> debbugs.gnu.org > > Eli Zaretskii <eliz@HIDDEN> writes: > > >> From: Spencer Baugh <sbaugh@HIDDEN> > >> Date: Tue, 03 Oct 2023 14:39:02 -0400 > >> > >> +(defcustom warning-to-error-types nil > >> + "List of warning types to signal as an error instead. > >> +If any element of this list matches the TYPE argument to `display-warning', > >> +an error is signaled instead of logging a warning. > > ^^^^^^^^^^^^^^^^^^^^ > > Passive voice alert! > > > >> (defun display-warning (type message &optional level buffer-name) > >> "Display a warning message, MESSAGE. > >> @@ -263,105 +278,109 @@ display-warning > >> disable automatic display of the warning or disable the warning > >> entirely by setting `warning-suppress-types' or > >> `warning-suppress-log-types' on their behalf." > >> - (if (not (or after-init-time noninteractive (daemonp))) > >> - ;; Ensure warnings that happen early in the startup sequence > >> - ;; are visible when startup completes (bug#20792). > >> - (delay-warning type message level buffer-name) > >> - (unless level > >> - (setq level :warning)) > >> - (unless buffer-name > >> - (setq buffer-name "*Warnings*")) > >> + (unless level > >> + (setq level :warning)) > >> + (unless buffer-name > >> + (setq buffer-name "*Warnings*")) > >> + (cond > >> + ((< (warning-numeric-level level) > >> + (warning-numeric-level warning-minimum-log-level))) > >> + ((warning-suppress-p type warning-suppress-log-types)) > >> + ((warning-suppress-p type warning-to-error-types) > >> + (warning-to-error type message level)) > >> + ((not (or after-init-time noninteractive (daemonp))) > >> + ;; Ensure warnings that happen early in the startup sequence > >> + ;; are visible when startup completes (bug#20792). > >> + (delay-warning type message level buffer-name)) > >> + (t > > > > AFAICT, this reorders parts of the evaluation, and thus changes the > > semantics/behavior. Please try to keep the order of the evaluation > > the same as it was, to avoid unintended consequences. (It will also > > make the patch review easier.) > > Unfortuantely it's not possible to avoid either reordering the > evaluation or duplicating some parts of it. Because, of course we want > a warning to not become an error if it's listed in > warning-suppress-log-types, and we do want it to become an error even if > it occurs early in the startup sequence. So the > warning-suppress-log-types check has to happen before the to-error > check, and the to-error check has to happen before the early-startup > check. Even if the above is true, I see no justification to calling delay-warning with overridden values of level and buffer, and after the other 'cond' cases, where it originally was called right away. And in this case, duplication is a lesser evil than reordering of logic, since the chances of unintended consequences would be lower in the former case. > Reordering them doesn't actually change behavior, because the > early-startup check just delays the warning, so it should be fine. Famous last words. When will we learn that Emacs is so much complex that we should humbly realize we never have the full picture to make such cavalier assumptions? > I can separate out the reordering change into a separate patch if you > like, then you can see that it should not change behavior. No, that won't help me to be sure we are not introducing some incompatible changes in this long-standing behavior. Please realize: this is a very minor feature, useful in a small number of situations, so the risk of it causing us trouble in the much more important cases of issuing and delaying warnings is unacceptable. So unless I'm reasonably sure this risk is very low, I will simply not agree to installing this feature. TIA
bug-gnu-emacs@HIDDEN
:bug#66326
; Package emacs
.
Full text available.Received: (at 66326) by debbugs.gnu.org; 3 Oct 2023 19:16:36 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 03 15:16:36 2023 Received: from localhost ([127.0.0.1]:40730 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qnksl-00037M-II for submit <at> debbugs.gnu.org; Tue, 03 Oct 2023 15:16:35 -0400 Received: from s.wrqvtzvf.outbound-mail.sendgrid.net ([149.72.126.143]:3546) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <bounces+21787432-a142-66326=debbugs.gnu.org@HIDDEN>) id 1qnksj-000377-3i for 66326 <at> debbugs.gnu.org; Tue, 03 Oct 2023 15:16:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=catern.com; h=from:subject:in-reply-to:references:mime-version:to:cc:content-type: content-transfer-encoding:cc:content-type:from:subject:to; s=s1; bh=mJJ2QtiSXCyRH2bUJE58u32LpCXiHBHJaEXoH2moam8=; b=qgQK/rfiq9cYgWGZiqHfeNun7/L+mq6T3oCND1hdN9hCk5rWmt1B2avSSP+uyRy7SFfI X4YFMK8mJrOTpDIgyf8wIBwMmk9cKL1VSzYhc0nIetiRU+GiqWgSsvFOu7kDsiFoJf9A3r fNBxdWNxsI/VerGnRLxN5XjXy6dBMtJXd4SCNGZnW0XQO1oGLwTE3vpw6qkOG2C3hPokK+ bXdSxGuGetBgdBSdfI8sh4V7lZDcxTULZjcfsEPhVpzdUKm4pvzcla9AGB9/kzzBJmWFkv FcS7B0AsuO5YYD/eeys2RFfS6LhL6EWcIeuMWSLPPsAwslNa56jxGQF/4Jn5p1xA== Received: by filterdrecv-8684c58db7-fnjnw with SMTP id filterdrecv-8684c58db7-fnjnw-1-651C6879-64 2023-10-03 19:16:09.666180311 +0000 UTC m=+12598670.700885501 Received: from earth.catern.com (unknown) by geopod-ismtpd-4 (SG) with ESMTP id iJNwJsvtRf2CLEgAWiUHFg Tue, 03 Oct 2023 19:16:09.216 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=::1; helo=localhost; envelope-from=sbaugh@HIDDEN; receiver=gnu.org Received: from localhost (localhost [IPv6:::1]) by earth.catern.com (Postfix) with ESMTPSA id 678D262E99; Tue, 3 Oct 2023 15:16:08 -0400 (EDT) From: sbaugh@HIDDEN Subject: Re: bug#66326: 29.1.50; There should be a way to promote warnings to errors In-Reply-To: <83y1gj5ya9.fsf@HIDDEN> (Eli Zaretskii's message of "Tue, 03 Oct 2023 21:57:50 +0300") References: <ierr0mbveyt.fsf@HIDDEN> <iero7hfv9dl.fsf@HIDDEN> <83y1gj5ya9.fsf@HIDDEN> Date: Tue, 03 Oct 2023 19:16:09 +0000 (UTC) Message-ID: <87wmw3zfd3.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-SG-EID: =?us-ascii?Q?ZgbRq7gjGrt0q=2FPjvxk7wM0yQFRdOkTJAtEbkjCkHbIkyEN1eRcRPUZS578lrj?= =?us-ascii?Q?Gm=2FpFqf3hccczSywezJ+PQzypgJMvDr=2FO50a5rt?= =?us-ascii?Q?SqMiOAec+aLg3lxHmRUJpxmKuvgKaV4ZFrG7GRT?= =?us-ascii?Q?1CZqOlhE=2FPGTvMRCI2ksMA6uaHl9Iu9iQKjEzQJ?= =?us-ascii?Q?etbXe9JLeDx8Rz9n7jjOpUtKu3sw3za2LQQ=3D=3D?= To: Eli Zaretskii <eliz@HIDDEN> X-Entity-ID: d/0VcHixlS0t7iB1YKCv4Q== Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Eli Zaretskii <eliz@HIDDEN> writes: >> From: Spencer Baugh <sbaugh@HIDDEN> >> Date: Tue, 03 Oct 2023 14:39:02 -0400 >> >> +(defcustom warning-to-error-types nil >> + "List of warning types to signal as an error instead. >> +If a [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see <https://www.spamcop.net/bl.shtml?149.72.126.143>] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-Debbugs-Envelope-To: 66326 Cc: Spencer Baugh <sbaugh@HIDDEN>, 66326 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: 0.2 (/) Eli Zaretskii <eliz@HIDDEN> writes: >> From: Spencer Baugh <sbaugh@HIDDEN> >> Date: Tue, 03 Oct 2023 14:39:02 -0400 >> >> +(defcustom warning-to-error-types nil >> + "List of warning types to signal as an error instead. >> +If any element of this list matches the TYPE argument to `display-warning', >> +an error is signaled instead of logging a warning. > ^^^^^^^^^^^^^^^^^^^^ > Passive voice alert! > >> (defun display-warning (type message &optional level buffer-name) >> "Display a warning message, MESSAGE. >> @@ -263,105 +278,109 @@ display-warning >> disable automatic display of the warning or disable the warning >> entirely by setting `warning-suppress-types' or >> `warning-suppress-log-types' on their behalf." >> - (if (not (or after-init-time noninteractive (daemonp))) >> - ;; Ensure warnings that happen early in the startup sequence >> - ;; are visible when startup completes (bug#20792). >> - (delay-warning type message level buffer-name) >> - (unless level >> - (setq level :warning)) >> - (unless buffer-name >> - (setq buffer-name "*Warnings*")) >> + (unless level >> + (setq level :warning)) >> + (unless buffer-name >> + (setq buffer-name "*Warnings*")) >> + (cond >> + ((< (warning-numeric-level level) >> + (warning-numeric-level warning-minimum-log-level))) >> + ((warning-suppress-p type warning-suppress-log-types)) >> + ((warning-suppress-p type warning-to-error-types) >> + (warning-to-error type message level)) >> + ((not (or after-init-time noninteractive (daemonp))) >> + ;; Ensure warnings that happen early in the startup sequence >> + ;; are visible when startup completes (bug#20792). >> + (delay-warning type message level buffer-name)) >> + (t > > AFAICT, this reorders parts of the evaluation, and thus changes the > semantics/behavior. Please try to keep the order of the evaluation > the same as it was, to avoid unintended consequences. (It will also > make the patch review easier.) Unfortuantely it's not possible to avoid either reordering the evaluation or duplicating some parts of it. Because, of course we want a warning to not become an error if it's listed in warning-suppress-log-types, and we do want it to become an error even if it occurs early in the startup sequence. So the warning-suppress-log-types check has to happen before the to-error check, and the to-error check has to happen before the early-startup check. But currently the warning-suppress-log-types check is after the early-startup check. Reordering them doesn't actually change behavior, because the early-startup check just delays the warning, so it should be fine. I can separate out the reordering change into a separate patch if you like, then you can see that it should not change behavior.
bug-gnu-emacs@HIDDEN
:bug#66326
; Package emacs
.
Full text available.Received: (at 66326) by debbugs.gnu.org; 3 Oct 2023 18:58:39 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 03 14:58:39 2023 Received: from localhost ([127.0.0.1]:40710 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qnkbO-0002d2-Br for submit <at> debbugs.gnu.org; Tue, 03 Oct 2023 14:58:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48776) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1qnkb9-0002cR-QA for 66326 <at> debbugs.gnu.org; Tue, 03 Oct 2023 14:58:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1qnkaa-0007Ug-M4; Tue, 03 Oct 2023 14:57:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=vxXO+ldZR3/f1UmoL+T/whH0XDZJgoRIJxZiP3DNlIs=; b=rBIXQ+Q6t+UJ W86fHdpTZpx2iAeK7E5PMOHOBj+310VlFwEkVJ3sLf/I5SdNM+/CN40vAYZpej4bGYZ4T2qcsd7rI CED9EwxX9Bfm5Unp0BPDPqYX3ijAfUS+JTIL5y3khRrHjyyDhMpNi2Azpm2GbF7KUAByRfW1yWv2A p0xm5VgjQEkuyl3VssXbsFE5Vslsg6rs9SnPx/SjdXoDbh//uPDqJMLP6UGtQ4tkzYPhPD6macpCq aq3k4MBoSRJLjzCdc7eeIHIapsTWsdazc6eqQjUpYck7QlSEfgH3ga45WJZ6/HKUgILi3hJgZ2suQ ysZzqX8V6Qn4gIZeko2QdA==; Date: Tue, 03 Oct 2023 21:57:50 +0300 Message-Id: <83y1gj5ya9.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <iero7hfv9dl.fsf@HIDDEN> (message from Spencer Baugh on Tue, 03 Oct 2023 14:39:02 -0400) Subject: Re: bug#66326: 29.1.50; There should be a way to promote warnings to errors References: <ierr0mbveyt.fsf@HIDDEN> <iero7hfv9dl.fsf@HIDDEN> X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66326 Cc: 66326 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Spencer Baugh <sbaugh@HIDDEN> > Date: Tue, 03 Oct 2023 14:39:02 -0400 > > +(defcustom warning-to-error-types nil > + "List of warning types to signal as an error instead. > +If any element of this list matches the TYPE argument to `display-warning', > +an error is signaled instead of logging a warning. ^^^^^^^^^^^^^^^^^^^^ Passive voice alert! > (defun display-warning (type message &optional level buffer-name) > "Display a warning message, MESSAGE. > @@ -263,105 +278,109 @@ display-warning > disable automatic display of the warning or disable the warning > entirely by setting `warning-suppress-types' or > `warning-suppress-log-types' on their behalf." > - (if (not (or after-init-time noninteractive (daemonp))) > - ;; Ensure warnings that happen early in the startup sequence > - ;; are visible when startup completes (bug#20792). > - (delay-warning type message level buffer-name) > - (unless level > - (setq level :warning)) > - (unless buffer-name > - (setq buffer-name "*Warnings*")) > + (unless level > + (setq level :warning)) > + (unless buffer-name > + (setq buffer-name "*Warnings*")) > + (cond > + ((< (warning-numeric-level level) > + (warning-numeric-level warning-minimum-log-level))) > + ((warning-suppress-p type warning-suppress-log-types)) > + ((warning-suppress-p type warning-to-error-types) > + (warning-to-error type message level)) > + ((not (or after-init-time noninteractive (daemonp))) > + ;; Ensure warnings that happen early in the startup sequence > + ;; are visible when startup completes (bug#20792). > + (delay-warning type message level buffer-name)) > + (t AFAICT, this reorders parts of the evaluation, and thus changes the semantics/behavior. Please try to keep the order of the evaluation the same as it was, to avoid unintended consequences. (It will also make the patch review easier.) Thanks.
bug-gnu-emacs@HIDDEN
:bug#66326
; Package emacs
.
Full text available.Received: (at 66326) by debbugs.gnu.org; 3 Oct 2023 18:39:28 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 03 14:39:28 2023 Received: from localhost ([127.0.0.1]:40705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qnkIq-00024k-2a for submit <at> debbugs.gnu.org; Tue, 03 Oct 2023 14:39:28 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:53495) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1qnkIo-00024T-2u for 66326 <at> debbugs.gnu.org; Tue, 03 Oct 2023 14:39:26 -0400 From: Spencer Baugh <sbaugh@HIDDEN> To: 66326 <at> debbugs.gnu.org Subject: Re: bug#66326: 29.1.50; There should be a way to promote warnings to errors In-Reply-To: <ierr0mbveyt.fsf@HIDDEN> (Spencer Baugh's message of "Tue, 03 Oct 2023 12:38:18 -0400") References: <ierr0mbveyt.fsf@HIDDEN> Date: Tue, 03 Oct 2023 14:39:02 -0400 Message-ID: <iero7hfv9dl.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 66326 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Patch implementing this: --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Support-turning-warnings-into-errors.patch From 6fad83ea8729569c968ccdfc1ec2807387bc979e Mon Sep 17 00:00:00 2001 From: Spencer Baugh <sbaugh@HIDDEN> Date: Tue, 3 Oct 2023 14:36:25 -0400 Subject: [PATCH] Support turning warnings into errors Support turning warnings into errors in a user-configurable way. This is especially useful in combination with (setq debug-on-error t) to drop to the debugger when a warning happens. * lisp/emacs-lisp/warnings.el (warning-suppress-types): Improve docstring. (warning-to-error-types, warning-to-error): Add. (display-warning): Check warning-to-error-types. --- lisp/emacs-lisp/warnings.el | 209 ++++++++++++++++++++---------------- 1 file changed, 114 insertions(+), 95 deletions(-) diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el index 31b840d6c83..9e0a35b87bb 100644 --- a/lisp/emacs-lisp/warnings.el +++ b/lisp/emacs-lisp/warnings.el @@ -114,11 +114,20 @@ warning-suppress-types The element must match an initial segment of the list TYPE. Thus, (foo bar) as an element matches (foo bar) or (foo bar ANYTHING...) as TYPE. +An empty list as an element matches any TYPE. If TYPE is a symbol FOO, that is equivalent to the list (FOO), so only the element (FOO) will match it. See also `warning-suppress-log-types'." :type '(repeat (repeat symbol)) :version "22.1") + +(defcustom warning-to-error-types nil + "List of warning types to signal as an error instead. +If any element of this list matches the TYPE argument to `display-warning', +an error is signaled instead of logging a warning. +See `warning-suppress-types' for the format of elements in this list." + :type '(repeat (repeat symbol)) + :version "30.1") ;; The autoload cookie is so that programs can bind this variable ;; safely, testing the existing value, before they call one of the @@ -230,6 +239,12 @@ warnings-suppress (cons (list type) warning-suppress-types))) (_ (message "Exiting")))) +(defun warning-to-error (type message level) + (let* ((typename (if (consp type) (car type) type)) + (level-info (assq level warning-levels))) + (error (nth 1 level-info) + (format warning-type-format typename)))) + ;;;###autoload (defun display-warning (type message &optional level buffer-name) "Display a warning message, MESSAGE. @@ -263,105 +278,109 @@ display-warning disable automatic display of the warning or disable the warning entirely by setting `warning-suppress-types' or `warning-suppress-log-types' on their behalf." - (if (not (or after-init-time noninteractive (daemonp))) - ;; Ensure warnings that happen early in the startup sequence - ;; are visible when startup completes (bug#20792). - (delay-warning type message level buffer-name) - (unless level - (setq level :warning)) - (unless buffer-name - (setq buffer-name "*Warnings*")) + (unless level + (setq level :warning)) + (unless buffer-name + (setq buffer-name "*Warnings*")) + (cond + ((< (warning-numeric-level level) + (warning-numeric-level warning-minimum-log-level))) + ((warning-suppress-p type warning-suppress-log-types)) + ((warning-suppress-p type warning-to-error-types) + (warning-to-error type message level)) + ((not (or after-init-time noninteractive (daemonp))) + ;; Ensure warnings that happen early in the startup sequence + ;; are visible when startup completes (bug#20792). + (delay-warning type message level buffer-name)) + (t (with-suppressed-warnings ((obsolete warning-level-aliases)) (when-let ((new (cdr (assq level warning-level-aliases)))) (warn "Warning level `%s' is obsolete; use `%s' instead" level new) (setq level new))) - (or (< (warning-numeric-level level) - (warning-numeric-level warning-minimum-log-level)) - (warning-suppress-p type warning-suppress-log-types) - (let* ((typename (if (consp type) (car type) type)) - (old (get-buffer buffer-name)) - (buffer (or old (get-buffer-create buffer-name))) - (level-info (assq level warning-levels)) - ;; `newline' may be unbound during bootstrap. - (newline (if (fboundp 'newline) #'newline - (lambda () (insert "\n")))) - start end) - (with-current-buffer buffer - ;; If we created the buffer, disable undo. - (unless old - (when (fboundp 'special-mode) ; Undefined during bootstrap. - (special-mode)) - (setq buffer-read-only t) - (setq buffer-undo-list t)) - (goto-char (point-max)) - (when (and warning-series (symbolp warning-series)) - (setq warning-series - (prog1 (point-marker) - (unless (eq warning-series t) - (funcall warning-series))))) - (let ((inhibit-read-only t)) - (unless (bolp) - (funcall newline)) - (setq start (point)) - ;; Don't output the button when doing batch compilation - ;; and similar. - (unless (or noninteractive (eq type 'bytecomp)) - (insert (buttonize (icon-string 'warnings-suppress) - #'warnings-suppress type) - " ")) - (if warning-prefix-function - (setq level-info (funcall warning-prefix-function - level level-info))) - (insert (format (nth 1 level-info) - (format warning-type-format typename)) - message) - (funcall newline) - (when (and warning-fill-prefix - (not (string-search "\n" message)) - (not noninteractive)) - (let ((fill-prefix warning-fill-prefix) - (fill-column warning-fill-column)) - (fill-region start (point)))) - (setq end (point))) - (when (and (markerp warning-series) - (eq (marker-buffer warning-series) buffer)) - (goto-char warning-series))) - (if (nth 2 level-info) - (funcall (nth 2 level-info))) - (cond (noninteractive - ;; Noninteractively, take the text we inserted - ;; in the warnings buffer and print it. - ;; Do this unconditionally, since there is no way - ;; to view logged messages unless we output them. - (with-current-buffer buffer - (save-excursion - ;; Don't include the final newline in the arg - ;; to `message', because it adds a newline. - (goto-char end) - (if (bolp) - (forward-char -1)) - (message "%s" (buffer-substring start (point)))))) - ((and (daemonp) (null after-init-time)) - ;; Warnings assigned during daemon initialization go into - ;; the messages buffer. - (message "%s" - (with-current-buffer buffer - (save-excursion - (goto-char end) - (if (bolp) - (forward-char -1)) - (buffer-substring start (point)))))) - (t - ;; Interactively, decide whether the warning merits - ;; immediate display. - (or (< (warning-numeric-level level) - (warning-numeric-level warning-minimum-level)) - (warning-suppress-p type warning-suppress-types) - (let ((window (display-buffer buffer))) - (when (and (markerp warning-series) - (eq (marker-buffer warning-series) buffer)) - (set-window-start window warning-series)) - (sit-for 0))))))))) + (let* ((typename (if (consp type) (car type) type)) + (old (get-buffer buffer-name)) + (buffer (or old (get-buffer-create buffer-name))) + (level-info (assq level warning-levels)) + ;; `newline' may be unbound during bootstrap. + (newline (if (fboundp 'newline) #'newline + (lambda () (insert "\n")))) + start end) + (with-current-buffer buffer + ;; If we created the buffer, disable undo. + (unless old + (when (fboundp 'special-mode) ; Undefined during bootstrap. + (special-mode)) + (setq buffer-read-only t) + (setq buffer-undo-list t)) + (goto-char (point-max)) + (when (and warning-series (symbolp warning-series)) + (setq warning-series + (prog1 (point-marker) + (unless (eq warning-series t) + (funcall warning-series))))) + (let ((inhibit-read-only t)) + (unless (bolp) + (funcall newline)) + (setq start (point)) + ;; Don't output the button when doing batch compilation + ;; and similar. + (unless (or noninteractive (eq type 'bytecomp)) + (insert (buttonize (icon-string 'warnings-suppress) + #'warnings-suppress type) + " ")) + (if warning-prefix-function + (setq level-info (funcall warning-prefix-function + level level-info))) + (insert (format (nth 1 level-info) + (format warning-type-format typename)) + message) + (funcall newline) + (when (and warning-fill-prefix + (not (string-search "\n" message)) + (not noninteractive)) + (let ((fill-prefix warning-fill-prefix) + (fill-column warning-fill-column)) + (fill-region start (point)))) + (setq end (point))) + (when (and (markerp warning-series) + (eq (marker-buffer warning-series) buffer)) + (goto-char warning-series))) + (if (nth 2 level-info) + (funcall (nth 2 level-info))) + (cond (noninteractive + ;; Noninteractively, take the text we inserted + ;; in the warnings buffer and print it. + ;; Do this unconditionally, since there is no way + ;; to view logged messages unless we output them. + (with-current-buffer buffer + (save-excursion + ;; Don't include the final newline in the arg + ;; to `message', because it adds a newline. + (goto-char end) + (if (bolp) + (forward-char -1)) + (message "%s" (buffer-substring start (point)))))) + ((and (daemonp) (null after-init-time)) + ;; Warnings assigned during daemon initialization go into + ;; the messages buffer. + (message "%s" + (with-current-buffer buffer + (save-excursion + (goto-char end) + (if (bolp) + (forward-char -1)) + (buffer-substring start (point)))))) + (t + ;; Interactively, decide whether the warning merits + ;; immediate display. + (or (< (warning-numeric-level level) + (warning-numeric-level warning-minimum-level)) + (warning-suppress-p type warning-suppress-types) + (let ((window (display-buffer buffer))) + (when (and (markerp warning-series) + (eq (marker-buffer warning-series) buffer)) + (set-window-start window warning-series)) + (sit-for 0))))))))) ;; Use \\<special-mode-map> so that help-enable-autoload can do its thing. ;; Any keymap that is defined will do. -- 2.39.3 --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#66326
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 3 Oct 2023 16:38:47 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 03 12:38:47 2023 Received: from localhost ([127.0.0.1]:40616 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qniQ2-0007Ft-K8 for submit <at> debbugs.gnu.org; Tue, 03 Oct 2023 12:38:47 -0400 Received: from lists.gnu.org ([2001:470:142::17]:41542) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1qniQ0-0007Fg-HX for submit <at> debbugs.gnu.org; Tue, 03 Oct 2023 12:38:45 -0400 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 <sbaugh@HIDDEN>) id 1qniPd-00077k-Hf for bug-gnu-emacs@HIDDEN; Tue, 03 Oct 2023 12:38:21 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <sbaugh@HIDDEN>) id 1qniPb-0005hp-UW for bug-gnu-emacs@HIDDEN; Tue, 03 Oct 2023 12:38:21 -0400 From: Spencer Baugh <sbaugh@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: 29.1.50; There should be a way to promote warnings to errors Date: Tue, 03 Oct 2023 12:38:18 -0400 Message-ID: <ierr0mbveyt.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@HIDDEN; helo=mxout5.mail.janestreet.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -0.1 (/) It's common in other languages to have a flag such as -Werror to turn warnings into errors. This is useful if you're writing some code and you want to be scrupulous about preventing potential bugs; if code would warn, you just want to error instead of trying to continue running. It would be nice to have this feature in Emacs Lisp. I've personally frequently had trouble with figuring out where exactly a warning is triggered from. I eventually settled on (debug-on-warning 'display-warning) and looking at *Backtrace*, but it would be nicer to just make all warnings into errors which could be handled using whatever normal error mechanism - which might or might not be the debugger. I'll implement this feature in a subsequent patch. In GNU Emacs 29.1.50 (build 4, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2023-09-11 built on Repository revision: f9bc92d0b36bc631d11c194e4b580f43b7b8dcba Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.8 (Green Obsidian) Configured using: 'configure --config-cache --with-x-toolkit=lucid --with-gif=ifavailable' Configured features: CAIRO DBUS FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Markdown Memory information: ((conses 16 4175004 208691) (symbols 48 59948 1) (strings 32 259924 33150) (string-bytes 1 10506599) (vectors 16 91335) (vector-slots 8 2087528 344365) (floats 8 615 413) (intervals 56 366721 1629) (buffers 976 282))
Spencer Baugh <sbaugh@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#66326
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.