X-Loop: help-debbugs@HIDDEN Subject: bug#66326: 29.1.50; There should be a way to promote warnings to errors Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 03 Oct 2023 16:39:02 +0000 Resent-Message-ID: <handler.66326.B.169635112727898 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 66326 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 66326 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.169635112727898 (code B ref -1); Tue, 03 Oct 2023 16:39:02 +0000 Received: (at submit) by debbugs.gnu.org; 3 Oct 2023 16:38:47 +0000 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> 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-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))
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Spencer Baugh <sbaugh@HIDDEN> Subject: bug#66326: Acknowledgement (29.1.50; There should be a way to promote warnings to errors) Message-ID: <handler.66326.B.169635112727898.ack <at> debbugs.gnu.org> References: <ierr0mbveyt.fsf@HIDDEN> X-Gnu-PR-Message: ack 66326 X-Gnu-PR-Package: emacs Reply-To: 66326 <at> debbugs.gnu.org Date: Tue, 03 Oct 2023 16:39:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-gnu-emacs@HIDDEN If you wish to submit further information on this problem, please send it to 66326 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 66326: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D66326 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#66326: 29.1.50; There should be a way to promote warnings to errors Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 03 Oct 2023 18:40:01 +0000 Resent-Message-ID: <handler.66326.B66326.16963583687986 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 66326 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 66326 <at> debbugs.gnu.org Received: via spool by 66326-submit <at> debbugs.gnu.org id=B66326.16963583687986 (code B ref 66326); Tue, 03 Oct 2023 18:40:01 +0000 Received: (at 66326) by debbugs.gnu.org; 3 Oct 2023 18:39:28 +0000 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> 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-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 --=-=-=--
X-Loop: help-debbugs@HIDDEN Subject: bug#66326: 29.1.50; There should be a way to promote warnings to errors Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 03 Oct 2023 18:59:01 +0000 Resent-Message-ID: <handler.66326.B66326.169635951910112 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 66326 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh <sbaugh@HIDDEN> Cc: 66326 <at> debbugs.gnu.org Received: via spool by 66326-submit <at> debbugs.gnu.org id=B66326.169635951910112 (code B ref 66326); Tue, 03 Oct 2023 18:59:01 +0000 Received: (at 66326) by debbugs.gnu.org; 3 Oct 2023 18:58:39 +0000 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> In-Reply-To: <iero7hfv9dl.fsf@HIDDEN> (message from Spencer Baugh on Tue, 03 Oct 2023 14:39:02 -0400) References: <ierr0mbveyt.fsf@HIDDEN> <iero7hfv9dl.fsf@HIDDEN> X-Spam-Score: 0.0 (/) 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.
X-Loop: help-debbugs@HIDDEN Subject: bug#66326: 29.1.50; There should be a way to promote warnings to errors Resent-From: sbaugh@HIDDEN Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 03 Oct 2023 19:17:02 +0000 Resent-Message-ID: <handler.66326.B66326.169636059611992 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 66326 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii <eliz@HIDDEN> Cc: Spencer Baugh <sbaugh@HIDDEN>, 66326 <at> debbugs.gnu.org Received: via spool by 66326-submit <at> debbugs.gnu.org id=B66326.169636059611992 (code B ref 66326); Tue, 03 Oct 2023 19:17:02 +0000 Received: (at 66326) by debbugs.gnu.org; 3 Oct 2023 19:16:36 +0000 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 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: ZgbRq7gjGrt0q/Pjvxk7wM0yQFRdOkTJAtEbkjCkHbIkyEN1eRcRPUZS578lrjGm/pFqf3hccczSywezJ+PQzypgJMvDr/O50a5rtSqMiOAec+aLg3lxHmRUJpxmKuvgKaV4ZFrG7GRT1CZqOlhE/PGTvMRCI2ksMA6uaHl9Iu9iQKjEzQJetbXe9JLeDx8Rz9n7jjOpUtKu3sw3za2LQQ== 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-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.
X-Loop: help-debbugs@HIDDEN Subject: bug#66326: 29.1.50; There should be a way to promote warnings to errors Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Wed, 04 Oct 2023 06:00:01 +0000 Resent-Message-ID: <handler.66326.B66326.16963991778982 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 66326 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: sbaugh@HIDDEN Cc: sbaugh@HIDDEN, 66326 <at> debbugs.gnu.org Received: via spool by 66326-submit <at> debbugs.gnu.org id=B66326.16963991778982 (code B ref 66326); Wed, 04 Oct 2023 06:00:01 +0000 Received: (at 66326) by debbugs.gnu.org; 4 Oct 2023 05:59:37 +0000 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> In-Reply-To: <87wmw3zfd3.fsf@HIDDEN> (sbaugh@HIDDEN) References: <ierr0mbveyt.fsf@HIDDEN> <iero7hfv9dl.fsf@HIDDEN> <83y1gj5ya9.fsf@HIDDEN> <87wmw3zfd3.fsf@HIDDEN> X-Spam-Score: -2.3 (--) 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
X-Loop: help-debbugs@HIDDEN Subject: bug#66326: 29.1.50; There should be a way to promote warnings to errors Resent-From: Spencer Baugh <sbaugh@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Wed, 04 Oct 2023 12:22:01 +0000 Resent-Message-ID: <handler.66326.B66326.169642207516904 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 66326 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii <eliz@HIDDEN> Cc: sbaugh@HIDDEN, 66326 <at> debbugs.gnu.org Received: via spool by 66326-submit <at> debbugs.gnu.org id=B66326.169642207516904 (code B ref 66326); Wed, 04 Oct 2023 12:22:01 +0000 Received: (at 66326) by debbugs.gnu.org; 4 Oct 2023 12:21:15 +0000 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> 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-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 --=-=-=--
Received: (at control) by debbugs.gnu.org; 5 Oct 2023 21:54:14 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 05 17:54:13 2023 Received: from localhost ([127.0.0.1]:48828 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qoWIP-0003DE-Mi for submit <at> debbugs.gnu.org; Thu, 05 Oct 2023 17:54:13 -0400 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]:48412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1qoWIN-0003D0-Nm for control <at> debbugs.gnu.org; Thu, 05 Oct 2023 17:54:12 -0400 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-5044dd5b561so1845016e87.1 for <control <at> debbugs.gnu.org>; Thu, 05 Oct 2023 14:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696542827; x=1697147627; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=q4SG21+/xbIB5ZQPnnC4QlZ6khArl7Kv+qgy3kYq8Vk=; b=LzdUnYl6XYD4+DO+rA/mX3f7wSz2+4tGMY3YFYhGiuwprTg4kC2CThIld5KT6696Sl VRyotJYi1unaasPEBwaOodcPEEYRsBHD3Llvu8AZpWofOzOc390XtYZF5UPJVXQU5USY mXO6gq7l4wKNQP37qCe3vIA502fEiaHsjjmqvs/TqDZfG/Y4jYUixSG2Fh4paPkdxHyy xBLdFxODEe847HA+GnURa65yEkE6yZCunqARYueuYiyBB8PD0mkiAowBy/yseYje5ybG cJVP1Weyv43FPEt8+5z2IpyhIJlEC9eaYSQ3bDo9IUzs5cIUi36R9F8eBYDD3ITHFPGt nCjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696542827; x=1697147627; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=q4SG21+/xbIB5ZQPnnC4QlZ6khArl7Kv+qgy3kYq8Vk=; b=uQRLWg7RUL+U4UIQMSTbePmlVxn3n7tCIWmfdvkQlzoYgsNIpRu0SL7KXWWYv1Gkh1 43Ce/I+nZoq7XOA9QRxYTanofavEVW6VT2Cvvn1Rdn7M+q2yyYxZ1AsewD48V5w9mhui b79p3rmSh2NbLyGO91Iip1sU1sadxykPEp0y8O5f9eCcmXJjxt9MFoLzAhpr+bJ2DY/g xcTXY8ElZEcok5oiwwiQVAr23IOW2dZidvoUfY23EKR7s8O1r0qDr+S1lKeLa7/++1aO MFW/iujRe67pOrVyvf1zlUElJvsrzebnFwto6QcfyfG4LoPdpGzGmBR3qWh7XdbihVtC erXA== X-Gm-Message-State: AOJu0YwRxjZHho28+XBu3KAu/yIcJAcjG3yR1b8LJDcJUdGtR/zk56yk wF8DXwdgdsRnUkKyDUjQcjSre12pREfiLMuz+BQLhn18 X-Google-Smtp-Source: AGHT+IHwOzRQXDr/8jdMtlvz3OHb2JmLxtTCZ/bKru7jFbYIydFlEH4bTvtsYX0+XzY5f/3YcBfhXcMzORlDTU2SZhw= X-Received: by 2002:a05:6512:31d0:b0:4ff:a04c:8a5b with SMTP id j16-20020a05651231d000b004ffa04c8a5bmr6612126lfe.47.1696542827314; Thu, 05 Oct 2023 14:53:47 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 5 Oct 2023 21:53:46 +0000 From: Stefan Kangas <stefankangas@HIDDEN> MIME-Version: 1.0 Date: Thu, 5 Oct 2023 21:53:46 +0000 Message-ID: <CADwFkmkLzjn4oEeNR0GJEKX13ArkaYd4knaehGjjxWtcR_UHyg@HIDDEN> Subject: control message for bug #66326 To: control <at> debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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 (-) severity 66326 wishlist quit
Received: (at control) by debbugs.gnu.org; 5 Oct 2023 21:54:32 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Oct 05 17:54:31 2023 Received: from localhost ([127.0.0.1]:48834 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qoWIh-0003E8-Hh for submit <at> debbugs.gnu.org; Thu, 05 Oct 2023 17:54:31 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:45275) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>) id 1qoWIT-0003D7-MS for control <at> debbugs.gnu.org; Thu, 05 Oct 2023 17:54:18 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2c12ae20a5cso17014011fa.2 for <control <at> debbugs.gnu.org>; Thu, 05 Oct 2023 14:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696542833; x=1697147633; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=HmZiUTJ/TcIFucICFYr9REuT5zZYGOS7YPSNcQbzdSI=; b=mdXXOWv1mZbvkwL3FMfaYaqZyGcufzdfiEz+OAbchKpMsZWIGTfwEM6b5+IopYKKfu wv/OnIoaJNW+wrBdz2yI5I5hg/UnxwnhzShaLm/pWECG/Gk7TvOoKwoMNt0ROm4v1KYi fSGgbe3mvKKYpsSlc9LY+rSl1VRnzgrGYt0aoP7gUiycqpLb0WT6TksriyoiAR3IKDUW WRHY/ZRUqPkpHF06zf5YkIDvwDMOATwe6jX/5gERvwmZQYwBY2sl5qEMSyhFYt3l8vuy 2250jCIwHR3SjNgHrzORd5Vrvg+AEvXtOHec6gEj7zqum05MjCBHdaiyrGOP8E1wdJe2 KgVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696542833; x=1697147633; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HmZiUTJ/TcIFucICFYr9REuT5zZYGOS7YPSNcQbzdSI=; b=TAMGQmKzAulJiEGBEYNV+QS3/vPPbjB7FwhtcP6pVw66gnbg2T9sMUr6MsmC4VBoBI e9PmFzCbBE5liHzvZCTl7BPz/F+h3fiQwu7I8Y1ZZye3+kuSYWcBV8GGTaAcOE/YFM4f +s9EdtC144EFRm/bKUgBFZ7MDRiIHL7j0vRhuI9LdVKEU4OGPdaGFCRvjYf/LnLLgjt0 MJwvTEBabCHc7Y2iqoB8w/4DSSxcV36oQCL4GxVnmn5dm0AGaetuORHI2efzm14Srlmz YDEUgDyRIHFfHWrwWs+z5l79zT6vfb9HUtFb9nSSNUqqbXnBWXvDZ+ove4xkvRPRKWD6 wQSA== X-Gm-Message-State: AOJu0YyhCuq8jQIPA6lT7foNFmLdEPoc+D+ABND6Escg+M2Ns4Wd6Opu 4MloJEJytBlXTszokt7LbHkLycwFO9pk7zzhmwH8WWCs X-Google-Smtp-Source: AGHT+IFj128QxptrSYPtdbsWkU5nCq/AKi4yyA/pigofuLfjqJqzzlIEns/2q6iyY+wAGhgxug4JwD3KswkWwC+2IdE= X-Received: by 2002:a19:6452:0:b0:500:a08e:2fd3 with SMTP id b18-20020a196452000000b00500a08e2fd3mr4921043lfj.21.1696542833457; Thu, 05 Oct 2023 14:53:53 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 5 Oct 2023 21:53:53 +0000 From: Stefan Kangas <stefankangas@HIDDEN> MIME-Version: 1.0 Date: Thu, 5 Oct 2023 21:53:53 +0000 Message-ID: <CADwFkm=kSydh_=3Xz95BxgH9maosaofqc5KpMAavYQx9dPgjpg@HIDDEN> Subject: control message for bug #66326 To: control <at> debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control 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 (-) tags 66326 + patch quit
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.