annotate lisp/warnings.el @ 47280:7e81df5e2e1a

(syms_of_w32select): Fix spacing.
author Juanma Barranquero <lekktu@gmail.com>
date Fri, 06 Sep 2002 09:04:56 +0000
parents b4cd4023d957
children 0d4291124ff0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; warnings.el --- log and display warnings
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 2002 Free Software Foundation, Inc.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Maintainer: FSF
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Keywords: internal
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; This file implements the entry points `warn', `lwarn'
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; and `display-warnings'.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;;; Code:
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 (defvar warning-levels
46656
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
33 '((:emergency "Emergency%s: " ding)
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
34 (:error "Error%s: ")
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
35 (:warning "Warning%s: ")
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
36 (:debug "Debug%s: "))
46698
ae636e084c86 (warning-levels): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 46696
diff changeset
37 "List of severity level definitions for `display-warning'.
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 Each element looks like (LEVEL STRING FUNCTION) and
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
39 defines LEVEL as a severity level. STRING specifies the
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
40 description of this level. STRING should use `%s' to
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
41 specify where to put the warning group information,
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
42 or it can omit the `%s' so as not to include that information.
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
44 The optional FUNCTION, if non-nil, is a function to call
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
45 with no arguments, to get the user's attention.
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
46
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
47 The standard levels are :emergency, :error, :warning and :debug.
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
48 See `display-warning' for documentation of their meanings.
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
49 Level :debug is ignored by default (see `warning-minimum-level').")
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 (put 'warning-levels 'risky-local-variable t)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;; These are for compatibility with XEmacs.
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
53 ;; I don't think there is any chance of designing meaningful criteria
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; to distinguish so many levels.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 (defvar warning-level-aliases
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 '((emergency . :emergency)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (error . :error)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (warning . :warning)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (notice . :warning)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (info . :warning)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (critical . :emergency)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 (alarm . :emergency))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 "Alist of aliases for severity levels for `display-warning'.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 Each element looks like (ALIAS . LEVEL) and defines
47271
b4cd4023d957 (warning-level-aliases): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents: 47109
diff changeset
65 ALIAS as equivalent to LEVEL. LEVEL must be defined in `warning-levels';
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
66 it may not itself be an alias.")
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
67
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 (defcustom warning-minimum-level :warning
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 "Minimum severity level for displaying the warning buffer.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 If a warning's severity level is lower than this,
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 the warning is logged in the warnings buffer, but the buffer
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 is not immediately displayed. See also `warning-minimum-log-level'."
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 :group 'warnings
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 :type '(choice (const :emergency) (const :error) (const :warning))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 :version "21.4")
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (defvaralias 'display-warning-minimum-level 'warning-minimum-level)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (defcustom warning-minimum-log-level :warning
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 "Minimum severity level for logging a warning.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 If a warning severity level is lower than this,
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 the warning is completely ignored."
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 :group 'warnings
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 :type '(choice (const :emergency) (const :error) (const :warning))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 :version "21.4")
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (defvaralias 'log-warning-minimum-level 'warning-minimum-log-level)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
46656
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
87 (defcustom warning-suppress-log-types nil
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 "List of warning types that should not be logged.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 If any element of this list matches the GROUP argument to `display-warning',
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 the warning is completely ignored.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 The element must match the first elements of GROUP.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 Thus, (foo bar) as an element matches (foo bar)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 or (foo bar ANYTHING...) as GROUP.
46698
ae636e084c86 (warning-levels): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 46696
diff changeset
94 If GROUP is a symbol FOO, that is equivalent to the list (FOO),
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 so only the element (FOO) will match it."
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 :group 'warnings
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 :type '(repeat (repeat symbol))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 :version "21.4")
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99
46656
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
100 (defcustom warning-suppress-types nil
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 "Custom groups for warnings not to display immediately.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 If any element of this list matches the GROUP argument to `display-warning',
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 the warning is logged nonetheless, but the warnings buffer is
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 not immediately displayed.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 The element must match an initial segment of the list GROUP.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 Thus, (foo bar) as an element matches (foo bar)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 or (foo bar ANYTHING...) as GROUP.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 If GROUP is a symbol FOO, that is equivalent to the list (FOO),
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 so only the element (FOO) will match it.
46656
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
110 See also `warning-suppress-log-types'."
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 :group 'warnings
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 :type '(repeat (repeat symbol))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 :version "21.4")
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
114
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
115 ;;; The autoload cookie is so that programs can bind this variable
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
116 ;;; safely, testing the existing value, before they call one of the
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
117 ;;; warnings functions.
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
118 ;;;###autoload
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (defvar warning-prefix-function nil
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 "Function to generate warning prefixes.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 This function, if non-nil, is called with two arguments,
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 the severity level and its entry in `warning-levels',
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 and should return the entry that should actually be used.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 The warnings buffer is current when this function is called
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 and the function can insert text in it. This text becomes
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 the beginning of the warning.")
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
128 ;;; The autoload cookie is so that programs can bind this variable
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
129 ;;; safely, testing the existing value, before they call one of the
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
130 ;;; warnings functions.
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
131 ;;;###autoload
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (defvar warning-series nil
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 "Non-nil means treat multiple `display-warning' calls as a series.
47109
796b2ef84d40 (warning-series): Now can be a marker, not an integer.
Richard M. Stallman <rms@gnu.org>
parents: 46830
diff changeset
134 A marker indicates a position in the warnings buffer
796b2ef84d40 (warning-series): Now can be a marker, not an integer.
Richard M. Stallman <rms@gnu.org>
parents: 46830
diff changeset
135 which is the start of the current series; it means that
796b2ef84d40 (warning-series): Now can be a marker, not an integer.
Richard M. Stallman <rms@gnu.org>
parents: 46830
diff changeset
136 additional warnings in the same buffer should not move point.
796b2ef84d40 (warning-series): Now can be a marker, not an integer.
Richard M. Stallman <rms@gnu.org>
parents: 46830
diff changeset
137 t means the next warning begins a series (and stores a marker here).
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 A symbol with a function definition is like t, except
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 also call that function before the next warning.")
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 (put 'warning-series 'risky-local-variable t)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
142 ;;; The autoload cookie is so that programs can bind this variable
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
143 ;;; safely, testing the existing value, before they call one of the
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
144 ;;; warnings functions.
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
145 ;;;###autoload
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (defvar warning-fill-prefix nil
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 "Non-nil means fill each warning text using this string as `fill-prefix'.")
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
149 ;;; The autoload cookie is so that programs can bind this variable
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
150 ;;; safely, testing the existing value, before they call one of the
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
151 ;;; warnings functions.
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
152 ;;;###autoload
46656
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
153 (defvar warning-group-format " (%s)"
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
154 "Format for displaying the warning group in the warning message.
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
155 The result of formatting the group this way gets included in the
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
156 message under the control of the string in `warning-levels'.")
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
157
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
158 (defun warning-numeric-level (level)
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
159 "Return a numeric measure of the warning severity level LEVEL."
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
160 (let* ((elt (assq level warning-levels))
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
161 (link (memq elt warning-levels)))
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
162 (length link)))
46656
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
163
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164 (defun warning-suppress-p (group suppress-list)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 "Non-nil if a warning with group GROUP should be suppressed.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
166 SUPPRESS-LIST is the list of kinds of warnings to suppress."
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
167 (let (some-match)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (dolist (elt suppress-list)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
169 (if (symbolp group)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
170 ;; If GROUP is a symbol, the ELT must be (GROUP).
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
171 (if (and (consp elt)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (eq (car elt) group)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (null (cdr elt)))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 (setq some-match t))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 ;; If GROUP is a list, ELT must match it or some initial segment of it.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 (let ((tem1 group)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 (tem2 elt)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
178 (match t))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
179 ;; Check elements of ELT until we run out of them.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
180 (while tem2
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
181 (if (not (equal (car tem1) (car tem2)))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
182 (setq match nil))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
183 (setq tem1 (cdr tem1)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
184 tem2 (cdr tem2)))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 ;; If ELT is an initial segment of GROUP, MATCH is t now.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 ;; So set SOME-MATCH.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 (if match
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
188 (setq some-match t)))))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 ;; If some element of SUPPRESS-LIST matched,
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 ;; we return t.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 some-match))
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
192
46579
e07579b3efcc (display-warning, warn, lwarn): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 46575
diff changeset
193 ;;;###autoload
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (defun display-warning (group message &optional level buffer-name)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 "Display a warning message, MESSAGE.
46698
ae636e084c86 (warning-levels): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 46696
diff changeset
196 GROUP should be a custom group name (a symbol),
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 or else a list of symbols whose first element is a custom group name.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 \(The rest of the symbols represent subcategories, for warning purposes
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 only, and you can use whatever symbols you like.)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 LEVEL should be either :warning, :error, or :emergency.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 :emergency -- a problem that will seriously impair Emacs operation soon
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 if you do not attend to it promptly.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 :error -- data or circumstances that are inherently wrong.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
205 :warning -- data or circumstances that are not inherently wrong,
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 but raise suspicion of a possible problem.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 :debug -- info for debugging only.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 BUFFER-NAME, if specified, is the name of the buffer for logging the
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 warning. By default, it is `*Warnings*'.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 See the `warnings' custom group for user customization features.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 See also `warning-series', `warning-prefix-function' and
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 `warning-fill-prefix' for additional programming features."
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 (unless level
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (setq level :warning))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 (if (assq level warning-level-aliases)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219 (setq level (cdr (assq level warning-level-aliases))))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (or (< (warning-numeric-level level)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (warning-numeric-level warning-minimum-log-level))
46656
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
222 (warning-suppress-p group warning-suppress-log-types)
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (let* ((groupname (if (consp group) (car group) group))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 (buffer (get-buffer-create (or buffer-name "*Warnings*")))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225 (level-info (assq level warning-levels))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
226 start end)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (with-current-buffer buffer
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228 (goto-char (point-max))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
229 (when (and warning-series (symbolp warning-series))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (setq warning-series
47109
796b2ef84d40 (warning-series): Now can be a marker, not an integer.
Richard M. Stallman <rms@gnu.org>
parents: 46830
diff changeset
231 (prog1 (point-marker)
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
232 (unless (eq warning-series t)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (funcall warning-series)))))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (unless (bolp)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
235 (newline))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (setq start (point))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (if warning-prefix-function
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (setq level-info (funcall warning-prefix-function
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 level level-info)))
46698
ae636e084c86 (warning-levels): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 46696
diff changeset
240 (insert (format (nth 1 level-info)
ae636e084c86 (warning-levels): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 46696
diff changeset
241 (format warning-group-format groupname))
46656
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
242 message)
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (newline)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (when (and warning-fill-prefix (not (string-match "\n" message)))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 (let ((fill-prefix warning-fill-prefix)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (fill-column 78))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (fill-region start (point))))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 (setq end (point))
47109
796b2ef84d40 (warning-series): Now can be a marker, not an integer.
Richard M. Stallman <rms@gnu.org>
parents: 46830
diff changeset
249 (when (and (markerp warning-series)
796b2ef84d40 (warning-series): Now can be a marker, not an integer.
Richard M. Stallman <rms@gnu.org>
parents: 46830
diff changeset
250 (eq (marker-buffer warning-series) buffer))
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (goto-char warning-series)))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (if (nth 2 level-info)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (funcall (nth 2 level-info)))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 (if noninteractive
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 ;; Noninteractively, take the text we inserted
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 ;; in the warnings buffer and print it.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 ;; Do this unconditionally, since there is no way
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 ;; to view logged messages unless we output them.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (with-current-buffer buffer
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 (message "%s" (buffer-substring start end)))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 ;; Interactively, decide whether the warning merits
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 ;; immediate display.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (or (< (warning-numeric-level level)
46698
ae636e084c86 (warning-levels): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 46696
diff changeset
264 (warning-numeric-level warning-minimum-level))
46656
ac53ae45c502 (warning-levels): Add %s to the strings.
Richard M. Stallman <rms@gnu.org>
parents: 46646
diff changeset
265 (warning-suppress-p group warning-suppress-types)
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 (let ((window (display-buffer buffer)))
47109
796b2ef84d40 (warning-series): Now can be a marker, not an integer.
Richard M. Stallman <rms@gnu.org>
parents: 46830
diff changeset
267 (when (and (markerp warning-series)
796b2ef84d40 (warning-series): Now can be a marker, not an integer.
Richard M. Stallman <rms@gnu.org>
parents: 46830
diff changeset
268 (eq (marker-buffer warning-series) buffer))
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (set-window-start window warning-series))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270 (sit-for 0)))))))
46830
fa2c544d95fd (warning-prefix-function, warning-series)
Richard M. Stallman <rms@gnu.org>
parents: 46698
diff changeset
271
46579
e07579b3efcc (display-warning, warn, lwarn): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 46575
diff changeset
272 ;;;###autoload
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 (defun lwarn (group level message &rest args)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 "Display a warning message made from (format MESSAGE ARGS...).
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 Aside from generating the message with `format',
46696
6caa78f4752d (lwarn, warn): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 46656
diff changeset
276 this is equivalent to `display-warning'.
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 GROUP should be a custom group name (a symbol).
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 or else a list of symbols whose first element is a custom group name.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 \(The rest of the symbols represent subcategories and
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281 can be whatever you like.)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 LEVEL should be either :warning, :error, or :emergency.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
284 :emergency -- a problem that will seriously impair Emacs operation soon
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 if you do not attend to it promptly.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 :error -- invalid data or circumstances.
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 :warning -- suspicious data or circumstances."
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (display-warning group (apply 'format message args) level))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289
46579
e07579b3efcc (display-warning, warn, lwarn): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 46575
diff changeset
290 ;;;###autoload
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (defun warn (message &rest args)
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 "Display a warning message made from (format MESSAGE ARGS...).
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 Aside from generating the message with `format',
46696
6caa78f4752d (lwarn, warn): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents: 46656
diff changeset
294 this is equivalent to `display-warning', using
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 `emacs' as the group and `:warning' as the level."
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (display-warning 'emacs (apply 'format message args)))
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297
46646
ba559abe46e6 Add `provide' call.
Richard M. Stallman <rms@gnu.org>
parents: 46579
diff changeset
298 (provide 'warnings)
ba559abe46e6 Add `provide' call.
Richard M. Stallman <rms@gnu.org>
parents: 46579
diff changeset
299
46575
30fda32839de New file.
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 ;;; warnings.el ends here