Mercurial > emacs
comparison lisp/warnings.el @ 46830:fa2c544d95fd
(warning-prefix-function, warning-series)
(warning-fill-prefix, warning-group-format): Add autoload cookies.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 07 Aug 2002 14:26:28 +0000 |
parents | ae636e084c86 |
children | 796b2ef84d40 |
comparison
equal
deleted
inserted
replaced
46829:fb00e3e4754d | 46830:fa2c544d95fd |
---|---|
34 (:error "Error%s: ") | 34 (:error "Error%s: ") |
35 (:warning "Warning%s: ") | 35 (:warning "Warning%s: ") |
36 (:debug "Debug%s: ")) | 36 (:debug "Debug%s: ")) |
37 "List of severity level definitions for `display-warning'. | 37 "List of severity level definitions for `display-warning'. |
38 Each element looks like (LEVEL STRING FUNCTION) and | 38 Each element looks like (LEVEL STRING FUNCTION) and |
39 defines LEVEL as a severity level. STRING is the description | 39 defines LEVEL as a severity level. STRING specifies the |
40 to use in the buffer, and FUNCTION (which may be omitted) | 40 description of this level. STRING should use `%s' to |
41 if non-nil is a function to call with no arguments | 41 specify where to put the warning group information, |
42 to get the user's attention. STRING should use `%s' to | 42 or it can omit the `%s' so as not to include that information. |
43 specify where to put the warning group information. | 43 |
44 | 44 The optional FUNCTION, if non-nil, is a function to call |
45 :debug level is ignored by default (see `warning-minimum-level').") | 45 with no arguments, to get the user's attention. |
46 | |
47 The standard levels are :emergency, :error, :warning and :debug. | |
48 See `display-warning' for documentation of their meanings. | |
49 Level :debug is ignored by default (see `warning-minimum-level').") | |
46 (put 'warning-levels 'risky-local-variable t) | 50 (put 'warning-levels 'risky-local-variable t) |
47 | 51 |
48 ;; These are for compatibility with XEmacs. | 52 ;; These are for compatibility with XEmacs. |
49 ;; I don't think there is any chance of finding meaningful distinctions | 53 ;; I don't think there is any chance of designing meaningful criteria |
50 ;; to distinguish so many levels. | 54 ;; to distinguish so many levels. |
51 (defvar warning-level-aliases | 55 (defvar warning-level-aliases |
52 '((emergency . :emergency) | 56 '((emergency . :emergency) |
53 (error . :error) | 57 (error . :error) |
54 (warning . :warning) | 58 (warning . :warning) |
56 (info . :warning) | 60 (info . :warning) |
57 (critical . :emergency) | 61 (critical . :emergency) |
58 (alarm . :emergency)) | 62 (alarm . :emergency)) |
59 "Alist of aliases for severity levels for `display-warning'. | 63 "Alist of aliases for severity levels for `display-warning'. |
60 Each element looks like (ALIAS . LEVEL) and defines | 64 Each element looks like (ALIAS . LEVEL) and defines |
61 ALIAS as equivalent to LEVEL.") | 65 ALIAS as equivalent to LEVEL. LEVEL must be defined in `warning-levels'; |
62 | 66 it may not itself be an alias.") |
67 | |
63 (defcustom warning-minimum-level :warning | 68 (defcustom warning-minimum-level :warning |
64 "Minimum severity level for displaying the warning buffer. | 69 "Minimum severity level for displaying the warning buffer. |
65 If a warning's severity level is lower than this, | 70 If a warning's severity level is lower than this, |
66 the warning is logged in the warnings buffer, but the buffer | 71 the warning is logged in the warnings buffer, but the buffer |
67 is not immediately displayed. See also `warning-minimum-log-level'." | 72 is not immediately displayed. See also `warning-minimum-log-level'." |
104 so only the element (FOO) will match it. | 109 so only the element (FOO) will match it. |
105 See also `warning-suppress-log-types'." | 110 See also `warning-suppress-log-types'." |
106 :group 'warnings | 111 :group 'warnings |
107 :type '(repeat (repeat symbol)) | 112 :type '(repeat (repeat symbol)) |
108 :version "21.4") | 113 :version "21.4") |
109 | 114 |
115 ;;; The autoload cookie is so that programs can bind this variable | |
116 ;;; safely, testing the existing value, before they call one of the | |
117 ;;; warnings functions. | |
118 ;;;###autoload | |
110 (defvar warning-prefix-function nil | 119 (defvar warning-prefix-function nil |
111 "Function to generate warning prefixes. | 120 "Function to generate warning prefixes. |
112 This function, if non-nil, is called with two arguments, | 121 This function, if non-nil, is called with two arguments, |
113 the severity level and its entry in `warning-levels', | 122 the severity level and its entry in `warning-levels', |
114 and should return the entry that should actually be used. | 123 and should return the entry that should actually be used. |
115 The warnings buffer is current when this function is called | 124 The warnings buffer is current when this function is called |
116 and the function can insert text in it. This text becomes | 125 and the function can insert text in it. This text becomes |
117 the beginning of the warning.") | 126 the beginning of the warning.") |
118 | 127 |
119 (defun warning-numeric-level (level) | 128 ;;; The autoload cookie is so that programs can bind this variable |
120 "Return a numeric measure of the warning severity level LEVEL." | 129 ;;; safely, testing the existing value, before they call one of the |
121 (let* ((elt (assq level warning-levels)) | 130 ;;; warnings functions. |
122 (link (memq elt warning-levels))) | 131 ;;;###autoload |
123 (length link))) | |
124 | |
125 (defvar warning-series nil | 132 (defvar warning-series nil |
126 "Non-nil means treat multiple `display-warning' calls as a series. | 133 "Non-nil means treat multiple `display-warning' calls as a series. |
127 An integer is a position in the warnings buffer | 134 An integer is a position in the warnings buffer |
128 which is the start of the current series. | 135 which is the start of the current series. |
129 t means the next warning begins a series (and stores an integer here). | 136 t means the next warning begins a series (and stores an integer here). |
130 A symbol with a function definition is like t, except | 137 A symbol with a function definition is like t, except |
131 also call that function before the next warning.") | 138 also call that function before the next warning.") |
132 (put 'warning-series 'risky-local-variable t) | 139 (put 'warning-series 'risky-local-variable t) |
133 | 140 |
141 ;;; The autoload cookie is so that programs can bind this variable | |
142 ;;; safely, testing the existing value, before they call one of the | |
143 ;;; warnings functions. | |
144 ;;;###autoload | |
134 (defvar warning-fill-prefix nil | 145 (defvar warning-fill-prefix nil |
135 "Non-nil means fill each warning text using this string as `fill-prefix'.") | 146 "Non-nil means fill each warning text using this string as `fill-prefix'.") |
136 | 147 |
148 ;;; The autoload cookie is so that programs can bind this variable | |
149 ;;; safely, testing the existing value, before they call one of the | |
150 ;;; warnings functions. | |
151 ;;;###autoload | |
137 (defvar warning-group-format " (%s)" | 152 (defvar warning-group-format " (%s)" |
138 "Format for displaying the warning group in the warning message. | 153 "Format for displaying the warning group in the warning message. |
139 The result of formatting the group this way gets included in the | 154 The result of formatting the group this way gets included in the |
140 message under the control of the string in `warning-levels'.") | 155 message under the control of the string in `warning-levels'.") |
156 | |
157 (defun warning-numeric-level (level) | |
158 "Return a numeric measure of the warning severity level LEVEL." | |
159 (let* ((elt (assq level warning-levels)) | |
160 (link (memq elt warning-levels))) | |
161 (length link))) | |
141 | 162 |
142 (defun warning-suppress-p (group suppress-list) | 163 (defun warning-suppress-p (group suppress-list) |
143 "Non-nil if a warning with group GROUP should be suppressed. | 164 "Non-nil if a warning with group GROUP should be suppressed. |
144 SUPPRESS-LIST is the list of kinds of warnings to suppress." | 165 SUPPRESS-LIST is the list of kinds of warnings to suppress." |
145 (let (some-match) | 166 (let (some-match) |
165 (if match | 186 (if match |
166 (setq some-match t))))) | 187 (setq some-match t))))) |
167 ;; If some element of SUPPRESS-LIST matched, | 188 ;; If some element of SUPPRESS-LIST matched, |
168 ;; we return t. | 189 ;; we return t. |
169 some-match)) | 190 some-match)) |
170 | 191 |
171 ;;;###autoload | 192 ;;;###autoload |
172 (defun display-warning (group message &optional level buffer-name) | 193 (defun display-warning (group message &optional level buffer-name) |
173 "Display a warning message, MESSAGE. | 194 "Display a warning message, MESSAGE. |
174 GROUP should be a custom group name (a symbol), | 195 GROUP should be a custom group name (a symbol), |
175 or else a list of symbols whose first element is a custom group name. | 196 or else a list of symbols whose first element is a custom group name. |
242 (warning-suppress-p group warning-suppress-types) | 263 (warning-suppress-p group warning-suppress-types) |
243 (let ((window (display-buffer buffer))) | 264 (let ((window (display-buffer buffer))) |
244 (when warning-series | 265 (when warning-series |
245 (set-window-start window warning-series)) | 266 (set-window-start window warning-series)) |
246 (sit-for 0))))))) | 267 (sit-for 0))))))) |
247 | 268 |
248 ;;;###autoload | 269 ;;;###autoload |
249 (defun lwarn (group level message &rest args) | 270 (defun lwarn (group level message &rest args) |
250 "Display a warning message made from (format MESSAGE ARGS...). | 271 "Display a warning message made from (format MESSAGE ARGS...). |
251 Aside from generating the message with `format', | 272 Aside from generating the message with `format', |
252 this is equivalent to `display-warning'. | 273 this is equivalent to `display-warning'. |