1 ;;; emacsbug.el --- command to report Emacs bugs to appropriate mailing list
3 ;; Copyright (C) 1985, 1994, 1997, 1998, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
6 ;; Author: K. Shane Hartman
8 ;; Keywords: maint mail
10 ;; Not fully installed because it can work only on Internet hosts.
11 ;; This file is part of GNU Emacs.
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
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
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.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;; `M-x report-emacs-bug' starts an email note to the Emacs maintainers
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.
37 (defgroup emacsbug nil
38 "Sending Emacs bug reports."
42 (defcustom report-emacs-bug-address
"bug-gnu-emacs@gnu.org"
43 "Address of mailing list for GNU Emacs bugs."
47 (defcustom report-emacs-bug-pretest-address
"emacs-pretest-bug@gnu.org"
48 "Address of mailing list for GNU Emacs pretest bugs."
52 (defcustom report-emacs-bug-no-confirmation nil
53 "If non-nil, suppress the confirmations asked for the sake of novice users."
57 (defcustom report-emacs-bug-no-explanations nil
58 "If non-nil, suppress the explanations given for the sake of novice users."
62 ;; User options end here.
65 (defvar report-emacs-bug-orig-text nil
66 "The automatically-created initial text of bug report.")
68 (declare-function x-server-vendor
"xfns.c" (&optional terminal
))
69 (declare-function x-server-version
"xfns.c" (&optional terminal
))
72 (defun report-emacs-bug (topic &optional recent-keys
)
73 "Report a bug in GNU Emacs.
74 Prompts for bug subject. Leaves you in a mail buffer."
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: "))))
78 ;; The syntax `version;' is preferred to `[version]' because the
79 ;; latter could be mistakenly stripped by mailing software.
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
)
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
98 user-point message-end-point
)
99 (setq message-end-point
100 (with-current-buffer (get-buffer-create "*Messages*")
102 (compose-mail reporting-address
104 ;; The rest of this does not execute
105 ;; if the user was asked to confirm and said no.
109 (let ((signature (buffer-substring (point) (point-max))))
110 (delete-region (point) (point-max))
112 (backward-char (length signature
)))
113 (unless report-emacs-bug-no-explanations
114 ;; Insert warnings for novice users.
115 (when (string-match "@gnu\\.org^" reporting-address
)
116 (insert "This bug report will be sent to the Free Software Foundation,\n")
118 (insert "not to your local site managers!")
119 (put-text-property pos
(point) 'face
'highlight
)))
120 (insert "\nPlease write in ")
123 (put-text-property pos
(point) 'face
'highlight
))
124 (insert " if possible, because the Emacs maintainers
125 usually do not have translators to read other languages for them.\n\n")
126 (insert (format "Your bug report will be posted to the %s mailing list"
130 (insert ",\nand to the gnu.emacs.bug news group.\n\n")))
132 (insert "Please describe exactly what actions triggered the bug\n"
133 "and the precise symptoms of the bug:\n\n")
134 (add-text-properties (point) (save-excursion (mail-text) (point))
137 (setq user-point
(point))
140 (insert "If Emacs crashed, and you have the Emacs process in the gdb debugger,\n"
141 "please include the output from the following gdb commands:\n"
142 " `bt full' and `xbacktrace'.\n")
144 (let ((debug-file (expand-file-name "DEBUG" data-directory
)))
145 (if (file-readable-p debug-file
)
146 (insert "If you would like to further debug the crash, please read the file\n"
147 debug-file
" for instructions.\n")))
148 (add-text-properties (1+ user-point
) (point) prompt-properties
)
150 (insert "\n\nIn " (emacs-version) "\n")
151 (if (fboundp 'x-server-vendor
)
153 ;; This is used not only for X11 but also W32 and others.
154 (insert "Windowing system distributor `" (x-server-vendor)
156 (mapconcat 'number-to-string
(x-server-version) ".") "\n")
158 (if (and system-configuration-options
159 (not (equal system-configuration-options
"")))
160 (insert "configured using `configure "
161 system-configuration-options
"'\n\n"))
162 (insert "Important settings:\n")
165 (insert (format " value of $%s: %s\n" var
(getenv var
))))
166 '("LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES"
167 "LC_MONETARY" "LC_NUMERIC" "LC_TIME" "LANG" "XMODIFIERS"))
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
))
172 (insert (format "Major mode: %s\n"
174 (buffer-local-value 'mode-name from-buffer
)
175 nil nil from-buffer
)))
177 (insert "Minor modes in effect:\n")
178 (dolist (mode minor-mode-list
)
179 (and (boundp mode
) (buffer-local-value mode from-buffer
)
180 (insert (format " %s: %s\n" mode
181 (buffer-local-value mode from-buffer
)))))
183 (insert "Recent input:\n")
184 (let ((before-keys (point)))
185 (insert (mapconcat (lambda (key)
186 (if (or (integerp key
)
189 (single-key-description key
)
190 (prin1-to-string key nil
)))
191 (or recent-keys
(recent-keys))
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
)
199 (let ((message-buf (get-buffer "*Messages*")))
202 (end-pos message-end-point
))
203 (with-current-buffer message-buf
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
)
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"))
221 (princ (substitute-command-keys
222 "Type \\[report-emacs-bug-info] to visit in Info the Emacs Manual section
223 about when and how to write a bug report,
224 and what information to supply so that the bug can be fixed.
225 Type SPC to scroll through this section and its subsections."))))
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
)
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
)))
236 (defun report-emacs-bug-info ()
237 "Go to the Info node on reporting Emacs bugs."
239 (info "(emacs)Bugs"))
241 (defun report-emacs-bug-hook ()
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")))
252 ;; Check the buffer contents and reject non-English letters.
254 (goto-char (point-min))
255 (skip-chars-forward "\0-\177")
257 (if (or report-emacs-bug-no-confirmation
258 (y-or-n-p "Convert non-ASCII letters to hexadecimal? "))
259 (while (progn (skip-chars-forward "\0-\177")
261 (let ((ch (following-char)))
263 (insert (format "=%02x" ch
)))))))
265 ;; The last warning for novice users.
266 (if (or report-emacs-bug-no-confirmation
268 "Send this bug report to the Emacs maintainers? "))
269 ;; Just send the current mail.
271 (goto-char (point-min))
272 (if (search-forward "To: ")
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 "\
279 You invoked the command M-x report-emacs-bug,
280 but you decided not to mail the bug report to the Emacs maintainers.
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"))
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
)))))))
296 ;; arch-tag: 248b6523-c3b5-4fec-9a3f-0411fafa7d49
297 ;;; emacsbug.el ends here