22609
|
1 ;;; feedmail.el --- assist other email packages to massage outgoing messages
|
|
2 ;;; This file is in the public domain.
|
|
3
|
|
4 ;;; Commentary:
|
|
5
|
|
6 ;; A replacement for parts of Emacs' sendmail.el (specifically,
|
|
7 ;; it's what handles your outgoing mail after you hit C-c C-c in mail
|
|
8 ;; mode). See below for a list of additional features, including the
|
|
9 ;; ability to queue messages for later sending. If you are using
|
|
10 ;; fakemail as a subprocess, you can switch to feedmail and eliminate
|
|
11 ;; the use of fakemail. feedmail works with recent versions of
|
|
12 ;; Emacs (mostly, but not exclusively, tested against 19.34 on
|
|
13 ;; Win95; some testing on 20.x) and XEmacs (tested with 20.4 and
|
|
14 ;; later betas). It probably no longer works with Emacs 18,
|
|
15 ;; though I haven't tried that in a long time. Sorry, no manual yet
|
|
16 ;; in this release. Look for one with the next release.
|
22513
|
17
|
|
18 ;; As far as I'm concerned, anyone can do anything they want with
|
|
19 ;; this specific piece of code. No warranty or promise of support is
|
|
20 ;; offered. This code is hereby released into the public domain.
|
|
21
|
|
22 ;; Author: Bill Carpenter <bill@bubblegum.net>, <bill@carpenter.ORG>
|
|
23 ;; Version: 8
|
|
24 ;; Keywords: email, queue, mail, sendmail, message, spray, smtp, draft
|
|
25 ;; Where: <URL:http://www.carpenter.org/feedmail/feedmail.html>
|
|
26 ;; Thanks: My thanks to the many people who have sent me suggestions
|
|
27 ;; and fixes over time, as well as those who have tested many beta
|
|
28 ;; iterations. Some are cited in comments in code fragments below,
|
|
29 ;; but that doesn't correlate well with the list of folks who have
|
|
30 ;; actually helped me along the way.
|
|
31
|
|
32 ;; If you use feedmail, I invite you to send me some email about it.
|
|
33 ;; I appreciate feedback about problems you find or suggestions for
|
|
34 ;; improvements or added features (even though I can't predict when
|
|
35 ;; I'll incorporate changes). It's also OK with me if you send me a
|
|
36 ;; note along the lines of "I use feedmail and find it useful" or "I
|
|
37 ;; tried feedmail and didn't find it useful, so I stopped using it".
|
|
38 ;;
|
|
39 ;; It is most useful, when sending a bug report, if you tell me what
|
22609
|
40 ;; version of Emacs you are using, what version of feedmail you are
|
22513
|
41 ;; using, and what versions of other email-related elisp packages you
|
|
42 ;; are using. If in doubt about any of that, send the bug report
|
|
43 ;; anyhow.
|
22609
|
44 ;;
|
22513
|
45 ;; =====
|
|
46 ;; A NOTE TO THOSE WHO WOULD CHANGE THIS CODE... Since it is PD,
|
|
47 ;; you're within your rights to do whatever you want. If you do
|
|
48 ;; publish a new version with your changes in it, please (1) insert
|
|
49 ;; lisp comments describing the changes, (2) insert lisp comments
|
|
50 ;; that clearly delimit where your changes are, (3) email me a copy
|
|
51 ;; (I can't always consistently follow the relevant usenet groups),
|
|
52 ;; and (4) use a version number that is based on the version you're
|
|
53 ;; changing along with something that indicates you changed it. For
|
|
54 ;; example,
|
|
55 ;;
|
|
56 ;; (defconst feedmail-patch-level "123")
|
|
57 ;; (defconst feedmail-patch-level "123-XYZ-mods")
|
|
58 ;;
|
|
59 ;; The point of the last item, of course, is to try to minimize
|
|
60 ;; confusion. Odds are good that if your idea makes sense to me that
|
|
61 ;; it will show up in some future version of feedmail, though it's
|
|
62 ;; hard to say when releases will tumble out.
|
|
63 ;; =====
|
|
64 ;;
|
|
65 ;; This file requires the mail-utils library.
|
|
66 ;;
|
|
67 ;; This file requires the smtpmail library if you use
|
|
68 ;; feedmail-buffer-to-smtpmail.
|
|
69 ;;
|
|
70 ;; This file requires the custom library. Unfortunately, there are
|
|
71 ;; two incompatible versions of the custom library. If you don't have
|
|
72 ;; custom or you have the old version, this file will still load and
|
|
73 ;; work properly. If you don't know what custom is all about and want
|
|
74 ;; to edit your user option elisp variables the old fashioned way,
|
|
75 ;; just imagine that all the "defcustom" stuff you see below is really
|
|
76 ;; "defvar", and ignore everthing else. For info about custom, see
|
|
77 ;; <URL:http://www.dina.kvl.dk/~abraham/custom/>.
|
|
78 ;;
|
|
79 ;; This code does in elisp a superset of the stuff that used to be done
|
|
80 ;; by the separate program "fakemail" for processing outbound email.
|
|
81 ;; In other words, it takes over after you hit "C-c C-c" in mail mode.
|
|
82 ;; By appropriate setting of options, you can still use "fakemail",
|
|
83 ;; or you can even revert to sendmail (which is not too popular
|
|
84 ;; locally). See the variables at the top of the elisp for how to
|
|
85 ;; achieve these effects (there are more features than in this bullet
|
|
86 ;; list, so trolling through the variable and function doc strings may
|
|
87 ;; be worth your while):
|
|
88 ;;
|
|
89 ;; --- you can park outgoing messages into a disk-based queue and
|
|
90 ;; stimulate sending them all later (handy for laptop users);
|
|
91 ;; there is also a queue for draft messages
|
|
92 ;;
|
|
93 ;; --- you can get one last look at the prepped outbound message and
|
|
94 ;; be prompted for confirmation
|
|
95 ;;
|
|
96 ;; --- removes BCC:/RESENT-BCC: headers after getting address info
|
|
97 ;;
|
|
98 ;; --- does smart filling of address headers
|
|
99 ;;
|
|
100 ;; --- calls a routine to process FCC: lines and removes them
|
|
101 ;;
|
|
102 ;; --- empty headers are removed
|
|
103 ;;
|
|
104 ;; --- can force FROM: or SENDER: line
|
|
105 ;;
|
|
106 ;; --- can generate a MESSAGE-ID: line
|
|
107 ;;
|
|
108 ;; --- can generate a DATE: line; the date can be the time the
|
|
109 ;; message was written or the time it is being sent
|
|
110 ;;
|
|
111 ;; --- strips comments from address info (both "()" and "<>" are
|
|
112 ;; handled via a call to mail-strip-quoted-names); the
|
|
113 ;; comments are stripped in the simplified address list given
|
|
114 ;; to a subprocess, not in the headers in the mail itself
|
|
115 ;; (they are left unchanged, modulo smart filling)
|
|
116 ;;
|
|
117 ;; --- error info is pumped into a normal buffer instead of the
|
|
118 ;; minibuffer
|
|
119 ;;
|
|
120 ;; --- just before the optional prompt for confirmation, lets you
|
|
121 ;; run a hook on the prepped message and simplified address
|
|
122 ;; list
|
|
123 ;;
|
|
124 ;; --- you can specify something other than /bin/mail for the
|
|
125 ;; subprocess
|
|
126 ;;
|
|
127 ;; --- you can generate/modify an X-MAILER: message header
|
|
128 ;;
|
|
129 ;; After a long list of options below, you will find the function
|
|
130 ;; feedmail-send-it. Hers's the best way to use the stuff in this
|
|
131 ;; file:
|
|
132 ;;
|
|
133 ;; Save this file as feedmail.el somewhere on your elisp
|
|
134 ;; loadpath; byte-compile it. Put the following lines somewhere in
|
|
135 ;; your ~/.emacs stuff:
|
|
136 ;;
|
|
137 ;; (setq send-mail-function 'feedmail-send-it)
|
|
138 ;; (autoload 'feedmail-send-it "feedmail")
|
|
139 ;;
|
|
140 ;; If you plan to use the queue stuff, also use this:
|
|
141 ;;
|
|
142 ;; (setq feedmail-enable-queue t)
|
|
143 ;; (autoload 'feedmail-run-the-queue "feedmail")
|
|
144 ;; (autoload 'feedmail-run-the-queue-no-prompts "feedmail")
|
|
145 ;; (setq auto-mode-alist (cons '("\\.fqm$" . mail-mode) auto-mode-alist))
|
|
146 ;;
|
22609
|
147 ;; If you are using the desktop.el library to restore your sessions, you might
|
22513
|
148 ;; like to add the suffix ".fqm" to the list of non-saved things via the variable
|
|
149 ;; desktop-files-not-to-save.
|
|
150 ;;
|
|
151 ;; If you are planning to call feedmail-queue-reminder from your .emacs or
|
|
152 ;; something similar, you might need this:
|
|
153 ;;
|
|
154 ;; (autoload 'feedmail-queue-reminder "feedmail")
|
|
155 ;;
|
|
156 ;; If you ever use rmail-resend and queue messages, you should do this:
|
|
157 ;;
|
|
158 ;; (setq feedmail-queue-alternative-mail-header-separator "")
|
|
159 ;;
|
|
160 ;; If you want to automatically spell-check messages, but not when sending
|
|
161 ;; them from the queue, you could do something like this:
|
|
162 ;;
|
|
163 ;; (autoload 'feedmail-mail-send-hook-splitter "feedmail")
|
|
164 ;; (add-hook 'mail-send-hook 'feedmail-mail-send-hook-splitter)
|
|
165 ;; (add-hook 'feedmail-mail-send-hook 'ispell-message)
|
|
166 ;;
|
|
167 ;; If you are using message-mode to compose and send mail, feedmail will
|
|
168 ;; probably work fine with that (someone else tested it and told me it worked).
|
|
169 ;; Follow the directions above, but make these adjustments instead:
|
|
170 ;;
|
|
171 ;; (setq message-send-mail-function 'feedmail-send-it)
|
|
172 ;; (add-hook 'message-mail-send-hook 'feedmail-mail-send-hook-splitter)
|
|
173 ;;
|
|
174 ;; I think the LCD is no longer being updated, but if it were, this
|
|
175 ;; would be a proper LCD record. There is an old version of
|
|
176 ;; feedmail.el in the LCD archive. It works but is missing a lot of
|
|
177 ;; features.
|
|
178 ;;
|
|
179 ;; LCD record:
|
|
180 ;; feedmail|Bill Carpenter|bill@bubblegum.net,bill@carpenter.ORG|Outbound mail queue handling|98-06-15|8|feedmail.el
|
|
181 ;;
|
|
182 ;; Change log:
|
|
183 ;; original, 31 March 1991
|
|
184 ;; patchlevel 1, 5 April 1991
|
|
185 ;; patchlevel 2, 24 May 1991
|
|
186 ;; 5-may-92 jwz Conditionalized calling expand-mail-aliases, since that
|
22609
|
187 ;; function doesn't exist in Lucid Emacs or when using
|
22513
|
188 ;; mail-abbrevs.el.
|
|
189 ;; patchlevel 3, 3 October 1996
|
|
190 ;; added queue stuff; still works in v18
|
|
191 ;; patchlevel 4, issued by someone else
|
|
192 ;; patchlevel 5, issued by someone else
|
|
193 ;; patchlevel 6, not issued as far as I know
|
|
194 ;; patchlevel 7, 20 May 1997
|
22609
|
195 ;; abandon futile support of Emacs 18 (sorry if that hurts you)
|
22513
|
196 ;; provide a DATE: header by default
|
|
197 ;; provide a default for generating MESSAGE-ID: header contents
|
|
198 ;; and use it by default (slightly changed API)
|
|
199 ;; return value from feedmail-run-the-queue
|
|
200 ;; new wrapper function feedmail-run-the-queue-no-prompts
|
|
201 ;; user-mail-address as default for FROM:
|
|
202 ;; properly deal with RESENT-{TO,CC,BCC}
|
|
203 ;; BCC and RESENT-* now included in smart filling
|
|
204 ;; limited support for a "drafts" directory
|
|
205 ;; user-configurable default message action
|
|
206 ;; allow timeout for confirmation prompt (where available)
|
|
207 ;; move FCC handling to as late as possible to get max
|
|
208 ;; header munging in the saved file
|
|
209 ;; work around sendmail.el's prompts when working from queue
|
|
210 ;; more reliably detect voluntary user bailouts
|
|
211 ;; offer to save modified buffers visiting queue files
|
|
212 ;; offer to delete old file copies of messages being queued
|
|
213 ;; offer to delete queue files when sending immediately
|
|
214 ;; queue filename convention preserves queue order
|
|
215 ;; default queue and draft directory names that work on VMS
|
|
216 ;; deduced address list now really a list, not a string (API change)
|
|
217 ;; no more address buffer
|
|
218 ;; when sending immediately, brief reminder of queue/draft counts
|
|
219 ;; copy trace of smtpmail stuff to feedmail error buffer on no-go
|
|
220 ;; more granularity on when to confirm sending
|
|
221 ;; pause a bit for errors while running queue
|
|
222 ;; try to clean up some pesky auto-save files from the
|
|
223 ;; queue/draft directories
|
|
224 ;; feedmail-force-expand-mail-aliases in case you can't figure
|
|
225 ;; any other way
|
|
226 ;; cleanup some of my sloppiness about case-fold-search (a strange
|
|
227 ;; variable)
|
22609
|
228 ;; best effort following coding conventions from Emacs
|
22513
|
229 ;; elisp manual appendix
|
|
230 ;; "customize" (see custom.el)
|
|
231 ;; when user selects "immediate send", clear action prompt since
|
|
232 ;; hooks may take a while to operate, and user may think the
|
|
233 ;; response didn't take
|
|
234 ;; fixes to the argument conventions for the
|
|
235 ;; feedmail-queue-runner-* functions; allows
|
|
236 ;; feedmail-run-the-queue[-no-prompts] to properly be called
|
|
237 ;; non-interactively
|
|
238 ;; eliminate reliance on directory-sep-char and feedmail-sep-thing
|
|
239 ;; tweak smart filling (reminded of comma problem by levitte@lp.se)
|
|
240 ;; option to control writing in text vs binary mode
|
22552
|
241 ;; patchlevel 8, 15 June 1998
|
22513
|
242 ;; reliable re-editing of text-mode (vs binary) queued messages
|
|
243 ;; user option to keep BCC: in FCC: copy (keep by default)
|
|
244 ;; user option to delete body from FCC: copy (keep by default)
|
|
245 ;; feedmail-deduce-bcc-where for envelope (API change for
|
|
246 ;; feedmail-deduce-address list)
|
|
247 ;; feedmail-queue-alternative-mail-header-separator
|
|
248 ;; at message action prompt, "I"/"S" bypass message confirmation prompt
|
|
249 ;; feedmail-mail-send-hook-splitter, feedmail-mail-send-hook,
|
|
250 ;; feedmail-mail-send-hook-queued
|
|
251 ;; user can supply stuff for message action prompt
|
|
252 ;; variable feedmail-queue-runner-confirm-global, function feedmail-run-the-queue-global-prompt
|
|
253 ;; bugfix: absolute argument to directory-files (tracked down for me
|
|
254 ;; by gray@austin.apc.slb.com (Douglas Gray Stephens)); relative
|
|
255 ;; pathnames can tickle stuff in ange-ftp remote directories
|
|
256 ;; (perhaps because feedmail is careless about its working
|
|
257 ;; directory)
|
|
258 ;; feedmail-deduce-envelope-from
|
|
259 ;; always supply envelope "from" (user-mail-address) to sendmail
|
|
260 ;; feedmail-message-id-suffix
|
|
261 ;; feedmail-queue-reminder, feedmail-queue-reminder-alist (after suggestions
|
|
262 ;; and/or code fragments from tonyl@Eng.Sun.COM (Tony Lam) and
|
|
263 ;; burge@newvision.com (Shane Burgess); bumped up the default value of
|
|
264 ;; feedmail-queue-chatty-sit-for since info is more complex sometimes
|
|
265 ;; feedmail-enable-spray (individual transmissions, crude mailmerge)
|
|
266 ;; blank SUBJECT: no longer a special case; see feedmail-nuke-empty-headers
|
|
267 ;; fiddle-plexes data structure used lots of places; see feedmail-fiddle-plex-blurb
|
|
268 ;; feedmail-fiddle-plex-user-list
|
|
269 ;; feedmail-is-a-resend
|
|
270 ;; honor mail-from-style in constructing default for feedmail-from-line
|
|
271 ;; re-implement feedmail-from-line and feedmail-sender-line with
|
|
272 ;; fiddle-plexes; slightly modified semantics for feedmail-sender-line
|
|
273 ;; feedmail-queue-default-file-slug; tidy up some other slug details
|
|
274 ;; feedmail-queue-auto-file-nuke
|
|
275 ;; feedmail-queue-express-to-queue and feedmail-queue-express-to-draft
|
|
276 ;; strong versions of "q"ueue and "d"raft answers (always make a new file)
|
|
277 ;;
|
|
278 ;; todo (probably in patchlevel 9):
|
|
279 ;; write texinfo manual
|
|
280 ;; maybe partition into multiple files, including files of examples
|
|
281 ;;
|
|
282 ;;; Code:
|
|
283
|
|
284 (defconst feedmail-patch-level "8")
|
|
285
|
|
286
|
|
287 ;; from <URL:http://www.dina.kvl.dk/~abraham/custom/>:
|
|
288 ;; If you write software that must work without the new custom, you
|
|
289 ;; can use this hack stolen from w3-cus.el:
|
|
290 (eval-and-compile
|
|
291 (condition-case ()
|
|
292 (require 'custom)
|
|
293 (error nil))
|
|
294 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
|
|
295 nil ;; We've got what we needed
|
|
296 ;; We have the old custom-library, hack around it!
|
|
297 (defmacro defgroup (&rest args)
|
|
298 nil)
|
|
299 (defmacro defcustom (var value doc &rest args)
|
|
300 (` (defvar (, var) (, value) (, doc))))))
|
|
301
|
|
302
|
|
303 (defgroup feedmail nil
|
|
304 "Assist other email packages to massage outgoing messages."
|
|
305 :group 'mail)
|
|
306
|
|
307 (defgroup feedmail-misc nil
|
|
308 "Miscellaneous feedmail options that don't fit in other groups."
|
|
309 :group 'feedmail)
|
|
310
|
|
311 (defgroup feedmail-headers nil
|
|
312 "Options related to manipulating specific headers or types of headers."
|
|
313 :group 'feedmail)
|
|
314
|
|
315 (defgroup feedmail-queue nil
|
|
316 "Options related to queuing messages for later sending."
|
|
317 :group 'feedmail)
|
|
318
|
|
319
|
|
320 (defcustom feedmail-confirm-outgoing nil
|
|
321 "*If non-nil, give a y-or-n confirmation prompt before sending mail.
|
|
322 This is done after the message is completely prepped, and you'll be
|
|
323 looking at the top of the message in a buffer when you get the prompt.
|
|
324 If set to the symbol 'queued, give the confirmation prompt only while
|
|
325 running the queue (however, the prompt is always suppressed if you are
|
|
326 processing the queue via feedmail-run-the-queue-no-prompts). If set
|
|
327 to the symbol 'immediate, give the confirmation prompt only when
|
|
328 sending immediately. For any other non-nil value, prompt in both
|
|
329 cases. You can give a timeout for the prompt; see variable
|
|
330 feedmail-confirm-outgoing-timeout."
|
|
331 :group 'feedmail-misc
|
|
332 :type 'boolean
|
|
333 )
|
|
334
|
|
335
|
|
336 (defcustom feedmail-confirm-outgoing-timeout nil
|
|
337 "*If non-nil, a timeout in seconds at the send confirmation prompt.
|
|
338 If a positive number, it's a timeout before sending. If a negative
|
|
339 number, it's a timeout before not sending. This will not work if your
|
22609
|
340 version of Emacs doesn't include the function y-or-n-p-with-timeout
|
|
341 \(e.g., some versions of XEmacs\)."
|
22513
|
342 :group 'feedmail-misc
|
|
343 :type '(choice (const nil) integer)
|
|
344 )
|
|
345
|
|
346
|
|
347 (defcustom feedmail-nuke-bcc t
|
|
348 "*If non-nil remove BCC: lines from the message headers.
|
|
349 In any case, the BCC: lines do participate in the composed address
|
|
350 list. You may want to leave them in if you're using sendmail
|
22609
|
351 \(see feedmail-buffer-eating-function\)."
|
22513
|
352 :group 'feedmail-headers
|
|
353 :type 'boolean
|
|
354 )
|
|
355
|
|
356
|
|
357 (defcustom feedmail-nuke-resent-bcc t
|
|
358 "*If non-nil remove RESENT-BCC: lines from the message headers.
|
|
359 In any case, the RESENT-BCC: lines do participate in the composed
|
|
360 address list. You may want to leave them in if you're using sendmail
|
22609
|
361 \(see feedmail-buffer-eating-function\)."
|
22513
|
362 :group 'feedmail-headers
|
|
363 :type 'boolean
|
|
364 )
|
|
365
|
|
366
|
|
367 (defcustom feedmail-deduce-bcc-where nil
|
22609
|
368 "*Where Bcc:/Resent-Bcc: addresses should appear in the envelope list.
|
22513
|
369 Addresses for the message envelope are deduced by examining
|
|
370 appropriate address headers in the message. Generally, they will show
|
|
371 up in the list of deduced addresses in the order that the headers
|
|
372 happen to appear (duplicate addresses are eliminated in any case).
|
|
373 This variable can be set to the symbol 'first, in which case the
|
22609
|
374 Bcc:/Resent-Bcc: addresses will appear at the beginning in the list;
|
22513
|
375 or, it can be set to the symbol 'last, in which case they will appear
|
|
376 at the end of the list.
|
|
377
|
|
378 Why should you care? Well, maybe you don't, and certainly the same
|
|
379 things could be accomplished by affecting the order of message headers
|
|
380 in the outgoing message. Some people use BCC: as a way of getting
|
|
381 their own \"come back\" copy of each message they send. If BCC:
|
|
382 addresses are not handled first, there can be substantial delays in
|
|
383 seeing the message again. Some configurations of sendmail, for example,
|
|
384 seem to try to deliver to each addressee at least once, immediately
|
|
385 and serially, so slow SMTP conversations can add up to a delay. There
|
|
386 is an option for either 'first or 'last because you might have a
|
|
387 delivery agent that processes the addresses backwards."
|
|
388 :group 'feedmail-headers
|
|
389 :type 'boolean
|
|
390 )
|
|
391
|
|
392
|
|
393 (defcustom feedmail-fill-to-cc t
|
|
394 "*If non-nil do smart filling of addressee header lines.
|
|
395 Smart filling means breaking long lines at appropriate points and
|
|
396 making continuation lines. Despite the function name, it includes
|
|
397 TO:, CC:, BCC: (and their RESENT-* forms), as well as FROM: and
|
|
398 REPLY-TO: (though they seldom need it). If nil, the lines are left
|
|
399 as-is. The filling is done after mail address alias expansion."
|
|
400 :group 'feedmail-headers
|
|
401 :type 'boolean
|
|
402 )
|
|
403
|
|
404
|
|
405 (defcustom feedmail-fill-to-cc-fill-column default-fill-column
|
|
406 "*Fill column used by feedmail-fill-to-cc."
|
|
407 :group 'feedmail-headers
|
|
408 :type 'integer
|
|
409 )
|
|
410
|
|
411
|
|
412 (defcustom feedmail-nuke-bcc-in-fcc nil
|
|
413 "*If non-nil remove [RESENT-]BCC: lines in message copies saved via FCC:.
|
|
414 This is independent of whether the BCC: header lines are actually sent
|
|
415 with the message (see feedmail-nuke-bcc). Though not implied in the name,
|
|
416 the same FCC: treatment applies to both BCC: and RESENT-BCC: lines."
|
|
417 :group 'feedmail-headers
|
|
418 :type 'boolean
|
|
419 )
|
|
420
|
|
421
|
|
422 (defcustom feedmail-nuke-body-in-fcc nil
|
|
423 "*If non-nil remove body of message in copies saved via FCC:.
|
|
424 If an positive integer value, leave (up to) that many lines of the
|
|
425 beginning of the body intact. The result is that the FCC: copy will
|
|
426 consist only of the message headers, serving as a sort of an outgoing
|
|
427 message log."
|
|
428 :group 'feedmail-headers
|
|
429 :type '(choice (const nil) (const t) integer)
|
|
430 ;; :type 'boolean
|
|
431 )
|
|
432
|
|
433
|
|
434 (defcustom feedmail-force-expand-mail-aliases nil
|
22609
|
435 "*If non-nil, force the calling of `expand-mail-aliases'.
|
22513
|
436 Normally, feedmail tries to figure out if you're using mailalias or
|
22609
|
437 mailabbrevs and only calls `expand-mail-aliases' if it thinks you're
|
22513
|
438 using the mailalias package. This user option can be used to force
|
|
439 the issue since there are configurations which fool the figuring
|
|
440 out."
|
|
441 :group 'feedmail-headers
|
|
442 :type 'boolean
|
|
443 )
|
|
444
|
|
445
|
|
446 (defcustom feedmail-nuke-empty-headers t
|
|
447 "*If non-nil, remove header lines which have no contents.
|
|
448 A completely empty SUBJECT: header is always removed, regardless of
|
|
449 the setting of this variable. The only time you would want them left
|
|
450 in would be if you used some headers whose presence indicated
|
|
451 something rather than their contents. This is rare in Internet email
|
|
452 but common in some proprietary systems."
|
|
453 :group 'feedmail-headers
|
|
454 :type 'boolean
|
|
455 )
|
|
456
|
|
457 ;; wjc sez: I think the use of the SENDER: line is pretty pointless,
|
|
458 ;; but I left it in to be compatible with sendmail.el and because
|
|
459 ;; maybe some distant mail system needs it. Really, though, if you
|
|
460 ;; want a sender line in your mail, just put one in there and don't
|
|
461 ;; wait for feedmail to do it for you. (Yes, I know all about
|
|
462 ;; RFC-822 and RFC-1123, but are you *really* one of those cases
|
|
463 ;; they're talking about? I doubt it.)
|
|
464 (defcustom feedmail-sender-line nil
|
|
465 "*If non-nil and the email has no SENDER: header, use this value.
|
|
466 May be nil, in which case nothing in particular is done with respect
|
|
467 to SENDER: lines. By design, will not replace an existing SENDER:
|
|
468 line, but you can achieve that with a fiddle-plex 'replace action.
|
|
469 NB: it makes no sense to use the value t since there is no sensible
|
|
470 default for SENDER:.
|
|
471
|
|
472 If not nil, it may be a string, a fiddle-plex, or a function which
|
|
473 returns either nil, t, a string, or a fiddle-plex (or, in fact,
|
|
474 another function, but let's not be ridiculous). If a string, it
|
|
475 should be just the contents of the header, not the name of the header
|
|
476 itself nor the trailing newline. If a function, it will be called
|
|
477 with no arguments. For an explanation of fiddle-plexes, see the
|
|
478 documentation for the variable feedmail-fiddle-plex-blurb. In all
|
|
479 cases the name element of the fiddle-plex is ignored and is hardwired
|
|
480 by feedmail to either \"X-Sender\" or \"X-Resent-Sender\".
|
|
481
|
|
482 You can probably leave this nil, but if you feel like using it, a good
|
|
483 value would be a string of a fully-qualified domain name form of your
|
|
484 address. For example, \"bill@bubblegum.net (WJCarpenter)\". The SENDER:
|
|
485 header is fiddled after the FROM: header is fiddled."
|
|
486 :group 'feedmail-headers
|
|
487 :type '(choice (const nil) string)
|
|
488 )
|
|
489
|
|
490
|
|
491 (defcustom feedmail-force-binary-write t
|
22609
|
492 "*If non-nil, force writing file as binary (this applies to queues and FCC:).
|
22513
|
493 On systems where there is a difference between binary and text files,
|
22609
|
494 feedmail will temporarily manipulate the values of `buffer-file-type'
|
22513
|
495 and/or default-buffer-file-type to make the writing as binary. If
|
|
496 nil, writing will be in text mode. On systems where there is no
|
|
497 distinction or where it is controlled by other variables or other
|
|
498 means, this option has no effect."
|
|
499 :group 'feedmail-misc
|
|
500 :type 'boolean
|
|
501 )
|
|
502
|
|
503
|
|
504 (defcustom feedmail-from-line t
|
|
505 "*If non-nil and the email has no FROM: header, use this value.
|
|
506 May be t, in which case a default is computed (and you probably won't
|
|
507 be happy with it). May be nil, in which case nothing in particular is
|
|
508 done with respect to FROM: lines. By design, will not replace an
|
|
509 existing FROM: line, but you can achieve that with a fiddle-plex 'replace
|
|
510 action.
|
|
511
|
|
512 If neither nil nor t, it may be a string, a fiddle-plex, or a function
|
|
513 which returns either nil, t, a string, or a fiddle-plex (or, in fact,
|
|
514 another function, but let's not be ridiculous). If a string, it
|
|
515 should be just the contents of the header, not the name of the header
|
|
516 itself nor the trailing newline. If a function, it will be called
|
|
517 with no arguments. For an explanation of fiddle-plexes, see the
|
|
518 documentation for the variable feedmail-fiddle-plex-blurb. In all
|
|
519 cases the name element of the fiddle-plex is ignored and is hardwired
|
|
520 by feedmail to either \"X-From\" or \"X-Resent-From\".
|
|
521
|
|
522 A good value would be a string fully-qualified domain name form of
|
|
523 your address. For example, \"bill@bubblegum.net (WJCarpenter)\". The
|
|
524 default value of this variable uses the standard elisp variable
|
22609
|
525 `user-mail-address' which should be set on every system but has a decent
|
|
526 chance of being wrong. It also honors `mail-from-style'. Better to set
|
22513
|
527 this variable explicitly to the string you want or find some other way
|
|
528 to arrange for the message to get a FROM: line."
|
|
529 :group 'feedmail-headers
|
|
530 :type '(choice (const nil) string)
|
|
531 )
|
|
532
|
|
533
|
|
534 (defcustom feedmail-deduce-envelope-from t
|
|
535 "*If non-nil, deduce message envelope \"from\" from header FROM: or SENDER:.
|
|
536 In other words, if there is a SENDER: header in the message, temporarily
|
22609
|
537 change the value of `user-mail-address' to be the same while the message
|
22513
|
538 is being sent. If there is no SENDER: header, use the FROM: header,
|
|
539 if any. Address values are taken from the actual message just before
|
|
540 it is sent, and the process is independent of the values of
|
|
541 feedmail-from-line and/or feedmail-sender-line.
|
|
542
|
|
543 There are many and good reasons for having the message header
|
|
544 FROM:/SENDER: be different from the message envelope \"from\"
|
|
545 information. However, for most people and for most circumstances, it
|
|
546 is usual for them to be the same (this is probably especially true for
|
|
547 the case where the user doesn't understand the difference between the
|
|
548 two in the first place).
|
|
549
|
|
550 The idea behind this feature is that you can have everything set up
|
|
551 some normal way for yourself. If for some reason you want to send a
|
|
552 message with another FROM: line, you can just type it at the top of
|
|
553 the message, and feedmail will take care of \"fixing up\" the envelope
|
|
554 \"from\". This only works for mail senders which make use of
|
22609
|
555 `user-mail-address' as the envelope \"from\" value. For some mail
|
22513
|
556 senders (e.g., feedmail-buffer-to-bin-mail), there is no simple way to
|
|
557 influence what they will use as the envelope."
|
|
558 :group 'feedmail-headers
|
|
559 :type 'boolean
|
|
560 )
|
|
561
|
|
562
|
|
563 (defcustom feedmail-x-mailer-line-user-appendage nil
|
|
564 "*See feedmail-x-mailer-line."
|
|
565 :group 'feedmail-headers
|
|
566 :type '(choice (const nil) string)
|
|
567 )
|
|
568
|
|
569
|
|
570 (defcustom feedmail-x-mailer-line t
|
|
571 "*Control the form of an X-MAILER: header in an outgoing message.
|
|
572 Moderately useful for debugging, keeping track of your correspondents'
|
|
573 mailer preferences, or just wearing your MUA on your sleeve. You
|
|
574 should probably know that some people are fairly emotional about the
|
|
575 presence of X-MAILER: lines in email.
|
|
576
|
|
577 If nil, nothing is done about X-MAILER:.
|
|
578
|
|
579 If t, an X-MAILER: header of a predetermined format is produced,
|
|
580 combining its efforts with any existing X-MAILER: header. If you want
|
|
581 to take the default construct and just add a little blob of your own
|
|
582 at the end, define the variable feedmail-x-mailer-line-user-appendage
|
22609
|
583 as that blob string. A value of t is equivalent to using the function
|
22513
|
584 feedmail-default-x-mailer-generator.
|
|
585
|
|
586 If neither nil nor t, it may be a string, a fiddle-plex, or a function
|
|
587 which returns either nil, t, a string, or a fiddle-plex (or, in fact,
|
|
588 another function, but let's not be ridiculous). If a string, it
|
|
589 should be just the contents of the header, not the name of the header
|
|
590 itself nor the trailing newline. If a function, it will be called
|
|
591 with no arguments. For an explanation of fiddle-plexes, see the
|
|
592 documentation for the variable feedmail-fiddle-plex-blurb. In all
|
|
593 cases the name element of the fiddle-plex is ignored and is hardwired
|
|
594 by feedmail to either \"X-Mailer\" or \"X-Resent-Mailer\"."
|
|
595 :group 'feedmail-headers
|
|
596 :type '(choice (const t) (const nil) string function)
|
|
597 )
|
|
598
|
|
599
|
|
600 (defcustom feedmail-message-id-generator t
|
|
601 "*Specifies the creation of a MESSAGE-ID: header field.
|
|
602
|
|
603 If nil, nothing is done about MESSAGE-ID:.
|
|
604
|
|
605 If t, a MESSAGE-ID: header of a predetermined format is produced, but
|
|
606 only if there is not already a MESSAGE-ID: in the message. A value of
|
|
607 t is equivalent to using the function feedmail-default-message-id-generator.
|
|
608
|
|
609 If neither nil nor t, it may be a string, a fiddle-plex, or a function
|
|
610 which returns either nil, t, a string, or a fiddle-plex (or, in fact,
|
|
611 another function, but let's not be ridiculous). If a string, it
|
|
612 should be just the contents of the header, not the name of the header
|
|
613 itself nor the trailing newline. If a function, it will be called
|
|
614 with one argument: the possibly-nil name of the file associated with
|
|
615 the message buffer. For an explanation of fiddle-plexes, see the
|
|
616 documentation for the variable feedmail-fiddle-plex-blurb. In all
|
|
617 cases the name element of the fiddle-plex is ignored and is hardwired
|
|
618 by feedmail to either \"Message-ID\" or \"Resent-Message-ID\".
|
|
619
|
|
620 You should let feedmail generate a MESSAGE-ID: for you unless you are sure
|
|
621 that whatever you give your messages to will do it for you (e.g., most
|
|
622 configurations of sendmail). Even if the latter case is true, it
|
|
623 probably won't hurt you to generate your own, and it will then show up
|
|
624 in the saved message if you use FCC:."
|
|
625 :group 'feedmail-headers
|
|
626 :type '(choice (const nil) function)
|
|
627 )
|
|
628
|
|
629
|
|
630 (defcustom feedmail-message-id-suffix nil
|
22609
|
631 "*If non-nil, used as a suffix for generating unique Message-Id: headers.
|
|
632 The function `feedmail-default-message-id-generator' creates its work based
|
22513
|
633 on a formatted date-time string, a random number, and a domain-looking suffix.
|
22609
|
634 You can control the suffix used by assigning a string value to this variable.
|
|
635 If you don't supply one, the value of the variable `user-mail-address' will be
|
|
636 used. If the value of `feedmail-message-id-suffix' contains an \"@\" character,
|
|
637 the string will be used verbatim, else an \"@\" character will be prepended
|
|
638 automatically."
|
22513
|
639 :group 'feedmail-headers
|
|
640 :type 'string
|
|
641 )
|
|
642
|
|
643 ;; this was suggested in various forms by several people; first was
|
|
644 ;; Tony DeSimone in Oct 1992; sorry to be so tardy
|
|
645 (defcustom feedmail-date-generator t
|
|
646 "*Specifies the creation of a DATE: header field.
|
|
647
|
|
648 If nil, nothing is done about DATE:.
|
|
649
|
|
650 If t, a DATE: header of a predetermined format is produced, but only
|
|
651 if there is not already a DATE: in the message. A value of t is
|
|
652 equivalent to using the function feedmail-default-date-generator.
|
|
653
|
|
654 If neither nil nor t, it may be a string, a fiddle-plex, or a function
|
|
655 which returns either nil, t, a string, or a fiddle-plex (or, in fact,
|
|
656 another function, but let's not be ridiculous). If a string, it
|
|
657 should be just the contents of the header, not the name of the header
|
|
658 itself nor the trailing newline. If a function, it will be called
|
|
659 with one argument: the possibly-nil name of the file associated with
|
|
660 the message buffer. For an explanation of fiddle-plexes, see the
|
|
661 documentation for the variable feedmail-fiddle-plex-blurb. In all
|
|
662 cases the name element of the fiddle-plex is ignored and is hardwired
|
|
663 by feedmail to either \"Date\" or \"Resent-Date\".
|
|
664
|
|
665 If you decide to format your own date field, do us all a favor and know
|
|
666 what you're doing. Study the relevant parts of RFC-822 and RFC-1123.
|
|
667 Don't make me come up there!
|
|
668
|
|
669 You should let feedmail generate a DATE: for you unless you are sure
|
|
670 that whatever you give your messages to will do it for you (e.g., most
|
|
671 configurations of sendmail). Even if the latter case is true, it
|
|
672 probably won't hurt you to generate your own, and it will then show up
|
|
673 in the saved message if you use FCC:."
|
|
674 :group 'feedmail-headers
|
|
675 :type '(choice (const nil) function)
|
|
676 )
|
|
677
|
|
678
|
|
679 (defcustom feedmail-fiddle-headers-upwardly t
|
22609
|
680 "*Non-nil means fiddled header fields should go at the top of the header.
|
22513
|
681 Nil means insert them at the bottom. This is mostly a novelty issue since
|
|
682 the standards define the ordering of header fields to be immaterial and it's
|
|
683 fairly likely that some MTA along the way will have its own idea of what the
|
|
684 order should be, regardless of what you specify."
|
|
685 :group 'feedmail-header
|
|
686 :type 'boolean
|
|
687 )
|
|
688
|
|
689
|
|
690 (defcustom feedmail-fiddle-plex-user-list nil
|
|
691 "If non-nil, should be a list of one or more fiddle-plexes.
|
|
692 Each element of the list can also be a function which returns a
|
|
693 fiddle-plex.
|
|
694
|
|
695 feedmail will use this list of fiddle-plexes to manipulate user-specified
|
|
696 message header fields. It does this after it has completed all normal
|
|
697 message header field manipulation and before calling feedmail-last-chance-hook.
|
|
698
|
|
699 For an explanation of fiddle-plexes, see the documentation for the
|
|
700 variable feedmail-fiddle-plex-blurb. In contrast to some other fiddle-plex
|
|
701 manipulation functions, in this context, it makes no sense to have an element
|
|
702 which is nil, t, or a simple string."
|
|
703 :group 'feedmail-header
|
|
704 :type 'list
|
|
705 )
|
|
706
|
|
707
|
|
708 (defcustom feedmail-enable-spray nil
|
|
709 "If non-nil, transmit message separately to each addressee.
|
|
710 feedmail normally accumulates a list of addressees and passes the message
|
|
711 along with that list to a buffer-eating function which expects any number
|
|
712 of addressees. If this variable is non-nil, however, feedmail will
|
|
713 repeatedly call the same buffer-eating function. Each time, the list of
|
|
714 addressees will be just one item from the original list. This only affects
|
22609
|
715 the message envelope addresses and doesn't affect what appears in the
|
22513
|
716 message headers except as noted.
|
|
717
|
|
718 Spray mode is usually pointless, and if you can't think of a good reason for
|
22609
|
719 it, you should avoid it since it is inherently less efficient than normal
|
22513
|
720 multiple delivery. One reason to use it is to overcome mis-featured mail
|
|
721 transports which betray your trust by revealing BCC: addressees in the
|
|
722 headers of a message. Another use is to do a crude form of mailmerge, for
|
|
723 which see feedmail-spray-address-fiddle-plex-list.
|
|
724
|
|
725 If one of the calls to the buffer-eating function results in an error,
|
|
726 what happens next is carelessly defined, so beware."
|
|
727 :group 'feedmail-spray
|
|
728 :type 'boolean
|
|
729 )
|
|
730
|
|
731 (defvar feedmail-spray-this-address nil
|
|
732 "Do not set or change this variable. See feedmail-spray-address-fiddle-plex-list.")
|
|
733
|
|
734 (defcustom feedmail-spray-address-fiddle-plex-list nil
|
|
735 "User-supplied specification for a crude form of mailmerge capability.
|
|
736 When spraying is enabled, feedmail composes a list of envelope addresses.
|
|
737 In turn, feedmail-spray-this-address is temporarily set to each address
|
22609
|
738 \(stripped of any comments and angle brackets\) and calls a function which
|
|
739 fiddles message headers according to this variable. See the documentation for
|
|
740 `feedmail-fiddle-plex-blurb', for an overview of fiddle-plex data structures.
|
22513
|
741
|
|
742 May be nil, in which case nothing in particular is done about message
|
|
743 headers for specific addresses.
|
|
744
|
|
745 May be t, in which case a \"TO:\" header is added to the message with
|
|
746 the stripped address as the header contents. The fiddle-plex operator
|
|
747 is 'supplement.
|
|
748
|
|
749 May be a string, in which case the string is assumed to be the name of
|
|
750 a message header field with the stripped address serving as the value.
|
|
751 The fiddle-plex operator is 'supplement.
|
|
752
|
|
753 May be a function, in which case it is called with no arguments and is
|
|
754 expected to return nil, t, a string, another function, or a fiddle-plex.
|
|
755 The result is used recursively.
|
|
756
|
|
757 May be a list of any combination of the foregoing and fiddle-plexes. (A
|
|
758 value for this variable which consists of a single fiddle-plex must be
|
|
759 nested inside another list to avoid ambiguity.) If a list, each item
|
|
760 is acted on in turn as described above.
|
|
761
|
|
762 For example,
|
|
763
|
|
764 (setq feedmail-spray-address-fiddle-plex-list 'my-address-embellisher)
|
|
765
|
|
766 The idea of the example is that, during spray mode, as each message is
|
|
767 about to be transmitted to an individual address, the function will be
|
|
768 called and will consult feedmail-spray-this-address to find the
|
|
769 stripped envelope email address (no comments or angle brackets). The
|
|
770 function should return an embellished form of the address.
|
|
771
|
|
772 The recipe for sending form letters is: (1) create a message with all
|
|
773 addressees on BCC: headers; (2) tell feedmail to remove BCC: headers
|
22609
|
774 before sending the message; (3) create a function which will embellish
|
22513
|
775 stripped addresses, if desired; (4) define feedmail-spray-address-fiddle-plex-list
|
|
776 appropriately; (5) send the message with feedmail-enable-spray set
|
|
777 non-nil; (6) stand back and watch co-workers wonder at how efficient
|
|
778 you are at accomplishing inherently inefficient things."
|
|
779 :group 'feedmail-spray
|
|
780 :type 'list
|
|
781 )
|
|
782
|
|
783
|
|
784 (defcustom feedmail-enable-queue nil
|
|
785 "*If non-nil, provide for stashing outgoing messages in a queue.
|
|
786 This is the master on/off switch for feedmail message queuing.
|
|
787 Queuing is quite handy for laptop-based users. It's also handy if you
|
|
788 get a lot of mail and process it more or less sequentially. For
|
|
789 example, you might change your mind about contents of a reply based on
|
|
790 a message you see a bit later.
|
|
791
|
|
792 There is a separate queue for draft messages, intended to prevent
|
|
793 you from accidentally sending incomplete messages. The queues are
|
|
794 disk-based and intended for later transmission. The messages are
|
|
795 queued in their raw state as they appear in the mail-mode buffer and
|
|
796 can be arbitrarily edited later, before sending, by visiting the
|
|
797 appropriate file in the queue directory (and setting the buffer to
|
|
798 mail-mode or whatever). If you visit a file in the queue directory
|
|
799 and try to queue it again, it will just get saved in its existing file
|
|
800 name. You can move a message from the draft to the main queue or vice
|
|
801 versa by pretending to send it and then selecting whichever queue
|
|
802 directory you want at the prompt. The right thing will happen.
|
|
803
|
|
804 To transmit all the messages in the queue, invoke the command
|
|
805 feedmail-run-the-queue or feedmail-run-the-queue-no-prompts."
|
|
806 :group 'feedmail-queue
|
|
807 :type 'boolean
|
|
808 )
|
|
809
|
|
810
|
|
811 (defcustom feedmail-queue-runner-confirm-global nil
|
|
812 "*If non-nil, give a y-or-n confirmation prompt before running the queue.
|
|
813 Prompt even if the queue is about to be processed as a result of a call to
|
|
814 feedmail-run-the-queue-no-prompts. This gives you a way to bail out
|
|
815 without having to answer no to the individual message prompts."
|
|
816 :group 'feedmail-queue
|
|
817 :type 'boolean)
|
|
818
|
|
819
|
|
820 ;; I provided a default for VMS because someone asked for it (the
|
|
821 ;; normal default doesn't work there), but, puh-lease!, it is a user
|
|
822 ;; definable option, so if you don't like the default, change it to
|
|
823 ;; whatever you want. I am unable to directly test the VMS goop
|
|
824 ;; provided here by levitte@lp.se (Richard Levitte - VMS Whacker).
|
|
825 (defcustom feedmail-queue-directory
|
|
826 (if (memq system-type '(axp-vms vax-vms))
|
|
827 (expand-file-name (concat (getenv "HOME") "[.MAIL.Q]"))
|
|
828 (concat (getenv "HOME") "/mail/q"))
|
|
829 "*Name of a directory where messages will be queued.
|
|
830 Directory will be created if necessary. Should be a string that
|
|
831 doesn't end with a slash. Default, except on VMS, is \"$HOME/mail/q\"."
|
|
832 :group 'feedmail-queue
|
|
833 :type 'string
|
|
834 )
|
|
835
|
|
836
|
|
837 (defcustom feedmail-queue-draft-directory
|
|
838 (if (memq system-type '(axp-vms vax-vms))
|
|
839 (expand-file-name (concat (getenv "HOME") "[.MAIL.DRAFT]"))
|
|
840 (concat (getenv "HOME") "/mail/draft"))
|
|
841 "*Name of an directory where DRAFT messages will be queued.
|
|
842 Directory will be created if necessary. Should be a string that
|
|
843 doesn't end with a slash. Default, except on VMS, is \"$HOME/mail/draft\"."
|
|
844 :group 'feedmail-queue
|
|
845 :type 'string
|
|
846 )
|
|
847
|
|
848
|
|
849 (defcustom feedmail-ask-before-queue t
|
|
850 "*If non-nil, feedmail will ask what you want to do with the message.
|
|
851 Default choices for the message action prompt will include sending it
|
|
852 immediately, putting it in the main queue, putting it in the draft
|
|
853 queue, or returning to the buffer to continue editing. Only matters if
|
|
854 queuing is enabled. If nil, the message is placed in the main queue
|
|
855 without a prompt."
|
|
856 :group 'feedmail-queue
|
|
857 :type 'boolean
|
|
858 )
|
|
859
|
|
860
|
|
861 (defcustom feedmail-ask-before-queue-prompt "FQM: Message action (q, i, d, e, ?)? [%s]: "
|
|
862 "*A string which will be used for the message action prompt.
|
|
863 If it contains a \"%s\", that will be replaced with the value of
|
|
864 feedmail-ask-before-queue-default."
|
|
865 :group 'feedmail-queue
|
|
866 :type 'string
|
|
867 )
|
|
868
|
|
869
|
|
870 (defcustom feedmail-ask-before-queue-reprompt "FQM: Please type q, i, d, or e; or ? for help [%s]: "
|
|
871 "*A string which will be used for repompting after invalid input.
|
|
872 If it contains a \"%s\", that will be replaced with the value of
|
|
873 feedmail-ask-before-queue-default."
|
|
874 :group 'feedmail-queue
|
|
875 :type 'string
|
|
876 )
|
|
877
|
|
878
|
|
879 (defcustom feedmail-ask-before-queue-default "queue"
|
|
880 "*Meaning if user hits return in response to the message action prompt.
|
|
881 Should be a character or a string; if a string, only the first
|
|
882 character is significant. Useful values are those described in
|
|
883 the help for the message action prompt."
|
|
884 :group 'feedmail-queue
|
|
885 :type '(choice string integer) ;use integer to get char
|
|
886 )
|
|
887
|
|
888
|
|
889 (defvar feedmail-prompt-before-queue-standard-alist
|
|
890 '((?q . feedmail-message-action-queue)
|
|
891 (?Q . feedmail-message-action-queue-strong)
|
|
892
|
|
893 (?d . feedmail-message-action-draft)
|
|
894 (?r . feedmail-message-action-draft)
|
|
895 (?D . feedmail-message-action-draft-strong)
|
|
896 (?R . feedmail-message-action-draft-strong)
|
|
897
|
|
898 (?e . feedmail-message-action-edit)
|
|
899 (?E . feedmail-message-action-edit)
|
|
900 (?\C-g . feedmail-message-action-edit)
|
|
901 (?n . feedmail-message-action-edit)
|
|
902 (?N . feedmail-message-action-edit)
|
|
903
|
|
904 (?i . feedmail-message-action-send)
|
|
905 (?I . feedmail-message-action-send-strong)
|
|
906 (?s . feedmail-message-action-send)
|
|
907 (?S . feedmail-message-action-send-strong)
|
|
908
|
|
909 (?* . feedmail-message-action-toggle-spray)
|
|
910
|
|
911 (?\C-v . feedmail-message-action-help)
|
|
912 (?? . feedmail-message-action-help))
|
|
913 "An alist of choices for the message action prompt.
|
|
914 All of the values are function names, except help, which is a special
|
|
915 symbol that calls up help for the prompt (the help describes the
|
|
916 actions from the standard alist). To customize your own choices,
|
|
917 define a similar alist called feedmail-prompt-before-queue-user-alist.
|
|
918 The actual alist used for message action will be the standard alist
|
|
919 overlaid with the user-alist. To neutralize an item in the standard
|
|
920 alist without providing a replacement, define an appropriate element
|
|
921 in the user alist with a value of nil." )
|
|
922
|
|
923
|
|
924 (defcustom feedmail-prompt-before-queue-user-alist nil
|
|
925 "See feedmail-prompt-before-queue-standard-alist."
|
|
926 :group 'feedmail-queue
|
|
927 :type 'alist
|
|
928 )
|
|
929
|
|
930
|
|
931 (defcustom feedmail-prompt-before-queue-help-supplement nil
|
|
932 "User-provided supplementary help string for the message action prompt.
|
|
933 When the message action prompt is shown, the user can as for verbose help,
|
|
934 at which point a buffer pops up describing the meaning of possible
|
|
935 responses to the prompt. Through various customizations (see, for
|
|
936 example, feedmail-prompt-before-queue-user-alist), the available responses
|
|
937 and the prompt itself can be changed. If this variable is set to a string
|
|
938 value, that string is written to the help buffer after the standard info.
|
|
939 It may contain embedded line breaks. It will be printed via princ."
|
|
940 :group 'feedmail-queue
|
|
941 :type 'string
|
|
942 )
|
|
943
|
|
944
|
|
945 (defcustom feedmail-queue-reminder-alist
|
|
946 '((after-immediate . feedmail-queue-reminder-brief)
|
|
947 (after-queue . feedmail-queue-reminder-medium)
|
|
948 (after-draft . feedmail-queue-reminder-medium)
|
|
949 (after-run . feedmail-queue-reminder-brief)
|
|
950 (on-demand . feedmail-run-the-queue-global-prompt))
|
|
951 "See feedmail-queue-reminder."
|
|
952 :group 'feedmail-queue
|
|
953 :type 'alist
|
|
954 )
|
|
955
|
|
956
|
|
957 (defcustom feedmail-queue-chatty t
|
|
958 "*If non-nil, blat a few status messages and such in the mini-buffer.
|
|
959 If nil, just do the work and don't pester people about what's going on.
|
|
960 In some cases, though, specific options inspire mini-buffer prompting.
|
|
961 That's not affected by this variable setting. Also does not control
|
|
962 reporting of error/abnormal conditions."
|
|
963 :group 'feedmail-queue
|
|
964 :type 'boolean
|
|
965 )
|
|
966
|
|
967
|
|
968 (defcustom feedmail-queue-chatty-sit-for 2
|
|
969 "*Duration of pause after most queue-related messages.
|
|
970 After some messages are divulged, it is prudent to pause before
|
|
971 something else obliterates them. This value controls the duration of
|
|
972 the pause."
|
|
973 :group 'feedmail-queue
|
|
974 :type 'integer
|
|
975 )
|
|
976
|
|
977
|
|
978 (defcustom feedmail-queue-run-orderer nil
|
|
979 "*If non-nil, name a function which will sort the queued messages.
|
|
980 The function is called during a running of the queue for sending, and
|
|
981 takes one argument, a list of the files in the queue directory. It
|
|
982 may contain the names of non-message files, and it's okay to leave
|
|
983 them in the list when reordering it; they get skipped over later.
|
|
984 When nil, the default action processes the messages in normal sort
|
|
985 order by queued file name, which will typically result in the order
|
|
986 they were placed in the queue."
|
|
987 :group 'feedmail-queue
|
|
988 :type '(choice (const nil) function)
|
|
989 )
|
|
990
|
|
991
|
|
992 (defcustom feedmail-queue-use-send-time-for-date nil
|
|
993 "*If non-nil, use send time for the DATE: header value.
|
|
994 This variable is used by the default date generating function,
|
|
995 feedmail-default-date-generator. If nil, the default, the
|
|
996 last-modified timestamp of the queue file is used to create the
|
|
997 message DATE: header; if there is no queue file, the current time is
|
|
998 used."
|
|
999 :group 'feedmail-queue
|
|
1000 :type 'boolean
|
|
1001 )
|
|
1002
|
|
1003
|
|
1004 (defcustom feedmail-queue-use-send-time-for-message-id nil
|
|
1005 "*If non-nil, use send time for the MESSAGE-ID: header value.
|
|
1006 This variable is used by the default MESSAGE-ID: generating function,
|
|
1007 feedmail-default-message-id-generator. If nil, the default, the
|
|
1008 last-modified timestamp of the queue file is used to create the
|
|
1009 message MESSAGE-ID: header; if there is no queue file, the current time is
|
|
1010 used."
|
|
1011 :group 'feedmail-queue
|
|
1012 :type 'boolean
|
|
1013 )
|
|
1014
|
|
1015
|
|
1016 (defcustom feedmail-ask-for-queue-slug nil
|
|
1017 "*If non-nil, prompt user for part of the queue file name.
|
|
1018 The file will automatically get the FQM suffix and an embedded
|
|
1019 sequence number for uniqueness, so don't specify that. feedmail will
|
|
1020 get rid of all characters other than alphanumeric and hyphen in the
|
|
1021 results. If this variable is nil or if you just hit return in
|
|
1022 response to the prompt, feedmail queuing will take care of things
|
|
1023 properly. At the prompt, completion is available if you want to see
|
|
1024 what filenames are already in use, though, as noted, you will not be
|
|
1025 typing a complete file name. You probably don't want to be bothered
|
|
1026 with this prompting since feedmail, by default, uses queue file names
|
|
1027 based on the subjects of the messages."
|
|
1028 :group 'feedmail-queue
|
|
1029 :type 'boolean
|
|
1030 )
|
|
1031
|
|
1032
|
|
1033 (defcustom feedmail-queue-slug-maker 'feedmail-queue-subject-slug-maker
|
|
1034 "*If non-nil, a function which creates part of the queued file name.
|
|
1035 Takes a single argument giving the name of the directory into
|
|
1036 which the message will be queued. The returned string should be just
|
|
1037 the non-directory filename part, without FQM suffix or uniquifying
|
|
1038 sequence numbers. The current buffer holds the raw message. The
|
|
1039 default function creates the slug based on the message subject, if
|
|
1040 any."
|
|
1041 :group 'feedmail-queue
|
|
1042 :type '(choice (const nil) function)
|
|
1043 )
|
|
1044
|
|
1045
|
|
1046 (defcustom feedmail-queue-default-file-slug t
|
|
1047 "*Indicates what to use for subject-less messages when forming a file name.
|
22609
|
1048 When feedmail queues a message, it creates a unique file name. By default,
|
22513
|
1049 the file name is based in part on the subject of the message being queued.
|
|
1050 If there is no subject, consult this variable. See documentation for the
|
|
1051 function feedmail-queue-subject-slug-maker.
|
|
1052
|
|
1053 If t, an innocuous default is used.
|
|
1054
|
|
1055 If a string, it is used directly.
|
|
1056
|
|
1057 If a function, it is called with no arguments from the buffer containing the raw
|
|
1058 text of the message. It must return a string (which may be empty).
|
|
1059
|
|
1060 If the symbol 'ask, you will be prompted for a string in the mini-buffer.
|
|
1061 Filename completion is available so that you can inspect what's already been
|
|
1062 used, but feedmail will do further manipulation on the string you return, so
|
|
1063 it's not expected to be a complete filename."
|
|
1064 :group 'feedmail-queue
|
|
1065 :type 'string
|
|
1066 )
|
|
1067
|
|
1068
|
|
1069 (defcustom feedmail-queue-fqm-suffix ".fqm"
|
|
1070 "*The FQM suffix used to distinguish feedmail queued message files.
|
|
1071 You probably want this to be a period followed by some letters and/or
|
|
1072 digits. The distinction is to be able to tell them from other random
|
|
1073 files that happen to be in the feedmail-queue-directory or
|
|
1074 feedmail-queue-draft-directory. By the way, FQM stands for feedmail
|
|
1075 queued message."
|
|
1076 :group 'feedmail-queue
|
|
1077 :type 'string
|
|
1078 )
|
|
1079
|
|
1080
|
|
1081 (defcustom feedmail-nuke-buffer-after-queue nil
|
|
1082 "*If non-nil, silently kill the buffer after a message is queued.
|
|
1083 You might like that since a side-effect of queueing the message is
|
|
1084 that its buffer name gets changed to the filename. That means that
|
|
1085 the buffer won't be reused for the next message you compose. If you
|
|
1086 are using VM for creating messages, you probably want to leave this
|
|
1087 nil, since VM has its own options for managing the recycling of
|
|
1088 message buffers."
|
|
1089 :group 'feedmail-queue
|
|
1090 :type 'boolean
|
|
1091 )
|
|
1092
|
|
1093
|
|
1094 (defcustom feedmail-queue-auto-file-nuke nil
|
|
1095 "*If non-nil, automatically delete queue files when a message is sent.
|
|
1096 Normally, feedmail will notice such files when you send a message in
|
|
1097 immediate mode (i.e., not when you're running the queue) and will ask if
|
|
1098 you want to delete them. Since the answer is usually yes, setting this
|
22609
|
1099 variable to non-nil will tell feedmail to skip the prompt and just delete
|
22513
|
1100 the file without bothering you."
|
|
1101 :group 'feedmail-queue
|
|
1102 :type 'boolean
|
|
1103 )
|
|
1104
|
|
1105
|
|
1106 ;; defvars to make byte-compiler happy(er)
|
22609
|
1107 (defvar feedmail-error-buffer nil)
|
|
1108 (defvar feedmail-prepped-text-buffer nil)
|
|
1109 (defvar feedmail-raw-text-buffer nil)
|
|
1110 (defvar feedmail-address-list nil)
|
22513
|
1111
|
|
1112
|
|
1113 (defun feedmail-mail-send-hook-splitter ()
|
|
1114 "Facilitate dividing mail-send-hook things into queued and immediate cases.
|
|
1115 If you have mail-send-hook functions that should only be called for sending/
|
|
1116 queueing messages or only be called for the sending of queued messages, this is
|
|
1117 for you. Add this function to mail-send-hook with something like this:
|
|
1118
|
|
1119 (add-hook 'mail-send-hook 'feedmail-mail-send-hook-splitter)
|
|
1120
|
|
1121 Then add the functions you want called to either feedmail-mail-send-hook-queued
|
|
1122 or feedmail-mail-send-hook, as apprpriate. The distinction is that
|
|
1123 feedmail-mail-send-hook will be called when you send mail from a composition
|
|
1124 buffer (typically by typing C-c C-c), whether the message is sent immediately
|
|
1125 or placed in the queue or drafts directory. feedmail-mail-send-hook-queued is
|
|
1126 called when messages are being sent from the queue directory, typically via a
|
|
1127 call to feedmail-run-the-queue."
|
|
1128 (if feedmail-queue-runner-is-active
|
|
1129 (run-hooks 'feedmail-mail-send-hook-queued)
|
|
1130 (run-hooks 'feedmail-mail-send-hook))
|
|
1131 )
|
|
1132
|
|
1133
|
|
1134 (defvar feedmail-mail-send-hook nil
|
|
1135 "*See documentation for feedmail-mail-send-hook-splitter.")
|
|
1136
|
|
1137
|
|
1138 (defvar feedmail-mail-send-hook-queued nil
|
|
1139 "*See documentation for feedmail-mail-send-hook-splitter.")
|
|
1140
|
|
1141
|
|
1142 (defun feedmail-confirm-addresses-hook-example ()
|
|
1143 "An example of a feedmail-last-chance-hook.
|
|
1144 It shows the simple addresses and gets a confirmation. Use as:
|
|
1145 (setq feedmail-last-chance-hook 'feedmail-confirm-addresses-hook-example)."
|
|
1146 (save-window-excursion
|
|
1147 (display-buffer (set-buffer (get-buffer-create " F-C-A-H-E")))
|
|
1148 (erase-buffer)
|
|
1149 (insert (mapconcat 'identity feedmail-address-list " "))
|
|
1150 (if (not (y-or-n-p "How do you like them apples? "))
|
|
1151 (error "FQM: Sending...gave up in last chance hook")
|
|
1152 )))
|
|
1153
|
|
1154
|
|
1155 (defcustom feedmail-last-chance-hook nil
|
|
1156 "*User's last opportunity to modify the message on its way out.
|
|
1157 It has already had all the header prepping from the standard package.
|
|
1158 The next step after running the hook will be to push the buffer into a
|
|
1159 subprocess that mails the mail. The hook might be interested in
|
|
1160 these: (1) feedmail-prepped-text-buffer contains the header and body
|
|
1161 of the message, ready to go; (2) feedmail-address-list contains a list
|
|
1162 of simplified recipients of addresses which are to be given to the
|
|
1163 subprocess (the hook may change the list); (3) feedmail-error-buffer
|
|
1164 is an empty buffer intended to soak up errors for display to the user.
|
|
1165 If the hook allows interactive activity, the user should not send more
|
|
1166 mail while in the hook since some of the internal buffers will be
|
|
1167 reused and things will get confused."
|
|
1168 :group 'feedmail-misc
|
|
1169 :type 'hook
|
|
1170 )
|
|
1171
|
|
1172
|
|
1173 (defcustom feedmail-before-fcc-hook nil
|
|
1174 "*User's last opportunity to modify the message before FCC action.
|
|
1175 It has already had all the header prepping from the standard package.
|
|
1176 The next step after running the hook will be to save the message via
|
|
1177 FCC: processing. The hook might be interested in these: (1)
|
|
1178 feedmail-prepped-text-buffer contains the header and body of the
|
|
1179 message, ready to go; (2) feedmail-address-list contains a list of
|
|
1180 simplified recipients of addressees to whom the message was sent (3)
|
|
1181 feedmail-error-buffer is an empty buffer intended to soak up errors
|
|
1182 for display to the user. If the hook allows interactive activity, the
|
|
1183 user should not send more mail while in the hook since some of the
|
|
1184 internal buffers will be reused and things will get confused."
|
|
1185 :group 'feedmail-misc
|
|
1186 :type 'hook
|
|
1187 )
|
|
1188
|
|
1189 (defcustom feedmail-queue-runner-mode-setter
|
|
1190 '(lambda (&optional arg) (mail-mode))
|
22609
|
1191 "*A function to set the proper mode of a message file.
|
|
1192 Called when the message is read back out of the queue directory with a single
|
22513
|
1193 argument, the optional argument used in the call to
|
|
1194 feedmail-run-the-queue or feedmail-run-the-queue-no-prompts.
|
|
1195
|
22609
|
1196 Most people want `mail-mode', so the default value is an anonymous
|
22513
|
1197 function which is just a wrapper to ignore the supplied argument when
|
|
1198 calling it, but here's your chance to have something different.
|
22609
|
1199 Called with funcall, not `call-interactively'."
|
22513
|
1200 :group 'feedmail-queue
|
|
1201 :type 'function
|
|
1202 )
|
|
1203
|
|
1204
|
|
1205 (defcustom feedmail-queue-alternative-mail-header-separator nil
|
|
1206 "*Alternative header demarcation for queued messages.
|
22609
|
1207 If you sometimes get alternative values for `mail-header-separator' in
|
22513
|
1208 queued messages, set the value of this variable to whatever it is.
|
22609
|
1209 For example, `rmail-resend' uses a `mail-header-separator' value of empty
|
22513
|
1210 string (\"\") when you send/queue a message.
|
|
1211
|
|
1212 When trying to send a queued message, if the value of this variable is
|
|
1213 non-nil, feedmail will first try to send the message using the value
|
22609
|
1214 of `mail-header-separator'. If it can't find that, it will temporarily
|
|
1215 set `mail-header-separator' to the value of
|
22513
|
1216 feedmail-queue-alternative-mail-header-separator and try again."
|
|
1217 :group 'feedmail-queue
|
|
1218 :type 'string
|
|
1219 )
|
|
1220
|
|
1221
|
|
1222 (defcustom feedmail-queue-runner-message-sender 'mail-send-and-exit
|
|
1223 "*Function to initiate sending a message file.
|
|
1224 Called for each message read back out of the queue directory with a
|
|
1225 single argument, the optional argument used in the call to
|
|
1226 feedmail-run-the-queue or feedmail-run-the-queue-no-prompts.
|
|
1227 Interactively, that argument will be the prefix argument. Most people
|
|
1228 want mail-send-and-exit (bound to C-c C-c in mail-mode), but here's
|
|
1229 your chance to have something different. Called with funcall, not
|
|
1230 call-interactively."
|
|
1231 :group 'feedmail-queue
|
|
1232 :type 'function
|
|
1233 )
|
|
1234
|
|
1235
|
|
1236 (defcustom feedmail-queue-runner-cleaner-upper
|
|
1237 '(lambda (fqm-file &optional arg)
|
|
1238 (delete-file fqm-file)
|
|
1239 (if (and arg feedmail-queue-chatty) (message "FQM: Nuked %s" fqm-file)))
|
22609
|
1240 "*Function that will be called after a message has been sent.
|
|
1241 Not called in the case of errors. This function is called with two
|
|
1242 arguments: the name of the message queue file for the message just sent,
|
|
1243 and the optional argument used in the call to `feedmail-run-the-queue'
|
|
1244 or `feedmail-run-the-queue-no-prompts' (prefix arg if interactive).
|
|
1245 In any case, the affiliated buffer is killed elsewhere, so don't do that
|
22513
|
1246 inside this function. Return value is ignored.
|
|
1247
|
|
1248 The default action is an anonymous function which gets rid of the file
|
|
1249 from the queue directory. With a non-nil second argument, a brief
|
|
1250 message is give for each file deleted. You could replace this
|
|
1251 function, for example, to archive all of your sent messages someplace
|
22609
|
1252 \(though there are better ways to get that particular result\)."
|
22513
|
1253 :group 'feedmail-queue
|
|
1254 :type 'function
|
|
1255 )
|
|
1256
|
|
1257
|
|
1258 (defvar feedmail-queue-runner-is-active nil
|
|
1259 "*Non-nil means we're inside the logic of the queue-running loop.
|
|
1260 That is, iterating over all messages in the queue to send them. In
|
|
1261 that case, the value is the name of the queued message file currently
|
|
1262 being processed. This can be used for differentiating customized code
|
|
1263 for different scenarios. Users shouldn't set or change this
|
|
1264 variable, but may depend on its value as described here.")
|
|
1265
|
|
1266
|
|
1267 (defvar feedmail-is-a-resend nil
|
|
1268 "*Non-nil means the the message is a RESEND (in the RFC-822 sense).
|
|
1269 This affects the composition of certain headers. feedmail sets this
|
|
1270 variable as soon as it starts prepping the message text buffer, so any
|
|
1271 user-supplied functions can rely on it. Users shouldn't set or change this
|
|
1272 variable, but may depend on its value as described here.")
|
|
1273
|
|
1274
|
|
1275 (defcustom feedmail-buffer-eating-function 'feedmail-buffer-to-binmail
|
|
1276 "*Function used to send the prepped buffer to a subprocess.
|
|
1277 The function's three (mandatory) arguments are: (1) the buffer
|
|
1278 containing the prepped message; (2) a buffer where errors should be
|
|
1279 directed; and (3) a list containing the addresses individually as
|
|
1280 strings. Three popular choices for this are
|
|
1281 feedmail-buffer-to-binmail, feedmail-buffer-to-smtpmail, and
|
|
1282 feedmail-buffer-to-sendmail. If you use the sendmail form, you
|
|
1283 probably want to set feedmail-nuke-bcc and/or feedmail-nuke-resent-bcc
|
|
1284 to nil. If you use the binmail form, check the value of
|
|
1285 feedmail-binmail-template."
|
|
1286 :group 'feedmail-misc
|
|
1287 :type 'function
|
|
1288 )
|
|
1289
|
|
1290
|
|
1291 (defcustom feedmail-binmail-template (if mail-interactive "/bin/mail %s" "/bin/rmail %s")
|
|
1292 "*Command template for the subprocess which will get rid of the mail.
|
|
1293 It can result in any command understandable by /bin/sh. Might not
|
|
1294 work at all in non-UNIX environments. The single '%s', if present,
|
|
1295 gets replaced by the space-separated, simplified list of addressees.
|
|
1296 Used in feedmail-buffer-to-binmail to form the shell command which
|
|
1297 will receive the contents of the prepped buffer as stdin. If you'd
|
|
1298 like your errors to come back as mail instead of immediately in a
|
|
1299 buffer, try /bin/rmail instead of /bin/mail (this can be accomplished
|
22609
|
1300 by keeping the default nil setting of `mail-interactive'). You might
|
22513
|
1301 also like to consult local mail experts for any other interesting
|
|
1302 command line possibilities."
|
|
1303 :group 'feedmail-misc
|
|
1304 :type 'string
|
|
1305 )
|
|
1306
|
|
1307
|
|
1308 ;; feedmail-buffer-to-binmail, feedmail-buffer-to-sendmail, and
|
|
1309 ;; feedmail-buffer-to-smptmail are the only things provided for values
|
|
1310 ;; for the variable feedmail-buffer-eating-function. It's pretty easy
|
|
1311 ;; to write your own, though.
|
|
1312 (defun feedmail-buffer-to-binmail (prepped errors-to addr-listoid)
|
|
1313 "Function which actually calls /bin/mail as a subprocess.
|
|
1314 Feeds the buffer to it."
|
|
1315 (set-buffer prepped)
|
|
1316 (apply
|
|
1317 'call-process-region
|
|
1318 (append (list (point-min) (point-max) "/bin/sh" nil errors-to nil "-c"
|
|
1319 (format feedmail-binmail-template
|
|
1320 (mapconcat 'identity addr-listoid " "))))))
|
|
1321
|
|
1322
|
|
1323 (defun feedmail-buffer-to-sendmail (prepped errors-to addr-listoid)
|
|
1324 "Function which actually calls sendmail as a subprocess.
|
|
1325 Feeds the buffer to it. Probably has some flaws for RESENT-* and other
|
|
1326 complicated cases."
|
|
1327 (set-buffer prepped)
|
|
1328 (apply 'call-process-region
|
|
1329 (append (list (point-min) (point-max)
|
|
1330 (if (boundp 'sendmail-program) sendmail-program "/usr/lib/sendmail")
|
|
1331 nil errors-to nil "-oi" "-t")
|
|
1332 ;; provide envelope "from" to sendmail; results will vary
|
|
1333 (list "-f" user-mail-address)
|
|
1334 ;; These mean "report errors by mail" and "deliver in background".
|
|
1335 (if (null mail-interactive) '("-oem" "-odb")))))
|
|
1336
|
|
1337 ;; provided by jam@austin.asc.slb.com (James A. McLaughlin);
|
|
1338 ;; simplified by WJC after more feedmail development;
|
|
1339 ;; idea (but not implementation) of copying smtpmail trace buffer to
|
|
1340 ;; feedmail error buffer from:
|
|
1341 ;; Mon 14-Oct-1996; Douglas Gray Stephens
|
|
1342 ;; modified to insert error for displaying
|
|
1343 (defun feedmail-buffer-to-smtpmail (prepped errors-to addr-listoid)
|
|
1344 "Function which actually calls smtpmail-via-smtp to send buffer as e-mail."
|
|
1345 ;; I'm not sure smtpmail.el is careful about the following
|
|
1346 ;; return value, but it also uses it internally, so I will fear
|
|
1347 ;; no evil.
|
|
1348 (require 'smtpmail)
|
|
1349 (if (not (smtpmail-via-smtp addr-listoid prepped))
|
|
1350 (progn
|
|
1351 (set-buffer errors-to)
|
|
1352 (insert "Send via smtpmail failed. Probable SMTP protocol error.\n")
|
|
1353 (insert "Look for details below or in the *Messages* buffer.\n\n")
|
|
1354 (let ((case-fold-search t)
|
|
1355 ;; don't be overconfident about the name of the trace buffer
|
|
1356 (tracer (concat "trace.*smtp.*" (regexp-quote smtpmail-smtp-server))))
|
|
1357 (mapcar
|
|
1358 '(lambda (buffy)
|
|
1359 (if (string-match tracer (buffer-name buffy))
|
|
1360 (progn
|
|
1361 (insert "SMTP Trace from " (buffer-name buffy) "\n---------------")
|
|
1362 (insert-buffer buffy)
|
|
1363 (insert "\n\n"))))
|
|
1364 (buffer-list))))))
|
|
1365
|
|
1366
|
|
1367 ;; just a place to park a docstring
|
|
1368 (defconst feedmail-fiddle-plex-blurb nil
|
22609
|
1369 "A fiddle-plex is a concise way of specifying header field fiddling.
|
22513
|
1370 It is a list of up to 4 elements: NAME, VALUE, ACTION, FOLDING. The element
|
|
1371 VALUE can also be a list sometimes.
|
|
1372
|
22609
|
1373 NAME is the name of the header field to be fiddled with. Although case
|
|
1374 doesn't matter in looking for headers, case of NAME is preserved when a header
|
|
1375 is inserted via fiddling. It shouldn't include the trailing colon.
|
22513
|
1376
|
|
1377 VALUE is either nil, a simple string, a function returning nil or a string, or,
|
22609
|
1378 as described below for ACTION `combine', a list of up to three values.
|
22513
|
1379
|
|
1380 ACTION describes the nature of the fiddling to be done. Possibilities
|
22609
|
1381 for ACTION (default is `supplement'):
|
22513
|
1382
|
22609
|
1383 `supplement' Leave other like fields as-is, insert this one.
|
22513
|
1384
|
22609
|
1385 `replace' Delete other like fields, if any, and insert this one.
|
22513
|
1386
|
22609
|
1387 `create' Insert this one only if no like field exists.
|
22513
|
1388
|
22609
|
1389 `combine' Combine aggregate values of like fields with this one.
|
22513
|
1390 In this case, VALUE has a special form. It is a list
|
|
1391 of three items: VAL-PRE, VAL-LIKE, and VAL-POST.
|
|
1392 VAL-PRE and VAL-POST are strings or nil. VAL-LIKE may
|
|
1393 be either a string or a function (it may also be nil,
|
|
1394 but there's not much point to that).
|
|
1395
|
|
1396 Values of like header fields are aggregated, leading and
|
|
1397 trailing whitespace is removed, and embedded
|
|
1398 whitespace is left as-is. If there are no like
|
|
1399 fields, or the aggregate value is an empty string,
|
|
1400 VAL-LIKE is not used. Else, if VAL-LIKE is a function,
|
|
1401 it is called with two arguments: NAME and the
|
22609
|
1402 aggregate like values. Else, if VAL-LIKE is a string, it is
|
22513
|
1403 used as a format string where a single \%s will be
|
|
1404 replaced by the aggregate values of like fields.
|
|
1405
|
|
1406 VAL-PRE, the results of using VAL-LIKE, and VAL-POST
|
|
1407 are concatenated, and the result, if not nil and not
|
|
1408 an empty string, is used as the new value for the
|
|
1409 field. Although this description sounds a bit
|
|
1410 complicated, the idea is to provide a mechanism for
|
|
1411 combining the old value with a new value in a flexible
|
|
1412 way. For example, if you wanted to add a new value to
|
|
1413 an existing header field by adding a semi-colon and
|
|
1414 then starting the new value on a continuation line,
|
|
1415 you might specify this:
|
|
1416
|
|
1417 (nil \"%s;\\n\\t\" \"This is my new value\")
|
|
1418
|
|
1419 FOLDING can be nil, in which case VALUE is used as-is. If FOLDING is
|
|
1420 non-nil, feedmail \"smart filling\" is done on VALUE just before
|
22609
|
1421 insertion.")
|
22513
|
1422
|
|
1423
|
|
1424 (defun feedmail-send-it ()
|
22609
|
1425 "A function which is a suitable value for `send-mail-function'.
|
22513
|
1426 To use it, you probably want something like this in your .emacs or
|
|
1427 similar place:
|
|
1428
|
|
1429 (setq send-mail-function 'feedmail-send-it)
|
|
1430 (autoload 'feedmail-send-it \"feedmail\")"
|
|
1431
|
|
1432 ;; avoid matching trouble over slash vs backslash by getting canonical
|
|
1433 (if feedmail-queue-directory
|
|
1434 (setq feedmail-queue-directory (expand-file-name feedmail-queue-directory)))
|
|
1435 (if feedmail-queue-draft-directory
|
|
1436 (setq feedmail-queue-draft-directory (expand-file-name feedmail-queue-draft-directory)))
|
|
1437 (if (not feedmail-enable-queue) (feedmail-send-it-immediately)
|
|
1438 ;; else, queuing is enabled, should we ask about it or just do it?
|
|
1439 (if feedmail-ask-before-queue
|
|
1440 (funcall (feedmail-queue-send-edit-prompt))
|
|
1441 (feedmail-dump-message-to-queue feedmail-queue-directory 'after-queue))))
|
|
1442
|
|
1443
|
|
1444 (defun feedmail-message-action-send ()
|
|
1445 ;; hooks can make this take a while so clear the prompt
|
|
1446 (message "FQM: Immediate send...")
|
|
1447 (feedmail-send-it-immediately))
|
|
1448
|
|
1449
|
|
1450 ;; From a VM mailing list discussion and some suggestions from Samuel Mikes <smikes@alumni.hmc.edu>
|
|
1451 (defun feedmail-queue-express-to-queue ()
|
|
1452 "*Send message directly to the queue, with a minimum of fuss and bother."
|
|
1453 (interactive)
|
|
1454 (let ((feedmail-enable-queue t)
|
|
1455 (feedmail-ask-before-queue nil)
|
|
1456 (feedmail-queue-reminder-alist nil)
|
|
1457 (feedmail-queue-chatty-sit-for 0))
|
|
1458 (feedmail-send-it)
|
|
1459 )
|
|
1460 )
|
|
1461
|
|
1462
|
|
1463 (defun feedmail-queue-express-to-draft ()
|
|
1464 "*Send message directly to the draft queue, with a minimum of fuss and bother."
|
|
1465 (interactive)
|
|
1466 (let ((feedmail-queue-directory feedmail-queue-draft-directory))
|
|
1467 (feedmail-queue-express-to-queue)
|
|
1468 )
|
|
1469 )
|
|
1470
|
|
1471
|
|
1472 (defun feedmail-message-action-send-strong ()
|
|
1473 (let ((feedmail-confirm-outgoing nil)) (feedmail-message-action-send)))
|
|
1474
|
|
1475
|
|
1476 (defun feedmail-message-action-edit ()
|
|
1477 (error "FQM: Message not queued; returning to edit"))
|
|
1478
|
|
1479
|
|
1480 (defun feedmail-message-action-draft ()
|
|
1481 (feedmail-dump-message-to-queue feedmail-queue-draft-directory 'after-draft))
|
|
1482
|
|
1483
|
|
1484 (defun feedmail-message-action-draft-strong ()
|
|
1485 (let ((buffer-file-name nil))
|
|
1486 (feedmail-message-action-draft)))
|
|
1487
|
|
1488
|
|
1489 (defun feedmail-message-action-queue ()
|
|
1490 (feedmail-dump-message-to-queue feedmail-queue-directory 'after-queue))
|
|
1491
|
|
1492
|
|
1493 (defun feedmail-message-action-queue-strong ()
|
|
1494 (let ((buffer-file-name nil))
|
|
1495 (feedmail-message-action-queue)))
|
|
1496
|
|
1497
|
|
1498 (defun feedmail-message-action-toggle-spray ()
|
|
1499 (let ((feedmail-enable-spray (not feedmail-enable-spray)))
|
|
1500 (if feedmail-enable-spray
|
|
1501 (message "FQM: For this message, spray toggled ON")
|
|
1502 (message "FQM: For this message, spray toggled OFF"))
|
|
1503 (sit-for 3)
|
|
1504 ;; recursion, but harmless
|
|
1505 (feedmail-send-it)))
|
|
1506
|
|
1507
|
|
1508 (defun feedmail-message-action-help ()
|
|
1509 (let ((d-string " "))
|
|
1510 (if (stringp feedmail-ask-before-queue-default)
|
|
1511 (setq d-string feedmail-ask-before-queue-default)
|
|
1512 (setq d-string (char-to-string feedmail-ask-before-queue-default)))
|
|
1513 (feedmail-queue-send-edit-prompt-help d-string)
|
|
1514 ;; recursive, but no worries (it goes deeper on user action)
|
|
1515 (feedmail-send-it)))
|
|
1516
|
|
1517
|
|
1518 ;;;###autoload
|
|
1519 (defun feedmail-run-the-queue-no-prompts (&optional arg)
|
|
1520 "Like feedmail-run-the-queue, but suppress confirmation prompts."
|
|
1521 (interactive "p")
|
|
1522 (let ((feedmail-confirm-outgoing nil)) (feedmail-run-the-queue arg)))
|
|
1523
|
|
1524 ;;;###autoload
|
|
1525 (defun feedmail-run-the-queue-global-prompt (&optional arg)
|
|
1526 "Like feedmail-run-the-queue, but with a global confirmation prompt.
|
22609
|
1527 This is generally most useful if run non-interactively, since you can
|
22513
|
1528 bail out with an appropriate answer to the global confirmation prompt."
|
|
1529 (interactive "p")
|
|
1530 (let ((feedmail-queue-runner-confirm-global t)) (feedmail-run-the-queue arg)))
|
|
1531
|
|
1532 ;;;###autoload
|
|
1533 (defun feedmail-run-the-queue (&optional arg)
|
|
1534 "Visit each message in the feedmail queue directory and send it out.
|
|
1535 Return value is a list of three things: number of messages sent, number of
|
|
1536 messages skipped, and number of non-message things in the queue (commonly
|
|
1537 backup file names and the like)."
|
|
1538 (interactive "p")
|
|
1539 ;; avoid matching trouble over slash vs backslash by getting canonical
|
|
1540 (if feedmail-queue-directory
|
|
1541 (setq feedmail-queue-directory (expand-file-name feedmail-queue-directory)))
|
|
1542 (if feedmail-queue-draft-directory
|
|
1543 (setq feedmail-queue-draft-directory (expand-file-name feedmail-queue-draft-directory)))
|
|
1544 (let* ((maybe-file)
|
|
1545 (qlist (feedmail-look-at-queue-directory feedmail-queue-directory))
|
|
1546 (dlist (feedmail-look-at-queue-directory feedmail-queue-draft-directory))
|
|
1547 (q-cnt (nth 0 qlist))
|
|
1548 (q-oth (nth 1 qlist))
|
|
1549 (d-cnt (nth 0 dlist))
|
|
1550 (d-oth (nth 1 dlist))
|
|
1551 (messages-sent 0)
|
|
1552 (messages-skipped 0)
|
|
1553 (blobby-buffer)
|
|
1554 (already-buffer)
|
|
1555 (this-mhsep)
|
|
1556 (do-the-run t)
|
|
1557 (list-of-possible-fqms))
|
|
1558 (if (and (> q-cnt 0) feedmail-queue-runner-confirm-global)
|
|
1559 (setq do-the-run
|
|
1560 (if (fboundp 'y-or-n-p-with-timeout)
|
|
1561 (y-or-n-p-with-timeout (format "FQM: Draft: %dm+%d, Queue: %dm+%d; run the queue? "
|
|
1562 d-cnt d-oth q-cnt q-oth)
|
|
1563 5 nil)
|
|
1564 (y-or-n-p (format "FQM: Draft: %dm+%d, Queue: %dm+%d; run the queue? "
|
|
1565 d-cnt d-oth q-cnt q-oth))
|
|
1566 )))
|
|
1567 (if (not do-the-run)
|
|
1568 (setq messages-skipped q-cnt)
|
|
1569 (save-window-excursion
|
|
1570 (setq list-of-possible-fqms (directory-files feedmail-queue-directory t))
|
|
1571 (if feedmail-queue-run-orderer
|
|
1572 (setq list-of-possible-fqms (funcall feedmail-queue-run-orderer list-of-possible-fqms)))
|
|
1573 (mapcar
|
|
1574 '(lambda (blobby)
|
|
1575 (setq maybe-file (expand-file-name blobby feedmail-queue-directory))
|
|
1576 (cond
|
22609
|
1577 ((file-directory-p maybe-file) nil) ; don't care about subdirs
|
22513
|
1578 ((feedmail-fqm-p blobby)
|
|
1579 (setq blobby-buffer (generate-new-buffer (concat "FQM " blobby)))
|
|
1580 (setq already-buffer
|
|
1581 (if (fboundp 'find-buffer-visiting) ; missing from XEmacs
|
|
1582 (find-buffer-visiting maybe-file)
|
|
1583 (get-file-buffer maybe-file)))
|
|
1584 (if (and already-buffer (buffer-modified-p already-buffer))
|
|
1585 (save-window-excursion
|
|
1586 (display-buffer (set-buffer already-buffer))
|
|
1587 (if (fboundp 'y-or-n-p-with-timeout)
|
|
1588 ;; make a guess that the user just forgot to save
|
|
1589 (if (y-or-n-p-with-timeout (format "FQM: Visiting %s; save before send? " blobby) 10 t)
|
|
1590 (save-buffer))
|
|
1591 (if (y-or-n-p (format "FQM: Visiting %s; save before send? " blobby))
|
|
1592 (save-buffer))
|
|
1593 )))
|
|
1594
|
|
1595 (set-buffer blobby-buffer)
|
|
1596 (setq buffer-offer-save nil)
|
|
1597 (buffer-disable-undo blobby-buffer)
|
|
1598 (insert-file-contents-literally maybe-file)
|
|
1599 ;; work around text-vs-binary wierdness and also around rmail-resend's creative
|
|
1600 ;; manipulation of mail-header-separator
|
|
1601 ;;
|
|
1602 ;; if we don't find the normal M-H-S, and the alternative is defined but also
|
|
1603 ;; not found, try reading the file a different way
|
|
1604 ;;
|
|
1605 ;; if M-H-S not found and (a-M-H-S is nil or not found)
|
|
1606 (if (and (not (feedmail-find-eoh t))
|
|
1607 (or (not feedmail-queue-alternative-mail-header-separator)
|
22609
|
1608 (not
|
22513
|
1609 (let ((mail-header-separator feedmail-queue-alternative-mail-header-separator))
|
|
1610 (feedmail-find-eoh t)))))
|
|
1611 (let ((file-name-buffer-file-type-alist nil) (default-buffer-file-type nil))
|
|
1612 (erase-buffer) (insert-file-contents maybe-file))
|
|
1613 )
|
|
1614 ;; if M-H-S not found and (a-M-H-S is non-nil and is found)
|
|
1615 ;; temporarily set M-H-S to the value of a-M-H-S
|
|
1616 (if (and (not (feedmail-find-eoh t))
|
|
1617 feedmail-queue-alternative-mail-header-separator
|
|
1618 (let ((mail-header-separator feedmail-queue-alternative-mail-header-separator))
|
|
1619 (feedmail-find-eoh t)))
|
|
1620 (setq this-mhsep feedmail-queue-alternative-mail-header-separator)
|
|
1621 (setq this-mhsep mail-header-separator))
|
|
1622 (funcall feedmail-queue-runner-mode-setter arg)
|
|
1623 (condition-case nil ; don't give up the loop if user skips some
|
|
1624 (let ((feedmail-enable-queue nil)
|
|
1625 (mail-header-separator this-mhsep)
|
|
1626 (feedmail-queue-runner-is-active maybe-file))
|
|
1627 (funcall feedmail-queue-runner-message-sender arg)
|
|
1628 (set-buffer blobby-buffer)
|
|
1629 (if (buffer-modified-p) ; still modified, means wasn't sent
|
|
1630 (setq messages-skipped (1+ messages-skipped))
|
|
1631 (setq messages-sent (1+ messages-sent))
|
|
1632 (funcall feedmail-queue-runner-cleaner-upper maybe-file arg)
|
|
1633 (if (and already-buffer (not (file-exists-p maybe-file)))
|
|
1634 ;; we have gotten rid of the file associated with the
|
|
1635 ;; buffer, so update the buffer's notion of that
|
|
1636 (save-excursion
|
|
1637 (set-buffer already-buffer)
|
|
1638 (setq buffer-file-name nil)))))
|
|
1639 (error (setq messages-skipped (1+ messages-skipped))))
|
|
1640 (kill-buffer blobby-buffer)
|
|
1641 (if feedmail-queue-chatty
|
|
1642 (progn
|
|
1643 (message "FQM: %d to go, %d sent, %d skipped (%d other files ignored)"
|
|
1644 (- q-cnt messages-sent messages-skipped)
|
|
1645 messages-sent messages-skipped q-oth)
|
|
1646 (sit-for feedmail-queue-chatty-sit-for))))))
|
|
1647 list-of-possible-fqms)))
|
|
1648 (if feedmail-queue-chatty
|
22609
|
1649 (progn
|
22513
|
1650 (message "FQM: %d sent, %d skipped (%d other files ignored)"
|
|
1651 messages-sent messages-skipped q-oth)
|
|
1652 (sit-for feedmail-queue-chatty-sit-for)
|
|
1653 (feedmail-queue-reminder 'after-run)
|
|
1654 (sit-for feedmail-queue-chatty-sit-for)))
|
|
1655 (list messages-sent messages-skipped q-oth)))
|
|
1656
|
|
1657
|
|
1658 ;;;###autoload
|
|
1659 (defun feedmail-queue-reminder (&optional what-event)
|
|
1660 "Perform some kind of reminder activity about queued and draft messages.
|
|
1661 Called with an optional symbol argument which says what kind of event
|
|
1662 is triggering the reminder activity. The default is 'on-demand, which
|
|
1663 is what you typically would use if you were putting this in your emacs start-up
|
|
1664 or mail hook code. Other recognized values for WHAT-EVENT (these are passed
|
|
1665 internally by feedmail):
|
|
1666
|
|
1667 after-immediate (a message has just been sent in immediate mode)
|
|
1668 after-queue (a message has just been queued)
|
|
1669 after-draft (a message has just been placed in the draft directory)
|
|
1670 after-run (the queue has just been run, possibly sending messages)
|
|
1671
|
|
1672 WHAT-EVENT is used as a key into the table feedmail-queue-reminder-alist. If
|
|
1673 the associated value is a function, it is called without arguments and is expected
|
22609
|
1674 to perform the reminder activity. You can supply your own reminder functions
|
|
1675 by redefining feedmail-queue-reminder-alist. If you don't want any reminders,
|
22513
|
1676 you can set feedmail-queue-reminder-alist to nil."
|
|
1677 (interactive "p")
|
|
1678 (let ((key (if (and what-event (symbolp what-event)) what-event 'on-demand)) entry reminder)
|
|
1679 (setq entry (assoc key feedmail-queue-reminder-alist))
|
|
1680 (setq reminder (cdr entry))
|
|
1681 (if (fboundp reminder) (funcall reminder)))
|
|
1682 )
|
|
1683
|
|
1684
|
|
1685 (defun feedmail-queue-reminder-brief ()
|
|
1686 "Brief display of draft and queued message counts in modeline."
|
|
1687 (interactive)
|
|
1688 (let (q-cnt d-cnt q-lis d-lis)
|
|
1689 (setq q-lis (feedmail-look-at-queue-directory feedmail-queue-directory))
|
|
1690 (setq d-lis (feedmail-look-at-queue-directory feedmail-queue-draft-directory))
|
|
1691 (setq q-cnt (car q-lis))
|
|
1692 (setq d-cnt (car d-lis))
|
|
1693 (if (or (> q-cnt 0) (> d-cnt 0))
|
|
1694 (progn
|
|
1695 (message "FQM: [D: %d, Q: %d]" d-cnt q-cnt))))
|
|
1696 )
|
|
1697
|
|
1698
|
|
1699 (defun feedmail-queue-reminder-medium ()
|
|
1700 "Verbose display of draft and queued message counts in modeline."
|
|
1701 (interactive)
|
|
1702 (let (q-cnt d-cnt q-oth d-oth q-lis d-lis)
|
|
1703 (setq q-lis (feedmail-look-at-queue-directory feedmail-queue-directory))
|
|
1704 (setq d-lis (feedmail-look-at-queue-directory feedmail-queue-draft-directory))
|
|
1705 (setq q-cnt (car q-lis))
|
|
1706 (setq d-cnt (car d-lis))
|
|
1707 (setq q-oth (nth 1 q-lis))
|
|
1708 (setq d-oth (nth 1 d-lis))
|
|
1709 (if (or (> q-cnt 0) (> d-cnt 0))
|
|
1710 (progn
|
|
1711 (message "FQM: Draft: %dm+%d in \"%s\", Queue: %dm+%d in \"%s\""
|
|
1712 d-cnt d-oth (file-name-nondirectory feedmail-queue-draft-directory)
|
|
1713 q-cnt q-oth (file-name-nondirectory feedmail-queue-directory)))))
|
|
1714 )
|
|
1715
|
|
1716
|
|
1717 (defun feedmail-queue-send-edit-prompt ()
|
|
1718 "Ask whether to queue, send immediately, or return to editing a message."
|
|
1719 ;; Some implementation ideas here came from the userlock.el code
|
|
1720 (discard-input)
|
|
1721 (save-window-excursion
|
|
1722 (let ((answer) (d-char) (d-string " "))
|
|
1723 (if (stringp feedmail-ask-before-queue-default)
|
|
1724 (progn
|
|
1725 (setq d-char (string-to-char feedmail-ask-before-queue-default))
|
|
1726 (setq d-string feedmail-ask-before-queue-default))
|
|
1727 (setq d-string (char-to-string feedmail-ask-before-queue-default))
|
|
1728 (setq d-char feedmail-ask-before-queue-default)
|
|
1729 )
|
|
1730 (while (null answer)
|
|
1731 (message feedmail-ask-before-queue-prompt d-string)
|
|
1732 (let ((user-sez
|
|
1733 (let ((inhibit-quit t) (cursor-in-echo-area t) (echo-keystrokes 0))
|
|
1734 (read-char-exclusive))))
|
|
1735 (if (= user-sez help-char)
|
|
1736 (setq answer '(^ . feedmail-message-action-help))
|
|
1737 (if (or (eq user-sez ?\C-m) (eq user-sez ?\C-j) (eq user-sez ?y))
|
|
1738 (setq user-sez d-char))
|
22609
|
1739 ;; these char-to-int things are because of some
|
|
1740 ;; incomprensible difference between the two in
|
|
1741 ;; byte-compiled stuff between Emacs and XEmacs
|
|
1742 ;; (well, I'm sure someone could comprehend it,
|
|
1743 ;; but I say 'uncle')
|
22513
|
1744 (setq answer (or (assoc user-sez feedmail-prompt-before-queue-user-alist)
|
|
1745 (and (fboundp 'char-to-int)
|
|
1746 (assoc (char-to-int user-sez) feedmail-prompt-before-queue-user-alist))
|
|
1747 (assoc user-sez feedmail-prompt-before-queue-standard-alist)
|
|
1748 (and (fboundp 'char-to-int)
|
|
1749 (assoc (char-to-int user-sez) feedmail-prompt-before-queue-standard-alist))))
|
|
1750 (if (or (null answer) (null (cdr answer)))
|
|
1751 (progn
|
|
1752 (beep)
|
|
1753 (message feedmail-ask-before-queue-reprompt d-string)
|
|
1754 (sit-for 3)))
|
|
1755 )))
|
|
1756 (cdr answer)
|
|
1757 )))
|
|
1758
|
|
1759 (defconst feedmail-p-h-b-n "*FQM Help*")
|
|
1760
|
|
1761 (defun feedmail-queue-send-edit-prompt-help (d-string)
|
|
1762 (let ((fqm-help (get-buffer feedmail-p-h-b-n)))
|
|
1763 (if (and fqm-help (get-buffer-window fqm-help))
|
|
1764 (feedmail-queue-send-edit-prompt-help-later fqm-help d-string)
|
|
1765 (feedmail-queue-send-edit-prompt-help-first d-string))))
|
|
1766
|
|
1767 (defun feedmail-queue-send-edit-prompt-help-later (fqm-help d-string)
|
|
1768 ;; scrolling fun
|
|
1769 (save-selected-window
|
|
1770 (let ((signal-error-on-buffer-boundary nil)
|
|
1771 (fqm-window (display-buffer fqm-help)))
|
|
1772 (select-window fqm-window)
|
|
1773 (if (pos-visible-in-window-p (point-max) fqm-window)
|
|
1774 (feedmail-queue-send-edit-prompt-help-first d-string)
|
|
1775 ;; (goto-char (point-min))
|
|
1776 (scroll-up nil)
|
|
1777 ))))
|
|
1778
|
|
1779 (defun feedmail-queue-send-edit-prompt-help-first (d-string)
|
|
1780 (with-output-to-temp-buffer feedmail-p-h-b-n
|
|
1781 (princ "You're dispatching a message and feedmail queuing is enabled.
|
|
1782 Typing ? or C-v will normally scroll this help buffer.
|
|
1783
|
|
1784 Choices:
|
|
1785 q QUEUE for later sending (via feedmail-run-the-queue)
|
|
1786 Q QUEUE! like \"q\", but always make a new file
|
|
1787 i IMMEDIATELY send this (but not the other queued messages)
|
|
1788 I IMMEDIATELY! like \"i\", but skip following confirmation prompt
|
|
1789 d DRAFT queue in the draft directory
|
|
1790 D DRAFT! like \"d\", but always make a new file
|
|
1791 e EDIT return to the message edit buffer (don't send or queue)
|
|
1792 * SPRAY toggle spray mode (individual message transmissions)
|
|
1793
|
|
1794 Synonyms:
|
|
1795 s SEND immediately (same as \"i\")
|
|
1796 S SEND! immediately (same as \"I\")
|
|
1797 r ROUGH draft (same as \"d\")
|
|
1798 R ROUGH! draft (same as \"R\")
|
|
1799 n NOPE didn't mean it (same as \"e\")
|
|
1800 y YUP do the default behavior (same as \"C-m\")
|
|
1801
|
|
1802 The user-configurable default is currently \"")
|
|
1803 (princ d-string)
|
|
1804 (princ "\". For other possibilities,
|
|
1805 see the variable feedmail-prompt-before-queue-user-alist.
|
|
1806 ")
|
|
1807 (and (stringp feedmail-prompt-before-queue-help-supplement)
|
|
1808 (princ feedmail-prompt-before-queue-help-supplement))
|
|
1809 (save-excursion (set-buffer standard-output) (if (fboundp 'help-mode) (help-mode)))))
|
|
1810
|
|
1811 (defun feedmail-look-at-queue-directory (queue-directory)
|
|
1812 "Find out some things about a queue directory.
|
|
1813 Result is a list containing a count of queued messages in the
|
|
1814 directory, a count of other files in the directory, and a high water
|
|
1815 mark for prefix sequence numbers. Subdirectories are not included in
|
|
1816 the counts."
|
|
1817 (let ((q-cnt 0) (q-oth 0) (high-water 0) (blobbet))
|
|
1818 ;; iterate, counting things we find along the way in the directory
|
|
1819 (if (file-directory-p queue-directory)
|
|
1820 (mapcar
|
|
1821 '(lambda (blobby)
|
|
1822 (cond
|
|
1823 ((file-directory-p blobby) nil) ; don't care about subdirs
|
|
1824 ((feedmail-fqm-p blobby)
|
|
1825 (setq blobbet (file-name-nondirectory blobby))
|
|
1826 (if (string-match "^[0-9][0-9][0-9]-" blobbet)
|
|
1827 (let ((water-mark))
|
|
1828 (setq water-mark (string-to-int (substring blobbet 0 3)))
|
|
1829 (if (> water-mark high-water) (setq high-water water-mark))))
|
|
1830 (setq q-cnt (1+ q-cnt)))
|
|
1831 (t (setq q-oth (1+ q-oth)))
|
|
1832 ))
|
|
1833 (directory-files queue-directory t)))
|
|
1834 (list q-cnt q-oth high-water)))
|
|
1835
|
|
1836 (defun feedmail-tidy-up-slug (slug)
|
22609
|
1837 "Utility for mapping out suspect characters in a potential filename."
|
22513
|
1838 ;; even programmers deserve a break sometimes, so cover nil for them
|
|
1839 (if (null slug) (setq slug ""))
|
|
1840 ;; replace all non-alphanumerics with hyphen for safety
|
|
1841 (while (string-match "[^a-z0-9-]+" slug) (setq slug (replace-match "-" nil nil slug)))
|
|
1842 ;; collapse multiple hyphens to one
|
|
1843 (while (string-match "--+" slug) (setq slug (replace-match "-" nil nil slug)))
|
|
1844 ;; for tidyness, peel off leading hyphens
|
|
1845 (if (string-match "^-*" slug) (setq slug (replace-match "" nil nil slug)))
|
|
1846 ;; for tidyness, peel off trailing hyphens
|
|
1847 (if (string-match "-*$" slug) (setq slug (replace-match "" nil nil slug)))
|
|
1848 slug
|
22609
|
1849 )
|
22513
|
1850
|
|
1851 (defun feedmail-queue-subject-slug-maker (&optional queue-directory)
|
|
1852 "Create a name for storing the message in the queue.
|
|
1853 Optional argument QUEUE-DIRECTORY specifies into which directory the
|
|
1854 file will be placed. The name is based on the SUBJECT: header (if
|
|
1855 there is one). If there is no subject,
|
|
1856 feedmail-queue-default-file-slug is consulted Special characters are
|
|
1857 mapped to mostly alphanumerics for safety."
|
|
1858 (let ((eoh-marker) (case-fold-search t) (subject "") (s-point))
|
|
1859 (setq eoh-marker (feedmail-find-eoh))
|
|
1860 (goto-char (point-min))
|
|
1861 ;; get raw subject value (first line, anyhow)
|
|
1862 (if (re-search-forward "^SUBJECT:" eoh-marker t)
|
|
1863 (progn (setq s-point (point))
|
|
1864 (end-of-line)
|
|
1865 (setq subject (buffer-substring s-point (point)))))
|
|
1866 (setq subject (feedmail-tidy-up-slug subject))
|
|
1867 (if (zerop (length subject))
|
|
1868 (setq subject
|
|
1869 (cond
|
|
1870 ((stringp feedmail-queue-default-file-slug) feedmail-queue-default-file-slug)
|
|
1871 ((fboundp feedmail-queue-default-file-slug)
|
|
1872 (save-excursion (funcall feedmail-queue-default-file-slug)))
|
|
1873 ((eq feedmail-queue-default-file-slug 'ask)
|
|
1874 (file-name-nondirectory
|
|
1875 (read-file-name "FQM: Message filename slug? "
|
|
1876 (file-name-as-directory queue-directory) subject nil subject)))
|
|
1877 (t "no subject"))
|
|
1878 ))
|
|
1879 (feedmail-tidy-up-slug subject) ;; one more time, with feeling
|
|
1880 ))
|
|
1881
|
|
1882
|
|
1883 (defun feedmail-create-queue-filename (queue-directory)
|
|
1884 (let ((slug "wjc"))
|
|
1885 (cond
|
|
1886 (feedmail-queue-slug-maker
|
|
1887 (save-excursion (setq slug (funcall feedmail-queue-slug-maker queue-directory))))
|
|
1888 (feedmail-ask-for-queue-slug
|
|
1889 (setq slug (file-name-nondirectory
|
|
1890 (read-file-name (concat "FQM: Message filename slug? [" slug "]? ")
|
|
1891 (file-name-as-directory queue-directory) slug nil slug))))
|
|
1892 )
|
|
1893 (setq slug (feedmail-tidy-up-slug slug))
|
|
1894 (setq slug (format "%03d-%s" (1+ (nth 2 (feedmail-look-at-queue-directory queue-directory))) slug))
|
|
1895 (concat
|
|
1896 (expand-file-name slug queue-directory)
|
|
1897 feedmail-queue-fqm-suffix)
|
|
1898 ))
|
|
1899
|
|
1900
|
|
1901 (defun feedmail-dump-message-to-queue (queue-directory what-event)
|
|
1902 (or (file-accessible-directory-p queue-directory)
|
|
1903 ;; progn to get nil result no matter what
|
|
1904 (progn (make-directory queue-directory t) nil)
|
|
1905 (file-accessible-directory-p queue-directory)
|
|
1906 (error (concat "FQM: Message not queued; trouble with directory " queue-directory)))
|
|
1907 (let ((filename)
|
|
1908 (is-fqm)
|
|
1909 (is-in-this-dir)
|
|
1910 (previous-buffer-file-name buffer-file-name))
|
|
1911 (if buffer-file-name
|
|
1912 (progn
|
|
1913 (setq is-fqm (feedmail-fqm-p buffer-file-name))
|
|
1914 (setq is-in-this-dir (string-equal
|
|
1915 (directory-file-name queue-directory)
|
|
1916 (directory-file-name (expand-file-name (file-name-directory buffer-file-name)))))))
|
|
1917 ;; if visiting a queued message, just save
|
|
1918 (if (and is-fqm is-in-this-dir)
|
|
1919 (setq filename buffer-file-name)
|
|
1920 (setq filename (feedmail-create-queue-filename queue-directory)))
|
|
1921 ;; make binary file on DOS/Win95/WinNT, etc
|
|
1922 (let ((buffer-file-type feedmail-force-binary-write)) (write-file filename))
|
|
1923 ;; convenient for moving from draft to q, for example
|
|
1924 (if (and previous-buffer-file-name (or (not is-fqm) (not is-in-this-dir))
|
|
1925 (y-or-n-p (format "FQM: Was previously %s; delete that? " previous-buffer-file-name)))
|
|
1926 (delete-file previous-buffer-file-name))
|
|
1927 (if feedmail-nuke-buffer-after-queue
|
|
1928 (let ((a-s-file-name buffer-auto-save-file-name))
|
|
1929 ;; be aggressive in nuking auto-save files
|
|
1930 (and (kill-buffer (current-buffer))
|
|
1931 delete-auto-save-files
|
|
1932 (file-exists-p a-s-file-name)
|
|
1933 (delete-file a-s-file-name))))
|
|
1934 (if feedmail-queue-chatty
|
|
1935 (progn (message (concat "FQM: Queued in " filename))
|
|
1936 (sit-for feedmail-queue-chatty-sit-for)))
|
|
1937 (if feedmail-queue-chatty
|
|
1938 (progn
|
|
1939 (feedmail-queue-reminder what-event)
|
|
1940 (sit-for feedmail-queue-chatty-sit-for)))))
|
|
1941
|
|
1942
|
|
1943 ;; from a similar function in mail-utils.el
|
|
1944 (defun feedmail-rfc822-time-zone (time)
|
|
1945 (let* ((sec (or (car (current-time-zone time)) 0))
|
|
1946 (absmin (/ (abs sec) 60)))
|
|
1947 (format "%c%02d%02d" (if (< sec 0) ?- ?+) (/ absmin 60) (% absmin 60))))
|
|
1948
|
|
1949 (defun feedmail-rfc822-date (arg-time)
|
|
1950 (let ((time (if arg-time arg-time (current-time))))
|
|
1951 (concat
|
|
1952 (format-time-string "%a, %e %b %Y %T " time)
|
|
1953 (feedmail-rfc822-time-zone time)
|
|
1954 )))
|
|
1955
|
|
1956
|
|
1957 (defun feedmail-send-it-immediately ()
|
|
1958 "Handle immediate sending, including during a queue run."
|
|
1959 (let* ((feedmail-error-buffer (get-buffer-create " *FQM Outgoing Email Errors*"))
|
|
1960 (feedmail-prepped-text-buffer (get-buffer-create " *FQM Outgoing Email Text*"))
|
|
1961 (feedmail-raw-text-buffer (current-buffer))
|
|
1962 (feedmail-address-list)
|
|
1963 (eoh-marker)
|
|
1964 (bcc-holder)
|
|
1965 (resent-bcc-holder)
|
|
1966 (a-re-rtcb "^RESENT-\\(TO\\|CC\\|BCC\\):")
|
|
1967 (a-re-rtc "^RESENT-\\(TO\\|CC\\):")
|
|
1968 (a-re-rb "^RESENT-BCC:")
|
|
1969 (a-re-dtcb "^\\(TO\\|CC\\|BCC\\):")
|
|
1970 (a-re-dtc "^\\(TO\\|CC\\):")
|
|
1971 (a-re-db "^BCC:")
|
|
1972 (mail-header-separator mail-header-separator) ;; to get a temporary changable copy
|
|
1973 )
|
|
1974 (unwind-protect
|
|
1975 (save-excursion
|
|
1976 (set-buffer feedmail-error-buffer) (erase-buffer)
|
|
1977 (set-buffer feedmail-prepped-text-buffer) (erase-buffer)
|
|
1978
|
|
1979 ;; jam contents of user-supplied mail buffer into our scratch buffer
|
|
1980 (insert-buffer feedmail-raw-text-buffer)
|
|
1981
|
|
1982 ;; require one newline at the end.
|
|
1983 (goto-char (point-max))
|
|
1984 (or (= (preceding-char) ?\n) (insert ?\n))
|
|
1985
|
|
1986 (let ((case-fold-search nil))
|
|
1987 ;; Change header-delimiter to be what mailers expect (empty line).
|
|
1988 (setq eoh-marker (feedmail-find-eoh)) ;; leaves match data in place or signals error
|
|
1989 (replace-match "\n")
|
|
1990 (setq mail-header-separator ""))
|
|
1991
|
|
1992 ;; mail-aliases nil = mail-abbrevs.el
|
|
1993 (if (or feedmail-force-expand-mail-aliases
|
|
1994 (and (fboundp 'expand-mail-aliases) mail-aliases))
|
|
1995 (expand-mail-aliases (point-min) eoh-marker))
|
|
1996
|
|
1997 ;; make it pretty
|
|
1998 (if feedmail-fill-to-cc (feedmail-fill-to-cc-function eoh-marker))
|
|
1999 ;; ignore any blank lines in the header
|
|
2000 (goto-char (point-min))
|
|
2001 (while (and (re-search-forward "\n\n\n*" eoh-marker t) (< (point) eoh-marker))
|
|
2002 (replace-match "\n"))
|
|
2003
|
|
2004 (let ((case-fold-search t) (addr-regexp))
|
|
2005 (goto-char (point-min))
|
|
2006 ;; there are some RFC-822 combinations/cases missed here,
|
|
2007 ;; but probably good enough and what users expect
|
|
2008 ;;
|
|
2009 ;; use resent-* stuff only if there is at least one non-empty one
|
|
2010 (setq feedmail-is-a-resend
|
|
2011 (re-search-forward
|
|
2012 ;; header name, followed by optional whitespace, followed by
|
|
2013 ;; non-whitespace, followed by anything, followed by newline;
|
|
2014 ;; the idea is empty RESENT-* headers are ignored
|
|
2015 "^\\(RESENT-TO:\\|RESENT-CC:\\|RESENT-BCC:\\)\\s-*\\S-+.*$"
|
|
2016 eoh-marker t))
|
|
2017 ;; if we say so, gather the BCC stuff before the main course
|
|
2018 (if (eq feedmail-deduce-bcc-where 'first)
|
|
2019 (progn (if feedmail-is-a-resend (setq addr-regexp a-re-rb) (setq addr-regexp a-re-db))
|
|
2020 (setq feedmail-address-list (feedmail-deduce-address-list feedmail-prepped-text-buffer (point-min) eoh-marker addr-regexp feedmail-address-list))))
|
|
2021 ;; the main course
|
|
2022 (if (or (eq feedmail-deduce-bcc-where 'first) (eq feedmail-deduce-bcc-where 'last))
|
|
2023 ;; handled by first or last cases, so don't get BCC stuff
|
|
2024 (progn (if feedmail-is-a-resend (setq addr-regexp a-re-rtc) (setq addr-regexp a-re-dtc))
|
|
2025 (setq feedmail-address-list (feedmail-deduce-address-list feedmail-prepped-text-buffer (point-min) eoh-marker addr-regexp feedmail-address-list)))
|
|
2026 ;; not handled by first or last cases, so also get BCC stuff
|
|
2027 (progn (if feedmail-is-a-resend (setq addr-regexp a-re-rtcb) (setq addr-regexp a-re-dtcb))
|
|
2028 (setq feedmail-address-list (feedmail-deduce-address-list feedmail-prepped-text-buffer (point-min) eoh-marker addr-regexp feedmail-address-list))))
|
|
2029 ;; if we say so, gather the BCC stuff after the main course
|
|
2030 (if (eq feedmail-deduce-bcc-where 'last)
|
|
2031 (progn (if feedmail-is-a-resend (setq addr-regexp a-re-rb) (setq addr-regexp a-re-db))
|
|
2032 (setq feedmail-address-list (feedmail-deduce-address-list feedmail-prepped-text-buffer (point-min) eoh-marker addr-regexp feedmail-address-list))))
|
|
2033 (if (not feedmail-address-list) (error "FQM: Sending...abandoned, no addressees"))
|
|
2034 ;; not needed, but meets user expectations
|
|
2035 (setq feedmail-address-list (nreverse feedmail-address-list))
|
|
2036 ;; Find and handle any BCC fields.
|
|
2037 (setq bcc-holder (feedmail-accume-n-nuke-header eoh-marker "^BCC:"))
|
|
2038 (setq resent-bcc-holder (feedmail-accume-n-nuke-header eoh-marker "^RESENT-BCC:"))
|
|
2039 (if (and bcc-holder (not feedmail-nuke-bcc))
|
|
2040 (progn (goto-char (point-min))
|
|
2041 (insert bcc-holder)))
|
|
2042 (if (and resent-bcc-holder (not feedmail-nuke-resent-bcc))
|
|
2043 (progn (goto-char (point-min))
|
|
2044 (insert resent-bcc-holder)))
|
|
2045 (goto-char (point-min))
|
|
2046
|
|
2047 ;; fiddle about, fiddle about, fiddle about....
|
|
2048 (feedmail-fiddle-from)
|
|
2049 (feedmail-fiddle-sender)
|
|
2050 (feedmail-fiddle-x-mailer)
|
|
2051 (feedmail-fiddle-message-id
|
|
2052 (or feedmail-queue-runner-is-active (buffer-file-name feedmail-raw-text-buffer)))
|
|
2053 (feedmail-fiddle-date
|
|
2054 (or feedmail-queue-runner-is-active (buffer-file-name feedmail-raw-text-buffer)))
|
|
2055 (feedmail-fiddle-list-of-fiddle-plexes feedmail-fiddle-plex-user-list)
|
|
2056
|
|
2057 ;; don't send out a blank headers of various sorts
|
|
2058 ;; (this loses on continued line with a blank first line)
|
|
2059 (goto-char (point-min))
|
|
2060 (and feedmail-nuke-empty-headers ; hey, who's an empty-header?
|
|
2061 (while (re-search-forward "^[A-Za-z0-9-]+:[ \t]*\n" eoh-marker t)
|
|
2062 (replace-match ""))))
|
|
2063
|
|
2064 (run-hooks 'feedmail-last-chance-hook)
|
|
2065
|
|
2066 (let ((fcc (feedmail-accume-n-nuke-header eoh-marker "^FCC:"))
|
|
2067 (also-file)
|
|
2068 (confirm (cond
|
|
2069 ((eq feedmail-confirm-outgoing 'immediate)
|
|
2070 (not feedmail-queue-runner-is-active))
|
|
2071 ((eq feedmail-confirm-outgoing 'queued) feedmail-queue-runner-is-active)
|
|
2072 (t feedmail-confirm-outgoing))))
|
|
2073 (if (or (not confirm) (feedmail-one-last-look feedmail-prepped-text-buffer))
|
|
2074 (let ((user-mail-address (feedmail-envelope-deducer eoh-marker)))
|
|
2075 (feedmail-give-it-to-buffer-eater)
|
|
2076 (if (and (not feedmail-queue-runner-is-active) (setq also-file (buffer-file-name feedmail-raw-text-buffer)))
|
|
2077 (progn ; if a file but not running the queue, offer to delete it
|
|
2078 (setq also-file (expand-file-name also-file))
|
|
2079 (if (or feedmail-queue-auto-file-nuke
|
|
2080 (y-or-n-p (format "FQM: Delete message file %s? " also-file)))
|
|
2081 (save-excursion
|
|
2082 ;; if we delete the affiliated file, get rid
|
22609
|
2083 ;; of the file name association and make sure we
|
22513
|
2084 ;; don't annoy people with a prompt on exit
|
|
2085 (delete-file also-file)
|
|
2086 (set-buffer feedmail-raw-text-buffer)
|
|
2087 (setq buffer-offer-save nil)
|
|
2088 (setq buffer-file-name nil)
|
|
2089 )
|
|
2090 )))
|
|
2091 (goto-char (point-min))
|
|
2092 ;; re-insert and handle any FCC fields (and, optionally, any BCC).
|
|
2093 (if fcc (let ((default-buffer-file-type feedmail-force-binary-write))
|
|
2094 (insert fcc)
|
|
2095 (if (not feedmail-nuke-bcc-in-fcc)
|
|
2096 (progn (if bcc-holder (insert bcc-holder))
|
|
2097 (if resent-bcc-holder (insert resent-bcc-holder))))
|
|
2098
|
|
2099 (run-hooks 'feedmail-before-fcc-hook)
|
|
2100
|
|
2101 (if feedmail-nuke-body-in-fcc
|
|
2102 (progn (goto-char eoh-marker)
|
|
2103 (if (natnump feedmail-nuke-body-in-fcc)
|
|
2104 (forward-line feedmail-nuke-body-in-fcc))
|
|
2105 (delete-region (point) (point-max))
|
|
2106 ))
|
|
2107 (mail-do-fcc eoh-marker)
|
|
2108 )))
|
|
2109 (error "FQM: Sending...abandoned") ; user bailed out of one-last-look
|
|
2110 ))) ; unwind-protect body (save-excursion)
|
|
2111
|
|
2112 ;; unwind-protect cleanup forms
|
|
2113 (kill-buffer feedmail-prepped-text-buffer)
|
|
2114 (set-buffer feedmail-error-buffer)
|
|
2115 (if (zerop (buffer-size)) (kill-buffer feedmail-error-buffer)
|
|
2116 (progn (display-buffer feedmail-error-buffer)
|
|
2117 ;; read fast ... the meter is running
|
|
2118 (if (and feedmail-queue-runner-is-active feedmail-queue-chatty)
|
|
2119 (progn (message "FQM: Sending...failed") (ding t) (sit-for 3)))
|
|
2120 (error "FQM: Sending...failed")))
|
|
2121 (set-buffer feedmail-raw-text-buffer))
|
|
2122 ) ; let
|
|
2123 (if (and feedmail-queue-chatty (not feedmail-queue-runner-is-active))
|
|
2124 (progn
|
|
2125 (feedmail-queue-reminder 'after-immediate)
|
|
2126 (sit-for feedmail-queue-chatty-sit-for)))
|
|
2127 )
|
|
2128
|
|
2129
|
|
2130 (defun feedmail-fiddle-header (name value &optional action folding)
|
|
2131 "Internal feedmail function for jamming fields into message header.
|
|
2132 NAME, VALUE, ACTION, and FOLDING are the four elements of a
|
|
2133 fiddle-plex, as described in the documentation for the variable
|
|
2134 feedmail-fiddle-plex-blurb."
|
|
2135 (let ((case-fold-search t)
|
|
2136 (header-colon (concat (regexp-quote name) ":"))
|
|
2137 header-regexp eoh-marker has-like ag-like val-like that-point)
|
|
2138 (setq header-regexp (concat "^" header-colon))
|
|
2139 (setq eoh-marker (feedmail-find-eoh))
|
|
2140 (goto-char (point-min))
|
|
2141 (setq has-like (re-search-forward header-regexp eoh-marker t))
|
|
2142
|
|
2143 (if (not action) (setq action 'supplement))
|
|
2144 (cond
|
|
2145 ((eq action 'supplement)
|
|
2146 ;; trim leading/trailing whitespace
|
|
2147 (if (string-match "\\`[ \t\n]+" value)
|
|
2148 (setq value (substring value (match-end 0))))
|
|
2149 (if (string-match "[ \t\n]+\\'" value)
|
|
2150 (setq value (substring value 0 (match-beginning 0))))
|
|
2151 (if (> (length value) 0)
|
|
2152 (progn
|
|
2153 (if feedmail-fiddle-headers-upwardly
|
|
2154 (goto-char (point-min))
|
|
2155 (goto-char eoh-marker))
|
|
2156 (setq that-point (point))
|
|
2157 (insert name ": " value "\n")
|
|
2158 (if folding (feedmail-fill-this-one that-point (point))))))
|
|
2159
|
|
2160 ((eq action 'replace)
|
|
2161 (if has-like (feedmail-accume-n-nuke-header eoh-marker header-regexp))
|
|
2162 (feedmail-fiddle-header name value 'supplement folding))
|
|
2163
|
|
2164 ((eq action 'create)
|
|
2165 (if (not has-like) (feedmail-fiddle-header name value 'supplement folding)))
|
|
2166
|
|
2167 ((eq action 'combine)
|
|
2168 (setq val-like (nth 1 value))
|
|
2169 (setq ag-like (or (feedmail-accume-n-nuke-header eoh-marker header-regexp) ""))
|
|
2170 ;; get rid of initial header name from first instance (front of string)
|
|
2171 (if (string-match (concat header-regexp "[ \t\n]+") ag-like)
|
|
2172 (setq ag-like (replace-match "" t t ag-like)))
|
|
2173 ;; get rid of embedded header names from subsequent instances
|
|
2174 (while (string-match (concat "\n" header-colon "[ \t\n]+") ag-like)
|
|
2175 (setq ag-like (replace-match "\n\t" t t ag-like)))
|
|
2176 ;; trim leading/trailing whitespace
|
|
2177 (if (string-match "\\`[ \t\n]+" ag-like)
|
|
2178 (setq ag-like (substring ag-like (match-end 0))))
|
|
2179 (if (string-match "[ \t\n]+\\'" ag-like)
|
|
2180 (setq ag-like (substring ag-like 0 (match-beginning 0))))
|
|
2181 ;; if ag-like is not nil and not an empty string, transform it via a function
|
|
2182 ;; call or format operation
|
|
2183 (if (> (length ag-like) 0)
|
|
2184 (setq ag-like
|
|
2185 (cond
|
|
2186 ((and (symbolp val-like) (fboundp val-like))
|
|
2187 (funcall val-like name ag-like))
|
|
2188 ((stringp val-like)
|
|
2189 (format val-like ag-like))
|
|
2190 (t nil))))
|
|
2191 (feedmail-fiddle-header name (concat (nth 0 value) ag-like (nth 2 value)) 'supplement folding)))
|
|
2192 ))
|
|
2193
|
|
2194 (defun feedmail-give-it-to-buffer-eater ()
|
|
2195 (save-excursion
|
|
2196 (if feedmail-enable-spray
|
|
2197 (mapcar
|
|
2198 '(lambda (feedmail-spray-this-address)
|
|
2199 (let ((spray-buffer (get-buffer-create " *FQM Outgoing Email Spray*")))
|
22609
|
2200 (save-excursion
|
22513
|
2201 (set-buffer spray-buffer)
|
|
2202 (erase-buffer)
|
|
2203 ;; not life's most efficient methodology, but spraying isn't
|
|
2204 ;; an every-5-minutes event either
|
|
2205 (insert-buffer feedmail-prepped-text-buffer)
|
|
2206 ;; There's a good case to me made that each separate transmission of
|
|
2207 ;; a message in the spray should have a distinct MESSAGE-ID:. There
|
|
2208 ;; is also a less compelling argument in the other direction. I think
|
|
2209 ;; they technically should have distinct MESSAGE-ID:s, but I doubt that
|
|
2210 ;; anyone cares, practically. If someone complains about it, I'll add
|
|
2211 ;; it.
|
|
2212 (feedmail-fiddle-list-of-spray-fiddle-plexes feedmail-spray-address-fiddle-plex-list)
|
|
2213 ;; this (let ) is just in case some buffer eater
|
|
2214 ;; is cheating and using the global variable name instead
|
|
2215 ;; of its argument to find the buffer
|
|
2216 (let ((feedmail-prepped-text-buffer spray-buffer))
|
|
2217 (funcall feedmail-buffer-eating-function
|
|
2218 feedmail-prepped-text-buffer
|
|
2219 feedmail-error-buffer
|
|
2220 (list feedmail-spray-this-address))))
|
|
2221 (kill-buffer spray-buffer)
|
|
2222 ))
|
|
2223 feedmail-address-list)
|
|
2224 (funcall feedmail-buffer-eating-function
|
|
2225 feedmail-prepped-text-buffer
|
|
2226 feedmail-error-buffer
|
|
2227 feedmail-address-list))))
|
|
2228
|
|
2229
|
|
2230 (defun feedmail-envelope-deducer (eoh-marker)
|
22609
|
2231 "If feedmail-deduce-envelope-from is false, simply return `user-mail-address'.
|
|
2232 Else, look for SENDER: or FROM: (or RESENT-*) and
|
22513
|
2233 return that value."
|
|
2234 (if (not feedmail-deduce-envelope-from)
|
|
2235 user-mail-address
|
|
2236 (let ((from-list))
|
|
2237 (setq from-list
|
|
2238 (feedmail-deduce-address-list
|
|
2239 (current-buffer) (point-min) eoh-marker (if feedmail-is-a-resend "^RESENT-SENDER:" "^SENDER:")
|
|
2240 from-list))
|
|
2241 (if (not from-list)
|
|
2242 (setq from-list
|
|
2243 (feedmail-deduce-address-list
|
|
2244 (current-buffer) (point-min) eoh-marker (if feedmail-is-a-resend "^RESENT-FROM:" "^FROM:")
|
|
2245 from-list)))
|
|
2246 (if (and from-list (car from-list)) (car from-list) user-mail-address))))
|
|
2247
|
|
2248
|
|
2249 (defun feedmail-fiddle-from ()
|
|
2250 "Fiddle FROM:."
|
|
2251 ;; default is to fall off the end of the list and do nothing
|
|
2252 (cond
|
|
2253 ;; nil means do nothing
|
|
2254 ((eq nil feedmail-from-line) nil)
|
|
2255 ;; t is the same a using the default computation, so compute it and recurse
|
|
2256 ;; user-full-name suggested by kpc@ptolemy.arc.nasa.gov (=Kimball Collins)
|
|
2257 ;; improvement using user-mail-address suggested by
|
|
2258 ;; gray@austin.apc.slb.com (Douglas Gray Stephens)
|
|
2259 ((eq t feedmail-from-line)
|
22609
|
2260 (let ((feedmail-from-line
|
22513
|
2261 (let ((at-stuff
|
|
2262 (if user-mail-address user-mail-address (concat (user-login-name) "@" (system-name)))))
|
|
2263 (cond
|
|
2264 ((eq mail-from-style nil) at-stuff)
|
|
2265 ((eq mail-from-style 'parens) (concat at-stuff " (" (user-full-name) ")"))
|
|
2266 ((eq mail-from-style 'angles) (concat "\"" (user-full-name) "\" <" at-stuff ">"))
|
|
2267 ))))
|
|
2268 (feedmail-fiddle-from)))
|
|
2269
|
|
2270 ;; if it's a string, simply make a fiddle-plex out of it and recurse
|
|
2271 ((stringp feedmail-from-line)
|
|
2272 (let ((feedmail-from-line (list "ignored" feedmail-from-line 'create)))
|
|
2273 (feedmail-fiddle-from)))
|
|
2274
|
|
2275 ;; if it's a function, call it and recurse with the resulting value
|
|
2276 ((and (symbolp feedmail-from-line) (fboundp feedmail-from-line))
|
|
2277 (let ((feedmail-from-line (funcall feedmail-from-line)))
|
|
2278 (feedmail-fiddle-from)))
|
|
2279
|
|
2280 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
|
|
2281 ((listp feedmail-from-line)
|
|
2282 (feedmail-fiddle-header
|
|
2283 (if feedmail-is-a-resend "Resent-From" "From")
|
|
2284 (nth 1 feedmail-from-line) ;; value
|
|
2285 (nth 2 feedmail-from-line) ;; action
|
|
2286 (nth 3 feedmail-from-line))))) ;; folding
|
|
2287
|
|
2288
|
|
2289 (defun feedmail-fiddle-sender ()
|
|
2290 "Fiddle SENDER:."
|
|
2291 ;; default is to fall off the end of the list and do nothing
|
|
2292 (cond
|
|
2293 ;; nil means do nothing
|
|
2294 ((eq nil feedmail-sender-line) nil)
|
|
2295 ;; t is not allowed, but handled it just to avoid bugs later
|
|
2296 ((eq t feedmail-sender-line) nil)
|
|
2297
|
|
2298 ;; if it's a string, simply make a fiddle-plex out of it and recurse
|
|
2299 ((stringp feedmail-sender-line)
|
|
2300 (let ((feedmail-sender-line (list "ignored" feedmail-sender-line 'create)))
|
|
2301 (feedmail-fiddle-sender)))
|
|
2302
|
|
2303 ;; if it's a function, call it and recurse with the resulting value
|
|
2304 ((and (symbolp feedmail-sender-line) (fboundp feedmail-sender-line))
|
|
2305 (let ((feedmail-sender-line (funcall feedmail-sender-line)))
|
|
2306 (feedmail-fiddle-sender)))
|
|
2307
|
|
2308 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
|
|
2309 ((listp feedmail-sender-line)
|
|
2310 (feedmail-fiddle-header
|
|
2311 (if feedmail-is-a-resend "Resent-Sender" "Sender")
|
|
2312 (nth 1 feedmail-sender-line) ;; value
|
|
2313 (nth 2 feedmail-sender-line) ;; action
|
|
2314 (nth 3 feedmail-sender-line))))) ;; folding
|
|
2315
|
|
2316
|
|
2317 (defun feedmail-default-date-generator (maybe-file)
|
|
2318 "Default function for generating DATE: header contents."
|
|
2319 (let ((date-time))
|
|
2320 (if (and (not feedmail-queue-use-send-time-for-date) maybe-file)
|
|
2321 (setq date-time (nth 5 (file-attributes maybe-file))))
|
|
2322 (feedmail-rfc822-date date-time))
|
|
2323 )
|
|
2324
|
|
2325
|
|
2326 (defun feedmail-fiddle-date (maybe-file)
|
|
2327 "Fiddle DATE:. See documentation of feedmail-date-generator."
|
|
2328 ;; default is to fall off the end of the list and do nothing
|
|
2329 (cond
|
|
2330 ;; nil means do nothing
|
|
2331 ((eq nil feedmail-date-generator) nil)
|
|
2332 ;; t is the same a using the function feedmail-default-date-generator, so let it and recurse
|
|
2333 ((eq t feedmail-date-generator)
|
|
2334 (let ((feedmail-date-generator (feedmail-default-date-generator maybe-file)))
|
|
2335 (feedmail-fiddle-date maybe-file)))
|
|
2336
|
|
2337 ;; if it's a string, simply make a fiddle-plex out of it and recurse
|
|
2338 ((stringp feedmail-date-generator)
|
|
2339 (let ((feedmail-date-generator (list "ignored" feedmail-date-generator 'create)))
|
|
2340 (feedmail-fiddle-date maybe-file)))
|
|
2341
|
|
2342 ;; if it's a function, call it and recurse with the resulting value
|
|
2343 ((and (symbolp feedmail-date-generator) (fboundp feedmail-date-generator))
|
|
2344 (let ((feedmail-date-generator (funcall feedmail-date-generator maybe-file)))
|
|
2345 (feedmail-fiddle-date maybe-file)))
|
|
2346
|
|
2347 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
|
|
2348 ((listp feedmail-date-generator)
|
|
2349 (feedmail-fiddle-header
|
|
2350 (if feedmail-is-a-resend "Resent-Date" "Date")
|
|
2351 (nth 1 feedmail-date-generator) ;; value
|
|
2352 (nth 2 feedmail-date-generator) ;; action
|
|
2353 (nth 3 feedmail-date-generator))))) ;; folding
|
|
2354
|
|
2355
|
|
2356 (defun feedmail-default-message-id-generator (maybe-file)
|
|
2357 "Default function for generating MESSAGE-ID: header contents.
|
|
2358 Based on a date and a sort of random number for tie breaking. Unless
|
22609
|
2359 feedmail-message-id-suffix is defined, uses `user-mail-address', so be
|
22513
|
2360 sure it's set."
|
|
2361 (let ((date-time)
|
|
2362 (end-stuff (if feedmail-message-id-suffix feedmail-message-id-suffix user-mail-address)))
|
|
2363 (if (string-match "^\\(.*\\)@" end-stuff)
|
|
2364 (setq end-stuff
|
|
2365 (concat (if (equal (match-beginning 1) (match-end 1)) "" "-") end-stuff))
|
|
2366 (setq end-stuff (concat "@" end-stuff)))
|
|
2367 (if (and (not feedmail-queue-use-send-time-for-message-id) maybe-file)
|
|
2368 (setq date-time (nth 5 (file-attributes maybe-file))))
|
|
2369 (format "<%d-%s%s%s>"
|
|
2370 (mod (random) 10000)
|
|
2371 (format-time-string "%a%d%b%Y%H%M%S" date-time)
|
|
2372 (feedmail-rfc822-time-zone date-time)
|
|
2373 end-stuff))
|
|
2374 )
|
|
2375
|
|
2376 (defun feedmail-fiddle-message-id (maybe-file)
|
|
2377 "Fiddle MESSAGE-ID:. See documentation of feedmail-message-id-generator."
|
|
2378 ;; default is to fall off the end of the list and do nothing
|
|
2379 (cond
|
|
2380 ;; nil means do nothing
|
|
2381 ((eq nil feedmail-message-id-generator) nil)
|
|
2382 ;; t is the same a using the function feedmail-default-message-id-generator, so let it and recurse
|
|
2383 ((eq t feedmail-message-id-generator)
|
|
2384 (let ((feedmail-message-id-generator (feedmail-default-message-id-generator maybe-file)))
|
|
2385 (feedmail-fiddle-message-id maybe-file)))
|
|
2386
|
|
2387 ;; if it's a string, simply make a fiddle-plex out of it and recurse
|
|
2388 ((stringp feedmail-message-id-generator)
|
|
2389 (let ((feedmail-message-id-generator (list "ignored" feedmail-message-id-generator 'create)))
|
|
2390 (feedmail-fiddle-message-id maybe-file)))
|
|
2391
|
|
2392 ;; if it's a function, call it and recurse with the resulting value
|
|
2393 ((and (symbolp feedmail-message-id-generator) (fboundp feedmail-message-id-generator))
|
|
2394 (let ((feedmail-message-id-generator (funcall feedmail-message-id-generator maybe-file)))
|
|
2395 (feedmail-fiddle-message-id maybe-file)))
|
|
2396
|
|
2397 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
|
|
2398 ((listp feedmail-message-id-generator)
|
|
2399 (feedmail-fiddle-header
|
|
2400 (if feedmail-is-a-resend "Resent-Message-ID" "Message-ID")
|
|
2401 (nth 1 feedmail-message-id-generator) ;; value
|
|
2402 (nth 2 feedmail-message-id-generator) ;; action
|
|
2403 (nth 3 feedmail-message-id-generator))))) ;; folding
|
|
2404
|
|
2405
|
|
2406 (defun feedmail-default-x-mailer-generator ()
|
|
2407 "Default function for generating X-MAILER: header contents."
|
|
2408 (concat
|
|
2409 (let ((case-fold-search t)) (if (string-match "emacs" emacs-version) "" "emacs "))
|
|
2410 emacs-version " (via feedmail " feedmail-patch-level
|
|
2411 (if feedmail-queue-runner-is-active " Q" " I")
|
|
2412 (if feedmail-enable-spray "S" "")
|
|
2413 (if feedmail-x-mailer-line-user-appendage ") " ")")
|
|
2414 feedmail-x-mailer-line-user-appendage))
|
|
2415
|
|
2416
|
|
2417 (defun feedmail-fiddle-x-mailer ()
|
|
2418 "Fiddle X-MAILER:. See documentation of feedmail-x-mailer-line."
|
|
2419 ;; default is to fall off the end of the list and do nothing
|
|
2420 (cond
|
|
2421 ;; t is the same a using the function feedmail-default-x-mailer-generator, so let it and recurse
|
|
2422 ((eq t feedmail-x-mailer-line)
|
|
2423 (let ((feedmail-x-mailer-line (feedmail-default-x-mailer-generator)))
|
|
2424 (feedmail-fiddle-x-mailer)))
|
|
2425
|
|
2426 ;; if it's a string, simply make a fiddle-plex out of it and recurse
|
|
2427 ((stringp feedmail-x-mailer-line)
|
|
2428 (let ((feedmail-x-mailer-line (list "ignored" (list feedmail-x-mailer-line ";\n\t%s") 'combine)))
|
|
2429 (feedmail-fiddle-x-mailer)))
|
|
2430
|
|
2431 ;; if it's a function, call it and recurse with the resulting value
|
|
2432 ((and (symbolp feedmail-x-mailer-line) (fboundp feedmail-x-mailer-line))
|
|
2433 (let ((feedmail-x-mailer-line (funcall feedmail-x-mailer-line)))
|
|
2434 (feedmail-fiddle-x-mailer)))
|
|
2435
|
|
2436 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
|
|
2437 ((listp feedmail-x-mailer-line)
|
|
2438 (feedmail-fiddle-header
|
|
2439 (if feedmail-is-a-resend "X-Resent-Mailer" "X-Mailer")
|
|
2440 (nth 1 feedmail-x-mailer-line) ;; value
|
|
2441 (nth 2 feedmail-x-mailer-line) ;; action
|
|
2442 (nth 3 feedmail-x-mailer-line))))) ;; folding
|
|
2443
|
|
2444
|
|
2445 (defun feedmail-fiddle-spray-address (addy-plex)
|
|
2446 "Fiddle header for single spray address. Uses feedmail-spray-this-address."
|
|
2447 ;; default is to fall off the end of the list and do nothing
|
|
2448 (cond
|
|
2449 ;; nil means do nothing
|
|
2450 ((eq nil addy-plex) nil)
|
|
2451 ;; t means the same as using "TO: and unembellished addy
|
|
2452 ((eq t addy-plex)
|
|
2453 (let ((addy-plex (list "To" feedmail-spray-this-address)))
|
|
2454 (feedmail-fiddle-spray-address addy-plex)))
|
|
2455
|
|
2456 ;; if it's a string, simply make a fiddle-plex out of it and recurse, assuming
|
|
2457 ;; the string names a header field (e.g., "TO")
|
|
2458 ((stringp addy-plex)
|
|
2459 (let ((addy-plex (list addy-plex feedmail-spray-this-address)))
|
|
2460 (feedmail-fiddle-spray-address addy-plex)))
|
|
2461
|
|
2462 ;; if it's a function, call it and recurse with the resulting value
|
|
2463 ((and (symbolp addy-plex) (fboundp addy-plex))
|
|
2464 (let ((addy-plex (funcall addy-plex)))
|
|
2465 (feedmail-fiddle-spray-address addy-plex)))
|
|
2466
|
|
2467 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
|
|
2468 ((listp addy-plex)
|
|
2469 (feedmail-fiddle-header
|
|
2470 (nth 0 addy-plex) ;; name
|
|
2471 (nth 1 addy-plex) ;; value
|
|
2472 (nth 2 addy-plex) ;; action
|
|
2473 (nth 3 addy-plex))))) ;; folding
|
|
2474
|
|
2475
|
|
2476 (defun feedmail-fiddle-list-of-spray-fiddle-plexes (list-of-fiddle-plexes)
|
|
2477 "Fiddling based on a list of fiddle-plexes for spraying."
|
|
2478 ;; default is to fall off the end of the list and do nothing
|
|
2479 (let ((lofp list-of-fiddle-plexes) fp)
|
22609
|
2480 (if (listp lofp)
|
|
2481 (while lofp
|
|
2482 (setq fp (car lofp))
|
|
2483 (setq lofp (cdr lofp))
|
|
2484 (feedmail-fiddle-spray-address fp))
|
|
2485 (feedmail-fiddle-spray-address lofp))))
|
22513
|
2486
|
|
2487
|
|
2488 (defun feedmail-fiddle-list-of-fiddle-plexes (list-of-fiddle-plexes)
|
|
2489 "Fiddling based on a list of fiddle-plexes. Values t, nil, and string are pointless."
|
|
2490 ;; default is to fall off the end of the list and do nothing
|
|
2491 (let ((lofp list-of-fiddle-plexes) fp)
|
22609
|
2492 (while lofp
|
|
2493 (setq fp (car lofp))
|
|
2494 (setq lofp (cdr lofp))
|
|
2495 (cond
|
22513
|
2496
|
22609
|
2497 ;; if it's a function, call it and recurse with the resulting value
|
|
2498 ((and (symbolp fp) (fboundp fp))
|
|
2499 (let ((lofp (list (funcall fp)))) (feedmail-fiddle-list-of-fiddle-plexes lofp)))
|
22513
|
2500
|
22609
|
2501 ;; if it's a list, it must be a fiddle-plex -- so fiddle, man, fiddle
|
|
2502 ((listp fp)
|
|
2503 (feedmail-fiddle-header
|
|
2504 (nth 0 fp)
|
|
2505 (nth 1 fp);; value
|
|
2506 (nth 2 fp);; action
|
|
2507 (nth 3 fp)))))));; folding
|
22513
|
2508
|
|
2509
|
|
2510 (defun feedmail-accume-n-nuke-header (header-end header-regexp)
|
|
2511 "Delete headers matching a regexp and their continuation lines.
|
|
2512 There may be multiple such lines, and each may have arbitrarily
|
|
2513 many continuation lines. Return an accumulation of the deleted
|
|
2514 headers, including the intervening newlines."
|
|
2515 (let ((case-fold-search t) (dropout))
|
22609
|
2516 (save-excursion
|
|
2517 (goto-char (point-min))
|
|
2518 ;; iterate over all matching lines
|
|
2519 (while (re-search-forward header-regexp header-end t)
|
|
2520 (forward-line 1)
|
|
2521 (setq dropout (concat dropout (buffer-substring (match-beginning 0) (point))))
|
|
2522 (delete-region (match-beginning 0) (point))
|
|
2523 ;; get rid of any continuation lines
|
|
2524 (while (and (looking-at "^[ \t].*\n") (< (point) header-end))
|
|
2525 (forward-line 1)
|
|
2526 (setq dropout (concat dropout (buffer-substring (match-beginning 0) (point))))
|
|
2527 (replace-match ""))))
|
22513
|
2528 (identity dropout)))
|
|
2529
|
|
2530 (defun feedmail-fill-to-cc-function (header-end)
|
|
2531 "Smart filling of address headers (don't be fooled by the name).
|
|
2532 The filling tries to avoid splitting lines except at commas. This
|
|
2533 avoids, in particular, splitting within parenthesized comments in
|
|
2534 addresses. Headers filled include FROM:, REPLY-TO:, TO:, CC:, BCC:,
|
|
2535 RESENT-TO:, RESENT-CC:, and RESENT-BCC:."
|
|
2536 (let ((case-fold-search t)
|
|
2537 this-line
|
|
2538 this-line-end)
|
|
2539 (save-excursion
|
|
2540 (goto-char (point-min))
|
|
2541 ;; iterate over all TO:/CC:, etc, lines
|
|
2542 (while
|
|
2543 (re-search-forward
|
|
2544 "^\\(FROM:\\|REPLY-TO:\\|TO:\\|CC:\\|BCC:\\|RESENT-TO:\\|RESENT-CC:\\|RESENT-BCC:\\)"
|
|
2545 header-end t)
|
|
2546 (setq this-line (match-beginning 0))
|
|
2547 ;; replace 0 or more leading spaces with a single space
|
|
2548 (and (looking-at "[ \t]*") (replace-match " "))
|
|
2549 (forward-line 1)
|
|
2550 ;; get any continuation lines
|
|
2551 (while (and (looking-at "[ \t]+") (< (point) header-end))
|
|
2552 (forward-line 1))
|
|
2553 (setq this-line-end (point-marker))
|
|
2554 (save-excursion (feedmail-fill-this-one this-line this-line-end))
|
|
2555 ))))
|
|
2556
|
|
2557
|
|
2558 (defun feedmail-fill-this-one (this-line this-line-end)
|
|
2559 "In-place smart filling of the region bounded by the two arguments."
|
|
2560 (let ((fill-prefix "\t")
|
|
2561 (fill-column feedmail-fill-to-cc-fill-column))
|
|
2562 ;; The general idea is to break only on commas. Collapse
|
|
2563 ;; multiple whitespace to a single blank; change
|
|
2564 ;; all the blanks to something unprintable; change the
|
|
2565 ;; commas to blanks; fill the region; change it back.
|
|
2566 (goto-char this-line)
|
|
2567 (while (re-search-forward "\\s-+" (1- this-line-end) t)
|
|
2568 (replace-match " "))
|
|
2569
|
|
2570 (subst-char-in-region this-line this-line-end ? 2 t) ; blank->C-b
|
|
2571 (subst-char-in-region this-line this-line-end ?, ? t) ; comma->blank
|
|
2572
|
|
2573 (fill-region-as-paragraph this-line this-line-end)
|
|
2574
|
|
2575 (subst-char-in-region this-line this-line-end ? ?, t) ; comma<-blank
|
|
2576 (subst-char-in-region this-line this-line-end 2 ? t) ; blank<-C-b
|
|
2577
|
|
2578 ;; look out for missing commas before continuation lines
|
|
2579 (goto-char this-line)
|
|
2580 (while (re-search-forward "\\([^,]\\)\n\t[ ]*" this-line-end t)
|
|
2581 (replace-match "\\1,\n\t"))
|
|
2582 ))
|
|
2583
|
|
2584
|
|
2585 (require 'mail-utils) ; pick up mail-strip-quoted-names
|
|
2586 (defun feedmail-deduce-address-list (message-buffer header-start header-end addr-regexp address-list)
|
|
2587 "Get address list with all comments and other excitement trimmed.
|
|
2588 Addresses are collected only from headers whose names match the fourth
|
|
2589 argument Returns a list of strings. Duplicate addresses will have
|
|
2590 been weeded out."
|
|
2591 (let ((simple-address)
|
|
2592 (address-blob)
|
|
2593 (this-line)
|
|
2594 (this-line-end))
|
|
2595 (unwind-protect
|
|
2596 (save-excursion
|
|
2597 (set-buffer (get-buffer-create " *FQM scratch*")) (erase-buffer)
|
|
2598 (insert-buffer-substring message-buffer header-start header-end)
|
|
2599 (goto-char (point-min))
|
|
2600 (let ((case-fold-search t))
|
|
2601 (while (re-search-forward addr-regexp (point-max) t)
|
|
2602 (replace-match "")
|
|
2603 (setq this-line (match-beginning 0))
|
|
2604 (forward-line 1)
|
|
2605 ;; get any continuation lines
|
|
2606 (while (and (looking-at "^[ \t]+") (< (point) (point-max)))
|
|
2607 (forward-line 1))
|
|
2608 (setq this-line-end (point-marker))
|
|
2609 ;; only keep if we don't have it already
|
|
2610 (setq address-blob
|
|
2611 (mail-strip-quoted-names (buffer-substring this-line this-line-end)))
|
|
2612 (while (string-match "\\([, \t\n\r]*\\)\\([^, \t\n\r]+\\)" address-blob)
|
|
2613 (setq simple-address (substring address-blob (match-beginning 2) (match-end 2)))
|
|
2614 (setq address-blob (replace-match "" t t address-blob))
|
|
2615 (if (not (member simple-address address-list))
|
|
2616 (add-to-list 'address-list simple-address)))
|
|
2617 ))
|
|
2618 (kill-buffer nil)))
|
|
2619 (identity address-list)))
|
|
2620
|
|
2621
|
|
2622 (defun feedmail-one-last-look (feedmail-prepped-text-buffer)
|
|
2623 "Offer the user one last chance to give it up."
|
|
2624 (save-excursion
|
|
2625 (save-window-excursion
|
|
2626 (switch-to-buffer feedmail-prepped-text-buffer)
|
|
2627 (if (and (fboundp 'y-or-n-p-with-timeout) (numberp feedmail-confirm-outgoing-timeout))
|
|
2628 (y-or-n-p-with-timeout
|
|
2629 "FQM: Send this email? "
|
|
2630 (abs feedmail-confirm-outgoing-timeout)
|
|
2631 (> feedmail-confirm-outgoing-timeout 0))
|
|
2632 (y-or-n-p "FQM: Send this email? "))
|
|
2633 )))
|
|
2634
|
|
2635 (defun feedmail-fqm-p (might-be)
|
|
2636 "Internal; does filename end with FQM suffix?"
|
|
2637 (string-match (concat (regexp-quote feedmail-queue-fqm-suffix) "$") might-be))
|
|
2638
|
|
2639
|
|
2640 (defun feedmail-find-eoh (&optional noerror)
|
|
2641 "Internal; finds the end of message header fields, returns mark just before it"
|
|
2642 (save-excursion
|
|
2643 (goto-char (point-min))
|
|
2644 (if (re-search-forward (concat "^" (regexp-quote mail-header-separator) "\n") nil noerror)
|
|
2645 (progn
|
|
2646 (forward-line -1)
|
|
2647 (point-marker)))))
|
|
2648
|
|
2649 (provide 'feedmail)
|
|
2650 ;;; feedmail.el ends here
|