]> code.delx.au - gnu-emacs/blob - lisp/mail/emacsbug.el
(report-emacs-bug-hook): Don't absolutely
[gnu-emacs] / lisp / mail / emacsbug.el
1 ;;; emacsbug.el --- command to report Emacs bugs to appropriate mailing list.
2
3 ;; Copyright (C) 1985, 1994, 1997, 1998 Free Software Foundation, Inc.
4
5 ;; Author: K. Shane Hartman
6 ;; Maintainer: FSF
7 ;; Keywords: maint mail
8
9 ;; Not fully installed because it can work only on Internet hosts.
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
14 ;; the Free Software Foundation; either version 2, or (at your option)
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
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.
26
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
32 ;;; Code:
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
38 (require 'sendmail)
39
40 (defgroup emacsbug nil
41 "Sending Emacs bug reports."
42 :group 'maint
43 :group 'mail)
44
45 (defcustom report-emacs-bug-address "bug-gnu-emacs@gnu.org"
46 "*Address of mailing list for GNU Emacs bugs."
47 :group 'emacsbug
48 :type 'string)
49
50 (defcustom report-emacs-bug-pretest-address "emacs-pretest-bug@gnu.org"
51 "*Address of mailing list for GNU Emacs pretest bugs."
52 :group 'emacsbug
53 :type 'string)
54
55 (defvar report-emacs-bug-orig-text nil
56 "The automatically-created initial text of bug report.")
57
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)
67
68 ;;;###autoload
69 (defun report-emacs-bug (topic &optional recent-keys)
70 "Report a bug in GNU Emacs.
71 Prompts for bug subject. Leaves you in a mail buffer."
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: "))))
75 (let (user-point message-end-point)
76 (setq message-end-point
77 (with-current-buffer (get-buffer "*Messages*")
78 (point-max-marker)))
79 (compose-mail (if (string-match "\\..*\\..*\\." emacs-version)
80 ;; If there are four numbers in emacs-version,
81 ;; this is a pretest version.
82 report-emacs-bug-pretest-address
83 report-emacs-bug-address)
84 topic)
85 ;; The rest of this does not execute
86 ;; if the user was asked to confirm and said no.
87 (goto-char (point-min))
88 (re-search-forward (concat "^" (regexp-quote mail-header-separator) "\n"))
89 (unless report-emacs-bug-no-explanations
90 ;; Insert warnings for novice users.
91 (insert "This bug report will be sent to the Free Software Foundation,\n")
92 (let ((pos (point)))
93 (insert " not to your local site managers!!")
94 (put-text-property pos (point) 'face 'highlight))
95 (insert "\nPlease write in ")
96 (let ((pos (point)))
97 (insert "English")
98 (put-text-property pos (point) 'face 'highlight))
99 (insert ", because the Emacs maintainers do not have
100 translators to read other languages for them.\n\n"))
101
102 (insert "In " (emacs-version) "\n")
103 (if (and system-configuration-options
104 (not (equal system-configuration-options "")))
105 (insert "configured using `configure "
106 system-configuration-options "'\n"))
107 (insert "\n")
108 (insert "Please describe exactly what actions triggered the bug\n"
109 "and the precise symptoms of the bug:\n\n")
110 (setq user-point (point))
111 (insert "\n\n\n"
112 "Recent input:\n")
113 (let ((before-keys (point)))
114 (insert (mapconcat (lambda (key)
115 (if (or (integerp key)
116 (symbolp key)
117 (listp key))
118 (single-key-description key)
119 (prin1-to-string key nil)))
120 (or recent-keys (recent-keys))
121 " "))
122 (save-restriction
123 (narrow-to-region before-keys (point))
124 (goto-char before-keys)
125 (while (progn (move-to-column 50) (not (eobp)))
126 (search-forward " " nil t)
127 (insert "\n"))))
128 (let ((message-buf (get-buffer "*Messages*")))
129 (if message-buf
130 (let (beg-pos
131 (end-pos message-end-point))
132 (with-current-buffer message-buf
133 (goto-char end-pos)
134 (forward-line -10)
135 (setq beg-pos (point)))
136 (insert "\n\nRecent messages:\n")
137 (insert-buffer-substring message-buf beg-pos end-pos))))
138 ;; This is so the user has to type something
139 ;; in order to send easily.
140 (use-local-map (nconc (make-sparse-keymap) (current-local-map)))
141 (define-key (current-local-map) "\C-c\C-i" 'report-emacs-bug-info)
142 (with-output-to-temp-buffer "*Bug Help*"
143 (if (eq mail-user-agent 'sendmail-user-agent)
144 (princ (substitute-command-keys
145 "Type \\[mail-send-and-exit] to send the bug report.\n")))
146 (princ (substitute-command-keys
147 "Type \\[kill-buffer] RET to cancel (don't send it).\n"))
148 (terpri)
149 (princ (substitute-command-keys
150 "Type \\[report-emacs-bug-info] to visit in Info the Emacs Manual section
151 about when and how to write a bug report,
152 and what information to supply so that the bug can be fixed.
153 Type SPC to scroll through this section and its subsections.")))
154 ;; Make it less likely people will send empty messages.
155 (make-local-variable 'mail-send-hook)
156 (add-hook 'mail-send-hook 'report-emacs-bug-hook)
157 ;; Discourage users to write non-English text.
158 (set-buffer-multibyte nil)
159 (save-excursion
160 (goto-char (point-max))
161 (skip-chars-backward " \t\n")
162 (make-local-variable 'report-emacs-bug-orig-text)
163 (setq report-emacs-bug-orig-text (buffer-substring (point-min) (point))))
164 (goto-char user-point)))
165
166 (defun report-emacs-bug-info ()
167 "Go to the Info node on reporting Emacs bugs."
168 (interactive)
169 (info)
170 (Info-directory)
171 (Info-menu "emacs")
172 (Info-goto-node "Bugs"))
173
174 (defun report-emacs-bug-hook ()
175 (save-excursion
176 (goto-char (point-max))
177 (skip-chars-backward " \t\n")
178 (if (and (= (- (point) (point-min))
179 (length report-emacs-bug-orig-text))
180 (equal (buffer-substring (point-min) (point))
181 report-emacs-bug-orig-text))
182 (error "No text entered in bug report"))
183
184 ;; Check the buffer contents and reject non-English letters.
185 (save-excursion
186 (goto-char (point-min))
187 (skip-chars-forward "\0-\177")
188 (if (not (eobp))
189 (if (or report-emacs-bug-no-confirmation
190 (y-or-n-p "Convert non-ASCII letters to hexadecimal? "))
191 (while (progn (skip-chars-forward "\0-\177")
192 (not (eobp)))
193 (let ((ch (following-char)))
194 (delete-char 1)
195 (insert (format "=%02x" ch)))))))
196
197 ;; The last warning for novice users.
198 (if (or report-emacs-bug-no-confirmation
199 (yes-or-no-p
200 "Send this bug report to the Emacs maintainers? "))
201 ;; Just send the current mail.
202 nil
203 (goto-char (point-min))
204 (if (search-forward "To: ")
205 (let ((pos (point)))
206 (end-of-line)
207 (delete-region pos (point))))
208 (kill-local-variable 'mail-send-hook)
209 (with-output-to-temp-buffer "*Bug Help*"
210 (princ (substitute-command-keys "\
211 You invoked the command M-x report-emacs-bug,
212 but you decided not to mail the bug report to the Emacs maintainers.
213
214 If you want to mail it to someone else instead,
215 please insert the proper e-mail address after \"To: \",
216 and send the mail again using \\[mail-send-and-exit].")))
217 (error "M-x report-emacs-bug was cancelled, please read *Bug Help* buffer"))
218 ))
219
220 (provide 'emacsbug)
221
222 ;;; emacsbug.el ends here