;;; Code:
+(defgroup warnings nil
+ "Log and display warnings."
+ :version "21.4"
+ :group 'lisp)
+
(defvar warning-levels
'((:emergency "Emergency%s: " ding)
(:error "Error%s: ")
(alarm . :emergency))
"Alist of aliases for severity levels for `display-warning'.
Each element looks like (ALIAS . LEVEL) and defines
-ALIAS as equivalent to LEVEL. LEVEL must be defined in `warning-levels';
+ALIAS as equivalent to LEVEL. LEVEL must be defined in `warning-levels';
it may not itself be an alias.")
\f
(defcustom warning-minimum-level :warning
;;;###autoload
(defvar warning-series nil
"Non-nil means treat multiple `display-warning' calls as a series.
-An integer is a position in the warnings buffer
-which is the start of the current series.
-t means the next warning begins a series (and stores an integer here).
+A marker indicates a position in the warnings buffer
+which is the start of the current series; it means that
+additional warnings in the same buffer should not move point.
+t means the next warning begins a series (and stores a marker here).
A symbol with a function definition is like t, except
also call that function before the next warning.")
(put 'warning-series 'risky-local-variable t)
(goto-char (point-max))
(when (and warning-series (symbolp warning-series))
(setq warning-series
- (prog1 (point)
+ (prog1 (point-marker)
(unless (eq warning-series t)
(funcall warning-series)))))
(unless (bolp)
(fill-column 78))
(fill-region start (point))))
(setq end (point))
- (when warning-series
+ (when (and (markerp warning-series)
+ (eq (marker-buffer warning-series) buffer))
(goto-char warning-series)))
(if (nth 2 level-info)
(funcall (nth 2 level-info)))
;; Do this unconditionally, since there is no way
;; to view logged messages unless we output them.
(with-current-buffer buffer
- (message "%s" (buffer-substring start end)))
+ (save-excursion
+ ;; Don't include the final newline in the arg
+ ;; to `message', because it adds a newline.
+ (goto-char end)
+ (if (bolp)
+ (forward-char -1))
+ (message "%s" (buffer-substring start (point)))))
;; Interactively, decide whether the warning merits
;; immediate display.
(or (< (warning-numeric-level level)
(warning-numeric-level warning-minimum-level))
(warning-suppress-p group warning-suppress-types)
(let ((window (display-buffer buffer)))
- (when warning-series
+ (when (and (markerp warning-series)
+ (eq (marker-buffer warning-series) buffer))
(set-window-start window warning-series))
(sit-for 0)))))))
\f