Commit | Line | Data |
---|---|---|
55535639 | 1 | ;;; emacsbug.el --- command to report Emacs bugs to appropriate mailing list |
c0274f38 | 2 | |
acaf905b | 3 | ;; Copyright (C) 1985, 1994, 1997-1998, 2000-2012 |
893db5bc | 4 | ;; Free Software Foundation, Inc. |
9750e079 | 5 | |
e5167999 | 6 | ;; Author: K. Shane Hartman |
2f14b48d | 7 | ;; Maintainer: FSF |
fbd410d6 | 8 | ;; Keywords: maint mail |
bd78fa1d | 9 | ;; Package: emacs |
2f14b48d | 10 | |
a2535589 JA |
11 | ;; This file is part of GNU Emacs. |
12 | ||
b1fc2b50 | 13 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
a2535589 | 14 | ;; it under the terms of the GNU General Public License as published by |
b1fc2b50 GM |
15 | ;; the Free Software Foundation, either version 3 of the License, or |
16 | ;; (at your option) any later version. | |
a2535589 JA |
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 | |
b1fc2b50 | 24 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
a2535589 | 25 | |
e41b2db1 ER |
26 | ;;; Commentary: |
27 | ||
b92a07e0 | 28 | ;; `M-x report-emacs-bug' starts an email note to the Emacs maintainers |
4d8da9a4 GM |
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. | |
e41b2db1 | 32 | |
2f14b48d | 33 | ;;; Code: |
a2535589 | 34 | |
cc26d239 LI |
35 | (require 'sendmail) |
36 | (require 'message) | |
37 | ||
fbd410d6 RS |
38 | (defgroup emacsbug nil |
39 | "Sending Emacs bug reports." | |
40 | :group 'maint | |
41 | :group 'mail) | |
42 | ||
27be0364 GM |
43 | (define-obsolete-variable-alias 'report-emacs-bug-pretest-address |
44 | 'report-emacs-bug-address "24.1") | |
45 | ||
9b4e41ac | 46 | (defcustom report-emacs-bug-address "bug-gnu-emacs@gnu.org" |
4d8da9a4 | 47 | "Address of mailing list for GNU Emacs bugs." |
7b27eb53 RS |
48 | :group 'emacsbug |
49 | :type 'string) | |
a85a468e | 50 | |
fbd410d6 | 51 | (defcustom report-emacs-bug-no-confirmation nil |
4d8da9a4 | 52 | "If non-nil, suppress the confirmations asked for the sake of novice users." |
fbd410d6 RS |
53 | :group 'emacsbug |
54 | :type 'boolean) | |
55 | ||
56 | (defcustom report-emacs-bug-no-explanations nil | |
4d8da9a4 | 57 | "If non-nil, suppress the explanations given for the sake of novice users." |
fbd410d6 RS |
58 | :group 'emacsbug |
59 | :type 'boolean) | |
fe1d8b33 | 60 | |
4d8da9a4 GM |
61 | ;; User options end here. |
62 | ||
614316a7 TH |
63 | (defvar report-emacs-bug-tracker-url "http://debbugs.gnu.org/cgi/" |
64 | "Base URL of the GNU bugtracker. | |
65 | Used for querying duplicates and linking to existing bugs.") | |
4d8da9a4 GM |
66 | |
67 | (defvar report-emacs-bug-orig-text nil | |
85094855 GM |
68 | "The automatically-created initial text of the bug report.") |
69 | ||
70 | (defvar report-emacs-bug-send-command nil | |
71 | "Name of the command to send the bug report, as a string.") | |
72 | (make-variable-buffer-local 'report-emacs-bug-send-command) | |
73 | ||
74 | (defvar report-emacs-bug-send-hook nil | |
75 | "Hook run before sending the bug report.") | |
76 | (make-variable-buffer-local 'report-emacs-bug-send-hook) | |
4d8da9a4 | 77 | |
aa360da1 GM |
78 | (declare-function x-server-vendor "xfns.c" (&optional terminal)) |
79 | (declare-function x-server-version "xfns.c" (&optional terminal)) | |
a0cefee5 | 80 | (declare-function message-sort-headers "message" ()) |
27be0364 | 81 | (defvar message-strip-special-text-properties) |
aa360da1 | 82 | |
253f7d1b | 83 | (defun report-emacs-bug-can-use-osx-open () |
3f88cd72 | 84 | "Return non-nil if the OS X \"open\" command is available for mailing." |
253f7d1b JD |
85 | (and (featurep 'ns) |
86 | (equal (executable-find "open") "/usr/bin/open") | |
87 | (memq system-type '(darwin)))) | |
88 | ||
3f88cd72 | 89 | ;; FIXME this duplicates much of the logic from browse-url-can-use-xdg-open. |
489cd5bd | 90 | (defun report-emacs-bug-can-use-xdg-email () |
3f88cd72 GM |
91 | "Return non-nil if the \"xdg-email\" command can be used. |
92 | xdg-email is a desktop utility that calls your preferred mail client. | |
93 | This requires you to be running either Gnome, KDE, or Xfce4." | |
489cd5bd JD |
94 | (and (getenv "DISPLAY") |
95 | (executable-find "xdg-email") | |
96 | (or (getenv "GNOME_DESKTOP_SESSION_ID") | |
97 | ;; GNOME_DESKTOP_SESSION_ID is deprecated, check on Dbus also. | |
98 | (condition-case nil | |
99 | (eq 0 (call-process | |
100 | "dbus-send" nil nil nil | |
101 | "--dest=org.gnome.SessionManager" | |
102 | "--print-reply" | |
103 | "/org/gnome/SessionManager" | |
104 | "org.gnome.SessionManager.CanShutdown")) | |
105 | (error nil)) | |
106 | (equal (getenv "KDE_FULL_SESSION") "true") | |
3f88cd72 GM |
107 | ;; FIXME? browse-url-can-use-xdg-open also accepts LXDE. |
108 | ;; Is that no good here, or just overlooked? | |
489cd5bd JD |
109 | (condition-case nil |
110 | (eq 0 (call-process | |
111 | "/bin/sh" nil nil nil | |
112 | "-c" | |
3f88cd72 | 113 | ;; FIXME use string-match rather than grep. |
489cd5bd JD |
114 | "xprop -root _DT_SAVE_MODE|grep xfce4")) |
115 | (error nil))))) | |
116 | ||
117 | (defun report-emacs-bug-insert-to-mailer () | |
3f88cd72 GM |
118 | "Send the message to your preferred mail client. |
119 | This requires either the OS X \"open\" command, or the freedesktop | |
120 | \"xdg-email\" command to be available." | |
489cd5bd JD |
121 | (interactive) |
122 | (save-excursion | |
3f88cd72 | 123 | ;; FIXME? use mail-fetch-field? |
489cd5bd JD |
124 | (let* ((to (progn |
125 | (goto-char (point-min)) | |
126 | (forward-line) | |
127 | (and (looking-at "^To: \\(.*\\)") | |
128 | (match-string-no-properties 1)))) | |
129 | (subject (progn | |
130 | (forward-line) | |
131 | (and (looking-at "^Subject: \\(.*\\)") | |
132 | (match-string-no-properties 1)))) | |
133 | (body (progn | |
134 | (forward-line 2) | |
135 | (if (> (point-max) (point)) | |
136 | (buffer-substring-no-properties (point) (point-max)))))) | |
137 | (if (and to subject body) | |
253f7d1b JD |
138 | (if (report-emacs-bug-can-use-osx-open) |
139 | (start-process "/usr/bin/open" nil "open" | |
7d15102b | 140 | (concat "mailto:" to |
253f7d1b JD |
141 | "?subject=" (url-hexify-string subject) |
142 | "&body=" (url-hexify-string body))) | |
143 | (start-process "xdg-email" nil "xdg-email" | |
144 | "--subject" subject | |
145 | "--body" body | |
146 | (concat "mailto:" to))) | |
489cd5bd JD |
147 | (error "Subject, To or body not found"))))) |
148 | ||
aa228418 | 149 | ;;;###autoload |
01753e63 | 150 | (defun report-emacs-bug (topic &optional recent-keys) |
aa228418 | 151 | "Report a bug in GNU Emacs. |
a2535589 | 152 | Prompts for bug subject. Leaves you in a mail buffer." |
01753e63 EN |
153 | ;; This strange form ensures that (recent-keys) is the value before |
154 | ;; the bug subject string is read. | |
155 | (interactive (reverse (list (recent-keys) (read-string "Bug Subject: ")))) | |
a722966c MC |
156 | ;; The syntax `version;' is preferred to `[version]' because the |
157 | ;; latter could be mistakenly stripped by mailing software. | |
ef77dde4 MC |
158 | (if (eq system-type 'ms-dos) |
159 | (setq topic (concat emacs-version "; " topic)) | |
160 | (when (string-match "^\\(\\([.0-9]+\\)*\\)\\.[0-9]+$" emacs-version) | |
161 | (setq topic (concat (match-string 1 emacs-version) "; " topic)))) | |
27be0364 GM |
162 | (let ((from-buffer (current-buffer)) |
163 | ;; Put these properties on semantically-void text. | |
164 | ;; report-emacs-bug-hook deletes these regions before sending. | |
165 | (prompt-properties '(field emacsbug-prompt | |
1176868d CY |
166 | intangible but-helpful |
167 | rear-nonsticky t)) | |
253f7d1b JD |
168 | (can-insert-mail (or (report-emacs-bug-can-use-xdg-email) |
169 | (report-emacs-bug-can-use-osx-open))) | |
27be0364 | 170 | user-point message-end-point) |
0a18209b | 171 | (setq message-end-point |
5e11c425 | 172 | (with-current-buffer (get-buffer-create "*Messages*") |
0a18209b | 173 | (point-max-marker))) |
27be0364 | 174 | (compose-mail report-emacs-bug-address topic) |
2f1b7dc4 GM |
175 | ;; The rest of this does not execute if the user was asked to |
176 | ;; confirm and said no. | |
27be0364 GM |
177 | (when (eq major-mode 'message-mode) |
178 | ;; Message-mode sorts the headers before sending. We sort now so | |
179 | ;; that report-emacs-bug-orig-text remains valid. (Bug#5178) | |
180 | (message-sort-headers) | |
181 | ;; Stop message-mode stealing the properties we will add. | |
182 | (set (make-local-variable 'message-strip-special-text-properties) nil)) | |
9e68869b RS |
183 | (rfc822-goto-eoh) |
184 | (forward-line 1) | |
4443f204 RS |
185 | ;; Move the mail signature to the proper place. |
186 | (let ((signature (buffer-substring (point) (point-max))) | |
187 | (inhibit-read-only t)) | |
9e68869b | 188 | (delete-region (point) (point-max)) |
518adca2 RS |
189 | (insert signature) |
190 | (backward-char (length signature))) | |
fbd410d6 RS |
191 | (unless report-emacs-bug-no-explanations |
192 | ;; Insert warnings for novice users. | |
1176868d CY |
193 | (if (not (equal "bug-gnu-emacs@gnu.org" report-emacs-bug-address)) |
194 | (insert (format "The report will be sent to %s.\n\n" | |
195 | report-emacs-bug-address)) | |
196 | (insert "This bug report will be sent to the ") | |
197 | (insert-button | |
198 | "Bug-GNU-Emacs" | |
199 | 'face 'link | |
200 | 'help-echo (concat "mouse-2, RET: Follow this link") | |
201 | 'action (lambda (button) | |
202 | (browse-url "http://lists.gnu.org/archive/html/bug-gnu-emacs/")) | |
203 | 'follow-link t) | |
204 | (insert " mailing list\nand the GNU bug tracker at ") | |
205 | (insert-button | |
206 | "debbugs.gnu.org" | |
207 | 'face 'link | |
208 | 'help-echo (concat "mouse-2, RET: Follow this link") | |
209 | 'action (lambda (button) | |
210 | (browse-url "http://debbugs.gnu.org/")) | |
211 | 'follow-link t) | |
212 | ||
213 | (insert ". Please check that | |
214 | the From: line contains a valid email address. After a delay of up | |
215 | to one day, you should receive an acknowledgement at that address. | |
216 | ||
217 | Please write in English if possible, as the Emacs maintainers | |
218 | usually do not have translators for other languages.\n\n"))) | |
219 | ||
220 | (insert "Please describe exactly what actions triggered the bug, and\n" | |
221 | "the precise symptoms of the bug. If you can, give a recipe\n" | |
222 | "starting from `emacs -Q':\n\n") | |
85094855 GM |
223 | (add-text-properties (save-excursion |
224 | (rfc822-goto-eoh) | |
225 | (line-beginning-position 2)) | |
226 | (point) | |
9888f112 | 227 | prompt-properties) |
515ced27 | 228 | (setq user-point (point)) |
3a7f4c18 KS |
229 | (insert "\n\n") |
230 | ||
fca615d5 | 231 | (insert "If Emacs crashed, and you have the Emacs process in the gdb debugger,\n" |
3a7f4c18 KS |
232 | "please include the output from the following gdb commands:\n" |
233 | " `bt full' and `xbacktrace'.\n") | |
234 | ||
235 | (let ((debug-file (expand-file-name "DEBUG" data-directory))) | |
236 | (if (file-readable-p debug-file) | |
00006066 CY |
237 | (insert "For information about debugging Emacs, please read the file\n" |
238 | debug-file ".\n"))) | |
9888f112 | 239 | (add-text-properties (1+ user-point) (point) prompt-properties) |
515ced27 | 240 | |
3a7f4c18 | 241 | (insert "\n\nIn " (emacs-version) "\n") |
f4982064 | 242 | (if (fboundp 'x-server-vendor) |
6f8a2742 | 243 | (condition-case nil |
951c155f SM |
244 | ;; This is used not only for X11 but also W32 and others. |
245 | (insert "Windowing system distributor `" (x-server-vendor) | |
246 | "', version " | |
6f8a2742 JD |
247 | (mapconcat 'number-to-string (x-server-version) ".") "\n") |
248 | (error t))) | |
4d4ec1f8 EZ |
249 | (when (and system-configuration-options |
250 | (not (equal system-configuration-options ""))) | |
251 | (insert "Configured using:\n `configure " | |
252 | system-configuration-options "'\n\n") | |
253 | (fill-region (line-beginning-position -1) (point))) | |
dc81f8a2 | 254 | (insert "Important settings:\n") |
1daad47d | 255 | (mapc |
4f91a816 SM |
256 | (lambda (var) |
257 | (insert (format " value of $%s: %s\n" var (getenv var)))) | |
249dd409 | 258 | '("LC_ALL" "LC_COLLATE" "LC_CTYPE" "LC_MESSAGES" |
5dae4230 | 259 | "LC_MONETARY" "LC_NUMERIC" "LC_TIME" "LANG" "XMODIFIERS")) |
dc81f8a2 | 260 | (insert (format " locale-coding-system: %s\n" locale-coding-system)) |
597e2240 GM |
261 | (insert (format " default enable-multibyte-characters: %s\n" |
262 | (default-value 'enable-multibyte-characters))) | |
0a18209b | 263 | (insert "\n") |
3c3ba27b | 264 | (insert (format "Major mode: %s\n" |
48d33090 SM |
265 | (format-mode-line |
266 | (buffer-local-value 'mode-name from-buffer) | |
267 | nil nil from-buffer))) | |
e927088b RS |
268 | (insert "\n") |
269 | (insert "Minor modes in effect:\n") | |
270 | (dolist (mode minor-mode-list) | |
3c3ba27b RS |
271 | (and (boundp mode) (buffer-local-value mode from-buffer) |
272 | (insert (format " %s: %s\n" mode | |
273 | (buffer-local-value mode from-buffer))))) | |
e927088b | 274 | (insert "\n") |
515ced27 | 275 | (insert "Recent input:\n") |
0a18209b KH |
276 | (let ((before-keys (point))) |
277 | (insert (mapconcat (lambda (key) | |
278 | (if (or (integerp key) | |
279 | (symbolp key) | |
280 | (listp key)) | |
281 | (single-key-description key) | |
282 | (prin1-to-string key nil))) | |
283 | (or recent-keys (recent-keys)) | |
284 | " ")) | |
285 | (save-restriction | |
286 | (narrow-to-region before-keys (point)) | |
287 | (goto-char before-keys) | |
288 | (while (progn (move-to-column 50) (not (eobp))) | |
289 | (search-forward " " nil t) | |
290 | (insert "\n")))) | |
291 | (let ((message-buf (get-buffer "*Messages*"))) | |
292 | (if message-buf | |
293 | (let (beg-pos | |
294 | (end-pos message-end-point)) | |
295 | (with-current-buffer message-buf | |
296 | (goto-char end-pos) | |
297 | (forward-line -10) | |
298 | (setq beg-pos (point))) | |
299 | (insert "\n\nRecent messages:\n") | |
300 | (insert-buffer-substring message-buf beg-pos end-pos)))) | |
0b952197 GM |
301 | ;; After Recent messages, to avoid the messages produced by |
302 | ;; list-load-path-shadows. | |
303 | (unless (looking-back "\n") | |
304 | (insert "\n")) | |
305 | (insert "\n") | |
306 | (insert "Load-path shadows:\n") | |
fa05bfe0 GM |
307 | (let* ((msg "Checking for load-path shadows...") |
308 | (result "done") | |
309 | (shadows (progn (message "%s" msg) | |
310 | (condition-case nil (list-load-path-shadows t) | |
311 | (error | |
312 | (setq result "error") | |
313 | "Error during checking"))))) | |
314 | (message "%s%s" msg result) | |
0b952197 GM |
315 | (insert (if (zerop (length shadows)) |
316 | "None found.\n" | |
317 | shadows))) | |
9656d87b GM |
318 | (insert (format "\nFeatures:\n%s\n" features)) |
319 | (fill-region (line-beginning-position 0) (point)) | |
320 | ;; This is so the user has to type something in order to send easily. | |
0a18209b KH |
321 | (use-local-map (nconc (make-sparse-keymap) (current-local-map))) |
322 | (define-key (current-local-map) "\C-c\C-i" 'report-emacs-bug-info) | |
253f7d1b | 323 | (if can-insert-mail |
bd78fa1d | 324 | (define-key (current-local-map) "\C-cm" |
489cd5bd | 325 | 'report-emacs-bug-insert-to-mailer)) |
e554b3f8 GM |
326 | (setq report-emacs-bug-send-command (get mail-user-agent 'sendfunc) |
327 | report-emacs-bug-send-hook (get mail-user-agent 'hookvar)) | |
328 | (if report-emacs-bug-send-command | |
329 | (setq report-emacs-bug-send-command | |
330 | (symbol-name report-emacs-bug-send-command))) | |
e9227982 RS |
331 | (unless report-emacs-bug-no-explanations |
332 | (with-output-to-temp-buffer "*Bug Help*" | |
3e425845 | 333 | (princ "While in the mail buffer:\n\n") |
85094855 | 334 | (if report-emacs-bug-send-command |
d8194864 | 335 | (princ (substitute-command-keys |
85094855 GM |
336 | (format " Type \\[%s] to send the bug report.\n" |
337 | report-emacs-bug-send-command)))) | |
e9227982 | 338 | (princ (substitute-command-keys |
3e425845 | 339 | " Type \\[kill-buffer] RET to cancel (don't send it).\n")) |
253f7d1b | 340 | (if can-insert-mail |
489cd5bd | 341 | (princ (substitute-command-keys |
3f88cd72 | 342 | " Type \\[report-emacs-bug-insert-to-mailer] to copy text to your preferred mail program.\n"))) |
e9227982 RS |
343 | (terpri) |
344 | (princ (substitute-command-keys | |
3e425845 CY |
345 | " Type \\[report-emacs-bug-info] to visit in Info the Emacs Manual section |
346 | about when and how to write a bug report, and what | |
347 | information you should include to help fix the bug."))) | |
348 | (shrink-window-if-larger-than-buffer (get-buffer-window "*Bug Help*"))) | |
0a18209b | 349 | ;; Make it less likely people will send empty messages. |
85094855 GM |
350 | (if report-emacs-bug-send-hook |
351 | (add-hook report-emacs-bug-send-hook 'report-emacs-bug-hook nil t)) | |
2f1b7dc4 GM |
352 | (goto-char (point-max)) |
353 | (skip-chars-backward " \t\n") | |
354 | (make-local-variable 'report-emacs-bug-orig-text) | |
355 | (setq report-emacs-bug-orig-text | |
356 | (buffer-substring-no-properties (point-min) (point))) | |
0a18209b | 357 | (goto-char user-point))) |
e24ec555 | 358 | |
1628adc6 KH |
359 | (defun report-emacs-bug-info () |
360 | "Go to the Info node on reporting Emacs bugs." | |
361 | (interactive) | |
4d8da9a4 | 362 | (info "(emacs)Bugs")) |
1628adc6 | 363 | |
7d15102b GM |
364 | ;; It's the default mail mode, so it seems OK to use its features. |
365 | (autoload 'message-bogus-recipient-p "message") | |
d1a5d56a | 366 | (defvar message-send-mail-function) |
7d15102b | 367 | |
e24ec555 | 368 | (defun report-emacs-bug-hook () |
85094855 | 369 | "Do some checking before sending a bug report." |
e24ec555 | 370 | (save-excursion |
85094855 GM |
371 | (goto-char (point-max)) |
372 | (skip-chars-backward " \t\n") | |
85094855 GM |
373 | (and (= (- (point) (point-min)) |
374 | (length report-emacs-bug-orig-text)) | |
375 | (string-equal (buffer-substring-no-properties (point-min) (point)) | |
376 | report-emacs-bug-orig-text) | |
377 | (error "No text entered in bug report")) | |
cc26d239 | 378 | ;; Warning for novice users. |
85094855 | 379 | (unless (or report-emacs-bug-no-confirmation |
7d15102b GM |
380 | (yes-or-no-p |
381 | "Send this bug report to the Emacs maintainers? ")) | |
fe1d8b33 KH |
382 | (goto-char (point-min)) |
383 | (if (search-forward "To: ") | |
85094855 GM |
384 | (delete-region (point) (line-end-position))) |
385 | (if report-emacs-bug-send-hook | |
386 | (kill-local-variable report-emacs-bug-send-hook)) | |
fe1d8b33 | 387 | (with-output-to-temp-buffer "*Bug Help*" |
85094855 GM |
388 | (princ (substitute-command-keys |
389 | (format "\ | |
02f6b354 RS |
390 | You invoked the command M-x report-emacs-bug, |
391 | but you decided not to mail the bug report to the Emacs maintainers. | |
fe1d8b33 | 392 | |
02f6b354 RS |
393 | If you want to mail it to someone else instead, |
394 | please insert the proper e-mail address after \"To: \", | |
85094855 GM |
395 | and send the mail again%s." |
396 | (if report-emacs-bug-send-command | |
397 | (format " using \\[%s]" | |
398 | report-emacs-bug-send-command) | |
399 | ""))))) | |
02f6b354 | 400 | (error "M-x report-emacs-bug was cancelled, please read *Bug Help* buffer")) |
cc26d239 LI |
401 | ;; Query the user for the SMTP method, so that we can skip |
402 | ;; questions about From header validity if the user is going to | |
403 | ;; use mailclient, anyway. | |
fbae4637 | 404 | (when (or (and (derived-mode-p 'message-mode) |
e627be4c | 405 | (eq message-send-mail-function 'sendmail-query-once)) |
fbae4637 LMI |
406 | (and (not (derived-mode-p 'message-mode)) |
407 | (eq send-mail-function 'sendmail-query-once))) | |
cc26d239 LI |
408 | (sendmail-query-user-about-smtp) |
409 | (when (derived-mode-p 'message-mode) | |
410 | (setq message-send-mail-function (message-default-send-mail-function)))) | |
411 | (or report-emacs-bug-no-confirmation | |
412 | ;; mailclient.el does not need a valid From | |
413 | (if (derived-mode-p 'message-mode) | |
414 | (eq message-send-mail-function 'message-send-mail-with-mailclient) | |
415 | (eq send-mail-function 'mailclient-send-it)) | |
416 | ;; Not narrowing to the headers, but that's OK. | |
417 | (let ((from (mail-fetch-field "From"))) | |
418 | (and (or (not from) | |
419 | (message-bogus-recipient-p from) | |
420 | ;; This is the default user-mail-address. On today's | |
421 | ;; systems, it seems more likely to be wrong than right, | |
422 | ;; since most people don't run their own mail server. | |
423 | (string-match (format "\\<%s@%s\\>" | |
424 | (regexp-quote (user-login-name)) | |
425 | (regexp-quote (system-name))) | |
426 | from)) | |
427 | (not (yes-or-no-p | |
428 | (format "Is `%s' really your email address? " from))) | |
429 | (error "Please edit the From address and try again")))) | |
85094855 GM |
430 | ;; Delete the uninteresting text that was just to help fill out the report. |
431 | (rfc822-goto-eoh) | |
432 | (forward-line 1) | |
9888f112 TTN |
433 | (let ((pos (1- (point)))) |
434 | (while (setq pos (text-property-any pos (point-max) | |
435 | 'field 'emacsbug-prompt)) | |
436 | (delete-region pos (field-end (1+ pos))))))) | |
a2535589 | 437 | |
614316a7 TH |
438 | |
439 | ;; Querying the bug database | |
440 | ||
e554b3f8 GM |
441 | (defvar report-emacs-bug-bug-alist nil) |
442 | (make-variable-buffer-local 'report-emacs-bug-bug-alist) | |
443 | (defvar report-emacs-bug-choice-widget nil) | |
444 | (make-variable-buffer-local 'report-emacs-bug-choice-widget) | |
445 | ||
7dcd777e | 446 | (defun report-emacs-bug-create-existing-bugs-buffer (bugs keywords) |
614316a7 TH |
447 | (switch-to-buffer (get-buffer-create "*Existing Emacs Bugs*")) |
448 | (setq buffer-read-only t) | |
449 | (let ((inhibit-read-only t)) | |
450 | (erase-buffer) | |
e554b3f8 | 451 | (setq report-emacs-bug-bug-alist bugs) |
7dcd777e TH |
452 | (widget-insert (propertize (concat "Already known bugs (" |
453 | keywords "):\n\n") | |
454 | 'face 'bold)) | |
614316a7 | 455 | (if bugs |
e554b3f8 | 456 | (setq report-emacs-bug-choice-widget |
614316a7 | 457 | (apply 'widget-create 'radio-button-choice |
a140ec5f | 458 | :value (caar bugs) |
614316a7 TH |
459 | (let (items) |
460 | (dolist (bug bugs) | |
461 | (push (list | |
462 | 'url-link | |
f62f063d | 463 | :format (concat "Bug#" (number-to-string (nth 2 bug)) |
a140ec5f | 464 | ": " (cadr bug) "\n %[%v%]\n") |
614316a7 TH |
465 | ;; FIXME: Why is only the link of the |
466 | ;; active item clickable? | |
f62f063d | 467 | (car bug)) |
614316a7 TH |
468 | items)) |
469 | (nreverse items)))) | |
333f9019 | 470 | (widget-insert "No bugs matching your keywords found.\n")) |
614316a7 TH |
471 | (widget-insert "\n") |
472 | (widget-create 'push-button | |
473 | :notify (lambda (&rest ignore) | |
474 | ;; TODO: Do something! | |
475 | (message "Reporting new bug!")) | |
476 | "Report new bug") | |
477 | (when bugs | |
478 | (widget-insert " ") | |
479 | (widget-create 'push-button | |
480 | :notify (lambda (&rest ignore) | |
e554b3f8 | 481 | (let ((val (widget-value report-emacs-bug-choice-widget))) |
614316a7 TH |
482 | ;; TODO: Do something! |
483 | (message "Appending to bug %s!" | |
e554b3f8 | 484 | (nth 2 (assoc val report-emacs-bug-bug-alist))))) |
614316a7 TH |
485 | "Append to chosen bug")) |
486 | (widget-insert " ") | |
487 | (widget-create 'push-button | |
488 | :notify (lambda (&rest ignore) | |
489 | (kill-buffer)) | |
490 | "Quit reporting bug") | |
491 | (widget-insert "\n")) | |
492 | (use-local-map widget-keymap) | |
493 | (widget-setup) | |
494 | (goto-char (point-min))) | |
495 | ||
7dcd777e | 496 | (defun report-emacs-bug-parse-query-results (status keywords) |
614316a7 TH |
497 | (goto-char (point-min)) |
498 | (let (buglist) | |
499 | (while (re-search-forward "<a href=\"bugreport\\.cgi\\?bug=\\([[:digit:]]+\\)\">\\([^<]+\\)</a>" nil t) | |
500 | (let ((number (match-string 1)) | |
501 | (subject (match-string 2))) | |
502 | (when (not (string-match "^#" subject)) | |
503 | (push (list | |
504 | ;; first the bug URL | |
505 | (concat report-emacs-bug-tracker-url | |
506 | "bugreport.cgi?bug=" number) | |
507 | ;; then the subject and number | |
508 | subject (string-to-number number)) | |
509 | buglist)))) | |
7dcd777e | 510 | (report-emacs-bug-create-existing-bugs-buffer (nreverse buglist) keywords))) |
614316a7 | 511 | |
19c38752 | 512 | ;;;###autoload |
614316a7 TH |
513 | (defun report-emacs-bug-query-existing-bugs (keywords) |
514 | "Query for KEYWORDS at `report-emacs-bug-tracker-url', and return the result. | |
515 | The result is an alist with items of the form (URL SUBJECT NO)." | |
331460ac | 516 | (interactive "sBug keywords (comma separated): ") |
614316a7 TH |
517 | (url-retrieve (concat report-emacs-bug-tracker-url |
518 | "pkgreport.cgi?include=subject%3A" | |
519 | (replace-regexp-in-string "[[:space:]]+" "+" keywords) | |
520 | ";package=emacs") | |
7dcd777e | 521 | 'report-emacs-bug-parse-query-results (list keywords))) |
614316a7 | 522 | |
8e0ff8c8 ER |
523 | (provide 'emacsbug) |
524 | ||
c0274f38 | 525 | ;;; emacsbug.el ends here |