30 |
;;; Code: |
;;; Code: |
31 |
|
|
32 |
(defvar warning-levels |
(defvar warning-levels |
33 |
'((:emergency "Emergency: " ding) |
'((:emergency "Emergency%s: " ding) |
34 |
(:error "Error: ") |
(:error "Error%s: ") |
35 |
(:warning "Warning: ") |
(:warning "Warning%s: ") |
36 |
(:debug "Debug: ")) |
(:debug "Debug%s: ")) |
37 |
"List of severity level definitions for `define-warnings'. |
"List of severity level definitions for `define-warnings'. |
38 |
Each element looks like (LEVEL STRING FUNCTION) and |
Each element looks like (LEVEL STRING FUNCTION) and |
39 |
defines LEVEL as a severity level. STRING is the description |
defines LEVEL as a severity level. STRING is the description |
40 |
to use in the buffer, and FUNCTION (which may be omitted) |
to use in the buffer, and FUNCTION (which may be omitted) |
41 |
if non-nil is a function to call with no arguments |
if non-nil is a function to call with no arguments |
42 |
to get the user's attention. |
to get the user's attention. STRING should use `%s' to |
43 |
|
specify where to put the warning group information. |
44 |
|
|
45 |
:debug level is ignored by default (see `warning-minimum-level').") |
:debug level is ignored by default (see `warning-minimum-level').") |
46 |
(put 'warning-levels 'risky-local-variable t) |
(put 'warning-levels 'risky-local-variable t) |
79 |
:version "21.4") |
:version "21.4") |
80 |
(defvaralias 'log-warning-minimum-level 'warning-minimum-log-level) |
(defvaralias 'log-warning-minimum-level 'warning-minimum-log-level) |
81 |
|
|
82 |
(defcustom warning-suppress-log nil |
(defcustom warning-suppress-log-types nil |
83 |
"List of warning types that should not be logged. |
"List of warning types that should not be logged. |
84 |
If any element of this list matches the GROUP argument to `display-warning', |
If any element of this list matches the GROUP argument to `display-warning', |
85 |
the warning is completely ignored. |
the warning is completely ignored. |
92 |
:type '(repeat (repeat symbol)) |
:type '(repeat (repeat symbol)) |
93 |
:version "21.4") |
:version "21.4") |
94 |
|
|
95 |
(defcustom warning-suppress nil |
(defcustom warning-suppress-types nil |
96 |
"Custom groups for warnings not to display immediately. |
"Custom groups for warnings not to display immediately. |
97 |
If any element of this list matches the GROUP argument to `display-warning', |
If any element of this list matches the GROUP argument to `display-warning', |
98 |
the warning is logged nonetheless, but the warnings buffer is |
the warning is logged nonetheless, but the warnings buffer is |
102 |
or (foo bar ANYTHING...) as GROUP. |
or (foo bar ANYTHING...) as GROUP. |
103 |
If GROUP is a symbol FOO, that is equivalent to the list (FOO), |
If GROUP is a symbol FOO, that is equivalent to the list (FOO), |
104 |
so only the element (FOO) will match it. |
so only the element (FOO) will match it. |
105 |
See also `warning-suppress-log'." |
See also `warning-suppress-log-types'." |
106 |
:group 'warnings |
:group 'warnings |
107 |
:type '(repeat (repeat symbol)) |
:type '(repeat (repeat symbol)) |
108 |
:version "21.4") |
:version "21.4") |
134 |
(defvar warning-fill-prefix nil |
(defvar warning-fill-prefix nil |
135 |
"Non-nil means fill each warning text using this string as `fill-prefix'.") |
"Non-nil means fill each warning text using this string as `fill-prefix'.") |
136 |
|
|
137 |
|
(defvar warning-group-format " (%s)" |
138 |
|
"Format for displaying the warning group in the warning message. |
139 |
|
The result of formatting the group this way gets included in the |
140 |
|
message under the control of the string in `warning-levels'.") |
141 |
|
|
142 |
(defun warning-suppress-p (group suppress-list) |
(defun warning-suppress-p (group suppress-list) |
143 |
"Non-nil if a warning with group GROUP should be suppressed. |
"Non-nil if a warning with group GROUP should be suppressed. |
144 |
SUPPRESS-LIST is the list of kinds of warnings to suppress." |
SUPPRESS-LIST is the list of kinds of warnings to suppress." |
197 |
(setq level (cdr (assq level warning-level-aliases)))) |
(setq level (cdr (assq level warning-level-aliases)))) |
198 |
(or (< (warning-numeric-level level) |
(or (< (warning-numeric-level level) |
199 |
(warning-numeric-level warning-minimum-log-level)) |
(warning-numeric-level warning-minimum-log-level)) |
200 |
(warning-suppress-p group warning-suppress-log) |
(warning-suppress-p group warning-suppress-log-types) |
201 |
(let* ((groupname (if (consp group) (car group) group)) |
(let* ((groupname (if (consp group) (car group) group)) |
202 |
(buffer (get-buffer-create (or buffer-name "*Warnings*"))) |
(buffer (get-buffer-create (or buffer-name "*Warnings*"))) |
203 |
(level-info (assq level warning-levels)) |
(level-info (assq level warning-levels)) |
215 |
(if warning-prefix-function |
(if warning-prefix-function |
216 |
(setq level-info (funcall warning-prefix-function |
(setq level-info (funcall warning-prefix-function |
217 |
level level-info))) |
level level-info))) |
218 |
(insert (nth 1 level-info) message) |
(setq group-string (format warning-group-format groupname)) |
219 |
|
(insert (format (nth 1 level-info) group-string) |
220 |
|
message) |
221 |
(newline) |
(newline) |
222 |
(when (and warning-fill-prefix (not (string-match "\n" message))) |
(when (and warning-fill-prefix (not (string-match "\n" message))) |
223 |
(let ((fill-prefix warning-fill-prefix) |
(let ((fill-prefix warning-fill-prefix) |
239 |
;; immediate display. |
;; immediate display. |
240 |
(or (< (warning-numeric-level level) |
(or (< (warning-numeric-level level) |
241 |
(warning-numeric-level warning-minimum-level)) |
(warning-numeric-level warning-minimum-level)) |
242 |
(warning-suppress-p group warning-suppress) |
(warning-suppress-p group warning-suppress-types) |
243 |
(let ((window (display-buffer buffer))) |
(let ((window (display-buffer buffer))) |
244 |
(when warning-series |
(when warning-series |
245 |
(set-window-start window warning-series)) |
(set-window-start window warning-series)) |