annotate lisp/utils/reporter.el @ 195:a2f645c6b9f8 r20-3b24

Import from CVS: tag r20-3b24
author cvs
date Mon, 13 Aug 2007 09:59:05 +0200
parents ac2d302a0011
children
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 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
96 ;; Package author interface variables
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defvar reporter-prompt-for-summary-p nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 "Interface variable controlling prompting for problem summary.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 When non-nil, `reporter-submit-bug-report' prompts the user for a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 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
102 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
103 string.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 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
106 prompt, you should `let' bind this variable before calling
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 `reporter-submit-bug-report'. Note that this variable is not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 buffer-local so you should never just `setq' it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defvar reporter-dont-compact-list nil
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
111 "Interface variable controlling compacting of list values.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 When non-nil, this must be a list of variable symbols. When a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 variable containing a list value is formatted in the bug report mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 buffer, it normally is compacted so that its value fits one the fewest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 number of lines. If the variable's symbol appears in this list, its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 value is printed in a more verbose style, specifically, one elemental
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 sexp per line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 Note that this variable is not buffer-local so you should never just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 `setq' it. If you want to changes its default value, you should `let'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 bind it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
123 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
124 ;; End of editable variables
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
126
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (defvar reporter-eval-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 "Buffer to retrieve variable's value from.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 This is necessary to properly support the printing of buffer-local
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 variables. Current buffer will always be the mail buffer being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 composed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 (defconst reporter-version "3.2"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 "Reporter version number.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (defvar reporter-initial-text nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "The automatically created initial text of a bug report.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (make-variable-buffer-local 'reporter-initial-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
140
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
142 ;; status feedback to the user
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (defvar reporter-status-message nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (defvar reporter-status-count nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (defun reporter-update-status ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; periodically output a status message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (if (zerop (% reporter-status-count 10))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (message reporter-status-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (setq reporter-status-message (concat reporter-status-message "."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (setq reporter-status-count (1+ reporter-status-count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
155 ;; dumping/pretty printing of values
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (defun reporter-beautify-list (maxwidth compact-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; pretty print a list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (reporter-update-status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (let (linebreak indent-enclosing-p indent-p here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (condition-case nil ;loop exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (down-list 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (setq indent-enclosing-p t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (while t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (setq here (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (if (<= maxwidth (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (if linebreak
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (goto-char linebreak)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (newline-and-indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (setq linebreak nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (goto-char here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (setq indent-p (reporter-beautify-list maxwidth compact-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (goto-char here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (if indent-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (newline-and-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (if compact-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (setq linebreak (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (newline-and-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (error indent-enclosing-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (defun reporter-lisp-indent (indent-point state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;; a better lisp indentation style for bug reporting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (goto-char (1+ (nth 1 state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defun reporter-dump-variable (varsym mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; Pretty-print the value of the variable in symbol VARSYM. MAILBUF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; is the mail buffer being composed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (reporter-update-status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (let ((val (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (set-buffer reporter-eval-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (symbol-value varsym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (sym (symbol-name varsym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (print-escape-newlines t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (maxwidth (1- (window-width)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (here (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (insert " " sym " "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ((memq val '(t nil)) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ((listp val) "'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ((symbolp val) "'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (t ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (prin1-to-string val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (lisp-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;; clean up lists, but only if the line as printed was long
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;; enough to wrap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (if (and val ;nil is a list, but short
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (listp val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (<= maxwidth (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (let ((compact-p (not (memq varsym reporter-dont-compact-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (lisp-indent-function 'reporter-lisp-indent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (goto-char here)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (reporter-beautify-list maxwidth compact-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (void-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (set-buffer mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (mail-position-on-field "X-Reporter-Void-Vars-Found")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (insert (symbol-name varsym) " ")))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
230 (error
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
231 (error ""))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defun reporter-dump-state (pkgname varlist pre-hooks post-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;; Dump the state of the mode specific variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;; 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
236 ;; report (you must explicitly concat any version numbers).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; VARLIST is the list of variables to dump. Each element in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;; VARLIST can be a variable symbol, or a cons cell. If a symbol,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;; this will be passed to `reporter-dump-variable' for insertion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; 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
242 ;; symbol and the cdr must be a function which will be `funcall'd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 ;; with arguments the symbol and the mail buffer being composed. Use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; this to write your own custom variable value printers for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; specific variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;; Note that the global variable `reporter-eval-buffer' will be bound to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 ;; the buffer in which `reporter-submit-bug-report' was invoked. If you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 ;; want to print the value of a buffer local variable, you should wrap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; the `eval' call in your custom printer inside a `set-buffer' (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 ;; probably a `save-excursion'). `reporter-dump-variable' handles this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 ;; properly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; PRE-HOOKS is run after the emacs-version and PKGNAME are inserted, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; before the VARLIST is dumped. POST-HOOKS is run after the VARLIST is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 ;; dumped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (let ((buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (insert "Emacs : " (emacs-version) "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (and pkgname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (insert "Package: " pkgname "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (run-hooks 'pre-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (if (not varlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (insert "\ncurrent state:\n==============\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; create an emacs-lisp-mode buffer to contain the output, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; we'll later insert into the mail buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (condition-case fault
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (let ((mailbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (elbuf (get-buffer-create " *tmp-reporter-buffer*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (set-buffer elbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (emacs-lisp-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (insert "(setq\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (lisp-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (lambda (varsym-or-cons-cell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (let ((varsym (or (car-safe varsym-or-cons-cell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 varsym-or-cons-cell))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (printer (or (cdr-safe varsym-or-cons-cell)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 'reporter-dump-variable)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (funcall printer varsym mailbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 varlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (lisp-indent-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (insert ")\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (insert-buffer elbuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (insert "State could not be dumped due to the following error:\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (format "%s" fault)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 "\n\nYou should still send this bug report."))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (run-hooks 'post-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (defun reporter-calculate-separator ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; returns the string regexp matching the mail separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 "^\\(" ;beginning of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (mapconcat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 'identity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (list "[\t ]*" ;simple SMTP form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 "-+" ;mh-e form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (regexp-quote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 mail-header-separator)) ;sendmail.el form
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 "\\|") ;or them together
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 "\\)$") ;end of line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 'move) ;search for and move
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (buffer-substring (match-beginning 0) (match-end 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
316
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
317 ;; Serves as an interface to `mail' (sendmail.el), but when the user
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
318 ;; answers "no" to discarding an unsent message, it gives an error.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (defun reporter-mail (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (or (apply 'mail args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (error "Bug report aborted")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
323 (defun reporter-compose-outgoing ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
324 ;; compose the outgoing mail buffer, and return the selected
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
325 ;; paradigm, with the current-buffer tacked onto the beginning of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
326 ;; the list.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
327 (let* ((agent mail-user-agent)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
328 (compose (get mail-user-agent 'composefunc)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
329 ;; 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
330 ;; protocol, otherwise we must signal an error.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
331 (if (not (and compose (fboundp compose)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
332 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
333 (setq agent 'sendmail-user-agent
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
334 compose (get agent 'composefunc))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
335 (if (not (and compose (fboundp compose)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
336 (error "Could not find a valid `mail-user-agent'.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
337 (ding)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
338 (message "`%s' is an invalid `mail-user-agent'; using `sendmail-user-agent'."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
339 mail-user-agent)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
340 )))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
341 (funcall compose)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
342 agent))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
343
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
344
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (defun reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (address pkgname varlist &optional pre-hooks post-hooks salutation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;; Submit a bug report via mail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;; ADDRESS is the email address for the package's maintainer. PKGNAME is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 ;; the name of the mode (you must explicitly concat any version numbers).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;; VARLIST is the list of variables to dump (see `reporter-dump-state'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ;; for details). Optional PRE-HOOKS and POST-HOOKS are passed to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 ;; `reporter-dump-state'. Optional SALUTATION is inserted at the top of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 ;; mail buffer, and point is left after the salutation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;; This function will prompt for a summary if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 ;; reporter-prompt-for-summary-p is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
360 ;; The mailer used is described in by the variable `mail-user-agent'.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (let ((reporter-eval-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 final-resting-place
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 after-sep-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (reporter-status-message "Formatting bug report buffer...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (reporter-status-count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (problem (and reporter-prompt-for-summary-p
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
367 (read-string (if (stringp reporter-prompt-for-summary-p)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
368 reporter-prompt-for-summary-p
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
369 "(Very) brief summary of problem: "))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
370 (agent (reporter-compose-outgoing))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
371 (mailbuf (current-buffer))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
372 hookvar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
373 ;; do the work
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (require 'sendmail)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
375 ;; If mailbuf did not get made visible before, make it visible now.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
376 (let (same-window-buffer-names same-window-regexps)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
377 (pop-to-buffer mailbuf)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
378 ;; Just in case the original buffer is not visible now, bring it
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
379 ;; back somewhere
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
380 (display-buffer reporter-eval-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;; different mailers use different separators, some may not even
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
383 ;; use mail-header-separator, but sendmail.el stuff must have this
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
384 ;; variable bound.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (let ((mail-header-separator (reporter-calculate-separator)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (mail-position-on-field "to")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (insert address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;; insert problem summary if available
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (if (and reporter-prompt-for-summary-p problem pkgname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (mail-position-on-field "subject")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (insert pkgname "; " problem)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 ;; move point to the body of the message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (mail-text)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (setq after-sep-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (and salutation (insert "\n" salutation "\n\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (setq final-resting-place (point-marker))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (reporter-dump-state pkgname varlist pre-hooks post-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (goto-char final-resting-place))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (set-marker final-resting-place nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;; save initial text and set up the `no-empty-submission' hook.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
407 ;; This only works for mailers that support a pre-send hook, and
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
408 ;; for which the paradigm has a non-nil value for the `hookvar'
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
409 ;; key in its agent (i.e. sendmail.el's mail-send-hook).
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
410 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
411 (goto-char (point-max))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
412 (skip-chars-backward " \t\n")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
413 (setq reporter-initial-text (buffer-substring after-sep-pos (point))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
414 (if (setq hookvar (get agent 'hookvar))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (progn
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
416 (make-variable-buffer-local hookvar)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
417 (add-hook hookvar 'reporter-bug-hook)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
419 ;; compose the minibuf message and display this.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
420 (let* ((sendkey-whereis (where-is-internal
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
421 (get agent 'sendfunc) nil t))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
422 (abortkey-whereis (where-is-internal
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
423 (get agent 'abortfunc) nil t))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
424 (sendkey (if sendkey-whereis
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
425 (key-description sendkey-whereis)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
426 "C-c C-c")) ; TBD: BOGUS hardcode
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
427 (abortkey (if abortkey-whereis
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
428 (key-description abortkey-whereis)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
429 "M-x kill-buffer")) ; TBD: BOGUS hardcode
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
430 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
431 (message "Please enter your report. Type %s to send, %s to abort."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
432 sendkey abortkey))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (defun reporter-bug-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;; prohibit sending mail if empty bug report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (let ((after-sep-pos
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (re-search-forward (reporter-calculate-separator) (point-max) 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (skip-chars-backward " \t\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (if (and (= (- (point) after-sep-pos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (length reporter-initial-text))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (string= (buffer-substring after-sep-pos (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 reporter-initial-text))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
450 (error "Empty bug report cannot be sent."))
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
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
454
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (provide 'reporter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 ;;; reporter.el ends here