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