aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/warnings.el57
1 files changed, 39 insertions, 18 deletions
diff --git a/lisp/warnings.el b/lisp/warnings.el
index db371653e8d..5c75780aa64 100644
--- a/lisp/warnings.el
+++ b/lisp/warnings.el
@@ -36,17 +36,21 @@
36 (:debug "Debug%s: ")) 36 (:debug "Debug%s: "))
37 "List of severity level definitions for `display-warning'. 37 "List of severity level definitions for `display-warning'.
38Each element looks like (LEVEL STRING FUNCTION) and 38Each element looks like (LEVEL STRING FUNCTION) and
39defines LEVEL as a severity level. STRING is the description 39defines LEVEL as a severity level. STRING specifies the
40to use in the buffer, and FUNCTION (which may be omitted) 40description of this level. STRING should use `%s' to
41if non-nil is a function to call with no arguments 41specify where to put the warning group information,
42to get the user's attention. STRING should use `%s' to 42or it can omit the `%s' so as not to include that information.
43specify where to put the warning group information.
44 43
45:debug level is ignored by default (see `warning-minimum-level').") 44The optional FUNCTION, if non-nil, is a function to call
45with no arguments, to get the user's attention.
46
47The standard levels are :emergency, :error, :warning and :debug.
48See `display-warning' for documentation of their meanings.
49Level :debug is ignored by default (see `warning-minimum-level').")
46(put 'warning-levels 'risky-local-variable t) 50(put 'warning-levels 'risky-local-variable t)
47 51
48;; These are for compatibility with XEmacs. 52;; These are for compatibility with XEmacs.
49;; I don't think there is any chance of finding meaningful distinctions 53;; I don't think there is any chance of designing meaningful criteria
50;; to distinguish so many levels. 54;; to distinguish so many levels.
51(defvar warning-level-aliases 55(defvar warning-level-aliases
52 '((emergency . :emergency) 56 '((emergency . :emergency)
@@ -58,8 +62,9 @@ specify where to put the warning group information.
58 (alarm . :emergency)) 62 (alarm . :emergency))
59 "Alist of aliases for severity levels for `display-warning'. 63 "Alist of aliases for severity levels for `display-warning'.
60Each element looks like (ALIAS . LEVEL) and defines 64Each element looks like (ALIAS . LEVEL) and defines
61ALIAS as equivalent to LEVEL.") 65ALIAS as equivalent to LEVEL. LEVEL must be defined in `warning-levels';
62 66it may not itself be an alias.")
67
63(defcustom warning-minimum-level :warning 68(defcustom warning-minimum-level :warning
64 "Minimum severity level for displaying the warning buffer. 69 "Minimum severity level for displaying the warning buffer.
65If a warning's severity level is lower than this, 70If a warning's severity level is lower than this,
@@ -106,7 +111,11 @@ See also `warning-suppress-log-types'."
106 :group 'warnings 111 :group 'warnings
107 :type '(repeat (repeat symbol)) 112 :type '(repeat (repeat symbol))
108 :version "21.4") 113 :version "21.4")
109 114
115;;; The autoload cookie is so that programs can bind this variable
116;;; safely, testing the existing value, before they call one of the
117;;; warnings functions.
118;;;###autoload
110(defvar warning-prefix-function nil 119(defvar warning-prefix-function nil
111 "Function to generate warning prefixes. 120 "Function to generate warning prefixes.
112This function, if non-nil, is called with two arguments, 121This function, if non-nil, is called with two arguments,
@@ -116,12 +125,10 @@ The warnings buffer is current when this function is called
116and the function can insert text in it. This text becomes 125and the function can insert text in it. This text becomes
117the beginning of the warning.") 126the beginning of the warning.")
118 127
119(defun warning-numeric-level (level) 128;;; The autoload cookie is so that programs can bind this variable
120 "Return a numeric measure of the warning severity level LEVEL." 129;;; safely, testing the existing value, before they call one of the
121 (let* ((elt (assq level warning-levels)) 130;;; warnings functions.
122 (link (memq elt warning-levels))) 131;;;###autoload
123 (length link)))
124
125(defvar warning-series nil 132(defvar warning-series nil
126 "Non-nil means treat multiple `display-warning' calls as a series. 133 "Non-nil means treat multiple `display-warning' calls as a series.
127An integer is a position in the warnings buffer 134An integer is a position in the warnings buffer
@@ -131,13 +138,27 @@ A symbol with a function definition is like t, except
131also call that function before the next warning.") 138also call that function before the next warning.")
132(put 'warning-series 'risky-local-variable t) 139(put 'warning-series 'risky-local-variable t)
133 140
141;;; The autoload cookie is so that programs can bind this variable
142;;; safely, testing the existing value, before they call one of the
143;;; warnings functions.
144;;;###autoload
134(defvar warning-fill-prefix nil 145(defvar warning-fill-prefix nil
135 "Non-nil means fill each warning text using this string as `fill-prefix'.") 146 "Non-nil means fill each warning text using this string as `fill-prefix'.")
136 147
148;;; The autoload cookie is so that programs can bind this variable
149;;; safely, testing the existing value, before they call one of the
150;;; warnings functions.
151;;;###autoload
137(defvar warning-group-format " (%s)" 152(defvar warning-group-format " (%s)"
138 "Format for displaying the warning group in the warning message. 153 "Format for displaying the warning group in the warning message.
139The result of formatting the group this way gets included in the 154The result of formatting the group this way gets included in the
140message under the control of the string in `warning-levels'.") 155message under the control of the string in `warning-levels'.")
156
157(defun warning-numeric-level (level)
158 "Return a numeric measure of the warning severity level LEVEL."
159 (let* ((elt (assq level warning-levels))
160 (link (memq elt warning-levels)))
161 (length link)))
141 162
142(defun warning-suppress-p (group suppress-list) 163(defun warning-suppress-p (group suppress-list)
143 "Non-nil if a warning with group GROUP should be suppressed. 164 "Non-nil if a warning with group GROUP should be suppressed.
@@ -167,7 +188,7 @@ SUPPRESS-LIST is the list of kinds of warnings to suppress."
167 ;; If some element of SUPPRESS-LIST matched, 188 ;; If some element of SUPPRESS-LIST matched,
168 ;; we return t. 189 ;; we return t.
169 some-match)) 190 some-match))
170 191
171;;;###autoload 192;;;###autoload
172(defun display-warning (group message &optional level buffer-name) 193(defun display-warning (group message &optional level buffer-name)
173 "Display a warning message, MESSAGE. 194 "Display a warning message, MESSAGE.
@@ -244,7 +265,7 @@ See also `warning-series', `warning-prefix-function' and
244 (when warning-series 265 (when warning-series
245 (set-window-start window warning-series)) 266 (set-window-start window warning-series))
246 (sit-for 0))))))) 267 (sit-for 0)))))))
247 268
248;;;###autoload 269;;;###autoload
249(defun lwarn (group level message &rest args) 270(defun lwarn (group level message &rest args)
250 "Display a warning message made from (format MESSAGE ARGS...). 271 "Display a warning message made from (format MESSAGE ARGS...).