]> code.delx.au - gnu-emacs/blobdiff - lisp/warnings.el
*** empty log message ***
[gnu-emacs] / lisp / warnings.el
index 5c75780aa6460af1c9b3c98f63665283ca727310..4d0354236a806bc71000aaa43877259c8aef7a90 100644 (file)
 
 ;;; Code:
 
+(defgroup warnings nil
+  "Log and display warnings."
+  :version "21.4"
+  :group 'lisp)
+
 (defvar warning-levels
   '((:emergency "Emergency%s: " ding)
     (:error "Error%s: ")
@@ -62,7 +67,7 @@ Level :debug is ignored by default (see `warning-minimum-level').")
     (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
@@ -131,9 +136,10 @@ the beginning of the 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)
@@ -227,7 +233,7 @@ See also `warning-series', `warning-prefix-function' and
          (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)
@@ -245,7 +251,8 @@ See also `warning-series', `warning-prefix-function' and
                  (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)))
@@ -255,14 +262,21 @@ See also `warning-series', `warning-prefix-function' and
            ;; 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