annotate lisp/emacs-lisp/warnings.el @ 95332:4dfc7920f403

(update-elclist): Make errors in final sed non-fatal.
author Glenn Morris <rgm@gnu.org>
date Tue, 27 May 2008 02:14:46 +0000
parents 90a2847062be
children dab337a95b5a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
1 ;;; warnings.el --- log and display warnings
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
2
79704
78ee6fae0e41 Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78217
diff changeset
3 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
4
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
5 ;; Maintainer: FSF
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
6 ;; Keywords: internal
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
7
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
14
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
19
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
22
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
23 ;;; Commentary:
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
24
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
25 ;; This file implements the entry points `warn', `lwarn'
54486
34a469490568 Doc fix.
Juri Linkov <juri@jurta.org>
parents: 52401
diff changeset
26 ;; and `display-warning'.
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
27
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
28 ;;; Code:
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
29
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
30 (defgroup warnings nil
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
33 :group 'lisp)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
34
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
35 (defvar warning-levels
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
36 '((:emergency "Emergency%s: " ding)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
37 (:error "Error%s: ")
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
38 (:warning "Warning%s: ")
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
39 (:debug "Debug%s: "))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
40 "List of severity level definitions for `display-warning'.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
41 Each element looks like (LEVEL STRING FUNCTION) and
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
42 defines LEVEL as a severity level. STRING specifies the
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
45 or it can omit the `%s' so as not to include that information.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
46
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
47 The optional FUNCTION, if non-nil, is a function to call
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
48 with no arguments, to get the user's attention.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
49
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
50 The standard levels are :emergency, :error, :warning and :debug.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
51 See `display-warning' for documentation of their meanings.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
52 Level :debug is ignored by default (see `warning-minimum-level').")
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
53 (put 'warning-levels 'risky-local-variable t)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
54
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
55 ;; These are for compatibility with XEmacs.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
56 ;; I don't think there is any chance of designing meaningful criteria
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
57 ;; to distinguish so many levels.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
58 (defvar warning-level-aliases
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
59 '((emergency . :emergency)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
60 (error . :error)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
61 (warning . :warning)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
62 (notice . :warning)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
63 (info . :warning)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
64 (critical . :emergency)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
65 (alarm . :emergency))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
66 "Alist of aliases for severity levels for `display-warning'.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
67 Each element looks like (ALIAS . LEVEL) and defines
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
68 ALIAS as equivalent to LEVEL. LEVEL must be defined in `warning-levels';
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
69 it may not itself be an alias.")
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
70
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
71 (defcustom warning-minimum-level :warning
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
72 "Minimum severity level for displaying the warning buffer.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
73 If a warning's severity level is lower than this,
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
74 the warning is logged in the warnings buffer, but the buffer
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
75 is not immediately displayed. See also `warning-minimum-log-level'."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
80 (defvaralias 'display-warning-minimum-level 'warning-minimum-level)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
81
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
82 (defcustom warning-minimum-log-level :warning
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
83 "Minimum severity level for logging a warning.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
92 (defvaralias 'log-warning-minimum-level 'warning-minimum-log-level)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
93
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
94 (defcustom warning-suppress-log-types nil
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
102 so only the element (FOO) will match it."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
103 :group 'warnings
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
106
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
110 the warning is logged nonetheless, but the warnings buffer is
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
116 so only the element (FOO) will match it.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
117 See also `warning-suppress-log-types'."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
118 :group 'warnings
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
121
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
122 ;;; The autoload cookie is so that programs can bind this variable
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
123 ;;; safely, testing the existing value, before they call one of the
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
124 ;;; warnings functions.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
125 ;;;###autoload
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
126 (defvar warning-prefix-function nil
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
127 "Function to generate warning prefixes.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
128 This function, if non-nil, is called with two arguments,
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
129 the severity level and its entry in `warning-levels',
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
130 and should return the entry that should actually be used.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
131 The warnings buffer is current when this function is called
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
132 and the function can insert text in it. This text becomes
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
133 the beginning of the warning.")
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
134
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
135 ;;; The autoload cookie is so that programs can bind this variable
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
136 ;;; safely, testing the existing value, before they call one of the
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
137 ;;; warnings functions.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
138 ;;;###autoload
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
139 (defvar warning-series nil
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
140 "Non-nil means treat multiple `display-warning' calls as a series.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
141 A marker indicates a position in the warnings buffer
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
142 which is the start of the current series; it means that
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
143 additional warnings in the same buffer should not move point.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
144 t means the next warning begins a series (and stores a marker here).
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
145 A symbol with a function definition is like t, except
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
146 also call that function before the next warning.")
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
147 (put 'warning-series 'risky-local-variable t)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
148
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
149 ;;; The autoload cookie is so that programs can bind this variable
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
150 ;;; safely, testing the existing value, before they call one of the
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
151 ;;; warnings functions.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
152 ;;;###autoload
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
153 (defvar warning-fill-prefix nil
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
154 "Non-nil means fill each warning text using this string as `fill-prefix'.")
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
155
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
156 ;;; The autoload cookie is so that programs can bind this variable
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
157 ;;; safely, testing the existing value, before they call one of the
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
158 ;;; warnings functions.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
159 ;;;###autoload
52134
d26709514a27 Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents: 51349
diff changeset
160 (defvar warning-type-format " (%s)"
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
163 message under the control of the string in `warning-levels'.")
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
164
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
165 (defun warning-numeric-level (level)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
166 "Return a numeric measure of the warning severity level LEVEL."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
167 (let* ((elt (assq level warning-levels))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
168 (link (memq elt warning-levels)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
169 (length link)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
173 SUPPRESS-LIST is the list of kinds of warnings to suppress."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
174 (let (some-match)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
180 (null (cdr elt)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
184 (tem2 elt)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
185 (match t))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
186 ;; Check elements of ELT until we run out of them.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
187 (while tem2
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
188 (if (not (equal (car tem1) (car tem2)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
189 (setq match nil))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
190 (setq tem1 (cdr tem1)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
193 ;; So set SOME-MATCH.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
194 (if match
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
195 (setq some-match t)))))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
196 ;; If some element of SUPPRESS-LIST matched,
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
197 ;; we return t.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
198 some-match))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
199
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
205 \(The rest of the symbols represent subcategories, for warning purposes
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
206 only, and you can use whatever symbols you like.)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
212 :emergency -- a problem that will seriously impair Emacs operation soon
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
213 if you do not attend to it promptly.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
214 :error -- data or circumstances that are inherently wrong.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
215 :warning -- data or circumstances that are not inherently wrong,
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
216 but raise suspicion of a possible problem.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
217 :debug -- info for debugging only.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
222
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
223 See the `warnings' custom group for user customization features.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
224
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
225 See also `warning-series', `warning-prefix-function' and
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
226 `warning-fill-prefix' for additional programming features."
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
227 (unless level
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
231 (if (assq level warning-level-aliases)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
232 (setq level (cdr (assq level warning-level-aliases))))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
239 (level-info (assq level warning-levels))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
240 start end)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
245 (goto-char (point-max))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
246 (when (and warning-series (symbolp warning-series))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
247 (setq warning-series
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
248 (prog1 (point-marker)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
249 (unless (eq warning-series t)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
250 (funcall warning-series)))))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
251 (unless (bolp)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
252 (newline))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
253 (setq start (point))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
254 (if warning-prefix-function
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
255 (setq level-info (funcall warning-prefix-function
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
256 level level-info)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
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
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
259 message)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
260 (newline)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
261 (when (and warning-fill-prefix (not (string-match "\n" message)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
262 (let ((fill-prefix warning-fill-prefix)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
263 (fill-column 78))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
264 (fill-region start (point))))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
265 (setq end (point))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
266 (when (and (markerp warning-series)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
267 (eq (marker-buffer warning-series) buffer))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
268 (goto-char warning-series)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
269 (if (nth 2 level-info)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
270 (funcall (nth 2 level-info)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
271 (if noninteractive
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
272 ;; Noninteractively, take the text we inserted
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
273 ;; in the warnings buffer and print it.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
274 ;; Do this unconditionally, since there is no way
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
275 ;; to view logged messages unless we output them.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
276 (with-current-buffer buffer
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
277 (save-excursion
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
278 ;; Don't include the final newline in the arg
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
279 ;; to `message', because it adds a newline.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
280 (goto-char end)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
281 (if (bolp)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
282 (forward-char -1))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
283 (message "%s" (buffer-substring start (point)))))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
284 ;; Interactively, decide whether the warning merits
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
285 ;; immediate display.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
286 (or (< (warning-numeric-level level)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
287 (warning-numeric-level warning-minimum-level))
52134
d26709514a27 Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents: 51349
diff changeset
288 (warning-suppress-p type warning-suppress-types)
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
289 (let ((window (display-buffer buffer)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
290 (when (and (markerp warning-series)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
291 (eq (marker-buffer warning-series) buffer))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
292 (set-window-start window warning-series))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
293 (sit-for 0)))))))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
294
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
295 ;;;###autoload
52134
d26709514a27 Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents: 51349
diff changeset
296 (defun lwarn (type level message &rest args)
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
297 "Display a warning message made from (format MESSAGE ARGS...).
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
298 Aside from generating the message with `format',
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
299 this is equivalent to `display-warning'.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
300
70324
5a0747ecd057 (display-warning, lwarn): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 68648
diff changeset
301 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
302 or a list of symbols whose first element is a custom group name.
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
303 \(The rest of the symbols represent subcategories and
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
304 can be whatever you like.)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
305
63537
5bcd8e3411e3 (display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 59996
diff changeset
306 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
307 \(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
308
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
309 :emergency -- a problem that will seriously impair Emacs operation soon
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
310 if you do not attend to it promptly.
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
311 :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
312 :warning -- suspicious data or circumstances.
5bcd8e3411e3 (display-warning, lwarn, warning-minimum-log-level): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents: 59996
diff changeset
313 :debug -- info for debugging only."
52134
d26709514a27 Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents: 51349
diff changeset
314 (display-warning type (apply 'format message args) level))
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
315
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
316 ;;;###autoload
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
317 (defun warn (message &rest args)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
318 "Display a warning message made from (format MESSAGE ARGS...).
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
319 Aside from generating the message with `format',
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
320 this is equivalent to `display-warning', using
52134
d26709514a27 Doc fixes, args renamed.
Richard M. Stallman <rms@gnu.org>
parents: 51349
diff changeset
321 `emacs' as the type and `:warning' as the level."
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
322 (display-warning 'emacs (apply 'format message args)))
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
323
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
324 (provide 'warnings)
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
325
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 79704
diff changeset
326 ;; arch-tag: faaad1c8-7b2a-4161-af38-5ab4afde0496
51349
dd8d7c8c6ae8 Moved from lisp/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
327 ;;; warnings.el ends here