1 ;;; nxhtml-bug.el --- Reporting nXhtml bugs
3 ;; Author: Lennar Borgman
5 ;; Created: Wed Mar 07 15:57:15 2007
7 ;; Lxast-Updated: Wed Mar 07 16:00:22 2007 (3600 +0100)
11 ;; Fxeatures that might be required by this library:
15 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
28 ;; This program is free software; you can redistribute it and/or modify
29 ;; it under the terms of the GNU General Public License as published by
30 ;; the Free Software Foundation; either version 2, or (at your option)
33 ;; This program is distributed in the hope that it will be useful,
34 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
35 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 ;; GNU General Public License for more details.
38 ;; You should have received a copy of the GNU General Public License
39 ;; along with this program; see the file COPYING. If not, write to the
40 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
41 ;; Boston, MA 02111-1307, USA.
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47 (eval-when-compile (require 'nxhtml-menu nil t))
52 (autoload 'report-emacs-bug-info "emacsbug" "Go to the Info node on reporting Emacs bugs." t)
54 (defvar nxhtml-report-bug-orig-text nil
55 "The automatically-created initial text of bug report.")
57 (defvar nxhtml-report-bug-no-confirmation nil
58 "*If non-nil, suppress the confirmations asked for the sake of novice users.")
60 (defvar nxhtml-report-bug-no-explanations nil
61 "*If non-nil, suppress the explanations given when reporting bugs.")
63 ;; (defvar nxhtml-bug-launchpad-mode-map
64 ;; (let ((map (make-sparse-keymap)))
65 ;; (define-key map [(control ?c) (control ?c)] 'nxhtml-bug-maybe-to-launchpad)
68 ;; (define-minor-mode nxhtml-bug-launchpad-mode
69 ;; "Changes C-c C-c to ask to report on Launchpad."
71 ;; :keymap 'nxhtml-bug-launchpad-mode-map
74 ;; (defun nxhtml-bug-maybe-to-launchpad ()
76 ;; (if (y-or-n-p "Do you want to report bug on Launchad (preferred): ")
77 ;; (browse-url "https://bugs.launchpad.net/nxhtml")
78 ;; (mail-send-and-exit)))
81 (defun nxhtml-report-bug ()
82 "Report a bug in nXhtml."
84 (with-output-to-temp-buffer (help-buffer)
85 (help-setup-xref (list #'nxhtml-report-bug) (interactive-p))
86 (with-current-buffer (help-buffer)
89 "A lot of things can interfere with nXhtml/MuMaMo to cause bugs.\n"
90 "Therefore when reporting a bug please try to describe\n"
91 "how to show it without your own Emacs initializations.\n"
92 "To do that start from")
93 (fill-region here (point))
94 (insert "\n\n M-x `emacs-Q-nxhtml'\n\n")
97 "If you want to find out if your initialization files interfere\n"
98 "then you can try the both test commands `nxhtmltest-run' and\n"
99 "`nxhtmltest-run-Q' and see if there is any difference.\n\n")
100 (fill-region here (point))
103 "You may also want to look at the installation part of the ")
104 (insert-text-button "The Quick Guide"
105 'action (lambda (btn)
110 (insert " or the file ")
113 'action (lambda (btn)
114 (find-file-other-window
115 (expand-file-name "../readme.txt"
117 (symbol-file 'nxhtml-report-bug))))))
119 (fill-region here (point))
122 "If you know Emacs lisp and are reporting a bug it would be nice "
123 "if you wrote a new unit test case.\n"
124 "Please see the file ")
125 (insert-text-button "nxhtmltest-suites.el"
126 'help-echo "Visit file"
127 'action (lambda (button)
128 (find-file (symbol-file 'nxhtmltest-run))))
129 (insert " for examples.\n\n")
130 (fill-region here (point))
133 "There are several ways to report a bug, use the links below:\n"
134 "- By visiting URL `https://bugs.launchpad.net/nxhtml'.\n")
138 (insert-text-button "email to Launchpad"
139 'help-echo "Send email to Launchpad bug system"
140 'action (lambda (button)
142 'nxhtml-report-bug-by-mail)))
146 " This requires PGP signing the email\n"
147 " and that you have told your PGP key to Launchpad.\n")
148 (fill-region here (point))
151 "- The above ways are best since the bug get into the database,\n"
152 " and it is easy to communicate about it, but if they does\n"
153 " not work for you please go to \n"
154 " URL `http://www.emacswiki.org/cgi-bin/wiki/NxhtmlMode'.\n")
155 (fill-region here (point))
158 (with-no-warnings (print-help-return-message)))))
160 (defun nxhtml-report-bug-by-mail (topic)
161 "Report a bug by mail.
162 Prompts for bug subject. Leaves you in an Emacs mail
163 buffer. However when you send the bug your normal mail client
164 will take over the job (with your help)."
165 (interactive (list (read-string "nXhtml Bug Subject: ")))
166 ;; If there are four numbers in emacs-version, this is a pretest
168 (require 'nxhtml-menu)
169 (let* ((pretest-p (string-match "\\..*\\..*\\." emacs-version))
170 (from-buffer (current-buffer))
171 ;;(reporting-address "lennart.borgman@gmail.com")
172 ;;(reporting-address "emacs-nxml-mode@yahoogroups.com")
173 (reporting-address "new@bugs.launchpad.net")
174 ;; Put these properties on semantically-void text.
175 (prompt-properties '(field nxhtml-bug-prompt
176 intangible but-helpful
178 user-point message-end-point)
179 (setq message-end-point
180 (with-current-buffer (get-buffer-create "*Messages*")
182 (compose-mail reporting-address
184 ;; The rest of this does not execute
185 ;; if the user was asked to confirm and said no.
189 (let ((signature (buffer-substring (point) (point-max))))
190 (delete-region (point) (point-max))
192 (backward-char (length signature)))
193 ;;(nxhtml-bug-launchpad-mode 1)
195 "\nThis is a bug report for nXhtml mode.\n")
196 (unless nxhtml-report-bug-no-explanations
197 ;; Insert warnings for novice users.
198 (when (string-match "nxml-mode" reporting-address)
199 (insert "This bug report will be sent to the nXhtml maintainers,\n")
201 (insert "not to your local site managers!\n")
202 (put-text-property pos (point) 'face 'highlight)))
203 (insert "\nPlease write in ")
206 (put-text-property pos (point) 'face 'highlight))
207 (insert " if possible, because the nXhtml maintainers
208 usually do not have translators to read other languages for them.\n\n")
210 (insert "Please describe exactly what actions triggered the bug\n"
211 "and the precise symptoms of the bug, preferrably starting\n"
212 "from `M-x emacs-Q-nxhtml'\n"
213 "(it may also be helpful to include an *EXAMPLE FILE*!).\n\n")
214 (add-text-properties (point) (save-excursion (mail-text) (point))
217 (setq user-point (point))
220 (insert "\n\nnXhtml version " nxhtml-menu:version ", " (emacs-version) "\n\n")
221 (insert (format "Major mode: %s\n"
222 (buffer-local-value 'mode-name from-buffer)))
224 (insert "Minor modes in effect:\n")
225 (dolist (mode minor-mode-list)
226 (and (boundp mode) (buffer-local-value mode from-buffer)
227 (insert (format " %s: %s\n" mode
228 (buffer-local-value mode from-buffer)))))
230 (let ((message-buf (get-buffer "*Messages*")))
233 (end-pos message-end-point))
234 (with-current-buffer message-buf
237 (setq beg-pos (point)))
238 (insert "\n\nRecent messages:\n")
239 (insert-buffer-substring message-buf beg-pos end-pos))))
240 ;; This is so the user has to type something
241 ;; in order to send easily.
242 (use-local-map (nconc (make-sparse-keymap) (current-local-map)))
243 (define-key (current-local-map) "\C-c\C-i" 'report-emacs-bug-info)
244 (unless nxhtml-report-bug-no-explanations
245 (with-output-to-temp-buffer "*Bug Help*"
246 (if (eq mail-user-agent 'sendmail-user-agent)
247 (princ (substitute-command-keys
248 "Type \\[mail-send-and-exit] to send the bug report.\n")))
249 (princ (substitute-command-keys
250 "Type \\[kill-buffer] RET to cancel (don't send it).\n"))
252 (princ (substitute-command-keys
253 "Type \\[report-emacs-bug-info] to visit in Info the Emacs Manual section
254 about when and how to write a bug report,
255 and what information to supply so that the bug can be fixed.
257 When there type SPC to scroll through this section and its subsections.
259 Please notice that you are now reporting a bug for nXhtml, not
260 Emacs itself, so everyting in that manual section might not
262 ;; Make it less likely people will send empty messages.
263 (make-local-variable 'mail-send-hook)
264 (add-hook 'mail-send-hook 'nxhtml-report-bug-hook)
266 (goto-char (point-max))
267 (skip-chars-backward " \t\n")
268 (make-local-variable 'nxhtml-report-bug-orig-text)
269 (setq nxhtml-report-bug-orig-text (buffer-substring (point-min) (point))))
270 (goto-char user-point)))
273 (defun nxhtml-report-bug-hook ()
276 (goto-char (point-max))
277 (skip-chars-backward " \t\n")
278 (if (and (= (- (point) (point-min))
279 (length nxhtml-report-bug-orig-text))
280 (equal (buffer-substring (point-min) (point))
281 nxhtml-report-bug-orig-text))
282 (error "No text entered in bug report")))
284 ;; Check the buffer contents and reject non-English letters.
286 (goto-char (point-min))
287 (skip-chars-forward "\0-\177")
289 (if (or nxhtml-report-bug-no-confirmation
290 (y-or-n-p "Convert non-ASCII letters to hexadecimal? "))
291 (while (progn (skip-chars-forward "\0-\177")
293 (let ((ch (following-char)))
295 (insert (format "=%02x" ch)))))))
297 ;; The last warning for novice users.
298 (if (or nxhtml-report-bug-no-confirmation
300 "Send this bug report to the nXhtml maintainers? "))
301 ;; Just send the current mail.
303 (goto-char (point-min))
304 (if (search-forward "To: ")
307 (delete-region pos (point))))
308 (kill-local-variable 'mail-send-hook)
309 (with-output-to-temp-buffer "*Bug Help*"
310 (princ (substitute-command-keys "\
311 You invoked the command nxhtml-report-bug,
312 but you decided not to mail the bug report to the nXhtml maintainer.
314 If you want to mail it to someone else instead,
315 please insert the proper e-mail address after \"To: \",
316 and send the mail again using \\[mail-send-and-exit].")))
317 (error "M-x nxhtml-report-bug was cancelled, please read *Bug Help* buffer"))
322 "Next line tells Launchpad bug system what this is. Don't change it!\n"
323 " affects nxhtml\n\n")
325 (let ((pos (1- (point))))
326 (while (setq pos (text-property-any pos (point-max)
327 'field 'nxhtml-bug-prompt))
328 (delete-region pos (field-end (1+ pos)))))))
330 (provide 'nxhtml-bug)
331 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
332 ;;; nxhtml-bug.el ends here