annotate lisp/utils/reporter.el @ 98:0d2f883870bc r20-1b1

Import from CVS: tag r20-1b1
author cvs
date Mon, 13 Aug 2007 09:13:56 +0200
parents ac2d302a0011
children a2f645c6b9f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; reporter.el --- customizable bug reporting of lisp programs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
3 ;; Copyright (C) 1993 1994 1995 1996 Free Software Foundation, Inc.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
5 ;; Author: 1993-1996 Barry A. Warsaw
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Created: 19-Apr-1993
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
7 ;; Version: 3.3
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
8 ;; Last Modified: 1996/07/02 00:39:09
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
9 ;; Keywords: maint mail tools
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
13 ;; XEmacs is free software; you can redistribute it and/or modify
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
18 ;; XEmacs is distributed in the hope that it will be useful,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
21 ;; GNU General Public License for more details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
24 ;; along with XEmacs; see the file COPYING. If not, write to the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
26 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
28 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Commentary:
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
31
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
32 ;; End User Interface
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
33 ;; ==================
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
34 ;; The variable `mail-user-agent' contains a symbol indicating which
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
35 ;; Emacs mail package end users would like to use to compose outgoing
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
36 ;; mail. See that variable for details.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
37
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
38 ;; Mail Package Interface
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
39 ;; ======================
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
40 ;; Mail package authors can configure reporter to support their
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
41 ;; package by calling the function `define-mail-user-agent' See that
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
42 ;; function for details.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
43
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
44 ;; Lisp Package Authors
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
45 ;; ====================
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
46 ;; Reporter was written primarily for Emacs Lisp package authors so
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
47 ;; that their users can easily report bugs. When invoked,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
48 ;; reporter-submit-bug-report will set up an outgoing mail buffer with
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
49 ;; the appropriate bug report address, including a lisp expression the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
50 ;; maintainer of the package can eval to completely reproduce the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
51 ;; environment in which the bug was observed (e.g. by using
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
52 ;; eval-last-sexp). This package proved especially useful during my
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
53 ;; development of cc-mode, which is highly dependent on its
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
54 ;; configuration variables.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; Do a "C-h f reporter-submit-bug-report" for more information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; Here's an example usage:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;(defconst mypkg-version "9.801")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;(defconst mypkg-maintainer-address "mypkg-help@foo.com")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;(defun mypkg-submit-bug-report ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; "Submit via mail a bug report on mypkg"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; (reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; mypkg-maintainer-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; (concat "mypkg.el " mypkg-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; (list 'mypkg-variable-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; 'mypkg-variable-2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; ;; ...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; 'mypkg-variable-last)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; Mailing List
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;; ============
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
74 ;; I've set up a Majordomo mailing list to report bugs or suggest
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
75 ;; enhancements, etc. This list's intended audience is elisp package
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
76 ;; authors who are using reporter and want to stay current with
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
77 ;; releases. Here are the relevant addresses:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
79 ;; Administrivia: reporter-request@python.org
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
80 ;; Submissions: reporter@python.org
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; Packages that currently use reporter are: cc-mode, supercite, elp,
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
83 ;; tcl, ediff, crypt++ (crypt), dired-x, rmailgen, mode-line, vm,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
84 ;; mh-e, edebug, archie, viper, w3-mode, framepop, hl319, hilit19,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
85 ;; pgp, eos, hm--html, efs.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
86 ;;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
87 ;; If you know of others, please email me!
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
92 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
93 ;; End user interface
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
94
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
95 ;; XEmacs -- don't autoload
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
96 (defvar mail-user-agent 'sendmail-user-agent
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
97 "*Your preference for a mail composition package.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
98 Various Emacs Lisp packages (e.g. reporter) require you to compose an
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
99 outgoing email message. As there are several such packages available
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
100 for Emacs, you can indicate your preference by setting this variable.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
101
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
102 Valid values currently are:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
104 'sendmail-user-agent -- use Emacs built-in Mail package
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
105 'vm-user-agent -- use Kyle Jones' VM package
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
106 'mh-e-user-agent -- use the Emacs interface to the MH mail system
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
108 Additional valid symbols may be available; check with the author of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
109 your package for details.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
110
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
111
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
112
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
113 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
114 ;; Package author interface variables
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (defvar reporter-prompt-for-summary-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 "Interface variable controlling prompting for problem summary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 When non-nil, `reporter-submit-bug-report' prompts the user for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 brief summary of the problem, and puts this summary on the Subject:
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 line. If this variable is a string, that string is used as the prompt
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
121 string.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 Default behavior is to not prompt (i.e. nil). If you want reporter to
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 prompt, you should `let' bind this variable before calling
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 `reporter-submit-bug-report'. Note that this variable is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 buffer-local so you should never just `setq' it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defvar reporter-dont-compact-list nil
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
129 "Interface variable controlling compacting of list values.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 When non-nil, this must be a list of variable symbols. When a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 variable containing a list value is formatted in the bug report mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 buffer, it normally is compacted so that its value fits one the fewest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 number of lines. If the variable's symbol appears in this list, its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 value is printed in a more verbose style, specifically, one elemental
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 sexp per line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 Note that this variable is not buffer-local so you should never just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 `setq' it. If you want to changes its default value, you should `let'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 bind it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
141 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
142 ;; End of editable variables
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
144
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defvar reporter-eval-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 "Buffer to retrieve variable's value from.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 This is necessary to properly support the printing of buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 variables. Current buffer will always be the mail buffer being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 composed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
151 (defconst reporter-version "3.2"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 "Reporter version number.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defvar reporter-initial-text nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "The automatically created initial text of a bug report.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (make-variable-buffer-local 'reporter-initial-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
158
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
160 ;; status feedback to the user
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (defvar reporter-status-message nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (defvar reporter-status-count nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defun reporter-update-status ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; periodically output a status message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (if (zerop (% reporter-status-count 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (message reporter-status-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (setq reporter-status-message (concat reporter-status-message "."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (setq reporter-status-count (1+ reporter-status-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
173 ;; dumping/pretty printing of values
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (defun reporter-beautify-list (maxwidth compact-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; pretty print a list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (reporter-update-status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (let (linebreak indent-enclosing-p indent-p here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (condition-case nil ;loop exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (down-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (setq indent-enclosing-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (setq here (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (if (<= maxwidth (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if linebreak
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (goto-char linebreak)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (newline-and-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (setq linebreak nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (goto-char here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (setq indent-p (reporter-beautify-list maxwidth compact-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (goto-char here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (if indent-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (newline-and-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (if compact-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (setq linebreak (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (newline-and-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (error indent-enclosing-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (defun reporter-lisp-indent (indent-point state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; a better lisp indentation style for bug reporting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (goto-char (1+ (nth 1 state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (defun reporter-dump-variable (varsym mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;; Pretty-print the value of the variable in symbol VARSYM. MAILBUF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;; is the mail buffer being composed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (reporter-update-status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (let ((val (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (set-buffer reporter-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (symbol-value varsym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (sym (symbol-name varsym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (maxwidth (1- (window-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (insert " " sym " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ((memq val '(t nil)) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ((listp val) "'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ((symbolp val) "'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (t ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (prin1-to-string val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (lisp-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; clean up lists, but only if the line as printed was long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;; enough to wrap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (if (and val ;nil is a list, but short
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (listp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (<= maxwidth (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (let ((compact-p (not (memq varsym reporter-dont-compact-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (lisp-indent-function 'reporter-lisp-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (goto-char here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (reporter-beautify-list maxwidth compact-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (void-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (set-buffer mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (mail-position-on-field "X-Reporter-Void-Vars-Found")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (insert (symbol-name varsym) " ")))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
248 (error
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
249 (error ""))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defun reporter-dump-state (pkgname varlist pre-hooks post-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;; Dump the state of the mode specific variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 ;; PKGNAME contains the name of the mode as it will appear in the bug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; report (you must explicitly concat any version numbers).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; VARLIST is the list of variables to dump. Each element in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 ;; VARLIST can be a variable symbol, or a cons cell. If a symbol,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; this will be passed to `reporter-dump-variable' for insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;; into the mail buffer. If a cons cell, the car must be a variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; symbol and the cdr must be a function which will be `funcall'd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; with arguments the symbol and the mail buffer being composed. Use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; this to write your own custom variable value printers for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;; specific variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;; Note that the global variable `reporter-eval-buffer' will be bound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; the buffer in which `reporter-submit-bug-report' was invoked. If you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; want to print the value of a buffer local variable, you should wrap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; the `eval' call in your custom printer inside a `set-buffer' (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;; probably a `save-excursion'). `reporter-dump-variable' handles this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;; properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; PRE-HOOKS is run after the emacs-version and PKGNAME are inserted, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; before the VARLIST is dumped. POST-HOOKS is run after the VARLIST is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;; dumped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (let ((buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (insert "Emacs : " (emacs-version) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (and pkgname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (insert "Package: " pkgname "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (run-hooks 'pre-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (if (not varlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (insert "\ncurrent state:\n==============\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ;; create an emacs-lisp-mode buffer to contain the output, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 ;; we'll later insert into the mail buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (condition-case fault
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (let ((mailbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (elbuf (get-buffer-create " *tmp-reporter-buffer*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (set-buffer elbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (emacs-lisp-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (insert "(setq\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (lisp-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (lambda (varsym-or-cons-cell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (let ((varsym (or (car-safe varsym-or-cons-cell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 varsym-or-cons-cell))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (printer (or (cdr-safe varsym-or-cons-cell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 'reporter-dump-variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (funcall printer varsym mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 varlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (lisp-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (insert ")\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (insert-buffer elbuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (insert "State could not be dumped due to the following error:\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (format "%s" fault)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 "\n\nYou should still send this bug report."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (run-hooks 'post-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (defun reporter-calculate-separator ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ;; returns the string regexp matching the mail separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 "^\\(" ;beginning of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (list "[\t ]*" ;simple SMTP form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 "-+" ;mh-e form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 mail-header-separator)) ;sendmail.el form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 "\\|") ;or them together
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 "\\)$") ;end of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 'move) ;search for and move
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (buffer-substring (match-beginning 0) (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
334
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
335 ;; Serves as an interface to `mail' (sendmail.el), but when the user
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
336 ;; answers "no" to discarding an unsent message, it gives an error.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (defun reporter-mail (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (or (apply 'mail args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (error "Bug report aborted")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
341 (defun reporter-compose-outgoing ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
342 ;; compose the outgoing mail buffer, and return the selected
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
343 ;; paradigm, with the current-buffer tacked onto the beginning of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
344 ;; the list.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
345 (let* ((agent mail-user-agent)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
346 (compose (get mail-user-agent 'composefunc)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
347 ;; Sanity check. If this fails then we'll try to use the SENDMAIL
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
348 ;; protocol, otherwise we must signal an error.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
349 (if (not (and compose (fboundp compose)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
350 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
351 (setq agent 'sendmail-user-agent
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
352 compose (get agent 'composefunc))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
353 (if (not (and compose (fboundp compose)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
354 (error "Could not find a valid `mail-user-agent'.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
355 (ding)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
356 (message "`%s' is an invalid `mail-user-agent'; using `sendmail-user-agent'."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
357 mail-user-agent)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
358 )))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
359 (funcall compose)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
360 agent))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
361
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
362
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (defun reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (address pkgname varlist &optional pre-hooks post-hooks salutation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; Submit a bug report via mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;; ADDRESS is the email address for the package's maintainer. PKGNAME is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;; the name of the mode (you must explicitly concat any version numbers).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ;; VARLIST is the list of variables to dump (see `reporter-dump-state'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 ;; for details). Optional PRE-HOOKS and POST-HOOKS are passed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;; `reporter-dump-state'. Optional SALUTATION is inserted at the top of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 ;; mail buffer, and point is left after the salutation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 ;; This function will prompt for a summary if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; reporter-prompt-for-summary-p is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
378 ;; The mailer used is described in by the variable `mail-user-agent'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (let ((reporter-eval-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 final-resting-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 after-sep-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (reporter-status-message "Formatting bug report buffer...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (reporter-status-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (problem (and reporter-prompt-for-summary-p
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
385 (read-string (if (stringp reporter-prompt-for-summary-p)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
386 reporter-prompt-for-summary-p
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
387 "(Very) brief summary of problem: "))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
388 (agent (reporter-compose-outgoing))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
389 (mailbuf (current-buffer))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
390 hookvar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
391 ;; do the work
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (require 'sendmail)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
393 ;; If mailbuf did not get made visible before, make it visible now.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
394 (let (same-window-buffer-names same-window-regexps)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
395 (pop-to-buffer mailbuf)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
396 ;; Just in case the original buffer is not visible now, bring it
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
397 ;; back somewhere
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
398 (display-buffer reporter-eval-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 ;; different mailers use different separators, some may not even
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
401 ;; use mail-header-separator, but sendmail.el stuff must have this
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
402 ;; variable bound.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (let ((mail-header-separator (reporter-calculate-separator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (mail-position-on-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (insert address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;; insert problem summary if available
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (if (and reporter-prompt-for-summary-p problem pkgname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (mail-position-on-field "subject")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (insert pkgname "; " problem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 ;; move point to the body of the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (mail-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (setq after-sep-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (and salutation (insert "\n" salutation "\n\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (setq final-resting-place (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (reporter-dump-state pkgname varlist pre-hooks post-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (goto-char final-resting-place))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (set-marker final-resting-place nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 ;; save initial text and set up the `no-empty-submission' hook.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
425 ;; This only works for mailers that support a pre-send hook, and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
426 ;; for which the paradigm has a non-nil value for the `hookvar'
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
427 ;; key in its agent (i.e. sendmail.el's mail-send-hook).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
428 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
429 (goto-char (point-max))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
430 (skip-chars-backward " \t\n")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
431 (setq reporter-initial-text (buffer-substring after-sep-pos (point))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
432 (if (setq hookvar (get agent 'hookvar))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (progn
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
434 (make-variable-buffer-local hookvar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
435 (add-hook hookvar 'reporter-bug-hook)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
437 ;; compose the minibuf message and display this.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
438 (let* ((sendkey-whereis (where-is-internal
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
439 (get agent 'sendfunc) nil t))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
440 (abortkey-whereis (where-is-internal
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
441 (get agent 'abortfunc) nil t))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
442 (sendkey (if sendkey-whereis
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
443 (key-description sendkey-whereis)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
444 "C-c C-c")) ; TBD: BOGUS hardcode
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
445 (abortkey (if abortkey-whereis
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
446 (key-description abortkey-whereis)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
447 "M-x kill-buffer")) ; TBD: BOGUS hardcode
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
448 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
449 (message "Please enter your report. Type %s to send, %s to abort."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
450 sendkey abortkey))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (defun reporter-bug-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;; prohibit sending mail if empty bug report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (let ((after-sep-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (re-search-forward (reporter-calculate-separator) (point-max) 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (skip-chars-backward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (if (and (= (- (point) after-sep-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (length reporter-initial-text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (string= (buffer-substring after-sep-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 reporter-initial-text))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
468 (error "Empty bug report cannot be sent."))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
472 ;; paradigm definitions
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
473 (defun define-mail-user-agent (symbol composefunc sendfunc
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
474 &optional abortfunc hookvar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
475 "Define a symbol appropriate for `mail-user-agent'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
476
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
477 SYMBOL can be any meaningful lisp symbol. It need not have a function
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
478 or variable definition, as it is only used for its property list.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
479 The property names are equivalent to the formal argument described
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
480 below (but in lower case). Additional properties can be placed on the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
481 symbol.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
482
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
483 COMPOSEFUNC is program callable function that composes an outgoing
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
484 mail message buffer. This function should set up the basics of the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
485 buffer without requiring user interaction. It should populate the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
486 standard mail headers, leaving the `to:' and `subject:' headers blank.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
487
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
488 SENDFUNC is the command a user would type to send the message.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
489
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
490 Optional ABORTFUNC is the command a user would type to abort the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
491 message. For mail packages that don't have a separate abort function,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
492 this can be `kill-buffer' (the equivalent of omitting this argument).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
493
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
494 Optional HOOKVAR is a hook variable that gets run before the message
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
495 is actually sent. Reporter will install `reporter-bug-hook' onto this
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
496 hook so that empty bug reports can be suppressed by raising an error.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
497 If not supplied, `mail-send-hook' will be used."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
498 (put symbol 'composefunc composefunc)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
499 (put symbol 'sendfunc sendfunc)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
500 (put symbol 'abortfunc (or abortfunc 'kill-buffer))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
501 (put symbol 'hookvar (or hookvar 'mail-send-hook)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
502
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
503 (define-mail-user-agent 'sendmail-user-agent
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
504 'reporter-mail 'mail-send-and-exit)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
505
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
506 (define-mail-user-agent 'vm-user-agent
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
507 'vm-mail 'vm-mail-send-and-exit)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
508
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
509 (define-mail-user-agent 'mh-e-user-agent
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
510 'mh-smail-batch 'mh-send-letter 'mh-fully-kill-draft
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
511 'mh-before-send-letter-hook)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
512
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
513
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (provide 'reporter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 ;;; reporter.el ends here