Commit | Line | Data |
---|---|---|
55535639 | 1 | ;;; emacsbug.el --- command to report Emacs bugs to appropriate mailing list |
c0274f38 | 2 | |
e84b4b86 | 3 | ;; Copyright (C) 1985, 1994, 1997, 1998, 2000, 2001, 2002, 2003, |
48d33090 | 4 | ;; 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
9750e079 | 5 | |
e5167999 | 6 | ;; Author: K. Shane Hartman |
2f14b48d | 7 | ;; Maintainer: FSF |
fbd410d6 | 8 | ;; Keywords: maint mail |
2f14b48d | 9 | |
a2535589 | 10 | ;; Not fully installed because it can work only on Internet hosts. |
a2535589 JA |
11 | ;; This file is part of GNU Emacs. |
12 | ||
b1fc2b50 | 13 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
a2535589 | 14 | ;; it under the terms of the GNU General Public License as published by |
b1fc2b50 GM |
15 | ;; the Free Software Foundation, either version 3 of the License, or |
16 | ;; (at your option) any later version. | |
a2535589 JA |
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 | |
b1fc2b50 | 24 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
a2535589 | 25 | |
e41b2db1 ER |
26 | ;;; Commentary: |
27 | ||
b92a07e0 | 28 | ;; `M-x report-emacs-bug' starts an email note to the Emacs maintainers |
4d8da9a4 GM |
29 | ;; describing a problem. You need to be able to send mail from Emacs |
30 | ;; to complete the process. Alternatively, compose the bug report in | |
31 | ;; Emacs then paste it into your normal mail client. | |
e41b2db1 | 32 | |
2f14b48d | 33 | ;;; Code: |
a2535589 | 34 | |
f9f9cd92 KH |
35 | (require 'sendmail) |
36 | ||
fbd410d6 RS |
37 | (defgroup emacsbug nil |
38 | "Sending Emacs bug reports." | |
39 | :group 'maint | |
40 | :group 'mail) | |
41 | ||
9b4e41ac | 42 | (defcustom report-emacs-bug-address "bug-gnu-emacs@gnu.org" |
4d8da9a4 | 43 | "Address of mailing list for GNU Emacs bugs." |
7b27eb53 RS |
44 | :group 'emacsbug |
45 | :type 'string) | |
a85a468e | 46 | |
9b4e41ac | 47 | (defcustom report-emacs-bug-pretest-address "emacs-pretest-bug@gnu.org" |
4d8da9a4 | 48 | "Address of mailing list for GNU Emacs pretest bugs." |
7b27eb53 RS |
49 | :group 'emacsbug |
50 | :type 'string) | |
a2535589 | 51 | |
fbd410d6 | 52 | (defcustom report-emacs-bug-no-confirmation nil |
4d8da9a4 | 53 | "If non-nil, suppress the confirmations asked for the sake of novice users." |
fbd410d6 RS |
54 | :group 'emacsbug |
55 | :type 'boolean) | |
56 | ||
57 | (defcustom report-emacs-bug-no-explanations nil | |
4d8da9a4 | 58 | "If non-nil, suppress the explanations given for the sake of novice users." |
fbd410d6 RS |
59 | :group 'emacsbug |
60 | :type 'boolean) | |
fe1d8b33 | 61 | |
4d8da9a4 GM |
62 | ;; User options end here. |
63 | ||
64 | ||
65 | (defvar report-emacs-bug-orig-text nil | |
66 | "The automatically-created initial text of bug report.") | |
67 | ||
aa360da1 GM |
68 | (declare-function x-server-vendor "xfns.c" (&optional terminal)) |
69 | (declare-function x-server-version "xfns.c" (&optional terminal)) | |
70 | ||
aa228418 | 71 | ;;;###autoload |
01753e63 | 72 | (defun report-emacs-bug (topic &optional recent-keys) |
aa228418 | 73 | "Report a bug in GNU Emacs. |
a2535589 | 74 | Prompts for bug subject. Leaves you in a mail buffer." |
01753e63 EN |
75 | ;; This strange form ensures that (recent-keys) is the value before |
76 | ;; the bug subject string is read. | |
77 | (interactive (reverse (list (recent-keys) (read-string "Bug Subject: ")))) | |
a722966c MC |
78 | ;; The syntax `version;' is preferred to `[version]' because the |
79 | ;; latter could be mistakenly stripped by mailing software. | |
ef77dde4 MC |
80 | (if (eq system-type 'ms-dos) |
81 | (setq topic (concat emacs-version "; " topic)) | |
82 | (when (string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version) | |
83 | (setq topic (concat (match-string 1 emacs-version) "; " topic)))) | |
84 | ;; If there are four numbers in emacs-version (three for MS-DOS), | |
85 | ;; this is a pretest version. | |
86 | (let* ((pretest-p (string-match (if (eq system-type 'ms-dos) | |
87 | "\\..*\\." | |
88 | "\\..*\\..*\\.") | |
89 | emacs-version)) | |
a722966c MC |
90 | (from-buffer (current-buffer)) |
91 | (reporting-address (if pretest-p | |
92 | report-emacs-bug-pretest-address | |
93 | report-emacs-bug-address)) | |
94 | ;; Put these properties on semantically-void text. | |
95 | (prompt-properties '(field emacsbug-prompt | |
96 | intangible but-helpful | |
97 | rear-nonsticky t)) | |
98 | user-point message-end-point) | |
0a18209b | 99 | (setq message-end-point |
5e11c425 | 100 | (with-current-buffer (get-buffer-create "*Messages*") |
0a18209b | 101 | (point-max-marker))) |
53dab082 | 102 | (compose-mail reporting-address |
0a18209b KH |
103 | topic) |
104 | ;; The rest of this does not execute | |
105 | ;; if the user was asked to confirm and said no. | |
9e68869b RS |
106 | (rfc822-goto-eoh) |
107 | (forward-line 1) | |
108 | ||
109 | (let ((signature (buffer-substring (point) (point-max)))) | |
9e68869b | 110 | (delete-region (point) (point-max)) |
518adca2 RS |
111 | (insert signature) |
112 | (backward-char (length signature))) | |
fbd410d6 RS |
113 | (unless report-emacs-bug-no-explanations |
114 | ;; Insert warnings for novice users. | |
53dab082 EZ |
115 | (when (string-match "@gnu\\.org^" reporting-address) |
116 | (insert "This bug report will be sent to the Free Software Foundation,\n") | |
117 | (let ((pos (point))) | |
118 | (insert "not to your local site managers!") | |
119 | (put-text-property pos (point) 'face 'highlight))) | |
a722966c | 120 | (insert "\nPlease write in ") |
fbd410d6 RS |
121 | (let ((pos (point))) |
122 | (insert "English") | |
123 | (put-text-property pos (point) 'face 'highlight)) | |
9210027b RS |
124 | (insert " if possible, because the Emacs maintainers |
125 | usually do not have translators to read other languages for them.\n\n") | |
8ab5d35a | 126 | (insert (format "Your bug report will be posted to the %s mailing list" |
53dab082 | 127 | reporting-address)) |
8ab5d35a EZ |
128 | (if pretest-p |
129 | (insert ".\n\n") | |
130 | (insert ",\nand to the gnu.emacs.bug news group.\n\n"))) | |
fe1d8b33 | 131 | |
515ced27 | 132 | (insert "Please describe exactly what actions triggered the bug\n" |
9888f112 TTN |
133 | "and the precise symptoms of the bug:\n\n") |
134 | (add-text-properties (point) (save-excursion (mail-text) (point)) | |
135 | prompt-properties) | |
515ced27 | 136 | |
515ced27 | 137 | (setq user-point (point)) |
3a7f4c18 KS |
138 | (insert "\n\n") |
139 | ||
fca615d5 | 140 | (insert "If Emacs crashed, and you have the Emacs process in the gdb debugger,\n" |
3a7f4c18 KS |
141 | "please include the output from the following gdb commands:\n" |
142 | " `bt full' and `xbacktrace'.\n") | |
143 | ||
144 | (let ((debug-file (expand-file-name "DEBUG" data-directory))) | |
145 | (if (file-readable-p debug-file) | |
a722966c MC |
146 | (insert "If you would like to further debug the crash, please read the file\n" |
147 | debug-file " for instructions.\n"))) | |
9888f112 | 148 | (add-text-properties (1+ user-point) (point) prompt-properties) |
515ced27 | 149 | |
3a7f4c18 | 150 | (insert "\n\nIn " (emacs-version) "\n") |
f4982064 | 151 | (if (fboundp 'x-server-vendor) |
6f8a2742 | 152 | (condition-case nil |
951c155f SM |
153 | ;; This is used not only for X11 but also W32 and others. |
154 | (insert "Windowing system distributor `" (x-server-vendor) | |
155 | "', version " | |
6f8a2742 JD |
156 | (mapconcat 'number-to-string (x-server-version) ".") "\n") |
157 | (error t))) | |
0a18209b KH |
158 | (if (and system-configuration-options |
159 | (not (equal system-configuration-options ""))) | |
160 | (insert "configured using `configure " | |
515ced27 | 161 | system-configuration-options "'\n\n")) |
dc81f8a2 | 162 | (insert "Important settings:\n") |
1daad47d | 163 | (mapc |
249dd409 EZ |
164 | '(lambda (var) |
165 | (insert (format " value of $%s: %s\n" var (getenv var)))) | |
166 | '("LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES" | |
5dae4230 | 167 | "LC_MONETARY" "LC_NUMERIC" "LC_TIME" "LANG" "XMODIFIERS")) |
dc81f8a2 EZ |
168 | (insert (format " locale-coding-system: %s\n" locale-coding-system)) |
169 | (insert (format " default-enable-multibyte-characters: %s\n" | |
170 | default-enable-multibyte-characters)) | |
0a18209b | 171 | (insert "\n") |
3c3ba27b | 172 | (insert (format "Major mode: %s\n" |
48d33090 SM |
173 | (format-mode-line |
174 | (buffer-local-value 'mode-name from-buffer) | |
175 | nil nil from-buffer))) | |
e927088b RS |
176 | (insert "\n") |
177 | (insert "Minor modes in effect:\n") | |
178 | (dolist (mode minor-mode-list) | |
3c3ba27b RS |
179 | (and (boundp mode) (buffer-local-value mode from-buffer) |
180 | (insert (format " %s: %s\n" mode | |
181 | (buffer-local-value mode from-buffer))))) | |
e927088b | 182 | (insert "\n") |
515ced27 | 183 | (insert "Recent input:\n") |
0a18209b KH |
184 | (let ((before-keys (point))) |
185 | (insert (mapconcat (lambda (key) | |
186 | (if (or (integerp key) | |
187 | (symbolp key) | |
188 | (listp key)) | |
189 | (single-key-description key) | |
190 | (prin1-to-string key nil))) | |
191 | (or recent-keys (recent-keys)) | |
192 | " ")) | |
193 | (save-restriction | |
194 | (narrow-to-region before-keys (point)) | |
195 | (goto-char before-keys) | |
196 | (while (progn (move-to-column 50) (not (eobp))) | |
197 | (search-forward " " nil t) | |
198 | (insert "\n")))) | |
199 | (let ((message-buf (get-buffer "*Messages*"))) | |
200 | (if message-buf | |
201 | (let (beg-pos | |
202 | (end-pos message-end-point)) | |
203 | (with-current-buffer message-buf | |
204 | (goto-char end-pos) | |
205 | (forward-line -10) | |
206 | (setq beg-pos (point))) | |
207 | (insert "\n\nRecent messages:\n") | |
208 | (insert-buffer-substring message-buf beg-pos end-pos)))) | |
209 | ;; This is so the user has to type something | |
210 | ;; in order to send easily. | |
211 | (use-local-map (nconc (make-sparse-keymap) (current-local-map))) | |
212 | (define-key (current-local-map) "\C-c\C-i" 'report-emacs-bug-info) | |
e9227982 RS |
213 | (unless report-emacs-bug-no-explanations |
214 | (with-output-to-temp-buffer "*Bug Help*" | |
215 | (if (eq mail-user-agent 'sendmail-user-agent) | |
216 | (princ (substitute-command-keys | |
217 | "Type \\[mail-send-and-exit] to send the bug report.\n"))) | |
218 | (princ (substitute-command-keys | |
219 | "Type \\[kill-buffer] RET to cancel (don't send it).\n")) | |
220 | (terpri) | |
221 | (princ (substitute-command-keys | |
222 | "Type \\[report-emacs-bug-info] to visit in Info the Emacs Manual section | |
1628adc6 KH |
223 | about when and how to write a bug report, |
224 | and what information to supply so that the bug can be fixed. | |
e9227982 | 225 | Type SPC to scroll through this section and its subsections.")))) |
0a18209b KH |
226 | ;; Make it less likely people will send empty messages. |
227 | (make-local-variable 'mail-send-hook) | |
228 | (add-hook 'mail-send-hook 'report-emacs-bug-hook) | |
0a18209b KH |
229 | (save-excursion |
230 | (goto-char (point-max)) | |
231 | (skip-chars-backward " \t\n") | |
232 | (make-local-variable 'report-emacs-bug-orig-text) | |
233 | (setq report-emacs-bug-orig-text (buffer-substring (point-min) (point)))) | |
234 | (goto-char user-point))) | |
e24ec555 | 235 | |
1628adc6 KH |
236 | (defun report-emacs-bug-info () |
237 | "Go to the Info node on reporting Emacs bugs." | |
238 | (interactive) | |
4d8da9a4 | 239 | (info "(emacs)Bugs")) |
1628adc6 | 240 | |
e24ec555 RS |
241 | (defun report-emacs-bug-hook () |
242 | (save-excursion | |
c7127655 MR |
243 | (save-excursion |
244 | (goto-char (point-max)) | |
245 | (skip-chars-backward " \t\n") | |
246 | (if (and (= (- (point) (point-min)) | |
247 | (length report-emacs-bug-orig-text)) | |
248 | (equal (buffer-substring (point-min) (point)) | |
249 | report-emacs-bug-orig-text)) | |
250 | (error "No text entered in bug report"))) | |
fe1d8b33 KH |
251 | |
252 | ;; Check the buffer contents and reject non-English letters. | |
9b4e41ac RS |
253 | (save-excursion |
254 | (goto-char (point-min)) | |
255 | (skip-chars-forward "\0-\177") | |
256 | (if (not (eobp)) | |
fbd410d6 | 257 | (if (or report-emacs-bug-no-confirmation |
02f6b354 | 258 | (y-or-n-p "Convert non-ASCII letters to hexadecimal? ")) |
9b4e41ac RS |
259 | (while (progn (skip-chars-forward "\0-\177") |
260 | (not (eobp))) | |
261 | (let ((ch (following-char))) | |
262 | (delete-char 1) | |
22ad9937 | 263 | (insert (format "=%02x" ch))))))) |
fe1d8b33 KH |
264 | |
265 | ;; The last warning for novice users. | |
fbd410d6 | 266 | (if (or report-emacs-bug-no-confirmation |
fe1d8b33 | 267 | (yes-or-no-p |
02f6b354 | 268 | "Send this bug report to the Emacs maintainers? ")) |
fe1d8b33 KH |
269 | ;; Just send the current mail. |
270 | nil | |
271 | (goto-char (point-min)) | |
272 | (if (search-forward "To: ") | |
273 | (let ((pos (point))) | |
274 | (end-of-line) | |
275 | (delete-region pos (point)))) | |
276 | (kill-local-variable 'mail-send-hook) | |
277 | (with-output-to-temp-buffer "*Bug Help*" | |
278 | (princ (substitute-command-keys "\ | |
02f6b354 RS |
279 | You invoked the command M-x report-emacs-bug, |
280 | but you decided not to mail the bug report to the Emacs maintainers. | |
fe1d8b33 | 281 | |
02f6b354 RS |
282 | If you want to mail it to someone else instead, |
283 | please insert the proper e-mail address after \"To: \", | |
284 | and send the mail again using \\[mail-send-and-exit]."))) | |
285 | (error "M-x report-emacs-bug was cancelled, please read *Bug Help* buffer")) | |
ea33ba73 TTN |
286 | |
287 | ;; Unclutter | |
288 | (mail-text) | |
9888f112 TTN |
289 | (let ((pos (1- (point)))) |
290 | (while (setq pos (text-property-any pos (point-max) | |
291 | 'field 'emacsbug-prompt)) | |
292 | (delete-region pos (field-end (1+ pos))))))) | |
a2535589 | 293 | |
8e0ff8c8 ER |
294 | (provide 'emacsbug) |
295 | ||
951c155f | 296 | ;; arch-tag: 248b6523-c3b5-4fec-9a3f-0411fafa7d49 |
c0274f38 | 297 | ;;; emacsbug.el ends here |