From: Spencer Baugh <sbaugh@janestreet.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: sbaugh@catern.com, 66326@debbugs.gnu.org
Subject: bug#66326: 29.1.50; There should be a way to promote warnings to errors
Date: Wed, 04 Oct 2023 08:20:49 -0400 [thread overview]
Message-ID: <ierlecivase.fsf@janestreet.com> (raw)
In-Reply-To: <83wmw353ny.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 04 Oct 2023 08:59:13 +0300")
[-- Attachment #1: Type: text/plain, Size: 231 bytes --]
Eli Zaretskii <eliz@gnu.org> 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?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Support-turning-warnings-into-errors.patch --]
[-- Type: text/x-patch, Size: 3029 bytes --]
From 11fdd0cdd2d0da28848ad42d8087ebb1a4e05430 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@janestreet.com>
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")
\f
;; 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
next prev parent reply other threads:[~2023-10-04 12:20 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-03 16:38 bug#66326: 29.1.50; There should be a way to promote warnings to errors Spencer Baugh
2023-10-03 18:39 ` Spencer Baugh
2023-10-03 18:57 ` Eli Zaretskii
2023-10-03 19:16 ` sbaugh
2023-10-04 5:59 ` Eli Zaretskii
2023-10-04 12:20 ` Spencer Baugh [this message]
2023-10-14 7:27 ` Eli Zaretskii
2023-10-14 22:25 ` sbaugh
2023-10-15 5:45 ` Eli Zaretskii
2023-10-16 19:26 ` Spencer Baugh
2023-10-19 12:13 ` Eli Zaretskii
2023-10-19 14:50 ` Spencer Baugh
2023-10-19 15:07 ` Eli Zaretskii
2023-10-19 15:18 ` Spencer Baugh
2023-10-19 15:42 ` Eli Zaretskii
2023-10-19 16:15 ` Spencer Baugh
2023-10-20 7:20 ` Eli Zaretskii
2023-10-21 9:12 ` Stefan Kangas
2023-10-21 13:43 ` sbaugh
2023-11-10 21:40 ` Spencer Baugh
2023-11-11 7:02 ` Eli Zaretskii
2023-11-11 14:37 ` Spencer Baugh
2023-11-11 14:51 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ierlecivase.fsf@janestreet.com \
--to=sbaugh@janestreet.com \
--cc=66326@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=sbaugh@catern.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.