Mercurial > emacs
annotate lisp/emacs-lisp/warnings.el @ 109559:4325622babca
Remove declarations and unused variables.
* src/term.c (Qspace, QCalign_to, QCwidth): Remove declarations.
(encode_terminal_code, produce_composite_glyph): Remove unused variables.
(set_tty_color_mode, term_mouse_highlight, term_get_fkeys): Remove
local extern declarations.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Mon, 26 Jul 2010 21:20:51 -0700 |
parents | 1d1d5d9bd884 |
children | 6c2baabc9d98 376148b31b5e |
rev | line source |
---|---|
51349 | 1 ;;; warnings.el --- log and display warnings |
2 | |
106815 | 3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
51349 | 4 |
5 ;; Maintainer: FSF | |
6 ;; Keywords: internal | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
51349 | 11 ;; it under the terms of the GNU General Public License as published by |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; (at your option) any later version. |
51349 | 14 |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
51349 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;; This file implements the entry points `warn', `lwarn' | |
54486 | 26 ;; and `display-warning'. |
51349 | 27 |
28 ;;; Code: | |
29 | |
30 (defgroup warnings nil | |
31 "Log and display warnings." | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
54486
diff
changeset
|
32 :version "22.1" |
51349 | 33 :group 'lisp) |
34 | |
35 (defvar warning-levels | |
36 '((:emergency "Emergency%s: " ding) | |
37 (:error "Error%s: ") | |
38 (:warning "Warning%s: ") | |
39 (:debug "Debug%s: ")) | |
40 "List of severity level definitions for `display-warning'. | |
41 Each element looks like (LEVEL STRING FUNCTION) and | |
42 defines LEVEL as a severity level. STRING specifies the | |
43 description of this level. STRING should use `%s' to | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
44 specify where to put the warning type information, |
51349 | 45 or it can omit the `%s' so as not to include that information. |
46 | |
47 The optional FUNCTION, if non-nil, is a function to call | |
48 with no arguments, to get the user's attention. | |
49 | |
50 The standard levels are :emergency, :error, :warning and :debug. | |
51 See `display-warning' for documentation of their meanings. | |
52 Level :debug is ignored by default (see `warning-minimum-level').") | |
53 (put 'warning-levels 'risky-local-variable t) | |
54 | |
55 ;; These are for compatibility with XEmacs. | |
56 ;; I don't think there is any chance of designing meaningful criteria | |
57 ;; to distinguish so many levels. | |
58 (defvar warning-level-aliases | |
59 '((emergency . :emergency) | |
60 (error . :error) | |
61 (warning . :warning) | |
62 (notice . :warning) | |
63 (info . :warning) | |
64 (critical . :emergency) | |
65 (alarm . :emergency)) | |
66 "Alist of aliases for severity levels for `display-warning'. | |
67 Each element looks like (ALIAS . LEVEL) and defines | |
68 ALIAS as equivalent to LEVEL. LEVEL must be defined in `warning-levels'; | |
69 it may not itself be an alias.") | |
70 | |
71 (defcustom warning-minimum-level :warning | |
72 "Minimum severity level for displaying the warning buffer. | |
73 If a warning's severity level is lower than this, | |
74 the warning is logged in the warnings buffer, but the buffer | |
75 is not immediately displayed. See also `warning-minimum-log-level'." | |
76 :group 'warnings | |
63537
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
77 :type '(choice (const :emergency) (const :error) |
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
78 (const :warning) (const :debug)) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
54486
diff
changeset
|
79 :version "22.1") |
51349 | 80 (defvaralias 'display-warning-minimum-level 'warning-minimum-level) |
81 | |
82 (defcustom warning-minimum-log-level :warning | |
83 "Minimum severity level for logging a warning. | |
84 If a warning severity level is lower than this, | |
63537
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
85 the warning is completely ignored. |
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
86 Value must be lower or equal than `warning-minimum-level', |
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
87 because warnings not logged aren't displayed either." |
51349 | 88 :group 'warnings |
63537
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
89 :type '(choice (const :emergency) (const :error) |
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
90 (const :warning) (const :debug)) |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
54486
diff
changeset
|
91 :version "22.1") |
51349 | 92 (defvaralias 'log-warning-minimum-level 'warning-minimum-log-level) |
93 | |
94 (defcustom warning-suppress-log-types nil | |
95 "List of warning types that should not be logged. | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
96 If any element of this list matches the TYPE argument to `display-warning', |
51349 | 97 the warning is completely ignored. |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
98 The element must match the first elements of TYPE. |
51349 | 99 Thus, (foo bar) as an element matches (foo bar) |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
100 or (foo bar ANYTHING...) as TYPE. |
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
101 If TYPE is a symbol FOO, that is equivalent to the list (FOO), |
51349 | 102 so only the element (FOO) will match it." |
103 :group 'warnings | |
104 :type '(repeat (repeat symbol)) | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
54486
diff
changeset
|
105 :version "22.1") |
51349 | 106 |
107 (defcustom warning-suppress-types nil | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
108 "List of warning types not to display immediately. |
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
109 If any element of this list matches the TYPE argument to `display-warning', |
51349 | 110 the warning is logged nonetheless, but the warnings buffer is |
111 not immediately displayed. | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
112 The element must match an initial segment of the list TYPE. |
51349 | 113 Thus, (foo bar) as an element matches (foo bar) |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
114 or (foo bar ANYTHING...) as TYPE. |
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
115 If TYPE is a symbol FOO, that is equivalent to the list (FOO), |
51349 | 116 so only the element (FOO) will match it. |
117 See also `warning-suppress-log-types'." | |
118 :group 'warnings | |
119 :type '(repeat (repeat symbol)) | |
59996
aac0a33f5772
Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents:
54486
diff
changeset
|
120 :version "22.1") |
51349 | 121 |
122 ;;; The autoload cookie is so that programs can bind this variable | |
123 ;;; safely, testing the existing value, before they call one of the | |
124 ;;; warnings functions. | |
125 ;;;###autoload | |
126 (defvar warning-prefix-function nil | |
127 "Function to generate warning prefixes. | |
128 This function, if non-nil, is called with two arguments, | |
129 the severity level and its entry in `warning-levels', | |
130 and should return the entry that should actually be used. | |
131 The warnings buffer is current when this function is called | |
132 and the function can insert text in it. This text becomes | |
133 the beginning of the warning.") | |
134 | |
135 ;;; The autoload cookie is so that programs can bind this variable | |
136 ;;; safely, testing the existing value, before they call one of the | |
137 ;;; warnings functions. | |
138 ;;;###autoload | |
139 (defvar warning-series nil | |
140 "Non-nil means treat multiple `display-warning' calls as a series. | |
141 A marker indicates a position in the warnings buffer | |
142 which is the start of the current series; it means that | |
143 additional warnings in the same buffer should not move point. | |
144 t means the next warning begins a series (and stores a marker here). | |
145 A symbol with a function definition is like t, except | |
146 also call that function before the next warning.") | |
147 (put 'warning-series 'risky-local-variable t) | |
148 | |
149 ;;; The autoload cookie is so that programs can bind this variable | |
150 ;;; safely, testing the existing value, before they call one of the | |
151 ;;; warnings functions. | |
152 ;;;###autoload | |
153 (defvar warning-fill-prefix nil | |
154 "Non-nil means fill each warning text using this string as `fill-prefix'.") | |
155 | |
156 ;;; The autoload cookie is so that programs can bind this variable | |
157 ;;; safely, testing the existing value, before they call one of the | |
158 ;;; warnings functions. | |
159 ;;;###autoload | |
105870
26baacb565b0
* textmodes/tex-mode.el (tex-alt-dvi-print-command)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100908
diff
changeset
|
160 (defvar warning-type-format (purecopy " (%s)") |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
161 "Format for displaying the warning type in the warning message. |
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
162 The result of formatting the type this way gets included in the |
51349 | 163 message under the control of the string in `warning-levels'.") |
164 | |
165 (defun warning-numeric-level (level) | |
166 "Return a numeric measure of the warning severity level LEVEL." | |
167 (let* ((elt (assq level warning-levels)) | |
168 (link (memq elt warning-levels))) | |
169 (length link))) | |
170 | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
171 (defun warning-suppress-p (type suppress-list) |
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
172 "Non-nil if a warning with type TYPE should be suppressed. |
51349 | 173 SUPPRESS-LIST is the list of kinds of warnings to suppress." |
174 (let (some-match) | |
175 (dolist (elt suppress-list) | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
176 (if (symbolp type) |
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
177 ;; If TYPE is a symbol, the ELT must be (TYPE). |
51349 | 178 (if (and (consp elt) |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
179 (eq (car elt) type) |
51349 | 180 (null (cdr elt))) |
181 (setq some-match t)) | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
182 ;; If TYPE is a list, ELT must match it or some initial segment of it. |
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
183 (let ((tem1 type) |
51349 | 184 (tem2 elt) |
185 (match t)) | |
186 ;; Check elements of ELT until we run out of them. | |
187 (while tem2 | |
188 (if (not (equal (car tem1) (car tem2))) | |
189 (setq match nil)) | |
190 (setq tem1 (cdr tem1) | |
191 tem2 (cdr tem2))) | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
192 ;; If ELT is an initial segment of TYPE, MATCH is t now. |
51349 | 193 ;; So set SOME-MATCH. |
194 (if match | |
195 (setq some-match t))))) | |
196 ;; If some element of SUPPRESS-LIST matched, | |
197 ;; we return t. | |
198 some-match)) | |
199 | |
200 ;;;###autoload | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
201 (defun display-warning (type message &optional level buffer-name) |
51349 | 202 "Display a warning message, MESSAGE. |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
203 TYPE is the warning type: either a custom group name (a symbol), |
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
204 or a list of symbols whose first element is a custom group name. |
51349 | 205 \(The rest of the symbols represent subcategories, for warning purposes |
206 only, and you can use whatever symbols you like.) | |
207 | |
63537
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
208 LEVEL should be either :debug, :warning, :error, or :emergency |
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
209 \(but see `warning-minimum-level' and `warning-minimum-log-level'). |
70324
5a0747ecd057
(display-warning, lwarn): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
68648
diff
changeset
|
210 Default is :warning. |
63537
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
211 |
51349 | 212 :emergency -- a problem that will seriously impair Emacs operation soon |
213 if you do not attend to it promptly. | |
214 :error -- data or circumstances that are inherently wrong. | |
215 :warning -- data or circumstances that are not inherently wrong, | |
216 but raise suspicion of a possible problem. | |
217 :debug -- info for debugging only. | |
218 | |
76849
acccfec69255
(display-warning): If we create the buffer displaying the warning,
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
219 BUFFER-NAME, if specified, is the name of the buffer for logging |
acccfec69255
(display-warning): If we create the buffer displaying the warning,
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
220 the warning. By default, it is `*Warnings*'. If this function |
acccfec69255
(display-warning): If we create the buffer displaying the warning,
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
221 has to create the buffer, it disables undo in the buffer. |
51349 | 222 |
223 See the `warnings' custom group for user customization features. | |
224 | |
225 See also `warning-series', `warning-prefix-function' and | |
226 `warning-fill-prefix' for additional programming features." | |
227 (unless level | |
228 (setq level :warning)) | |
76849
acccfec69255
(display-warning): If we create the buffer displaying the warning,
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
229 (unless buffer-name |
acccfec69255
(display-warning): If we create the buffer displaying the warning,
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
230 (setq buffer-name "*Warnings*")) |
51349 | 231 (if (assq level warning-level-aliases) |
232 (setq level (cdr (assq level warning-level-aliases)))) | |
233 (or (< (warning-numeric-level level) | |
63537
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
234 (warning-numeric-level warning-minimum-log-level)) |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
235 (warning-suppress-p type warning-suppress-log-types) |
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
236 (let* ((typename (if (consp type) (car type) type)) |
76849
acccfec69255
(display-warning): If we create the buffer displaying the warning,
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
237 (old (get-buffer buffer-name)) |
acccfec69255
(display-warning): If we create the buffer displaying the warning,
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
238 (buffer (get-buffer-create buffer-name)) |
51349 | 239 (level-info (assq level warning-levels)) |
240 start end) | |
241 (with-current-buffer buffer | |
76849
acccfec69255
(display-warning): If we create the buffer displaying the warning,
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
242 ;; If we created the buffer, disable undo. |
acccfec69255
(display-warning): If we create the buffer displaying the warning,
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
243 (unless old |
acccfec69255
(display-warning): If we create the buffer displaying the warning,
Glenn Morris <rgm@gnu.org>
parents:
75346
diff
changeset
|
244 (setq buffer-undo-list t)) |
51349 | 245 (goto-char (point-max)) |
246 (when (and warning-series (symbolp warning-series)) | |
247 (setq warning-series | |
248 (prog1 (point-marker) | |
249 (unless (eq warning-series t) | |
250 (funcall warning-series))))) | |
251 (unless (bolp) | |
252 (newline)) | |
253 (setq start (point)) | |
254 (if warning-prefix-function | |
255 (setq level-info (funcall warning-prefix-function | |
256 level level-info))) | |
257 (insert (format (nth 1 level-info) | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
258 (format warning-type-format typename)) |
51349 | 259 message) |
260 (newline) | |
261 (when (and warning-fill-prefix (not (string-match "\n" message))) | |
262 (let ((fill-prefix warning-fill-prefix) | |
263 (fill-column 78)) | |
264 (fill-region start (point)))) | |
265 (setq end (point)) | |
266 (when (and (markerp warning-series) | |
267 (eq (marker-buffer warning-series) buffer)) | |
268 (goto-char warning-series))) | |
269 (if (nth 2 level-info) | |
270 (funcall (nth 2 level-info))) | |
98634
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
271 (cond (noninteractive |
51349 | 272 ;; Noninteractively, take the text we inserted |
273 ;; in the warnings buffer and print it. | |
274 ;; Do this unconditionally, since there is no way | |
275 ;; to view logged messages unless we output them. | |
276 (with-current-buffer buffer | |
277 (save-excursion | |
278 ;; Don't include the final newline in the arg | |
279 ;; to `message', because it adds a newline. | |
280 (goto-char end) | |
281 (if (bolp) | |
282 (forward-char -1)) | |
98634
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
283 (message "%s" (buffer-substring start (point)))))) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
284 ((and (daemonp) (null after-init-time)) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
285 ;; Warnings assigned during daemon initialization go into |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
286 ;; the messages buffer. |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
287 (message "%s" |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
288 (with-current-buffer buffer |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
289 (save-excursion |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
290 (goto-char end) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
291 (if (bolp) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
292 (forward-char -1)) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
293 (buffer-substring start (point)))))) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
294 (t |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
295 ;; Interactively, decide whether the warning merits |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
296 ;; immediate display. |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
297 (or (< (warning-numeric-level level) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
298 (warning-numeric-level warning-minimum-level)) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
299 (warning-suppress-p type warning-suppress-types) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
300 (let ((window (display-buffer buffer))) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
301 (when (and (markerp warning-series) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
302 (eq (marker-buffer warning-series) buffer)) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
303 (set-window-start window warning-series)) |
dab337a95b5a
(display-warning): Issue a message if called during daemon
Chong Yidong <cyd@stupidchicken.com>
parents:
94655
diff
changeset
|
304 (sit-for 0)))))))) |
51349 | 305 |
306 ;;;###autoload | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
307 (defun lwarn (type level message &rest args) |
51349 | 308 "Display a warning message made from (format MESSAGE ARGS...). |
309 Aside from generating the message with `format', | |
310 this is equivalent to `display-warning'. | |
311 | |
70324
5a0747ecd057
(display-warning, lwarn): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents:
68648
diff
changeset
|
312 TYPE is the warning type: either a custom group name (a symbol), |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
313 or a list of symbols whose first element is a custom group name. |
51349 | 314 \(The rest of the symbols represent subcategories and |
315 can be whatever you like.) | |
316 | |
63537
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
317 LEVEL should be either :debug, :warning, :error, or :emergency |
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
318 \(but see `warning-minimum-level' and `warning-minimum-log-level'). |
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
319 |
51349 | 320 :emergency -- a problem that will seriously impair Emacs operation soon |
321 if you do not attend to it promptly. | |
322 :error -- invalid data or circumstances. | |
63537
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
323 :warning -- suspicious data or circumstances. |
5bcd8e3411e3
(display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
59996
diff
changeset
|
324 :debug -- info for debugging only." |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
325 (display-warning type (apply 'format message args) level)) |
51349 | 326 |
327 ;;;###autoload | |
328 (defun warn (message &rest args) | |
329 "Display a warning message made from (format MESSAGE ARGS...). | |
330 Aside from generating the message with `format', | |
331 this is equivalent to `display-warning', using | |
52134
d26709514a27
Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents:
51349
diff
changeset
|
332 `emacs' as the type and `:warning' as the level." |
51349 | 333 (display-warning 'emacs (apply 'format message args))) |
334 | |
335 (provide 'warnings) | |
336 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79704
diff
changeset
|
337 ;; arch-tag: faaad1c8-7b2a-4161-af38-5ab4afde0496 |
51349 | 338 ;;; warnings.el ends here |