38412
|
1 ;;; emacsbug.el --- command to report Emacs bugs to appropriate mailing list
|
662
|
2
|
64754
|
3 ;; Copyright (C) 1985, 1994, 1997, 1998, 2000, 2001, 2002, 2003,
|
75347
|
4 ;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
845
|
5
|
807
|
6 ;; Author: K. Shane Hartman
|
794
|
7 ;; Maintainer: FSF
|
20774
|
8 ;; Keywords: maint mail
|
794
|
9
|
36
|
10 ;; Not fully installed because it can work only on Internet hosts.
|
|
11 ;; This file is part of GNU Emacs.
|
|
12
|
|
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
14 ;; it under the terms of the GNU General Public License as published by
|
78232
|
15 ;; the Free Software Foundation; either version 3, or (at your option)
|
36
|
16 ;; any later version.
|
|
17
|
|
18 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21 ;; GNU General Public License for more details.
|
|
22
|
|
23 ;; You should have received a copy of the GNU General Public License
|
14169
|
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
64085
|
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
26 ;; Boston, MA 02110-1301, USA.
|
36
|
27
|
2307
|
28 ;;; Commentary:
|
|
29
|
46564
293b682578b5
Update copyright notice and fix typo in commentary section.
Markus Rost <rost@math.uni-bielefeld.de>
diff
changeset
|
30 ;; `M-x report-emacs-bug' starts an email note to the Emacs maintainers
|
2307
|
31 ;; describing a problem. Here's how it's done...
|
|
32
|
794
|
33 ;;; Code:
|
36
|
34
|
|
35 ;; >> This should be an address which is accessible to your machine,
|
|
36 ;; >> otherwise you can't use this file. It will only work on the
|
|
37 ;; >> internet with this address.
|
|
38
|
6971
|
39 (require 'sendmail)
|
|
40
|
20774
|
41 (defgroup emacsbug nil
|
|
42 "Sending Emacs bug reports."
|
|
43 :group 'maint
|
|
44 :group 'mail)
|
|
45
|
21360
|
46 (defcustom report-emacs-bug-address "bug-gnu-emacs@gnu.org"
|
20797
|
47 "*Address of mailing list for GNU Emacs bugs."
|
|
48 :group 'emacsbug
|
|
49 :type 'string)
|
14815
4a742f2d5328
(report-emacs-bug): Use a different address for pretest versions.
Richard M. Stallman <rms@gnu.org>
diff
changeset
|
50
|
21360
|
51 (defcustom report-emacs-bug-pretest-address "emacs-pretest-bug@gnu.org"
|
20797
|
52 "*Address of mailing list for GNU Emacs pretest bugs."
|
|
53 :group 'emacsbug
|
|
54 :type 'string)
|
36
|
55
|
8130
|
56 (defvar report-emacs-bug-orig-text nil
|
|
57 "The automatically-created initial text of bug report.")
|
|
58
|
20774
|
59 (defcustom report-emacs-bug-no-confirmation nil
|
|
60 "*If non-nil, suppress the confirmations asked for the sake of novice users."
|
|
61 :group 'emacsbug
|
|
62 :type 'boolean)
|
|
63
|
|
64 (defcustom report-emacs-bug-no-explanations nil
|
|
65 "*If non-nil, suppress the explanations given for the sake of novice users."
|
|
66 :group 'emacsbug
|
|
67 :type 'boolean)
|
18795
|
68
|
|
69 ;;;###autoload
|
16576
|
70 (defun report-emacs-bug (topic &optional recent-keys)
|
474
|
71 "Report a bug in GNU Emacs.
|
36
|
72 Prompts for bug subject. Leaves you in a mail buffer."
|
16576
|
73 ;; This strange form ensures that (recent-keys) is the value before
|
|
74 ;; the bug subject string is read.
|
|
75 (interactive (reverse (list (recent-keys) (read-string "Bug Subject: "))))
|
82382
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
76 ;; The syntax `version;' is preferred to `[version]' because the
|
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
77 ;; latter could be mistakenly stripped by mailing software.
|
82434
e460d01bb038
(report-emacs-bug): Make MS-DOS a special case (there's no build number).
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
78 (if (eq system-type 'ms-dos)
|
e460d01bb038
(report-emacs-bug): Make MS-DOS a special case (there's no build number).
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
79 (setq topic (concat emacs-version "; " topic))
|
e460d01bb038
(report-emacs-bug): Make MS-DOS a special case (there's no build number).
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
80 (when (string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version)
|
e460d01bb038
(report-emacs-bug): Make MS-DOS a special case (there's no build number).
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
81 (setq topic (concat (match-string 1 emacs-version) "; " topic))))
|
e460d01bb038
(report-emacs-bug): Make MS-DOS a special case (there's no build number).
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
82 ;; If there are four numbers in emacs-version (three for MS-DOS),
|
e460d01bb038
(report-emacs-bug): Make MS-DOS a special case (there's no build number).
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
83 ;; this is a pretest version.
|
e460d01bb038
(report-emacs-bug): Make MS-DOS a special case (there's no build number).
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
84 (let* ((pretest-p (string-match (if (eq system-type 'ms-dos)
|
e460d01bb038
(report-emacs-bug): Make MS-DOS a special case (there's no build number).
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
85 "\\..*\\."
|
e460d01bb038
(report-emacs-bug): Make MS-DOS a special case (there's no build number).
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
86 "\\..*\\..*\\.")
|
e460d01bb038
(report-emacs-bug): Make MS-DOS a special case (there's no build number).
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
87 emacs-version))
|
82382
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
88 (from-buffer (current-buffer))
|
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
89 (reporting-address (if pretest-p
|
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
90 report-emacs-bug-pretest-address
|
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
91 report-emacs-bug-address))
|
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
92 ;; Put these properties on semantically-void text.
|
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
93 (prompt-properties '(field emacsbug-prompt
|
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
94 intangible but-helpful
|
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
95 rear-nonsticky t))
|
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
96 user-point message-end-point)
|
20052
|
97 (setq message-end-point
|
39067
|
98 (with-current-buffer (get-buffer-create "*Messages*")
|
20052
|
99 (point-max-marker)))
|
68075
d16e53a3e227
(report-emacs-bug): Let explanations correctly reflect the address to which
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
100 (compose-mail reporting-address
|
20052
|
101 topic)
|
|
102 ;; The rest of this does not execute
|
|
103 ;; if the user was asked to confirm and said no.
|
21869
|
104 (rfc822-goto-eoh)
|
|
105 (forward-line 1)
|
|
106
|
|
107 (let ((signature (buffer-substring (point) (point-max))))
|
|
108 (delete-region (point) (point-max))
|
21974
|
109 (insert signature)
|
|
110 (backward-char (length signature)))
|
20774
|
111 (unless report-emacs-bug-no-explanations
|
|
112 ;; Insert warnings for novice users.
|
68075
d16e53a3e227
(report-emacs-bug): Let explanations correctly reflect the address to which
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
113 (when (string-match "@gnu\\.org^" reporting-address)
|
d16e53a3e227
(report-emacs-bug): Let explanations correctly reflect the address to which
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
114 (insert "This bug report will be sent to the Free Software Foundation,\n")
|
d16e53a3e227
(report-emacs-bug): Let explanations correctly reflect the address to which
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
115 (let ((pos (point)))
|
d16e53a3e227
(report-emacs-bug): Let explanations correctly reflect the address to which
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
116 (insert "not to your local site managers!")
|
d16e53a3e227
(report-emacs-bug): Let explanations correctly reflect the address to which
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
117 (put-text-property pos (point) 'face 'highlight)))
|
82382
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
118 (insert "\nPlease write in ")
|
20774
|
119 (let ((pos (point)))
|
|
120 (insert "English")
|
|
121 (put-text-property pos (point) 'face 'highlight))
|
45273
|
122 (insert " if possible, because the Emacs maintainers
|
|
123 usually do not have translators to read other languages for them.\n\n")
|
35516
|
124 (insert (format "Your bug report will be posted to the %s mailing list"
|
68075
d16e53a3e227
(report-emacs-bug): Let explanations correctly reflect the address to which
Eli Zaretskii <eliz@gnu.org>
diff
changeset
|
125 reporting-address))
|
35516
|
126 (if pretest-p
|
|
127 (insert ".\n\n")
|
|
128 (insert ",\nand to the gnu.emacs.bug news group.\n\n")))
|
18795
|
129
|
45346
|
130 (insert "Please describe exactly what actions triggered the bug\n"
|
68115
|
131 "and the precise symptoms of the bug:\n\n")
|
|
132 (add-text-properties (point) (save-excursion (mail-text) (point))
|
|
133 prompt-properties)
|
45346
|
134
|
|
135 (setq user-point (point))
|
64555
|
136 (insert "\n\n")
|
|
137
|
73738
|
138 (insert "If Emacs crashed, and you have the Emacs process in the gdb debugger,\n"
|
64555
|
139 "please include the output from the following gdb commands:\n"
|
|
140 " `bt full' and `xbacktrace'.\n")
|
45346
|
141
|
64555
|
142 (let ((debug-file (expand-file-name "DEBUG" data-directory)))
|
|
143 (if (file-readable-p debug-file)
|
82382
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
144 (insert "If you would like to further debug the crash, please read the file\n"
|
5d46134ea7dd
(report-emacs-bug): Put `Bug: emacs-version; ' in the mail title.
Michaël Cadilhac <michael.cadilhac@lrde.org>
diff
changeset
|
145 debug-file " for instructions.\n")))
|
68115
|
146 (add-text-properties (1+ user-point) (point) prompt-properties)
|
64555
|
147
|
|
148 (insert "\n\nIn " (emacs-version) "\n")
|
57768
|
149 (if (fboundp 'x-server-vendor)
|
58462
8d3f889b4462
* mail/emacsbug.el (report-emacs-bug): Catch error that x-server-vendor
Jan Djärv <jan.h.d@swipnet.se>
diff
changeset
|
150 (condition-case nil
|
76450
|
151 ;; This is used not only for X11 but also W32 and others.
|
|
152 (insert "Windowing system distributor `" (x-server-vendor)
|
|
153 "', version "
|
58462
8d3f889b4462
* mail/emacsbug.el (report-emacs-bug): Catch error that x-server-vendor
Jan Djärv <jan.h.d@swipnet.se>
diff
changeset
|
154 (mapconcat 'number-to-string (x-server-version) ".") "\n")
|
8d3f889b4462
* mail/emacsbug.el (report-emacs-bug): Catch error that x-server-vendor
Jan Djärv <jan.h.d@swipnet.se>
diff
changeset
|
155 (error t)))
|
20052
|
156 (if (and system-configuration-options
|
|
157 (not (equal system-configuration-options "")))
|
|
158 (insert "configured using `configure "
|
45346
|
159 system-configuration-options "'\n\n"))
|
35427
|
160 (insert "Important settings:\n")
|
37065
|
161 (mapcar
|
|
162 '(lambda (var)
|
|
163 (insert (format " value of $%s: %s\n" var (getenv var))))
|
|
164 '("LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES"
|
|
165 "LC_MONETARY" "LC_NUMERIC" "LC_TIME" "LANG"))
|
35427
|
166 (insert (format " locale-coding-system: %s\n" locale-coding-system))
|
|
167 (insert (format " default-enable-multibyte-characters: %s\n"
|
|
168 default-enable-multibyte-characters))
|
20052
|
169 (insert "\n")
|
52757
|
170 (insert (format "Major mode: %s\n"
|
|
171 (buffer-local-value 'mode-name from-buffer)))
|
52686
|
172 (insert "\n")
|
|
173 (insert "Minor modes in effect:\n")
|
|
174 (dolist (mode minor-mode-list)
|
52757
|
175 (and (boundp mode) (buffer-local-value mode from-buffer)
|
|
176 (insert (format " %s: %s\n" mode
|
|
177 (buffer-local-value mode from-buffer)))))
|
52686
|
178 (insert "\n")
|
45346
|
179 (insert "Recent input:\n")
|
20052
|
180 (let ((before-keys (point)))
|
|
181 (insert (mapconcat (lambda (key)
|
|
182 (if (or (integerp key)
|
|
183 (symbolp key)
|
|
184 (listp key))
|
|
185 (single-key-description key)
|
|
186 (prin1-to-string key nil)))
|
|
187 (or recent-keys (recent-keys))
|
|
188 " "))
|
|
189 (save-restriction
|
|
190 (narrow-to-region before-keys (point))
|
|
191 (goto-char before-keys)
|
|
192 (while (progn (move-to-column 50) (not (eobp)))
|
|
193 (search-forward " " nil t)
|
|
194 (insert "\n"))))
|
|
195 (let ((message-buf (get-buffer "*Messages*")))
|
|
196 (if message-buf
|
|
197 (let (beg-pos
|
|
198 (end-pos message-end-point))
|
|
199 (with-current-buffer message-buf
|
|
200 (goto-char end-pos)
|
|
201 (forward-line -10)
|
|
202 (setq beg-pos (point)))
|
|
203 (insert "\n\nRecent messages:\n")
|
|
204 (insert-buffer-substring message-buf beg-pos end-pos))))
|
|
205 ;; This is so the user has to type something
|
|
206 ;; in order to send easily.
|
|
207 (use-local-map (nconc (make-sparse-keymap) (current-local-map)))
|
|
208 (define-key (current-local-map) "\C-c\C-i" 'report-emacs-bug-info)
|
21975
|
209 (unless report-emacs-bug-no-explanations
|
|
210 (with-output-to-temp-buffer "*Bug Help*"
|
|
211 (if (eq mail-user-agent 'sendmail-user-agent)
|
|
212 (princ (substitute-command-keys
|
|
213 "Type \\[mail-send-and-exit] to send the bug report.\n")))
|
|
214 (princ (substitute-command-keys
|
|
215 "Type \\[kill-buffer] RET to cancel (don't send it).\n"))
|
|
216 (terpri)
|
|
217 (princ (substitute-command-keys
|
|
218 "Type \\[report-emacs-bug-info] to visit in Info the Emacs Manual section
|
12155
|
219 about when and how to write a bug report,
|
|
220 and what information to supply so that the bug can be fixed.
|
21975
|
221 Type SPC to scroll through this section and its subsections."))))
|
20052
|
222 ;; Make it less likely people will send empty messages.
|
|
223 (make-local-variable 'mail-send-hook)
|
|
224 (add-hook 'mail-send-hook 'report-emacs-bug-hook)
|
|
225 (save-excursion
|
|
226 (goto-char (point-max))
|
|
227 (skip-chars-backward " \t\n")
|
|
228 (make-local-variable 'report-emacs-bug-orig-text)
|
|
229 (setq report-emacs-bug-orig-text (buffer-substring (point-min) (point))))
|
|
230 (goto-char user-point)))
|
8130
|
231
|
12155
|
232 (defun report-emacs-bug-info ()
|
|
233 "Go to the Info node on reporting Emacs bugs."
|
|
234 (interactive)
|
|
235 (info)
|
|
236 (Info-directory)
|
|
237 (Info-menu "emacs")
|
|
238 (Info-goto-node "Bugs"))
|
|
239
|
8130
|
240 (defun report-emacs-bug-hook ()
|
|
241 (save-excursion
|
45381
|
242 (save-excursion
|
|
243 (goto-char (point-max))
|
|
244 (skip-chars-backward " \t\n")
|
|
245 (if (and (= (- (point) (point-min))
|
|
246 (length report-emacs-bug-orig-text))
|
|
247 (equal (buffer-substring (point-min) (point))
|
|
248 report-emacs-bug-orig-text))
|
|
249 (error "No text entered in bug report")))
|
18795
|
250
|
|
251 ;; Check the buffer contents and reject non-English letters.
|
21360
|
252 (save-excursion
|
|
253 (goto-char (point-min))
|
|
254 (skip-chars-forward "\0-\177")
|
|
255 (if (not (eobp))
|
20774
|
256 (if (or report-emacs-bug-no-confirmation
|
18826
|
257 (y-or-n-p "Convert non-ASCII letters to hexadecimal? "))
|
21360
|
258 (while (progn (skip-chars-forward "\0-\177")
|
|
259 (not (eobp)))
|
|
260 (let ((ch (following-char)))
|
|
261 (delete-char 1)
|
21498
|
262 (insert (format "=%02x" ch)))))))
|
18795
|
263
|
|
264 ;; The last warning for novice users.
|
20774
|
265 (if (or report-emacs-bug-no-confirmation
|
18795
|
266 (yes-or-no-p
|
18826
|
267 "Send this bug report to the Emacs maintainers? "))
|
18795
|
268 ;; Just send the current mail.
|
|
269 nil
|
|
270 (goto-char (point-min))
|
|
271 (if (search-forward "To: ")
|
|
272 (let ((pos (point)))
|
|
273 (end-of-line)
|
|
274 (delete-region pos (point))))
|
|
275 (kill-local-variable 'mail-send-hook)
|
|
276 (with-output-to-temp-buffer "*Bug Help*"
|
|
277 (princ (substitute-command-keys "\
|
18826
|
278 You invoked the command M-x report-emacs-bug,
|
|
279 but you decided not to mail the bug report to the Emacs maintainers.
|
18795
|
280
|
18826
|
281 If you want to mail it to someone else instead,
|
|
282 please insert the proper e-mail address after \"To: \",
|
|
283 and send the mail again using \\[mail-send-and-exit].")))
|
|
284 (error "M-x report-emacs-bug was cancelled, please read *Bug Help* buffer"))
|
44056
|
285
|
|
286 ;; Unclutter
|
|
287 (mail-text)
|
68115
|
288 (let ((pos (1- (point))))
|
|
289 (while (setq pos (text-property-any pos (point-max)
|
|
290 'field 'emacsbug-prompt))
|
|
291 (delete-region pos (field-end (1+ pos)))))))
|
36
|
292
|
2348
|
293 (provide 'emacsbug)
|
|
294
|
76450
|
295 ;; arch-tag: 248b6523-c3b5-4fec-9a3f-0411fafa7d49
|
662
|
296 ;;; emacsbug.el ends here
|