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