comparison lisp/mail/reporter.el @ 10227:31d062ac1d2f

(reporter-submit-bug-report): Set up for status messages. Use mail-text to position point to the body of the message. (reporter-beautify-list): Complete rewrite. Optional nocompact-p argument. (reporter-dump-variable): Invert the test and passing of compact-p argument to reporter-beautify-list. List values are not printed as defuns or function calls. Updated package list. (reporter-lisp-indent): New defun. (reporter-dont-compact-list) (reporter-status-message, reporter-status-count): New variables. (reporter-update-status, reporter-beautify-list) reporter-dump-variable): Now smarter about formating variables with list values. Checks the value of reporter-dont-compact-list.
author Richard M. Stallman <rms@gnu.org>
date Fri, 23 Dec 1994 17:33:21 +0000
parents 2c26fd09c101
children db8f78f3f9a9
comparison
equal deleted inserted replaced
10226:1817c5332316 10227:31d062ac1d2f
1 ;;; reporter.el --- customizable bug reporting of lisp programs 1 ;;; reporter.el --- customizable bug reporting of lisp programs
2 2
3 ;; Author: 1993 Barry A. Warsaw, Century Computing Inc. <bwarsaw@cen.com> 3 ;; Author: 1993 Barry A. Warsaw <bwarsaw@cnri.reston.va.us>
4 ;; Maintainer: bwarsaw@cen.com 4 ;; Maintainer: bwarsaw@cnri.reston.va.us
5 ;; Created: 19-Apr-1993 5 ;; Created: 19-Apr-1993
6 ;; Version: 2.12 6 ;; Version: 2.21
7 ;; Last Modified: 1994/07/06 14:55:39 7 ;; Last Modified: 1994/11/29 16:13:50
8 ;; Keywords: bug reports lisp 8 ;; Keywords: bug reports lisp
9 9
10 ;; Copyright (C) 1993 1994 Barry A. Warsaw 10 ;; Copyright (C) 1993 1994 Barry A. Warsaw
11 ;; Copyright (C) 1993 1994 Free Software Foundation, Inc. 11 ;; Copyright (C) 1993 1994 Free Software Foundation, Inc.
12 12
33 ;; This program is for lisp package authors and can be used to ease 33 ;; This program is for lisp package authors and can be used to ease
34 ;; reporting of bugs. When invoked, reporter-submit-bug-report will 34 ;; reporting of bugs. When invoked, reporter-submit-bug-report will
35 ;; set up a mail buffer with the appropriate bug report address, 35 ;; set up a mail buffer with the appropriate bug report address,
36 ;; including a lisp expression the maintainer of the package can eval 36 ;; including a lisp expression the maintainer of the package can eval
37 ;; to completely reproduce the environment in which the bug was 37 ;; to completely reproduce the environment in which the bug was
38 ;; observed (e.g. by using eval-last-sexp). This package proved especially 38 ;; observed (e.g. by using eval-last-sexp). This package proved
39 ;; useful during my development of cc-mode.el, which is highly dependent 39 ;; especially useful during my development of cc-mode.el, which is
40 ;; on its configuration variables. 40 ;; highly dependent on its configuration variables.
41 ;; 41 ;;
42 ;; Do a "C-h f reporter-submit-bug-report" for more information. 42 ;; Do a "C-h f reporter-submit-bug-report" for more information.
43 ;; Here's an example usage: 43 ;; Here's an example usage:
44 ;; 44 ;;
45 ;;(defconst mypkg-version "9.801") 45 ;;(defconst mypkg-version "9.801")
54 ;; (list 'mypkg-variable-1 54 ;; (list 'mypkg-variable-1
55 ;; 'mypkg-variable-2 55 ;; 'mypkg-variable-2
56 ;; ;; ... 56 ;; ;; ...
57 ;; 'mypkg-variable-last))) 57 ;; 'mypkg-variable-last)))
58 58
59 ;; Major differences since version 1:
60 ;; ==================================
61 ;; * More robust in the face of void variables
62 ;; * New interface controlling variable reporter-prompt-for-summary-p
63 ;; * pretty-printing of lists!
64
65
66 ;; Mailing List 59 ;; Mailing List
67 ;; ============ 60 ;; ============
68 ;; I've set up a mailing list to report bugs or suggest enhancements, 61 ;; I've set up a mailing list to report bugs or suggest enhancements,
69 ;; etc. This list's intended audience is elisp package authors who are 62 ;; etc. This list's intended audience is elisp package authors who are
70 ;; using reporter and want to stay current with releases. Here are the 63 ;; using reporter and want to stay current with releases. Here are the
71 ;; relevent addresses: 64 ;; relevent addresses:
72 ;; 65 ;;
73 ;; Administrivia: reporter-request@anthem.nlm.nih.gov 66 ;; Administrivia: reporter-request@anthem.nlm.nih.gov
74 ;; Submissions: reporter@anthem.nlm.nih.gov 67 ;; Submissions: reporter@anthem.nlm.nih.gov
75 68
69 ;; Packages that currently use reporter are: cc-mode, supercite, elp,
70 ;; tcl, ediff, crypt, vm, edebug, archie, and efs. If you know of
71 ;; others, please email me!
72
76 ;; LCD Archive Entry: 73 ;; LCD Archive Entry:
77 ;; reporter|Barry A. Warsaw|bwarsaw@cen.com| 74 ;; reporter|Barry A. Warsaw|bwarsaw@cnri.reston.va.us|
78 ;; Customizable bug reporting of lisp programs.| 75 ;; Customizable bug reporting of lisp programs.|
79 ;; 1994/07/06 14:55:39|2.12|~/misc/reporter.el.Z| 76 ;; 1994/11/29 16:13:50|2.21|~/misc/reporter.el.Z|
80 77
81 ;;; Code: 78 ;;; Code:
82 79
83 80
84 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv 81 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
86 83
87 (defvar reporter-mailer '(vm-mail mail) 84 (defvar reporter-mailer '(vm-mail mail)
88 "*Mail package to use to generate bug report buffer. 85 "*Mail package to use to generate bug report buffer.
89 This can either be a function symbol or a list of function symbols. 86 This can either be a function symbol or a list of function symbols.
90 If a list, it tries to use each specified mailer in order until an 87 If a list, it tries to use each specified mailer in order until an
91 existing one is found.") 88 existing one is found.
89
90 MH-E users may want to use `mh-smail'.")
92 91
93 (defvar reporter-prompt-for-summary-p nil 92 (defvar reporter-prompt-for-summary-p nil
94 "Interface variable controlling prompting for problem summary. 93 "Interface variable controlling prompting for problem summary.
95 When non-nil, `reporter-submit-bug-report' prompts the user for a 94 When non-nil, `reporter-submit-bug-report' prompts the user for a
96 brief summary of the problem, and puts this summary on the Subject: 95 brief summary of the problem, and puts this summary on the Subject:
99 Default behavior is to not prompt (i.e. nil). If you want reporter to 98 Default behavior is to not prompt (i.e. nil). If you want reporter to
100 prompt, you should `let' bind this variable to t before calling 99 prompt, you should `let' bind this variable to t before calling
101 `reporter-submit-bug-report'. Note that this variable is not 100 `reporter-submit-bug-report'. Note that this variable is not
102 buffer-local so you should never just `setq' it.") 101 buffer-local so you should never just `setq' it.")
103 102
103 (defvar reporter-dont-compact-list nil
104 "Interface variable controlling compating of list values.
105 When non-nil, this must be a list of variable symbols. When a
106 variable containing a list value is formatted in the bug report mail
107 buffer, it normally is compacted so that its value fits one the fewest
108 number of lines. If the variable's symbol appears in this list, its
109 value is printed in a more verbose style, specifically, one elemental
110 sexp per line.
111
112 Note that this variable is not buffer-local so you should never just
113 `setq' it. If you want to changes its default value, you should `let'
114 bind it.")
104 115
105 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 116 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106 ;; end of user defined variables 117 ;; end of user defined variables
107 118
108 (defvar reporter-eval-buffer nil 119 (defvar reporter-eval-buffer nil
109 "Buffer to retrieve variable's value from. 120 "Buffer to retrieve variable's value from.
110 This is necessary to properly support the printing of buffer-local 121 This is necessary to properly support the printing of buffer-local
111 variables. Current buffer will always be the mail buffer being 122 variables. Current buffer will always be the mail buffer being
112 composed.") 123 composed.")
113 124
114 (defconst reporter-version "2.12" 125 (defconst reporter-version "2.21"
115 "Reporter version number.") 126 "Reporter version number.")
116 127
117 (defvar reporter-initial-text nil 128 (defvar reporter-initial-text nil
118 "The automatically created initial text of a bug report.") 129 "The automatically created initial text of a bug report.")
119 (make-variable-buffer-local 'reporter-initial-text) 130 (make-variable-buffer-local 'reporter-initial-text)
120 131
121
122 132
133 (defvar reporter-status-message nil)
134 (defvar reporter-status-count nil)
135
136 (defun reporter-update-status ()
137 ;; periodically output a status message
138 (if (zerop (% reporter-status-count 10))
139 (progn
140 (message reporter-status-message)
141 (setq reporter-status-message (concat reporter-status-message "."))))
142 (setq reporter-status-count (1+ reporter-status-count)))
143
144
145 (defun reporter-beautify-list (maxwidth compact-p)
146 ;; pretty print a list
147 (reporter-update-status)
148 (let (linebreak indent-enclosing-p indent-p here)
149 (condition-case nil ;loop exit
150 (progn
151 (down-list 1)
152 (setq indent-enclosing-p t)
153 (while t
154 (setq here (point))
155 (forward-sexp 1)
156 (if (<= maxwidth (current-column))
157 (if linebreak
158 (progn
159 (goto-char linebreak)
160 (newline-and-indent)
161 (setq linebreak nil))
162 (goto-char here)
163 (setq indent-p (reporter-beautify-list maxwidth compact-p))
164 (goto-char here)
165 (forward-sexp 1)
166 (if indent-p
167 (newline-and-indent))
168 t)
169 (if compact-p
170 (setq linebreak (point))
171 (newline-and-indent))
172 ))
173 t)
174 (error indent-enclosing-p))))
175
176 (defun reporter-lisp-indent (indent-point state)
177 ;; a better lisp indentation style for bug reporting
178 (save-excursion
179 (goto-char (1+ (nth 1 state)))
180 (current-column)))
181
123 (defun reporter-dump-variable (varsym mailbuf) 182 (defun reporter-dump-variable (varsym mailbuf)
124 ;; Pretty-print the value of the variable in symbol VARSYM. MAILBUF 183 ;; Pretty-print the value of the variable in symbol VARSYM. MAILBUF
125 ;; is the mail buffer being composed 184 ;; is the mail buffer being composed
185 (reporter-update-status)
126 (condition-case nil 186 (condition-case nil
127 (let ((val (save-excursion 187 (let ((val (save-excursion
128 (set-buffer reporter-eval-buffer) 188 (set-buffer reporter-eval-buffer)
129 (symbol-value varsym))) 189 (symbol-value varsym)))
130 (sym (symbol-name varsym)) 190 (sym (symbol-name varsym))
131 (print-escape-newlines t) 191 (print-escape-newlines t)
192 (maxwidth (1- (window-width)))
132 (here (point))) 193 (here (point)))
133 (insert " " sym " " 194 (insert " " sym " "
134 (cond 195 (cond
135 ((memq val '(t nil)) "") 196 ((memq val '(t nil)) "")
136 ((listp val) "'") 197 ((listp val) "'")
137 ((symbolp val) "'") 198 ((symbolp val) "'")
138 (t "")) 199 (t ""))
139 (prin1-to-string val)) 200 (prin1-to-string val))
201 (lisp-indent-line)
140 ;; clean up lists, but only if the line as printed was long 202 ;; clean up lists, but only if the line as printed was long
141 ;; enough to wrap 203 ;; enough to wrap
142 (if (and (listp val) 204 (if (and val ;nil is a list, but short
143 (< (window-width) (current-column))) 205 (listp val)
206 (<= maxwidth (current-column)))
144 (save-excursion 207 (save-excursion
145 (goto-char here) 208 (let ((compact-p (not (memq varsym reporter-dont-compact-list)))
146 ;; skip past the symbol name 209 (lisp-indent-function 'reporter-lisp-indent))
147 (down-list 1) 210 (goto-char here)
148 (condition-case nil ; actual loop exit 211 (reporter-beautify-list maxwidth compact-p))))
149 (while t
150 (forward-sexp 1)
151 (insert "\n")
152 ;; if the sexp is longer than a single line then
153 ;; fill it to fill-column
154 (if (< (window-width)
155 (save-excursion
156 (forward-char -1)
157 (current-column)))
158 (let (stop)
159 (unwind-protect
160 (setq stop (point-marker))
161 (forward-line -1)
162 (fill-region (point) (progn (end-of-line)
163 (point)))
164 ;; consume extra newline left by fill-region
165 (delete-char 1)
166 (goto-char stop))
167 (set-marker stop nil)))
168 (lisp-indent-line))
169 (error nil))))
170 (insert "\n")) 212 (insert "\n"))
171 (void-variable 213 (void-variable
172 (save-excursion 214 (save-excursion
173 (set-buffer mailbuf) 215 (set-buffer mailbuf)
174 (mail-position-on-field "X-Reporter-Void-Vars-Found") 216 (mail-position-on-field "X-Reporter-Void-Vars-Found")
228 (printer (or (cdr-safe varsym-or-cons-cell) 270 (printer (or (cdr-safe varsym-or-cons-cell)
229 'reporter-dump-variable))) 271 'reporter-dump-variable)))
230 (funcall printer varsym mailbuf) 272 (funcall printer varsym mailbuf)
231 ))) 273 )))
232 varlist) 274 varlist)
233 (insert ")\n") 275 (lisp-indent-line)
234 (beginning-of-defun) 276 (insert ")\n"))
235 (indent-sexp))
236 (insert-buffer elbuf)) 277 (insert-buffer elbuf))
237 (error 278 (error
238 (insert "State could not be dumped due to the following error:\n\n" 279 (insert "State could not be dumped due to the following error:\n\n"
239 (format "%s" fault) 280 (format "%s" fault)
240 "\n\nYou should still send this bug report.")))) 281 "\n\nYou should still send this bug report."))))
277 318
278 ;; The mailer used is described in the variable `reporter-mailer'. 319 ;; The mailer used is described in the variable `reporter-mailer'.
279 (let ((reporter-eval-buffer (current-buffer)) 320 (let ((reporter-eval-buffer (current-buffer))
280 final-resting-place 321 final-resting-place
281 after-sep-pos 322 after-sep-pos
323 (reporter-status-message "Formatting bug report buffer...")
324 (reporter-status-count 0)
282 (problem (and reporter-prompt-for-summary-p 325 (problem (and reporter-prompt-for-summary-p
283 (read-string "(Very) brief summary of problem: "))) 326 (read-string "(Very) brief summary of problem: ")))
284 (mailbuf 327 (mailbuf
285 (progn 328 (progn
286 (call-interactively 329 (call-interactively
311 ;; insert problem summary if available 354 ;; insert problem summary if available
312 (if (and reporter-prompt-for-summary-p problem pkgname) 355 (if (and reporter-prompt-for-summary-p problem pkgname)
313 (progn 356 (progn
314 (mail-position-on-field "subject") 357 (mail-position-on-field "subject")
315 (insert pkgname "; " problem))) 358 (insert pkgname "; " problem)))
316 (re-search-forward mail-header-separator (point-max) 'move) 359 ;; move point to the body of the message
360 (mail-text)
317 (forward-line 1) 361 (forward-line 1)
318 (setq after-sep-pos (point)) 362 (setq after-sep-pos (point))
319 (and salutation (insert "\n" salutation "\n\n")) 363 (and salutation (insert "\n" salutation "\n\n"))
320 (unwind-protect 364 (unwind-protect
321 (progn 365 (progn