1 ;;; emacsbug.el --- command to report Emacs bugs to appropriate mailing list.
3 ;; Copyright (C) 1985, 1994, 1997 Free Software Foundation, Inc.
5 ;; Author: K. Shane Hartman
9 ;; Not fully installed because it can work only on Internet hosts.
10 ;; This file is part of GNU Emacs.
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)
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.
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.
29 ;; `M-x report-emacs-bug ' starts an email note to the Emacs maintainers
30 ;; describing a problem. Here's how it's done...
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.
40 (defvar bug-gnu-emacs
"bug-gnu-emacs@prep.ai.mit.edu"
41 "Address of mailing list for GNU Emacs bugs.")
43 (defvar report-emacs-bug-pretest-address
"emacs-pretest-bug@gnu.ai.mit.edu"
44 "Address of mailing list for GNU Emacs pretest bugs.")
46 (defvar report-emacs-bug-orig-text nil
47 "The automatically-created initial text of bug report.")
50 (defvar report-emacs-bug-run-tersely nil
51 "*If non-nil, suppress confirmations for novice users.")
54 (defun report-emacs-bug (topic &optional recent-keys
)
55 "Report a bug in GNU Emacs.
56 Prompts for bug subject. Leaves you in a mail buffer."
57 ;; This strange form ensures that (recent-keys) is the value before
58 ;; the bug subject string is read.
59 (interactive (reverse (list (recent-keys) (read-string "Bug Subject: "))))
60 (let (user-point message-end-point
)
61 (setq message-end-point
62 (with-current-buffer (get-buffer "*Messages*")
64 (compose-mail (if (string-match "\\..*\\..*\\." emacs-version
)
65 ;; If there are four numbers in emacs-version,
66 ;; this is a pretest version.
67 report-emacs-bug-pretest-address
70 ;; The rest of this does not execute
71 ;; if the user was asked to confirm and said no.
72 (goto-char (point-min))
73 (re-search-forward (concat "^" (regexp-quote mail-header-separator
) "\n"))
74 ;; Insert warnings for novice users.
75 (insert "This bug report will be sent to the Free Software Foundation,\n")
77 (insert " not to your local site managers!!")
78 (put-text-property pos
(point) 'face
'highlight
))
79 (insert "\nPlease write in ")
82 (put-text-property pos
(point) 'face
'highlight
))
83 (insert ", because the Emacs maintainers do not have
84 translators to read other languages for them.\n\n")
86 (insert "In " (emacs-version) "\n")
87 (if (and system-configuration-options
88 (not (equal system-configuration-options
"")))
89 (insert "configured using `configure "
90 system-configuration-options
"'\n"))
92 (insert "Please describe exactly what actions triggered the bug\n"
93 "and the precise symptoms of the bug:\n\n")
94 (setq user-point
(point))
97 (let ((before-keys (point)))
98 (insert (mapconcat (lambda (key)
99 (if (or (integerp key
)
102 (single-key-description key
)
103 (prin1-to-string key nil
)))
104 (or recent-keys
(recent-keys))
107 (narrow-to-region before-keys
(point))
108 (goto-char before-keys
)
109 (while (progn (move-to-column 50) (not (eobp)))
110 (search-forward " " nil t
)
112 (let ((message-buf (get-buffer "*Messages*")))
115 (end-pos message-end-point
))
116 (with-current-buffer message-buf
119 (setq beg-pos
(point)))
120 (insert "\n\nRecent messages:\n")
121 (insert-buffer-substring message-buf beg-pos end-pos
))))
122 ;; This is so the user has to type something
123 ;; in order to send easily.
124 (use-local-map (nconc (make-sparse-keymap) (current-local-map)))
125 (define-key (current-local-map) "\C-c\C-i" 'report-emacs-bug-info
)
126 (with-output-to-temp-buffer "*Bug Help*"
127 (if (eq mail-user-agent
'sendmail-user-agent
)
128 (princ (substitute-command-keys
129 "Type \\[mail-send-and-exit] to send the bug report.\n")))
130 (princ (substitute-command-keys
131 "Type \\[kill-buffer] RET to cancel (don't send it).\n"))
133 (princ (substitute-command-keys
134 "Type \\[report-emacs-bug-info] to visit in Info the Emacs Manual section
135 about when and how to write a bug report,
136 and what information to supply so that the bug can be fixed.
137 Type SPC to scroll through this section and its subsections.")))
138 ;; Make it less likely people will send empty messages.
139 (make-local-variable 'mail-send-hook
)
140 (add-hook 'mail-send-hook
'report-emacs-bug-hook
)
141 ;; Discourage users to write non-English text.
142 (setq enable-multibyte-characters nil
)
144 (goto-char (point-max))
145 (skip-chars-backward " \t\n")
146 (make-local-variable 'report-emacs-bug-orig-text
)
147 (setq report-emacs-bug-orig-text
(buffer-substring (point-min) (point))))
148 (goto-char user-point
)))
150 (defun report-emacs-bug-info ()
151 "Go to the Info node on reporting Emacs bugs."
156 (Info-goto-node "Bugs"))
158 (defun report-emacs-bug-hook ()
160 (goto-char (point-max))
161 (skip-chars-backward " \t\n")
162 (if (and (= (- (point) (point-min))
163 (length report-emacs-bug-orig-text
))
164 (equal (buffer-substring (point-min) (point))
165 report-emacs-bug-orig-text
))
166 (error "No text entered in bug report"))
168 ;; Check the buffer contents and reject non-English letters.
169 (let ((charsets (delq 'ascii
170 (find-charset-region (point-min) (point-max)))))
172 (if (or report-emacs-bug-run-tersely
173 (y-or-n-p "Convert non-ASCII letters to hexadecimal? "))
175 (goto-char (point-min))
176 (let ((enable-multibyte-characters nil
)
177 (pattern (format "[%c-%c]" 128 255))
179 (while (re-search-forward pattern nil t
)
180 (setq ch
(preceding-char))
182 (insert (format "=%02x" ch
)))))
183 (error "Please convert non-ASCII characters to something else"))))
185 ;; The last warning for novice users.
186 (if (or report-emacs-bug-run-tersely
188 "Send this bug report to the Emacs maintainers? "))
189 ;; Just send the current mail.
191 (goto-char (point-min))
192 (if (search-forward "To: ")
195 (delete-region pos
(point))))
196 (kill-local-variable 'mail-send-hook
)
197 (with-output-to-temp-buffer "*Bug Help*"
198 (princ (substitute-command-keys "\
199 You invoked the command M-x report-emacs-bug,
200 but you decided not to mail the bug report to the Emacs maintainers.
202 If you want to mail it to someone else instead,
203 please insert the proper e-mail address after \"To: \",
204 and send the mail again using \\[mail-send-and-exit].")))
205 (error "M-x report-emacs-bug was cancelled, please read *Bug Help* buffer"))
210 ;;; emacsbug.el ends here