3421
|
1 ;;; reporter.el --- customizable bug reporting of lisp programs
|
3903
|
2 ;; Copyright (C) 1993 Free Software Foundation, Inc.
|
3421
|
3
|
|
4 ;; Author: 1993 Barry A. Warsaw, Century Computing Inc. <bwarsaw@cen.com>
|
|
5 ;; Maintainer: bwarsaw@cen.com
|
|
6 ;; Created: 19-Apr-1993
|
|
7 ;; Keywords: bug reports lisp
|
|
8
|
|
9 ;; This file is not yet part of GNU Emacs.
|
|
10 ;;
|
|
11 ;; This program is free software; you can redistribute it and/or modify
|
|
12 ;; it under the terms of the GNU General Public License as published by
|
|
13 ;; the Free Software Foundation; either version 2 of the License, or
|
|
14 ;; (at your option) any later version.
|
|
15 ;;
|
|
16 ;; This program is distributed in the hope that it will be useful,
|
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 ;; GNU General Public License for more details.
|
|
20 ;;
|
|
21 ;; You should have received a copy of the GNU General Public License
|
|
22 ;; along with this program; if not, write to the Free Software
|
|
23 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
24
|
|
25 ;; Introduction
|
|
26 ;; ============
|
|
27 ;; This program is for lisp package authors and is used to ease
|
|
28 ;; reporting of bugs. When invoked, reporter-submit-bug-report will
|
|
29 ;; set up a mail buffer with the appropriate bug report address,
|
|
30 ;; including a lisp expression the maintainer of the package can use
|
|
31 ;; to completely reproduce the environment in which the bug was
|
|
32 ;; observed (e.g. by using eval-last-sexp). This package is especially
|
|
33 ;; useful for my development of c++-mode.el, which is highly dependent
|
|
34 ;; on its configuration variables.
|
|
35 ;;
|
|
36 ;; Do a "C-h f reporter-submit-bug-report" for more information.
|
|
37 ;; Here's an example usage:
|
|
38 ;;
|
|
39 ;; (defconst mypkg-version "9.801")
|
|
40 ;; (defconst mypkg-maintainer-address "mypkg-help@foo.com")
|
|
41 ;; (defun mypkg-submit-bug-report ()
|
|
42 ;; "Submit via mail a bug report on mypkg"
|
|
43 ;; (interactive)
|
|
44 ;; (require 'reporter)
|
|
45 ;; (and (y-or-n-p "Do you really want to submit a report on mypkg? ")
|
|
46 ;; (reporter-submit-bug-report
|
|
47 ;; mypkg-maintainer-address
|
|
48 ;; (concat "mypkg.el " mypkg-version)
|
|
49 ;; (list 'mypkg-variable-1
|
|
50 ;; 'mypkg-variable-2
|
|
51 ;; ;; ...
|
|
52 ;; 'mypkg-variable-last))))
|
|
53
|
|
54 ;; Mailing List
|
|
55 ;; ============
|
|
56 ;; I've set up a mailing list to report bugs or suggest enhancements,
|
|
57 ;; etc. This list's intended audience is elisp package authors who are
|
|
58 ;; using reporter and want to stay current with releases. Here are the
|
3589
|
59 ;; relevant addresses:
|
3421
|
60 ;;
|
|
61 ;; Administrivia: reporter-request@anthem.nlm.nih.gov
|
|
62 ;; Submissions: reporter@anthem.nlm.nih.gov
|
|
63
|
|
64 ;; LCD Archive Entry:
|
|
65 ;; reporter|Barry A. Warsaw|warsaw@cen.com|
|
|
66 ;; Customizable bug reporting of lisp programs.|
|
|
67 ;; 1993/05/22 00:29:49|1.18|~/misc/reporter.el.Z|
|
|
68
|
|
69 ;;; Code:
|
|
70
|
|
71
|
|
72 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
|
73 ;; user defined variables
|
|
74
|
|
75 (defvar reporter-mailer 'mail
|
|
76 "*Mail package to use to generate bug report buffer.")
|
|
77
|
|
78 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
79 ;; end of user defined variables
|
|
80
|
3903
|
81 (defvar reporter-eval-buffer nil
|
|
82 "Buffer to retrieve variable's value from.
|
|
83 This is necessary to properly support the printing of buffer-local
|
|
84 variables. Current buffer will always be the mail buffer being
|
|
85 composed.")
|
3421
|
86
|
|
87 (defun reporter-dump-variable (varsym)
|
|
88 "Pretty-print the value of the variable in symbol VARSYM."
|
3903
|
89 (let ((val (save-excursion
|
|
90 (set-buffer reporter-eval-buffer)
|
|
91 (eval varsym)))
|
3421
|
92 (sym (symbol-name varsym))
|
|
93 (print-escape-newlines t))
|
|
94 (insert " " sym " "
|
|
95 (cond
|
|
96 ((memq val '(t nil)) "")
|
|
97 ((listp val) "'")
|
|
98 ((symbolp val) "'")
|
|
99 (t ""))
|
|
100 (prin1-to-string val)
|
|
101 "\n")))
|
|
102
|
|
103 (defun reporter-dump-state (pkgname varlist pre-hooks post-hooks)
|
|
104 "Dump the state of the mode specific variables.
|
|
105 PKGNAME contains the name of the mode as it will appear in the bug
|
|
106 report (you must explicitly concat any version numbers).
|
|
107
|
|
108 VARLIST is the list of variables to dump. Each element in VARLIST can
|
|
109 be a variable symbol, or a cons cell. If a symbol, this will be
|
|
110 passed to `reporter-dump-variable' for insertion into the mail buffer.
|
|
111 If a cons cell, the car must be a variable symbol and the cdr must be
|
|
112 a function which will be `funcall'd with the symbol. Use this to write
|
|
113 your own custom variable value printers for specific variables.
|
|
114
|
3903
|
115 Note that the global variable `reporter-eval-buffer' will be bound to
|
|
116 the buffer in which `reporter-submit-bug-report' was invoked. If you
|
|
117 want to print the value of a buffer local variable, you should wrap
|
|
118 the `eval' call in your custom printer inside a `set-buffer' (and
|
|
119 probably a `save-excursion'). `reporter-dump-variable' handles this
|
|
120 properly.
|
|
121
|
3421
|
122 PRE-HOOKS is run after the emacs-version and PKGNAME are inserted, but
|
|
123 before the VARLIST is dumped. POST-HOOKS is run after the VARLIST is
|
|
124 dumped."
|
|
125 (let ((buffer (current-buffer)))
|
|
126 (set-buffer buffer)
|
|
127 (insert "Emacs : " (emacs-version) "\nPackage: " pkgname "\n")
|
|
128 (run-hooks 'pre-hooks)
|
|
129 (insert "\ncurrent state:\n==============\n(setq\n")
|
|
130 (mapcar
|
|
131 (function
|
|
132 (lambda (varsym-or-cons-cell)
|
|
133 (let ((varsym (or (car-safe varsym-or-cons-cell)
|
|
134 varsym-or-cons-cell))
|
|
135 (printer (or (cdr-safe varsym-or-cons-cell)
|
|
136 'reporter-dump-variable)))
|
|
137 (funcall printer varsym)
|
|
138 )))
|
|
139 varlist)
|
|
140 (insert " )\n")
|
|
141 (run-hooks 'post-hooks)
|
|
142 ))
|
|
143
|
|
144 (defun reporter-submit-bug-report
|
|
145 (address pkgname varlist &optional pre-hooks post-hooks salutation)
|
|
146 "Submit a bug report via mail.
|
|
147
|
|
148 ADDRESS is the email address for the package's maintainer. PKGNAME is
|
|
149 the name of the mode (you must explicitly concat any version numbers).
|
|
150 VARLIST is the list of variables to dump (do a `\\[describe-function] reporter-dump-state'
|
|
151 for details). Optional PRE-HOOKS and POST-HOOKS are passed to
|
|
152 `reporter-dump-state'. Optional SALUTATION is inserted at the top of the
|
3589
|
153 mail buffer, and point is left after the salutation.
|
3421
|
154
|
|
155 The mailer used is described in the variable `reporter-mailer'."
|
|
156
|
3903
|
157 (let ((reporter-eval-buffer (current-buffer))
|
3421
|
158 (mailbuf (progn (call-interactively reporter-mailer)
|
|
159 (current-buffer))))
|
|
160 (require 'sendmail)
|
3903
|
161 (pop-to-buffer reporter-eval-buffer)
|
3421
|
162 (pop-to-buffer mailbuf)
|
|
163 (goto-char (point-min))
|
|
164 ;; different mailers use different separators, some may not even
|
|
165 ;; use m-h-s, but sendmail.el stuff must have m-h-s bound.
|
|
166 (let ((mail-header-separator
|
|
167 (save-excursion
|
|
168 (re-search-forward
|
|
169 (concat
|
|
170 "^\\(" ;beginning of line
|
|
171 (mapconcat
|
|
172 'identity
|
|
173 (list "[\t ]*" ;simple SMTP form
|
|
174 "-+" ;mh-e form
|
|
175 (regexp-quote
|
|
176 mail-header-separator)) ;sendmail.el form
|
|
177 "\\|") ;or them together
|
|
178 "\\)$") ;end of line
|
|
179 nil
|
|
180 'move) ;search for and move
|
|
181 (buffer-substring (match-beginning 0) (match-end 0)))))
|
|
182 (mail-position-on-field "to")
|
|
183 (insert address)
|
|
184 (mail-position-on-field "subject")
|
|
185 (insert "Report on package " pkgname)
|
|
186 (re-search-forward mail-header-separator (point-max) 'move)
|
|
187 (forward-line 1)
|
|
188 (and salutation (insert "\n" salutation "\n\n"))
|
|
189 (set-mark (point)) ;user should see mark change
|
|
190 (insert "\n\n")
|
|
191 (reporter-dump-state pkgname varlist pre-hooks post-hooks)
|
|
192 (exchange-point-and-mark))
|
|
193 (let* ((sendkey "C-c C-c") ;can this be generalized like below?
|
|
194 (killkey-whereis (where-is-internal 'kill-buffer nil t))
|
|
195 (killkey (if killkey-whereis
|
|
196 (key-description killkey-whereis)
|
|
197 "M-x kill-buffer")))
|
|
198 (message "Please type in your report. Hit %s to send, %s to abort."
|
|
199 sendkey killkey))
|
|
200 ))
|
|
201
|
|
202 ;; this is useful
|
|
203 (provide 'reporter)
|
|
204
|
|
205 ;;; reporter.el ends here
|