Commit | Line | Data |
---|---|---|
55535639 | 1 | ;;; emacsbug.el --- command to report Emacs bugs to appropriate mailing list |
c0274f38 | 2 | |
b92a07e0 MR |
3 | ;; Copyright (C) 1985, 1994, 1997, 1998, 2000, 2001, 2002 |
4 | ;; 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 | ||
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 | |
e5167999 | 15 | ;; the Free Software Foundation; either version 2, or (at your option) |
a2535589 JA |
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 | |
b578f267 EN |
24 | ;; along with GNU Emacs; see the file COPYING. If not, write to the |
25 | ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
26 | ;; Boston, MA 02111-1307, USA. | |
a2535589 | 27 | |
e41b2db1 ER |
28 | ;;; Commentary: |
29 | ||
b92a07e0 | 30 | ;; `M-x report-emacs-bug' starts an email note to the Emacs maintainers |
e41b2db1 ER |
31 | ;; describing a problem. Here's how it's done... |
32 | ||
2f14b48d | 33 | ;;; Code: |
a2535589 JA |
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 | ||
f9f9cd92 KH |
39 | (require 'sendmail) |
40 | ||
fbd410d6 RS |
41 | (defgroup emacsbug nil |
42 | "Sending Emacs bug reports." | |
43 | :group 'maint | |
44 | :group 'mail) | |
45 | ||
9b4e41ac | 46 | (defcustom report-emacs-bug-address "bug-gnu-emacs@gnu.org" |
7b27eb53 RS |
47 | "*Address of mailing list for GNU Emacs bugs." |
48 | :group 'emacsbug | |
49 | :type 'string) | |
a85a468e | 50 | |
9b4e41ac | 51 | (defcustom report-emacs-bug-pretest-address "emacs-pretest-bug@gnu.org" |
7b27eb53 RS |
52 | "*Address of mailing list for GNU Emacs pretest bugs." |
53 | :group 'emacsbug | |
54 | :type 'string) | |
a2535589 | 55 | |
e24ec555 RS |
56 | (defvar report-emacs-bug-orig-text nil |
57 | "The automatically-created initial text of bug report.") | |
58 | ||
515ced27 MR |
59 | (defvar report-emacs-bug-text-prompt nil |
60 | "The automatically-created initial prompt of bug report.") | |
61 | ||
fbd410d6 RS |
62 | (defcustom report-emacs-bug-no-confirmation nil |
63 | "*If non-nil, suppress the confirmations asked for the sake of novice users." | |
64 | :group 'emacsbug | |
65 | :type 'boolean) | |
66 | ||
67 | (defcustom report-emacs-bug-no-explanations nil | |
68 | "*If non-nil, suppress the explanations given for the sake of novice users." | |
69 | :group 'emacsbug | |
70 | :type 'boolean) | |
fe1d8b33 | 71 | |
aa228418 | 72 | ;;;###autoload |
01753e63 | 73 | (defun report-emacs-bug (topic &optional recent-keys) |
aa228418 | 74 | "Report a bug in GNU Emacs. |
a2535589 | 75 | Prompts for bug subject. Leaves you in a mail buffer." |
01753e63 EN |
76 | ;; This strange form ensures that (recent-keys) is the value before |
77 | ;; the bug subject string is read. | |
78 | (interactive (reverse (list (recent-keys) (read-string "Bug Subject: ")))) | |
8ab5d35a EZ |
79 | ;; If there are four numbers in emacs-version, this is a pretest |
80 | ;; version. | |
81 | (let ((pretest-p (string-match "\\..*\\..*\\." emacs-version)) | |
515ced27 | 82 | user-point prompt-beg-point message-end-point) |
0a18209b | 83 | (setq message-end-point |
5e11c425 | 84 | (with-current-buffer (get-buffer-create "*Messages*") |
0a18209b | 85 | (point-max-marker))) |
8ab5d35a | 86 | (compose-mail (if pretest-p |
0a18209b | 87 | report-emacs-bug-pretest-address |
7b27eb53 | 88 | report-emacs-bug-address) |
0a18209b KH |
89 | topic) |
90 | ;; The rest of this does not execute | |
91 | ;; if the user was asked to confirm and said no. | |
9e68869b RS |
92 | (rfc822-goto-eoh) |
93 | (forward-line 1) | |
94 | ||
95 | (let ((signature (buffer-substring (point) (point-max)))) | |
9e68869b | 96 | (delete-region (point) (point-max)) |
518adca2 RS |
97 | (insert signature) |
98 | (backward-char (length signature))) | |
515ced27 | 99 | (setq prompt-beg-point (point)) |
fbd410d6 RS |
100 | (unless report-emacs-bug-no-explanations |
101 | ;; Insert warnings for novice users. | |
102 | (insert "This bug report will be sent to the Free Software Foundation,\n") | |
103 | (let ((pos (point))) | |
94821e4f | 104 | (insert "not to your local site managers!") |
fbd410d6 RS |
105 | (put-text-property pos (point) 'face 'highlight)) |
106 | (insert "\nPlease write in ") | |
107 | (let ((pos (point))) | |
108 | (insert "English") | |
109 | (put-text-property pos (point) 'face 'highlight)) | |
9210027b RS |
110 | (insert " if possible, because the Emacs maintainers |
111 | usually do not have translators to read other languages for them.\n\n") | |
8ab5d35a EZ |
112 | (insert (format "Your bug report will be posted to the %s mailing list" |
113 | (if pretest-p | |
114 | report-emacs-bug-pretest-address | |
115 | report-emacs-bug-address))) | |
116 | (if pretest-p | |
117 | (insert ".\n\n") | |
118 | (insert ",\nand to the gnu.emacs.bug news group.\n\n"))) | |
fe1d8b33 | 119 | |
515ced27 MR |
120 | (insert "Please describe exactly what actions triggered the bug\n" |
121 | "and the precise symptoms of the bug:") | |
122 | (setq report-emacs-bug-text-prompt | |
123 | (buffer-substring prompt-beg-point (point))) | |
124 | ||
125 | (insert "\n\n") | |
126 | (setq user-point (point)) | |
127 | (insert "\n\n\n") | |
128 | ||
0a18209b KH |
129 | (insert "In " (emacs-version) "\n") |
130 | (if (and system-configuration-options | |
131 | (not (equal system-configuration-options ""))) | |
132 | (insert "configured using `configure " | |
515ced27 | 133 | system-configuration-options "'\n\n")) |
dc81f8a2 | 134 | (insert "Important settings:\n") |
249dd409 EZ |
135 | (mapcar |
136 | '(lambda (var) | |
137 | (insert (format " value of $%s: %s\n" var (getenv var)))) | |
138 | '("LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES" | |
139 | "LC_MONETARY" "LC_NUMERIC" "LC_TIME" "LANG")) | |
dc81f8a2 EZ |
140 | (insert (format " locale-coding-system: %s\n" locale-coding-system)) |
141 | (insert (format " default-enable-multibyte-characters: %s\n" | |
142 | default-enable-multibyte-characters)) | |
0a18209b | 143 | (insert "\n") |
515ced27 | 144 | (insert "Recent input:\n") |
0a18209b KH |
145 | (let ((before-keys (point))) |
146 | (insert (mapconcat (lambda (key) | |
147 | (if (or (integerp key) | |
148 | (symbolp key) | |
149 | (listp key)) | |
150 | (single-key-description key) | |
151 | (prin1-to-string key nil))) | |
152 | (or recent-keys (recent-keys)) | |
153 | " ")) | |
154 | (save-restriction | |
155 | (narrow-to-region before-keys (point)) | |
156 | (goto-char before-keys) | |
157 | (while (progn (move-to-column 50) (not (eobp))) | |
158 | (search-forward " " nil t) | |
159 | (insert "\n")))) | |
160 | (let ((message-buf (get-buffer "*Messages*"))) | |
161 | (if message-buf | |
162 | (let (beg-pos | |
163 | (end-pos message-end-point)) | |
164 | (with-current-buffer message-buf | |
165 | (goto-char end-pos) | |
166 | (forward-line -10) | |
167 | (setq beg-pos (point))) | |
168 | (insert "\n\nRecent messages:\n") | |
169 | (insert-buffer-substring message-buf beg-pos end-pos)))) | |
170 | ;; This is so the user has to type something | |
171 | ;; in order to send easily. | |
172 | (use-local-map (nconc (make-sparse-keymap) (current-local-map))) | |
173 | (define-key (current-local-map) "\C-c\C-i" 'report-emacs-bug-info) | |
e9227982 RS |
174 | (unless report-emacs-bug-no-explanations |
175 | (with-output-to-temp-buffer "*Bug Help*" | |
176 | (if (eq mail-user-agent 'sendmail-user-agent) | |
177 | (princ (substitute-command-keys | |
178 | "Type \\[mail-send-and-exit] to send the bug report.\n"))) | |
179 | (princ (substitute-command-keys | |
180 | "Type \\[kill-buffer] RET to cancel (don't send it).\n")) | |
181 | (terpri) | |
182 | (princ (substitute-command-keys | |
183 | "Type \\[report-emacs-bug-info] to visit in Info the Emacs Manual section | |
1628adc6 KH |
184 | about when and how to write a bug report, |
185 | and what information to supply so that the bug can be fixed. | |
e9227982 | 186 | Type SPC to scroll through this section and its subsections.")))) |
0a18209b KH |
187 | ;; Make it less likely people will send empty messages. |
188 | (make-local-variable 'mail-send-hook) | |
189 | (add-hook 'mail-send-hook 'report-emacs-bug-hook) | |
0a18209b KH |
190 | (save-excursion |
191 | (goto-char (point-max)) | |
192 | (skip-chars-backward " \t\n") | |
193 | (make-local-variable 'report-emacs-bug-orig-text) | |
194 | (setq report-emacs-bug-orig-text (buffer-substring (point-min) (point)))) | |
195 | (goto-char user-point))) | |
e24ec555 | 196 | |
1628adc6 KH |
197 | (defun report-emacs-bug-info () |
198 | "Go to the Info node on reporting Emacs bugs." | |
199 | (interactive) | |
200 | (info) | |
201 | (Info-directory) | |
202 | (Info-menu "emacs") | |
203 | (Info-goto-node "Bugs")) | |
204 | ||
e24ec555 RS |
205 | (defun report-emacs-bug-hook () |
206 | (save-excursion | |
c7127655 MR |
207 | (save-excursion |
208 | (goto-char (point-max)) | |
209 | (skip-chars-backward " \t\n") | |
210 | (if (and (= (- (point) (point-min)) | |
211 | (length report-emacs-bug-orig-text)) | |
212 | (equal (buffer-substring (point-min) (point)) | |
213 | report-emacs-bug-orig-text)) | |
214 | (error "No text entered in bug report"))) | |
fe1d8b33 KH |
215 | |
216 | ;; Check the buffer contents and reject non-English letters. | |
9b4e41ac RS |
217 | (save-excursion |
218 | (goto-char (point-min)) | |
219 | (skip-chars-forward "\0-\177") | |
220 | (if (not (eobp)) | |
fbd410d6 | 221 | (if (or report-emacs-bug-no-confirmation |
02f6b354 | 222 | (y-or-n-p "Convert non-ASCII letters to hexadecimal? ")) |
9b4e41ac RS |
223 | (while (progn (skip-chars-forward "\0-\177") |
224 | (not (eobp))) | |
225 | (let ((ch (following-char))) | |
226 | (delete-char 1) | |
22ad9937 | 227 | (insert (format "=%02x" ch))))))) |
fe1d8b33 KH |
228 | |
229 | ;; The last warning for novice users. | |
fbd410d6 | 230 | (if (or report-emacs-bug-no-confirmation |
fe1d8b33 | 231 | (yes-or-no-p |
02f6b354 | 232 | "Send this bug report to the Emacs maintainers? ")) |
fe1d8b33 KH |
233 | ;; Just send the current mail. |
234 | nil | |
235 | (goto-char (point-min)) | |
236 | (if (search-forward "To: ") | |
237 | (let ((pos (point))) | |
238 | (end-of-line) | |
239 | (delete-region pos (point)))) | |
240 | (kill-local-variable 'mail-send-hook) | |
241 | (with-output-to-temp-buffer "*Bug Help*" | |
242 | (princ (substitute-command-keys "\ | |
02f6b354 RS |
243 | You invoked the command M-x report-emacs-bug, |
244 | but you decided not to mail the bug report to the Emacs maintainers. | |
fe1d8b33 | 245 | |
02f6b354 RS |
246 | If you want to mail it to someone else instead, |
247 | please insert the proper e-mail address after \"To: \", | |
248 | and send the mail again using \\[mail-send-and-exit]."))) | |
249 | (error "M-x report-emacs-bug was cancelled, please read *Bug Help* buffer")) | |
ea33ba73 TTN |
250 | |
251 | ;; Unclutter | |
252 | (mail-text) | |
515ced27 MR |
253 | (if (looking-at report-emacs-bug-text-prompt) |
254 | (replace-match "Symptoms:")))) | |
a2535589 | 255 | |
8e0ff8c8 ER |
256 | (provide 'emacsbug) |
257 | ||
ab5796a9 | 258 | ;;; arch-tag: 248b6523-c3b5-4fec-9a3f-0411fafa7d49 |
c0274f38 | 259 | ;;; emacsbug.el ends here |