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