aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuanma Barranquero2011-05-05 02:06:10 +0200
committerJuanma Barranquero2011-05-05 02:06:10 +0200
commit455c834e6897366e554a457eedf9077ce768dca9 (patch)
tree83de5c8d5d7406dfcb8667387ba9d8e3ea72995a
parente968f4f300f67fe65ea5df010e6ee461f5d6df92 (diff)
downloademacs-455c834e6897366e554a457eedf9077ce768dca9.tar.gz
emacs-455c834e6897366e554a457eedf9077ce768dca9.zip
lisp/emacs-lisp/warnings.el: Tiny fixes.
* emacs-lisp/warnings.el (warning-level-aliases): Reflow docstring. (warning-series): Doc fix. (display-warning): Don't try to create the buffer if we just found it.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/emacs-lisp/warnings.el106
2 files changed, 59 insertions, 53 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 501b4e8babc..cf120f8df8e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12011-05-05 Juanma Barranquero <lekktu@gmail.com>
2
3 * emacs-lisp/warnings.el (warning-level-aliases): Reflow docstring.
4 (warning-series): Doc fix.
5 (display-warning): Don't try to create the buffer if we just found it.
6
12011-05-04 Chong Yidong <cyd@stupidchicken.com> 72011-05-04 Chong Yidong <cyd@stupidchicken.com>
2 8
3 * emacs-lisp/autoload.el (generated-autoload-file): Set to nil. 9 * emacs-lisp/autoload.el (generated-autoload-file): Set to nil.
diff --git a/lisp/emacs-lisp/warnings.el b/lisp/emacs-lisp/warnings.el
index 1fb8ac0c2b6..7f3657bbbe6 100644
--- a/lisp/emacs-lisp/warnings.el
+++ b/lisp/emacs-lisp/warnings.el
@@ -64,8 +64,8 @@ Level :debug is ignored by default (see `warning-minimum-level').")
64 (critical . :emergency) 64 (critical . :emergency)
65 (alarm . :emergency)) 65 (alarm . :emergency))
66 "Alist of aliases for severity levels for `display-warning'. 66 "Alist of aliases for severity levels for `display-warning'.
67Each element looks like (ALIAS . LEVEL) and defines 67Each element looks like (ALIAS . LEVEL) and defines ALIAS as
68ALIAS as equivalent to LEVEL. LEVEL must be defined in `warning-levels'; 68equivalent to LEVEL. LEVEL must be defined in `warning-levels';
69it may not itself be an alias.") 69it may not itself be an alias.")
70 70
71(defcustom warning-minimum-level :warning 71(defcustom warning-minimum-level :warning
@@ -141,7 +141,7 @@ the beginning of the warning.")
141A marker indicates a position in the warnings buffer 141A marker indicates a position in the warnings buffer
142which is the start of the current series; it means that 142which is the start of the current series; it means that
143additional warnings in the same buffer should not move point. 143additional warnings in the same buffer should not move point.
144t means the next warning begins a series (and stores a marker here). 144If t, the next warning begins a series (and stores a marker here).
145A symbol with a function definition is like t, except 145A symbol with a function definition is like t, except
146also call that function before the next warning.") 146also call that function before the next warning.")
147(put 'warning-series 'risky-local-variable t) 147(put 'warning-series 'risky-local-variable t)
@@ -235,7 +235,7 @@ See also `warning-series', `warning-prefix-function' and
235 (warning-suppress-p type warning-suppress-log-types) 235 (warning-suppress-p type warning-suppress-log-types)
236 (let* ((typename (if (consp type) (car type) type)) 236 (let* ((typename (if (consp type) (car type) type))
237 (old (get-buffer buffer-name)) 237 (old (get-buffer buffer-name))
238 (buffer (get-buffer-create buffer-name)) 238 (buffer (or old (get-buffer-create buffer-name)))
239 (level-info (assq level warning-levels)) 239 (level-info (assq level warning-levels))
240 start end) 240 start end)
241 (with-current-buffer buffer 241 (with-current-buffer buffer
@@ -251,60 +251,60 @@ See also `warning-series', `warning-prefix-function' and
251 (unless (eq warning-series t) 251 (unless (eq warning-series t)
252 (funcall warning-series))))) 252 (funcall warning-series)))))
253 (let ((inhibit-read-only t)) 253 (let ((inhibit-read-only t))
254 (unless (bolp) 254 (unless (bolp)
255 (newline)) 255 (newline))
256 (setq start (point)) 256 (setq start (point))
257 (if warning-prefix-function 257 (if warning-prefix-function
258 (setq level-info (funcall warning-prefix-function 258 (setq level-info (funcall warning-prefix-function
259 level level-info))) 259 level level-info)))
260 (insert (format (nth 1 level-info) 260 (insert (format (nth 1 level-info)
261 (format warning-type-format typename)) 261 (format warning-type-format typename))
262 message) 262 message)
263 (newline) 263 (newline)
264 (when (and warning-fill-prefix (not (string-match "\n" message))) 264 (when (and warning-fill-prefix (not (string-match "\n" message)))
265 (let ((fill-prefix warning-fill-prefix) 265 (let ((fill-prefix warning-fill-prefix)
266 (fill-column 78)) 266 (fill-column 78))
267 (fill-region start (point)))) 267 (fill-region start (point))))
268 (setq end (point))) 268 (setq end (point)))
269 (when (and (markerp warning-series) 269 (when (and (markerp warning-series)
270 (eq (marker-buffer warning-series) buffer)) 270 (eq (marker-buffer warning-series) buffer))
271 (goto-char warning-series))) 271 (goto-char warning-series)))
272 (if (nth 2 level-info) 272 (if (nth 2 level-info)
273 (funcall (nth 2 level-info))) 273 (funcall (nth 2 level-info)))
274 (cond (noninteractive 274 (cond (noninteractive
275 ;; Noninteractively, take the text we inserted 275 ;; Noninteractively, take the text we inserted
276 ;; in the warnings buffer and print it. 276 ;; in the warnings buffer and print it.
277 ;; Do this unconditionally, since there is no way 277 ;; Do this unconditionally, since there is no way
278 ;; to view logged messages unless we output them. 278 ;; to view logged messages unless we output them.
279 (with-current-buffer buffer 279 (with-current-buffer buffer
280 (save-excursion 280 (save-excursion
281 ;; Don't include the final newline in the arg 281 ;; Don't include the final newline in the arg
282 ;; to `message', because it adds a newline. 282 ;; to `message', because it adds a newline.
283 (goto-char end) 283 (goto-char end)
284 (if (bolp) 284 (if (bolp)
285 (forward-char -1)) 285 (forward-char -1))
286 (message "%s" (buffer-substring start (point)))))) 286 (message "%s" (buffer-substring start (point))))))
287 ((and (daemonp) (null after-init-time)) 287 ((and (daemonp) (null after-init-time))
288 ;; Warnings assigned during daemon initialization go into 288 ;; Warnings assigned during daemon initialization go into
289 ;; the messages buffer. 289 ;; the messages buffer.
290 (message "%s" 290 (message "%s"
291 (with-current-buffer buffer 291 (with-current-buffer buffer
292 (save-excursion 292 (save-excursion
293 (goto-char end) 293 (goto-char end)
294 (if (bolp) 294 (if (bolp)
295 (forward-char -1)) 295 (forward-char -1))
296 (buffer-substring start (point)))))) 296 (buffer-substring start (point))))))
297 (t 297 (t
298 ;; Interactively, decide whether the warning merits 298 ;; Interactively, decide whether the warning merits
299 ;; immediate display. 299 ;; immediate display.
300 (or (< (warning-numeric-level level) 300 (or (< (warning-numeric-level level)
301 (warning-numeric-level warning-minimum-level)) 301 (warning-numeric-level warning-minimum-level))
302 (warning-suppress-p type warning-suppress-types) 302 (warning-suppress-p type warning-suppress-types)
303 (let ((window (display-buffer buffer))) 303 (let ((window (display-buffer buffer)))
304 (when (and (markerp warning-series) 304 (when (and (markerp warning-series)
305 (eq (marker-buffer warning-series) buffer)) 305 (eq (marker-buffer warning-series) buffer))
306 (set-window-start window warning-series)) 306 (set-window-start window warning-series))
307 (sit-for 0)))))))) 307 (sit-for 0))))))))
308 308
309;;;###autoload 309;;;###autoload
310(defun lwarn (type level message &rest args) 310(defun lwarn (type level message &rest args)