1 ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs
3 ;; Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998,
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5 ;; Free Software Foundation, Inc.
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation, either version 3 of the License, or
15 ;; (at your option) any later version.
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
29 ;; Souped up by shane@mit-ajax based on ideas of rlk@athena.mit.edu
30 ;; New features include attribute and keyword support, message
31 ;; selection by dispatch table, summary by attributes and keywords,
32 ;; expunging by dispatch table, sticky options for file commands.
34 ;; Extended by Bob Weiner of Motorola
35 ;; New features include: rmail and rmail-summary buffers remain
36 ;; synchronized and key bindings basically operate the same way in both
37 ;; buffers, summary by topic or by regular expression, rmail-reply-prefix
38 ;; variable, and a bury rmail buffer (wipe) command.
43 (defconst rmail-attribute-header
"X-RMAIL-ATTRIBUTES"
44 "The header that stores the Rmail attribute data.")
46 (defconst rmail-keyword-header
"X-RMAIL-KEYWORDS"
47 "The header that stores the Rmail keyword data.")
51 (defconst rmail-answered-attr-index
0
52 "The index for the `answered' attribute.")
54 (defconst rmail-deleted-attr-index
1
55 "The index for the `deleted' attribute.")
57 (defconst rmail-edited-attr-index
2
58 "The index for the `edited' attribute.")
60 (defconst rmail-filed-attr-index
3
61 "The index for the `filed' attribute.")
63 (defconst rmail-retried-attr-index
4
64 "The index for the `retried' attribute.")
66 (defconst rmail-forwarded-attr-index
5
67 "The index for the `forwarded' attribute.")
69 (defconst rmail-unseen-attr-index
6
70 "The index for the `unseen' attribute.")
72 (defconst rmail-resent-attr-index
7
73 "The index for the `resent' attribute.")
75 (defconst rmail-attr-array
84 "An array that provides a mapping between an attribute index,
85 its character representation and its display representation.")
88 (defvar font-lock-fontified
)
89 (defvar mail-abbrev-syntax-table
)
91 (defvar messages-head
)
92 (defvar total-messages
)
95 (defvar rmail-header-style
'normal
96 "The current header display style choice, one of
97 'normal (selected headers) or 'full (all headers).")
99 ;; rmail-spool-directory and rmail-file-name are defined in paths.el.
102 "Mail reader for Emacs."
105 (defgroup rmail-retrieve nil
106 "Rmail retrieval options."
110 (defgroup rmail-files nil
115 (defgroup rmail-headers nil
116 "Rmail header options."
120 (defgroup rmail-reply nil
121 "Rmail reply options."
125 (defgroup rmail-summary nil
126 "Rmail summary options."
128 :prefix
"rmail-summary-"
131 (defgroup rmail-output nil
132 "Output message to a file."
133 :prefix
"rmail-output-"
137 (defgroup rmail-edit nil
139 :prefix
"rmail-edit-"
142 (defcustom rmail-movemail-program nil
143 "If non-nil, the file name of the `movemail' program."
144 :group
'rmail-retrieve
145 :type
'(choice (const nil
) string
))
147 (define-obsolete-variable-alias 'rmail-pop-password
148 'rmail-remote-password
"22.1")
150 (defcustom rmail-remote-password nil
151 "Password to use when reading mail from a remote server.
152 This setting is ignored for mailboxes whose URL already contains a password."
153 :type
'(choice (string :tag
"Password")
154 (const :tag
"Not Required" nil
))
155 :group
'rmail-retrieve
158 (define-obsolete-variable-alias 'rmail-pop-password-required
159 'rmail-remote-password-required
"22.1")
161 (defcustom rmail-remote-password-required nil
162 "Non-nil if a password is required when reading mail from a remote server."
164 :group
'rmail-retrieve
167 (defcustom rmail-movemail-flags nil
168 "List of flags to pass to movemail.
169 Most commonly used to specify `-g' to enable GSS-API authentication
170 or `-k' to enable Kerberos authentication."
171 :type
'(repeat string
)
172 :group
'rmail-retrieve
175 (defvar rmail-remote-password-error
"invalid usercode or password\\|
176 unknown user name or bad password\\|Authentication failed\\|MU_ERR_AUTH_FAILURE"
177 "Regular expression matching incorrect-password POP or IMAP server error
179 If you get an incorrect-password error that this expression does not match,
180 please report it with \\[report-emacs-bug].")
182 (defvar rmail-encoded-remote-password nil
)
184 (defcustom rmail-preserve-inbox nil
185 "Non-nil means leave incoming mail in the user's inbox--don't delete it."
187 :group
'rmail-retrieve
)
189 (defcustom rmail-movemail-search-path nil
190 "List of directories to search for movemail (in addition to `exec-path')."
191 :group
'rmail-retrieve
192 :type
'(repeat (directory)))
194 (declare-function mail-position-on-field
"sendmail" (field &optional soft
))
195 (declare-function mail-text-start
"sendmail" ())
196 (declare-function rmail-dont-reply-to
"mail-utils" (destinations))
197 (declare-function rmail-update-summary
"rmailsum" (&rest ignore
))
199 (defun rmail-probe (prog)
200 "Determine what flavor of movemail PROG is.
201 We do this by executing it with `--version' and analyzing its output."
203 (let ((tbuf (current-buffer)))
204 (buffer-disable-undo tbuf
)
205 (call-process prog nil tbuf nil
"--version")
206 (if (not (buffer-modified-p tbuf
))
207 ;; Should not happen...
209 (goto-char (point-min))
211 ((looking-at ".*movemail: invalid option")
212 'emacs
) ;; Possibly...
213 ((looking-at "movemail (GNU Mailutils .*)")
219 (defun rmail-autodetect ()
220 "Determine the file name of the `movemail' program and return its flavor.
221 If `rmail-movemail-program' is non-nil, use it.
222 Otherwise, look for `movemail' in the directories in
223 `rmail-movemail-search-path', those in `exec-path', and `exec-directory'."
224 (if rmail-movemail-program
225 (rmail-probe rmail-movemail-program
)
227 (dolist (dir (append rmail-movemail-search-path exec-path
228 (list exec-directory
)))
229 (when (and dir
(file-accessible-directory-p dir
))
230 ;; Previously, this didn't have to work on Windows, because
231 ;; rmail-insert-inbox-text before r1.439 fell back to using
232 ;; (expand-file-name "movemail" exec-directory) and just
233 ;; assuming it would work.
234 ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2008-02/msg00087.html
235 (let ((progname (expand-file-name
237 (if (memq system-type
'(ms-dos windows-nt
))
239 (when (and (not (file-directory-p progname
))
240 (file-executable-p progname
))
241 (let ((x (rmail-probe progname
)))
243 (setq rmail-movemail-program progname
)
244 (throw 'scan x
))))))))))
246 (defvar rmail-movemail-variant-in-use nil
247 "The movemail variant currently in use. Known variants are:
249 `emacs' Means any implementation, compatible with the native Emacs one.
251 `mailutils' Means GNU mailutils implementation, capable of handling full
252 mail URLs as the source mailbox.")
255 (defun rmail-movemail-variant-p (&rest variants
)
256 "Return t if the current movemail variant is any of VARIANTS.
257 Currently known variants are 'emacs and 'mailutils."
258 (when (not rmail-movemail-variant-in-use
)
260 (setq rmail-movemail-variant-in-use
(rmail-autodetect)))
261 (not (null (member rmail-movemail-variant-in-use variants
))))
263 ;; Call for effect, to set rmail-movemail-program (if not set by the
264 ;; user), and rmail-movemail-variant-in-use. Used by various functions.
265 ;; I'm not sure if M-x rmail is the only entry point to this package.
266 ;; If so, this can be moved there.
267 (rmail-movemail-variant-p)
270 (defcustom rmail-user-mail-address-regexp nil
271 "Regexp matching user mail addresses.
272 If non-nil, this variable is used to identify the correspondent
273 when receiving new mail. If it matches the address of the sender,
274 the recipient is taken as correspondent of a mail.
275 If nil \(default value\), your `user-login-name' and `user-mail-address'
276 are used to exclude yourself as correspondent.
278 Usually you don't have to set this variable, except if you collect mails
279 sent by you under different user names.
280 Then it should be a regexp matching your mail addresses.
282 Setting this variable has an effect only before reading a mail."
283 :type
'(choice (const :tag
"None" nil
) regexp
)
284 :group
'rmail-retrieve
288 (defcustom rmail-dont-reply-to-names nil
289 "A regexp specifying addresses to prune from a reply message.
290 If this is nil, it is set the first time you compose a reply, to
291 a value which excludes your own email address, plus whatever is
292 specified by `rmail-default-dont-reply-to-names'.
294 Matching addresses are excluded from the CC field in replies, and
295 also the To field, unless this would leave an empty To field."
296 :type
'(choice regexp
(const :tag
"Your Name" nil
))
300 (defvar rmail-default-dont-reply-to-names
(purecopy "\\`info-")
301 "Regexp specifying part of the default value of `rmail-dont-reply-to-names'.
302 This is used when the user does not set `rmail-dont-reply-to-names'
303 explicitly. (The other part of the default value is the user's
304 email address and name.) It is useful to set this variable in
305 the site customization file. The default value is conventionally
306 used for large mailing lists to broadcast announcements.")
307 ;; Is it really useful to set this site-wide?
310 (defcustom rmail-ignored-headers
312 (concat "^via:\\|^mail-from:\\|^origin:\\|^references:\\|^sender:"
313 "\\|^status:\\|^received:\\|^x400-originator:\\|^x400-recipients:"
314 "\\|^x400-received:\\|^x400-mts-identifier:\\|^x400-content-type:"
315 "\\|^\\(resent-\\|\\)message-id:\\|^summary-line:\\|^resent-date:"
316 "\\|^nntp-posting-host:\\|^path:\\|^x-char.*:\\|^x-face:\\|^face:"
317 "\\|^x-mailer:\\|^delivered-to:\\|^lines:"
318 "\\|^content-transfer-encoding:\\|^x-coding-system:"
319 "\\|^return-path:\\|^errors-to:\\|^return-receipt-to:"
320 "\\|^precedence:\\|^mime-version:"
321 "\\|^list-owner:\\|^list-help:\\|^list-post:\\|^list-subscribe:"
322 "\\|^list-id:\\|^list-unsubscribe:\\|^list-archive:"
323 "\\|^content-length:\\|^nntp-posting-date:\\|^user-agent"
324 "\\|^importance:\\|^envelope-to:\\|^delivery-date\\|^openpgp:"
325 "\\|^mbox-line:\\|^cancel-lock:"
326 "\\|^DomainKey-Signature:\\|^dkim-signature:"
327 "\\|^resent-face:\\|^resent-x.*:\\|^resent-organization:\\|^resent-openpgp:"
329 "Regexp to match header fields that Rmail should normally hide.
330 \(See also `rmail-nonignored-headers', which overrides this regexp.)
331 This variable is used for reformatting the message header,
332 which normally happens once for each message,
333 when you view the message for the first time in Rmail.
334 To make a change in this variable take effect
335 for a message that you have already viewed,
336 go to that message and type \\[rmail-toggle-header] twice."
338 :group
'rmail-headers
)
340 (defcustom rmail-nonignored-headers
"^x-spam-status:"
341 "Regexp to match X header fields that Rmail should show.
342 This regexp overrides `rmail-ignored-headers'; if both this regexp
343 and that one match a certain header field, Rmail shows the field.
344 If this is nil, ignore all header fields in `rmail-ignored-headers'.
346 This variable is used for reformatting the message header,
347 which normally happens once for each message,
348 when you view the message for the first time in Rmail.
349 To make a change in this variable take effect
350 for a message that you have already viewed,
351 go to that message and type \\[rmail-toggle-header] twice."
352 :type
'(choice (const nil
) (regexp))
353 :group
'rmail-headers
)
356 (defcustom rmail-displayed-headers nil
357 "Regexp to match Header fields that Rmail should display.
358 If nil, display all header fields except those matched by
359 `rmail-ignored-headers'."
360 :type
'(choice regexp
(const :tag
"All"))
361 :group
'rmail-headers
)
364 (defcustom rmail-retry-ignored-headers
(purecopy "^x-authentication-warning:\\|^x-detected-operating-system:\\|^x-spam[-a-z]*:\\|content-type:\\|content-transfer-encoding:\\|mime-version:")
365 "Headers that should be stripped when retrying a failed message."
366 :type
'(choice regexp
(const nil
:tag
"None"))
367 :group
'rmail-headers
368 :version
"23.2") ; added x-detected-operating-system, x-spam
371 (defcustom rmail-highlighted-headers
(purecopy "^From:\\|^Subject:")
372 "Regexp to match Header fields that Rmail should normally highlight.
373 A value of nil means don't highlight. Uses the face `rmail-highlight'."
375 :group
'rmail-headers
)
377 (defface rmail-highlight
378 '((t (:inherit highlight
)))
379 "Face to use for highlighting the most important header fields.
380 The variable `rmail-highlighted-headers' specifies which headers."
381 :group
'rmail-headers
384 (defface rmail-header-name
385 '((t (:inherit font-lock-function-name-face
)))
386 "Face to use for highlighting the header names.
387 The variable `rmail-font-lock-keywords' specifies which headers
389 :group
'rmail-headers
392 (defcustom rmail-delete-after-output nil
393 "Non-nil means automatically delete a message that is copied to a file."
398 (defcustom rmail-primary-inbox-list nil
399 "List of files that are inboxes for your primary mail file `rmail-file-name'.
400 If this is nil, uses the environment variable MAIL. If that is
401 unset, uses a file named by the function `user-login-name' in the
402 directory `rmail-spool-directory' (whose value depends on the
403 operating system). For example, \"/var/mail/USER\"."
404 ;; Don't use backquote here, because we don't want to need it at load time.
405 ;; (That must be an old comment - it's dumped these days.)
406 :type
(list 'choice
'(const :tag
"Default" nil
)
407 (list 'repeat
':value
(list (or (getenv "MAIL")
408 (concat rmail-spool-directory
411 :group
'rmail-retrieve
414 (defcustom rmail-mail-new-frame nil
415 "Non-nil means Rmail makes a new frame for composing outgoing mail.
416 This is handy if you want to preserve the window configuration of
417 the frame where you have the RMAIL buffer displayed."
422 (defcustom rmail-secondary-file-directory
(purecopy "~/")
423 "Directory for additional secondary Rmail files."
427 (defcustom rmail-secondary-file-regexp
(purecopy "\\.xmail$")
428 "Regexp for which files are secondary Rmail files."
432 (defcustom rmail-confirm-expunge
'y-or-n-p
433 "Whether and how to ask for confirmation before expunging deleted messages.
434 The value, if non-nil is a function to call with a question (string)
435 as argument, to ask the user that question."
436 :type
'(choice (const :tag
"No confirmation" nil
)
437 (const :tag
"Confirm with y-or-n-p" y-or-n-p
)
438 (const :tag
"Confirm with yes-or-no-p" yes-or-no-p
))
441 (put 'rmail-confirm-expunge
'risky-local-variable t
)
444 (defvar rmail-mode-hook nil
445 "List of functions to call when Rmail is invoked.")
447 (defvar rmail-get-new-mail-hook nil
448 "List of functions to call when Rmail has retrieved new mail.")
451 (defcustom rmail-show-message-hook nil
452 "List of functions to call when Rmail displays a message."
454 :options
'(goto-address)
457 (defvar rmail-quit-hook nil
458 "List of functions to call when quitting out of Rmail.")
460 (defvar rmail-delete-message-hook nil
461 "List of functions to call when Rmail deletes a message.
462 When the hooks are called, the message has been marked deleted but is
463 still the current message in the Rmail buffer.")
465 ;; These may be altered by site-init.el to match the format of mmdf files
466 ;; delimiting used on a given host (delim1 and delim2 from the config
469 (defvar rmail-mmdf-delim1
"^\001\001\001\001\n"
470 "Regexp marking the start of an mmdf message.")
471 (defvar rmail-mmdf-delim2
"^\001\001\001\001\n"
472 "Regexp marking the end of an mmdf message.")
474 ;; FIXME Post-mbox, this is now unused.
475 ;; In Emacs-22, this was called:
476 ;; i) the very first time a message was shown.
477 ;; ii) when toggling the headers to the normal state, every time.
478 ;; It's not clear what it should do now, since there is nothing that
479 ;; records when a message is shown for the first time (unseen is not
480 ;; necessarily the same thing).
481 (defcustom rmail-message-filter nil
482 "If non-nil, a filter function for new messages in RMAIL.
483 Called with region narrowed to the message, including headers,
484 before obeying `rmail-ignored-headers'."
485 :group
'rmail-headers
486 :type
'(choice (const nil
) function
))
488 (defcustom rmail-automatic-folder-directives nil
489 "List of directives specifying where to put a message.
490 Each element of the list is of the form:
492 (FOLDERNAME FIELD REGEXP [ FIELD REGEXP ] ... )
494 Where FOLDERNAME is the name of a folder to put the message.
495 If any of the field regexp's are nil, then it is ignored.
497 If FOLDERNAME is \"/dev/null\", it is deleted.
498 If FOLDERNAME is nil then it is deleted, and skipped.
500 FIELD is the plain text name of a field in the message, such as
501 \"subject\" or \"from\". A FIELD of \"to\" will automatically include
502 all text from the \"cc\" field as well.
504 REGEXP is an expression to match in the preceeding specified FIELD.
505 FIELD/REGEXP pairs continue in the list.
508 (\"/dev/null\" \"from\" \"@spam.com\") ; delete all mail from spam.com
509 (\"RMS\" \"from\" \"rms@\") ; save all mail from RMS.
511 Note that this is only applied in the folder specifed by `rmail-file-name'."
514 :type
'(repeat (sexp :tag
"Directive")))
516 (defvar rmail-reply-prefix
"Re: "
517 "String to prepend to Subject line when replying to a message.")
519 ;; Some mailers use "Re(2):" or "Re^2:" or "Re: Re:" or "Re[2]:".
520 ;; This pattern should catch all the common variants.
521 ;; rms: I deleted the change to delete tags in square brackets
522 ;; because they mess up RT tags.
523 (defvar rmail-reply-regexp
"\\`\\(Re\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?: *\\)*"
524 "Regexp to delete from Subject line before inserting `rmail-reply-prefix'.")
526 (defcustom rmail-display-summary nil
527 "If non-nil, Rmail always displays the summary buffer."
528 :group
'rmail-summary
531 (defvar rmail-inbox-list nil
)
532 (put 'rmail-inbox-list
'permanent-local t
)
534 (defvar rmail-buffer nil
535 "The RMAIL buffer related to the current buffer.
536 In an RMAIL buffer, this holds the RMAIL buffer itself.
537 In a summary buffer, this holds the RMAIL buffer it is a summary for.")
538 (put 'rmail-buffer
'permanent-local t
)
540 (defvar rmail-was-converted nil
541 "Non-nil in an Rmail buffer that was just converted from Babyl format.")
542 (put 'rmail-was-converted
'permanent-local t
)
544 (defvar rmail-seriously-modified nil
545 "Non-nil in an Rmail buffer that has been modified in a major way.")
546 (put 'rmail-seriously-modified
'permanent-local t
)
548 ;; Message counters and markers. Deleted flags.
550 (defvar rmail-current-message nil
551 "Integer specifying the message currently being displayed in this folder.")
552 (put 'rmail-current-message
'permanent-local t
)
554 (defvar rmail-total-messages nil
555 "Integer specifying the total number of messages in this folder.
556 Includes deleted messages.")
557 (put 'rmail-total-messages
'permanent-local t
)
559 (defvar rmail-message-vector nil
560 "Vector of markers specifying the start and end of each message.
561 Element N and N+1 specify the start and end of message N.")
562 (put 'rmail-message-vector
'permanent-local t
)
564 (defvar rmail-deleted-vector nil
565 "A string of length `rmail-total-messages' plus one.
566 Character N is either a space or \"D\", according to whether
567 message N is deleted or not.")
568 (put 'rmail-deleted-vector
'permanent-local t
)
570 (defvar rmail-msgref-vector nil
571 "In an Rmail buffer, a vector whose Nth element is a list (N).
572 When expunging renumbers messages, these lists are modified
573 by substituting the new message number into the existing list.")
574 (put 'rmail-msgref-vector
'permanent-local t
)
576 (defvar rmail-overlay-list nil
)
577 (put 'rmail-overlay-list
'permanent-local t
)
579 ;; These are used by autoloaded rmail-summary.
581 (defvar rmail-summary-buffer nil
)
582 (put 'rmail-summary-buffer
'permanent-local t
)
583 (defvar rmail-summary-vector nil
584 "In an Rmail buffer, vector of (newline-terminated) strings.
585 Element N specifies the summary line for message N+1.")
586 (put 'rmail-summary-vector
'permanent-local t
)
588 ;; Rmail buffer swapping variables.
590 (defvar rmail-buffer-swapped nil
591 "If non-nil, `rmail-buffer' is swapped with `rmail-view-buffer'.")
592 (make-variable-buffer-local 'rmail-buffer-swapped
)
593 (put 'rmail-buffer-swapped
'permanent-local t
)
595 (defvar rmail-view-buffer nil
596 "Buffer which holds RMAIL message for MIME displaying.")
597 (make-variable-buffer-local 'rmail-view-buffer
)
598 (put 'rmail-view-buffer
'permanent-local t
)
600 ;; `Sticky' default variables.
602 ;; Last individual label specified to a or k.
603 (defvar rmail-last-label nil
)
605 ;; Last set of values specified to C-M-n, C-M-p, C-M-s or C-M-l.
606 (defvar rmail-last-multi-labels nil
)
608 (defvar rmail-last-regexp nil
)
609 (put 'rmail-last-regexp
'permanent-local t
)
611 (defcustom rmail-default-file
"~/xmail"
612 "Default file name for \\[rmail-output]."
615 (defcustom rmail-default-body-file
"~/mailout"
616 "Default file name for \\[rmail-output-body-to-file]."
621 ;; Mule and MIME related variables.
624 (defvar rmail-file-coding-system nil
625 "Coding system used in RMAIL file.
627 This is set to nil by default.")
629 (defcustom rmail-enable-mime nil
630 "If non-nil, RMAIL uses MIME features.
631 If the value is t, RMAIL automatically shows MIME decoded message.
632 If the value is neither t nor nil, RMAIL does not show MIME decoded message
633 until a user explicitly requires it.
635 Even if the value is non-nil, you can't use MIME features
636 unless the feature specified by `rmail-mime-feature' is available."
637 :type
'(choice (const :tag
"on" t
)
638 (const :tag
"off" nil
)
639 (other :tag
"when asked" ask
))
642 (defvar rmail-enable-mime-composing nil
643 "*If non-nil, RMAIL uses `rmail-insert-mime-forwarded-message-function' to forward.")
646 (defvar rmail-show-mime-function nil
647 "Function to show MIME decoded message of RMAIL file.
648 This function is called when `rmail-enable-mime' is non-nil.
649 It is called with no argument.")
652 (defvar rmail-insert-mime-forwarded-message-function nil
653 "Function to insert a message in MIME format so it can be forwarded.
654 This function is called if `rmail-enable-mime' or
655 `rmail-enable-mime-composing' is non-nil.
656 It is called with one argument FORWARD-BUFFER, which is a
657 buffer containing the message to forward. The current buffer
658 is the outgoing mail buffer.")
660 (defvar rmail-insert-mime-resent-message-function nil
661 "Function to insert a message in MIME format so it can be resent.
662 This function is called by `rmail-resend' if `rmail-enable-mime' is non-nil.
663 It is called with one argument FORWARD-BUFFER, which is a
664 buffer containing the message to forward. The current buffer
665 is the outgoing mail buffer.")
667 ;; FIXME one might want to pass a LIMIT, as per
668 ;; rmail-search-mime-header-function.
669 (defvar rmail-search-mime-message-function nil
670 "Function to check if a regexp matches a MIME message.
671 This function is called by `rmail-search-message' if
672 `rmail-enable-mime' is non-nil. It is called (with point at the
673 start of the message) with two arguments MSG and REGEXP, where
674 MSG is the message number, REGEXP is the regular expression.")
676 (defvar rmail-search-mime-header-function nil
677 "Function to check if a regexp matches a header of MIME message.
678 This function is called by `rmail-message-regexp-p-1' if
679 `rmail-enable-mime' is non-nil. It is called (with point at the
680 start of the header) with three arguments MSG, REGEXP, and LIMIT,
681 where MSG is the message number, REGEXP is the regular
682 expression, LIMIT is the position specifying the end of header.")
684 (defvar rmail-mime-feature
'rmail-mime
685 "Feature to require to load MIME support in Rmail.
686 When starting Rmail, if `rmail-enable-mime' is non-nil,
687 this feature is required with `require'.
689 The default value is `rmail-mime'. This feature is provided by
690 the rmail-mime package available at <http://www.m17n.org/rmail-mime/>.")
692 ;; FIXME this is unused.
693 (defvar rmail-decode-mime-charset t
694 "*Non-nil means a message is decoded by MIME's charset specification.
695 If this variable is nil, or the message has not MIME specification,
696 the message is decoded as normal way.
698 If the variable `rmail-enable-mime' is non-nil, this variable is
699 ignored, and all the decoding work is done by a feature specified by
700 the variable `rmail-mime-feature'.")
702 (defvar rmail-mime-charset-pattern
703 (concat "^content-type:[ \t]*text/plain;"
704 "\\(?:[ \t\n]*\\(?:format\\|delsp\\)=\"?[-a-z0-9]+\"?;\\)*"
705 "[ \t\n]*charset=\"?\\([^ \t\n\";]+\\)\"?")
706 "Regexp to match MIME-charset specification in a header of message.
707 The first parenthesized expression should match the MIME-charset name.")
710 (defvar rmail-unix-mail-delimiter
711 (let ((time-zone-regexp
712 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
713 "\\|[-+]?[0-9][0-9][0-9][0-9]"
719 ;; Many things can happen to an RFC 822 mailbox before it is put into
720 ;; a `From' line. The leading phrase can be stripped, e.g.
721 ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g.
722 ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF
723 ;; can be removed, e.g.
724 ;; From: joe@y.z (Joe K
726 ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and
729 ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
730 ;; The mailbox can be removed or be replaced by white space, e.g.
731 ;; From: "Joe User"{space}{tab}
733 ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
734 ;; where {space} and {tab} represent the Ascii space and tab characters.
735 ;; We want to match the results of any of these manglings.
736 ;; The following regexp rejects names whose first characters are
737 ;; obviously bogus, but after that anything goes.
738 "\\([^\0-\b\n-\r\^?].*\\)? "
740 ;; The time the message was sent.
741 "\\([^\0-\r \^?]+\\) +" ; day of the week
742 "\\([^\0-\r \^?]+\\) +" ; month
743 "\\([0-3]?[0-9]\\) +" ; day of month
744 "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
746 ;; Perhaps a time zone, specified by an abbreviation, or by a
751 " \\([0-9][0-9]+\\) *"
753 ;; On some systems the time zone can appear after the year, too.
757 "\\(remote from .*\\)?"
760 "Regexp matching the delimiter of messages in UNIX mail format
761 \(UNIX From lines), minus the initial ^. Note that if you change
762 this expression, you must change the code in `rmail-nuke-pinhead-header'
763 that knows the exact ordering of the \\( \\) subexpressions.")
765 ;; FIXME the rmail-header-name headers ought to be customizable.
766 ;; It seems a bit arbitrary, for example, that all of the Date: line
768 (defvar rmail-font-lock-keywords
769 ;; These are all matched case-insensitively.
771 (let* ((cite-chars "[>|}]")
773 (cite-suffix (concat cite-prefix
"0-9_.@-`'\"")))
774 (list '("^\\(From\\|Sender\\|Resent-From\\):"
775 .
'rmail-header-name
)
776 '("^\\(Mail-\\)?Reply-To:.*$" .
'rmail-header-name
)
777 ;; FIXME Mail-Followup-To should probably be here too.
778 '("^Subject:" .
'rmail-header-name
)
779 '("^X-Spam-Status:" .
'rmail-header-name
)
780 '("^\\(To\\|Apparently-To\\|Cc\\|Newsgroups\\):"
781 .
'rmail-header-name
)
782 ;; Use MATCH-ANCHORED to effectively anchor the regexp left side.
784 (,(concat "\\=[ \t]*"
785 "\\(\\(\\([" cite-prefix
"]+[" cite-suffix
"]*\\)?"
786 "\\(" cite-chars
"[ \t]*\\)\\)+\\)"
788 (beginning-of-line) (end-of-line)
789 (1 font-lock-comment-delimiter-face nil t
)
790 (5 font-lock-comment-face nil t
)))
791 '("^\\(X-[a-z0-9-]+\\|In-reply-to\\|Date\\):.*\\(\n[ \t]+.*\\)*$"
792 .
'rmail-header-name
))))
793 "Additional expressions to highlight in Rmail mode.")
795 ;; Rmail does not expect horizontal splitting. (Bug#2282)
796 (defun rmail-pop-to-buffer (&rest args
)
797 "Like `pop-to-buffer', but with `split-width-threshold' set to nil."
798 (let (split-width-threshold)
799 (apply 'pop-to-buffer args
)))
801 ;; Perform BODY in the summary buffer
802 ;; in such a way that its cursor is properly updated in its own window.
803 (defmacro rmail-select-summary
(&rest body
)
804 `(let ((total rmail-total-messages
))
805 (if (rmail-summary-displayed)
806 (let ((window (selected-window)))
810 (rmail-pop-to-buffer rmail-summary-buffer
)
811 ;; rmail-total-messages is a buffer-local var
812 ;; in the rmail buffer.
813 ;; This way we make it available for the body
814 ;; even tho the rmail buffer is not current.
815 (let ((rmail-total-messages total
))
817 (select-window window
))))
818 (with-current-buffer rmail-summary-buffer
819 (let ((rmail-total-messages total
))
821 (rmail-maybe-display-summary)))
823 ;;;; *** Rmail Mode ***
825 (defun rmail-require-mime-maybe ()
826 "Require `rmail-mime-feature' if that is non-nil.
827 Signal an error and set `rmail-mime-feature' to nil if the feature
829 (when rmail-enable-mime
831 (require rmail-mime-feature
)
835 (format "Although MIME support is requested
836 by setting `rmail-enable-mime' to non-nil, the required feature
837 `%s' (the value of `rmail-mime-feature')
838 is not available in the current session.
839 So, the MIME support is turned off for the moment."
842 (setq rmail-enable-mime nil
)))))
846 (defun rmail (&optional file-name-arg
)
847 "Read and edit incoming mail.
848 Moves messages into file named by `rmail-file-name' and edits that
850 Type \\[describe-mode] once editing that file, for a list of RMAIL commands.
852 May be called with file name as argument; then performs rmail editing on
853 that file, but does not copy any new mail into the file.
854 Interactively, if you supply a prefix argument, then you
855 have a chance to specify a file name with the minibuffer.
857 If `rmail-display-summary' is non-nil, make a summary for this RMAIL file."
858 (interactive (if current-prefix-arg
859 (list (read-file-name "Run rmail on RMAIL file: "))))
860 (rmail-require-mime-maybe)
861 (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name
)))
862 ;; Use find-buffer-visiting, not get-file-buffer, for those users
863 ;; who have find-file-visit-truename set to t.
864 (existed (find-buffer-visiting file-name
))
865 run-mail-hook mail-buf msg-shown
)
866 ;; Determine if an existing mail file has been changed behind the
868 (if (and existed
(not (verify-visited-file-modtime existed
)))
869 ;; The mail file has been changed. Revisit it and reset the
870 ;; message state variables when in rmail mode.
872 (find-file file-name
)
873 (when (and (verify-visited-file-modtime existed
)
874 (eq major-mode
'rmail-mode
))
875 (rmail-swap-buffers-maybe)
876 (rmail-set-message-counters)))
877 ;; The mail file is either unchanged or not visited. Visit it.
879 (let ((enable-local-variables nil
)
880 ;; Force no-conversion by default, since that's what
881 ;; pre-mbox Rmail did with BABYL files (via
882 ;; auto-coding-regexp-alist).
883 (coding-system-for-read
884 (or coding-system-for-read
'no-conversion
)))
885 (find-file-noselect file-name
))))
886 ;; Ensure that the collection and view buffers are in sync and
887 ;; ensure that a message is not being edited.
888 (if (eq major-mode
'rmail-mode
)
889 (rmail-swap-buffers-maybe))
890 (if (eq major-mode
'rmail-edit-mode
)
891 (error "Exit Rmail Edit mode before getting new mail"))
892 (or (and existed
(> (buffer-size) 0))
893 (setq run-mail-hook t
))
894 ;; Ensure that the Rmail file is in mbox format, the buffer is in
895 ;; Rmail mode and has been scanned to find all the messages
896 ;; (setting the global message variables in the process).
897 (rmail-convert-file-maybe)
898 (unless (eq major-mode
'rmail-mode
)
900 (goto-char (point-max))
901 (rmail-maybe-set-message-counters)
902 (setq mail-buf rmail-buffer
)
903 ;; Show the first unread message and process summary mode.
905 ;; Only get new mail when there is not a file name argument.
906 (unless file-name-arg
907 (setq msg-shown
(rmail-get-new-mail)))
909 (set-buffer mail-buf
)
911 (rmail-show-message (rmail-first-unseen-message)))
912 (if rmail-display-summary
(rmail-summary))
913 (rmail-construct-io-menu)
915 (run-hooks 'rmail-mode-hook
))))))
917 (defun rmail-convert-file-maybe ()
918 "Determine if the file needs to be converted to mbox format."
920 (goto-char (point-min))
921 ;; Detect previous Babyl format files.
922 (let ((case-fold-search nil
))
923 (cond ((looking-at "BABYL OPTIONS:")
924 ;; The file is Babyl version 5. Use unrmail to convert
926 (rmail-convert-babyl-to-mbox))
927 ((looking-at "Version: 5\n")
928 ;; Losing babyl file made by old version of Rmail. Fix the
929 ;; babyl file header and use unrmail to convert to mbox
931 (let ((buffer-read-only nil
))
932 (insert "BABYL OPTIONS: -*- rmail -*-\n")
933 (rmail-convert-babyl-to-mbox)))
934 ((equal (point-min) (point-max))
935 (message "Empty Rmail file."))
936 ((looking-at "From "))
937 (t (error "Invalid mbox file")))))
939 (defun rmail-error-bad-format (&optional msgnum
)
940 "Report that the buffer is not in the mbox file format.
941 MSGNUM, if present, indicates the malformed message."
943 (error "Message %d is not a valid RFC2822 message" msgnum
)
944 (error "Message is not a valid RFC2822 message")))
946 (defun rmail-convert-babyl-to-mbox ()
947 "Convert the mail file from Babyl version 5 to mbox.
948 This function also reinitializes local variables used by Rmail."
949 (let ((old-file (make-temp-file "rmail"))
950 (new-file (make-temp-file "rmail")))
953 (kill-all-local-variables)
954 (write-region (point-min) (point-max) old-file
)
955 (unrmail old-file new-file
)
956 (message "Replacing BABYL format with mbox format...")
957 (let ((inhibit-read-only t
)
958 (coding-system-for-read 'raw-text
)
959 (buffer-undo-list t
))
961 (insert-file-contents new-file
)
962 ;; Rmail buffers need to be saved with Unix EOLs, or else
963 ;; the format will not be recognized.
964 (set-buffer-file-coding-system 'raw-text-unix
)
966 (rmail-perm-variables)
968 (setq rmail-was-converted t
)
969 (rmail-dont-modify-format)
970 (goto-char (point-max))
971 (rmail-set-message-counters))
972 (message "Replacing BABYL format with mbox format...done"))
973 (delete-file old-file
)
974 (delete-file new-file
))))
976 (defun rmail-get-coding-system ()
977 "Return a suitable coding system to use for the current mail message.
978 The buffer is expected to be narrowed to just the header of the message."
980 (goto-char (point-min))
981 (if (re-search-forward rmail-mime-charset-pattern nil t
)
982 (coding-system-from-name (match-string 1))
985 ;;; Set up Rmail mode keymaps
987 (defvar rmail-mode-map
988 (let ((map (make-keymap)))
989 (suppress-keymap map
)
990 (define-key map
"a" 'rmail-add-label
)
991 (define-key map
"b" 'rmail-bury
)
992 (define-key map
"c" 'rmail-continue
)
993 (define-key map
"d" 'rmail-delete-forward
)
994 (define-key map
"\C-d" 'rmail-delete-backward
)
995 (define-key map
"e" 'rmail-edit-current-message
)
996 ;; If you change this, change the rmail-resend menu-item's :keys.
997 (define-key map
"f" 'rmail-forward
)
998 (define-key map
"g" 'rmail-get-new-mail
)
999 (define-key map
"h" 'rmail-summary
)
1000 (define-key map
"i" 'rmail-input
)
1001 (define-key map
"j" 'rmail-show-message
)
1002 (define-key map
"k" 'rmail-kill-label
)
1003 (define-key map
"l" 'rmail-summary-by-labels
)
1004 (define-key map
"\e\C-h" 'rmail-summary
)
1005 (define-key map
"\e\C-l" 'rmail-summary-by-labels
)
1006 (define-key map
"\e\C-r" 'rmail-summary-by-recipients
)
1007 (define-key map
"\e\C-s" 'rmail-summary-by-regexp
)
1008 (define-key map
"\e\C-t" 'rmail-summary-by-topic
)
1009 (define-key map
"m" 'rmail-mail
)
1010 (define-key map
"\em" 'rmail-retry-failure
)
1011 (define-key map
"n" 'rmail-next-undeleted-message
)
1012 (define-key map
"\en" 'rmail-next-message
)
1013 (define-key map
"\e\C-n" 'rmail-next-labeled-message
)
1014 (define-key map
"o" 'rmail-output
)
1015 (define-key map
"\C-o" 'rmail-output-as-seen
)
1016 (define-key map
"p" 'rmail-previous-undeleted-message
)
1017 (define-key map
"\ep" 'rmail-previous-message
)
1018 (define-key map
"\e\C-p" 'rmail-previous-labeled-message
)
1019 (define-key map
"q" 'rmail-quit
)
1020 (define-key map
"r" 'rmail-reply
)
1021 ;; I find I can't live without the default M-r command -- rms.
1022 ;; (define-key rmail-mode-map "\er" 'rmail-search-backwards)
1023 (define-key map
"s" 'rmail-expunge-and-save
)
1024 (define-key map
"\es" 'rmail-search
)
1025 (define-key map
"t" 'rmail-toggle-header
)
1026 (define-key map
"u" 'rmail-undelete-previous-message
)
1027 (define-key map
"v" 'rmail-mime
)
1028 (define-key map
"w" 'rmail-output-body-to-file
)
1029 (define-key map
"\C-c\C-w" 'rmail-widen
)
1030 (define-key map
"x" 'rmail-expunge
)
1031 (define-key map
"." 'rmail-beginning-of-message
)
1032 (define-key map
"/" 'rmail-end-of-message
)
1033 (define-key map
"<" 'rmail-first-message
)
1034 (define-key map
">" 'rmail-last-message
)
1035 (define-key map
" " 'scroll-up
)
1036 (define-key map
"\177" 'scroll-down
)
1037 (define-key map
"?" 'describe-mode
)
1038 (define-key map
"\C-c\C-s\C-d" 'rmail-sort-by-date
)
1039 (define-key map
"\C-c\C-s\C-s" 'rmail-sort-by-subject
)
1040 (define-key map
"\C-c\C-s\C-a" 'rmail-sort-by-author
)
1041 (define-key map
"\C-c\C-s\C-r" 'rmail-sort-by-recipient
)
1042 (define-key map
"\C-c\C-s\C-c" 'rmail-sort-by-correspondent
)
1043 (define-key map
"\C-c\C-s\C-l" 'rmail-sort-by-lines
)
1044 (define-key map
"\C-c\C-s\C-k" 'rmail-sort-by-labels
)
1045 (define-key map
"\C-c\C-n" 'rmail-next-same-subject
)
1046 (define-key map
"\C-c\C-p" 'rmail-previous-same-subject
)
1049 (define-key map
[menu-bar
] (make-sparse-keymap))
1051 (define-key map
[menu-bar classify
]
1052 (cons "Classify" (make-sparse-keymap "Classify")))
1054 (define-key map
[menu-bar classify input-menu
]
1057 (define-key map
[menu-bar classify output-menu
]
1060 (define-key map
[menu-bar classify output-body
]
1061 '("Output body to file..." . rmail-output-body-to-file
))
1063 (define-key map
[menu-bar classify output-inbox
]
1064 '("Output..." . rmail-output
))
1066 (define-key map
[menu-bar classify output
]
1067 '("Output as seen..." . rmail-output-as-seen
))
1069 (define-key map
[menu-bar classify kill-label
]
1070 '("Kill Label..." . rmail-kill-label
))
1072 (define-key map
[menu-bar classify add-label
]
1073 '("Add Label..." . rmail-add-label
))
1075 (define-key map
[menu-bar summary
]
1076 (cons "Summary" (make-sparse-keymap "Summary")))
1078 (define-key map
[menu-bar summary senders
]
1079 '("By Senders..." . rmail-summary-by-senders
))
1081 (define-key map
[menu-bar summary labels
]
1082 '("By Labels..." . rmail-summary-by-labels
))
1084 (define-key map
[menu-bar summary recipients
]
1085 '("By Recipients..." . rmail-summary-by-recipients
))
1087 (define-key map
[menu-bar summary topic
]
1088 '("By Topic..." . rmail-summary-by-topic
))
1090 (define-key map
[menu-bar summary regexp
]
1091 '("By Regexp..." . rmail-summary-by-regexp
))
1093 (define-key map
[menu-bar summary all
]
1094 '("All" . rmail-summary
))
1096 (define-key map
[menu-bar mail
]
1097 (cons "Mail" (make-sparse-keymap "Mail")))
1099 (define-key map
[menu-bar mail rmail-get-new-mail
]
1100 '("Get New Mail" . rmail-get-new-mail
))
1102 (define-key map
[menu-bar mail lambda
]
1105 (define-key map
[menu-bar mail continue
]
1106 '("Continue" . rmail-continue
))
1108 (define-key map
[menu-bar mail resend
]
1109 '(menu-item "Resend..." rmail-resend
:keys
"C-u f"))
1111 (define-key map
[menu-bar mail forward
]
1112 '("Forward" . rmail-forward
))
1114 (define-key map
[menu-bar mail retry
]
1115 '("Retry" . rmail-retry-failure
))
1117 (define-key map
[menu-bar mail reply
]
1118 '("Reply" . rmail-reply
))
1120 (define-key map
[menu-bar mail mail
]
1121 '("Mail" . rmail-mail
))
1123 (define-key map
[menu-bar delete
]
1124 (cons "Delete" (make-sparse-keymap "Delete")))
1126 (define-key map
[menu-bar delete expunge
/save
]
1127 '("Expunge/Save" . rmail-expunge-and-save
))
1129 (define-key map
[menu-bar delete expunge
]
1130 '("Expunge" . rmail-expunge
))
1132 (define-key map
[menu-bar delete undelete
]
1133 '("Undelete" . rmail-undelete-previous-message
))
1135 (define-key map
[menu-bar delete delete
]
1136 '("Delete" . rmail-delete-forward
))
1138 (define-key map
[menu-bar move
]
1139 (cons "Move" (make-sparse-keymap "Move")))
1141 (define-key map
[menu-bar move search-back
]
1142 '("Search Back..." . rmail-search-backwards
))
1144 (define-key map
[menu-bar move search
]
1145 '("Search..." . rmail-search
))
1147 (define-key map
[menu-bar move previous
]
1148 '("Previous Nondeleted" . rmail-previous-undeleted-message
))
1150 (define-key map
[menu-bar move next
]
1151 '("Next Nondeleted" . rmail-next-undeleted-message
))
1153 (define-key map
[menu-bar move last
]
1154 '("Last" . rmail-last-message
))
1156 (define-key map
[menu-bar move first
]
1157 '("First" . rmail-first-message
))
1159 (define-key map
[menu-bar move previous
]
1160 '("Previous" . rmail-previous-message
))
1162 (define-key map
[menu-bar move next
]
1163 '("Next" . rmail-next-message
))
1166 "Keymap used in Rmail mode.")
1169 (defvar rmail-tool-bar-map
1170 (let ((map (make-sparse-keymap)))
1171 (tool-bar-local-item-from-menu 'rmail-get-new-mail
"mail/inbox"
1173 (tool-bar-local-item-from-menu 'rmail-next-undeleted-message
"right-arrow"
1175 (tool-bar-local-item-from-menu 'rmail-previous-undeleted-message
"left-arrow"
1177 (tool-bar-local-item-from-menu 'rmail-search
"search"
1179 (tool-bar-local-item-from-menu 'rmail-input
"open"
1181 (tool-bar-local-item-from-menu 'rmail-mail
"mail/compose"
1183 (tool-bar-local-item-from-menu 'rmail-reply
"mail/reply-all"
1185 (tool-bar-local-item-from-menu 'rmail-forward
"mail/forward"
1187 (tool-bar-local-item-from-menu 'rmail-delete-forward
"close"
1189 (tool-bar-local-item-from-menu 'rmail-output
"mail/move"
1191 (tool-bar-local-item-from-menu 'rmail-output-body-to-file
"mail/save"
1193 (tool-bar-local-item-from-menu 'rmail-expunge
"delete"
1199 ;; Rmail mode is suitable only for specially formatted data.
1200 (put 'rmail-mode
'mode-class
'special
)
1202 (defun rmail-mode-kill-summary ()
1203 (if rmail-summary-buffer
(kill-buffer rmail-summary-buffer
)))
1205 (defvar rmail-enable-multibyte
) ; dynamically bound
1208 (defun rmail-mode ()
1209 "Rmail Mode is used by \\<rmail-mode-map>\\[rmail] for editing Rmail files.
1210 All normal editing commands are turned off.
1211 Instead, these commands are available:
1213 \\[rmail-beginning-of-message] Move point to front of this message.
1214 \\[rmail-end-of-message] Move point to bottom of this message.
1215 \\[scroll-up] Scroll to next screen of this message.
1216 \\[scroll-down] Scroll to previous screen of this message.
1217 \\[rmail-next-undeleted-message] Move to Next non-deleted message.
1218 \\[rmail-previous-undeleted-message] Move to Previous non-deleted message.
1219 \\[rmail-next-message] Move to Next message whether deleted or not.
1220 \\[rmail-previous-message] Move to Previous message whether deleted or not.
1221 \\[rmail-first-message] Move to the first message in Rmail file.
1222 \\[rmail-last-message] Move to the last message in Rmail file.
1223 \\[rmail-show-message] Jump to message specified by numeric position in file.
1224 \\[rmail-search] Search for string and show message it is found in.
1225 \\[rmail-delete-forward] Delete this message, move to next nondeleted.
1226 \\[rmail-delete-backward] Delete this message, move to previous nondeleted.
1227 \\[rmail-undelete-previous-message] Undelete message. Tries current message, then earlier messages
1228 till a deleted message is found.
1229 \\[rmail-edit-current-message] Edit the current message. \\[rmail-cease-edit] to return to Rmail.
1230 \\[rmail-expunge] Expunge deleted messages.
1231 \\[rmail-expunge-and-save] Expunge and save the file.
1232 \\[rmail-quit] Quit Rmail: expunge, save, then switch to another buffer.
1233 \\[save-buffer] Save without expunging.
1234 \\[rmail-get-new-mail] Move new mail from system spool directory into this file.
1235 \\[rmail-mail] Mail a message (same as \\[mail-other-window]).
1236 \\[rmail-continue] Continue composing outgoing message started before.
1237 \\[rmail-reply] Reply to this message. Like \\[rmail-mail] but initializes some fields.
1238 \\[rmail-retry-failure] Send this message again. Used on a mailer failure message.
1239 \\[rmail-forward] Forward this message to another user.
1240 \\[rmail-output] Output (append) this message to another mail file.
1241 \\[rmail-output-as-seen] Output (append) this message to file as it's displayed.
1242 \\[rmail-output-body-to-file] Save message body to a file. Default filename comes from Subject line.
1243 \\[rmail-input] Input Rmail file. Run Rmail on that file.
1244 \\[rmail-add-label] Add label to message. It will be displayed in the mode line.
1245 \\[rmail-kill-label] Kill label. Remove a label from current message.
1246 \\[rmail-next-labeled-message] Move to Next message with specified label
1247 (label defaults to last one specified).
1248 Standard labels: filed, unseen, answered, forwarded, deleted.
1249 Any other label is present only if you add it with \\[rmail-add-label].
1250 \\[rmail-previous-labeled-message] Move to Previous message with specified label
1251 \\[rmail-summary] Show headers buffer, with a one line summary of each message.
1252 \\[rmail-summary-by-labels] Summarize only messages with particular label(s).
1253 \\[rmail-summary-by-recipients] Summarize only messages with particular recipient(s).
1254 \\[rmail-summary-by-regexp] Summarize only messages with particular regexp(s).
1255 \\[rmail-summary-by-topic] Summarize only messages with subject line regexp(s).
1256 \\[rmail-toggle-header] Toggle display of complete header."
1258 (let ((finding-rmail-file (not (eq major-mode
'rmail-mode
))))
1260 (when (and finding-rmail-file
1261 (null coding-system-for-read
)
1262 (default-value 'enable-multibyte-characters
))
1263 (let ((rmail-enable-multibyte t
))
1264 (rmail-require-mime-maybe)
1265 (rmail-convert-file-maybe)
1266 (goto-char (point-max))
1267 (set-buffer-multibyte t
)))
1268 (rmail-set-message-counters)
1269 (rmail-show-message rmail-total-messages
)
1270 (when finding-rmail-file
1271 (when rmail-display-summary
1273 (rmail-construct-io-menu))
1274 (run-mode-hooks 'rmail-mode-hook
)))
1276 (defun rmail-mode-2 ()
1277 (kill-all-local-variables)
1279 (rmail-perm-variables)
1282 (defun rmail-mode-1 ()
1283 (setq major-mode
'rmail-mode
)
1284 (setq mode-name
"RMAIL")
1285 (setq buffer-read-only t
)
1286 ;; No need to auto save RMAIL files in normal circumstances
1287 ;; because they contain no info except attribute changes
1288 ;; and deletion of messages.
1289 ;; The one exception is when messages are copied into another mbox buffer.
1290 ;; rmail-output enables auto save when you do that.
1291 (setq buffer-auto-save-file-name nil
)
1292 (use-local-map rmail-mode-map
)
1293 (set-syntax-table text-mode-syntax-table
)
1294 (setq local-abbrev-table text-mode-abbrev-table
)
1295 ;; Functions to support buffer swapping:
1296 (add-hook 'write-region-annotate-functions
1297 'rmail-write-region-annotate nil t
)
1298 (add-hook 'kill-buffer-hook
'rmail-mode-kill-buffer-hook nil t
)
1299 (add-hook 'change-major-mode-hook
'rmail-change-major-mode-hook nil t
))
1301 (defun rmail-generate-viewer-buffer ()
1302 "Return a reusable buffer suitable for viewing messages.
1303 Create the buffer if necessary."
1304 ;; We want to reuse any existing view buffer, so as not to create an
1305 ;; endless number of them. But we must avoid clashes if we visit
1306 ;; two different rmail files with the same basename (Bug#4593).
1307 (if (and (local-variable-p 'rmail-view-buffer
)
1308 (buffer-live-p rmail-view-buffer
))
1310 (generate-new-buffer
1311 (format " *message-viewer %s*"
1312 (file-name-nondirectory (or buffer-file-name
(buffer-name)))))))
1314 (defun rmail-swap-buffers ()
1315 "Swap text between current buffer and `rmail-view-buffer'.
1316 This function preserves the current buffer's modified flag, and also
1317 sets the current buffer's `buffer-file-coding-system' to that of
1318 `rmail-view-buffer'."
1319 (let ((modp-this (buffer-modified-p))
1321 (with-current-buffer rmail-view-buffer
(buffer-modified-p)))
1322 (coding-this buffer-file-coding-system
)
1324 (with-current-buffer rmail-view-buffer
1325 buffer-file-coding-system
)))
1326 (buffer-swap-text rmail-view-buffer
)
1327 (setq buffer-file-coding-system coding-that
)
1328 (with-current-buffer rmail-view-buffer
1329 (setq buffer-file-coding-system coding-this
)
1330 (restore-buffer-modified-p modp-that
))
1331 (restore-buffer-modified-p modp-this
)))
1333 (defun rmail-buffers-swapped-p ()
1334 "Return non-nil if the message collection is in `rmail-view-buffer'."
1335 ;; This is analogous to tar-data-swapped-p in tar-mode.el.
1336 (and (buffer-live-p rmail-view-buffer
)
1337 rmail-buffer-swapped
))
1339 (defun rmail-change-major-mode-hook ()
1340 ;; Bring the actual Rmail messages back into the main buffer.
1341 (when (rmail-buffers-swapped-p)
1342 (rmail-swap-buffers)
1343 (setq rmail-buffer-swapped nil
)))
1345 (defun rmail-swap-buffers-maybe ()
1346 "Determine if the Rmail buffer is showing a message.
1347 If so restore the actual mbox message collection."
1348 (with-current-buffer rmail-buffer
1349 (when (rmail-buffers-swapped-p)
1350 (rmail-swap-buffers)
1351 (setq rmail-buffer-swapped nil
))))
1353 (defun rmail-modify-format ()
1354 "Warn if important modifications would change Rmail file's format."
1355 (with-current-buffer rmail-buffer
1356 (and rmail-was-converted
1357 ;; If it's already modified, don't warn again.
1358 (not rmail-seriously-modified
)
1361 (message "After this, %s would be saved in mbox format. Proceed? "
1364 (setq rmail-seriously-modified t
)))
1366 (defun rmail-dont-modify-format ()
1367 (when (and rmail-was-converted
(not rmail-seriously-modified
))
1368 (set-buffer-modified-p nil
)
1369 (message "Marking buffer unmodified to avoid rewriting Babyl file as mbox file")))
1371 (defun rmail-mode-kill-buffer-hook ()
1372 (if (buffer-live-p rmail-view-buffer
) (kill-buffer rmail-view-buffer
)))
1374 ;; Set up the permanent locals associated with an Rmail file.
1375 (defun rmail-perm-variables ()
1376 (make-local-variable 'rmail-last-regexp
)
1377 (make-local-variable 'rmail-deleted-vector
)
1378 (make-local-variable 'rmail-buffer
)
1379 (make-local-variable 'rmail-was-converted
)
1380 (setq rmail-was-converted nil
)
1381 (make-local-variable 'rmail-seriously-modified
)
1382 (setq rmail-seriously-modified nil
)
1383 (setq rmail-buffer
(current-buffer))
1384 (set-buffer-multibyte nil
)
1385 (with-current-buffer (setq rmail-view-buffer
(rmail-generate-viewer-buffer))
1386 (setq buffer-undo-list t
)
1387 ;; Note that this does not erase the buffer. Should it?
1388 ;; It depends on how this is called. If somehow called with the
1389 ;; rmail buffers swapped, it would erase the message collection.
1390 (set (make-local-variable 'rmail-overlay-list
) nil
)
1391 (set-buffer-multibyte t
)
1392 ;; Force C-x C-s write Unix EOLs.
1393 (set-buffer-file-coding-system 'undecided-unix
))
1394 (make-local-variable 'rmail-summary-buffer
)
1395 (make-local-variable 'rmail-summary-vector
)
1396 (make-local-variable 'rmail-current-message
)
1397 (make-local-variable 'rmail-total-messages
)
1398 (setq rmail-total-messages
0)
1399 (make-local-variable 'rmail-message-vector
)
1400 (make-local-variable 'rmail-msgref-vector
)
1401 (make-local-variable 'rmail-inbox-list
)
1402 ;; Provide default set of inboxes for primary mail file ~/RMAIL.
1403 (and (null rmail-inbox-list
)
1404 (or (equal buffer-file-name
(expand-file-name rmail-file-name
))
1405 (equal buffer-file-truename
1406 (abbreviate-file-name (file-truename rmail-file-name
))))
1407 (setq rmail-inbox-list
1408 (or rmail-primary-inbox-list
1409 (list (or (getenv "MAIL")
1410 ;; FIXME expand-file-name?
1411 (concat rmail-spool-directory
1412 (user-login-name)))))))
1413 (set (make-local-variable 'tool-bar-map
) rmail-tool-bar-map
))
1415 ;; Set up the non-permanent locals associated with Rmail mode.
1416 (defun rmail-variables ()
1417 ;; Turn off undo. We turn it back on in rmail-edit.
1418 (setq buffer-undo-list t
)
1419 ;; Don't let a local variables list in a message cause confusion.
1420 (make-local-variable 'local-enable-local-variables
)
1421 (setq local-enable-local-variables nil
)
1422 ;; Don't turn off auto-saving based on the size of the buffer
1423 ;; because that code does not understand buffer-swapping.
1424 (make-local-variable 'auto-save-include-big-deletions
)
1425 (setq auto-save-include-big-deletions t
)
1426 (make-local-variable 'revert-buffer-function
)
1427 (setq revert-buffer-function
'rmail-revert
)
1428 (make-local-variable 'font-lock-defaults
)
1429 (setq font-lock-defaults
1430 '(rmail-font-lock-keywords
1432 (font-lock-maximum-size . nil
)
1433 (font-lock-fontify-buffer-function . rmail-fontify-buffer-function
)
1434 (font-lock-unfontify-buffer-function . rmail-unfontify-buffer-function
)
1435 (font-lock-inhibit-thing-lock .
(lazy-lock-mode fast-lock-mode
))))
1436 (make-local-variable 'require-final-newline
)
1437 (setq require-final-newline nil
)
1438 (make-local-variable 'version-control
)
1439 (setq version-control
'never
)
1440 (make-local-variable 'kill-buffer-hook
)
1441 (add-hook 'kill-buffer-hook
'rmail-mode-kill-summary
)
1442 (make-local-variable 'file-precious-flag
)
1443 (setq file-precious-flag t
)
1444 (make-local-variable 'desktop-save-buffer
)
1445 (setq desktop-save-buffer t
))
1447 ;; Handle M-x revert-buffer done in an rmail-mode buffer.
1448 (defun rmail-revert (arg noconfirm
)
1449 (set-buffer rmail-buffer
)
1450 (let* ((revert-buffer-function (default-value 'revert-buffer-function
))
1451 (rmail-enable-multibyte enable-multibyte-characters
)
1452 ;; See similar code in `rmail'.
1453 ;; FIXME needs updating?
1454 (coding-system-for-read (and rmail-enable-multibyte
'raw-text
))
1455 (before-revert-hook 'rmail-swap-buffers-maybe
))
1456 ;; Call our caller again, but this time it does the default thing.
1457 (when (revert-buffer arg noconfirm
)
1458 ;; If the user said "yes", and we changed something,
1459 ;; reparse the messages.
1460 (set-buffer rmail-buffer
)
1462 ;; Convert all or part to Babyl file if possible.
1463 (rmail-convert-file-maybe)
1464 ;; We have read the file as raw-text, so the buffer is set to
1465 ;; unibyte. Make it multibyte if necessary.
1466 (if (and rmail-enable-multibyte
1467 (not enable-multibyte-characters
))
1468 (set-buffer-multibyte t
))
1469 (goto-char (point-max))
1470 (rmail-set-message-counters)
1471 (rmail-show-message rmail-total-messages
)
1472 (run-hooks 'rmail-mode-hook
))))
1474 (defun rmail-expunge-and-save ()
1475 "Expunge and save RMAIL file."
1477 (set-buffer rmail-buffer
)
1479 ;; No need to swap buffers: rmail-write-region-annotate takes care of it.
1480 ;; (rmail-swap-buffers-maybe)
1482 (if (rmail-summary-exists)
1483 (rmail-select-summary (set-buffer-modified-p nil
))))
1485 (defun rmail-quit ()
1487 Hook `rmail-quit-hook' is run after expunging."
1489 (set-buffer rmail-buffer
)
1492 (when (boundp 'rmail-quit-hook
)
1493 (run-hooks 'rmail-quit-hook
))
1494 ;; Don't switch to the summary buffer even if it was recently visible.
1495 (when rmail-summary-buffer
1496 (with-current-buffer rmail-summary-buffer
1497 (set-buffer-modified-p nil
))
1498 (replace-buffer-in-windows rmail-summary-buffer
)
1499 (bury-buffer rmail-summary-buffer
))
1500 (if rmail-enable-mime
1501 (let ((obuf rmail-buffer
)
1502 (ovbuf rmail-view-buffer
))
1503 (set-buffer rmail-view-buffer
)
1505 (replace-buffer-in-windows ovbuf
)
1506 (replace-buffer-in-windows obuf
)
1508 (let ((obuf (current-buffer)))
1510 (replace-buffer-in-windows obuf
))))
1512 (defun rmail-bury ()
1513 "Bury current Rmail buffer and its summary buffer."
1515 ;; This let var was called rmail-buffer, but that interfered
1516 ;; with the buffer-local var used in summary buffers.
1517 (let ((buffer-to-bury (current-buffer)))
1518 (if (rmail-summary-exists)
1520 (while (setq window
(get-buffer-window rmail-summary-buffer
))
1521 (quit-window nil window
))
1522 (bury-buffer rmail-summary-buffer
)))
1525 (defun rmail-duplicate-message ()
1526 "Create a duplicated copy of the current message.
1527 The duplicate copy goes into the Rmail file just after the original."
1528 ;; If we are in a summary buffer, switch to the Rmail buffer.
1529 ;; FIXME simpler to swap the contents, not the buffers?
1530 (set-buffer rmail-buffer
)
1531 (rmail-modify-format)
1532 (let ((buff (current-buffer))
1533 (n rmail-current-message
)
1534 (beg (rmail-msgbeg rmail-current-message
))
1535 (end (rmail-msgend rmail-current-message
)))
1536 (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer
))
1538 (let ((buffer-read-only nil
)
1539 (string (buffer-substring-no-properties beg end
)))
1543 (rmail-swap-buffers-maybe)
1544 (goto-char (point-max))
1545 (rmail-set-message-counters)
1546 (set-buffer-modified-p t
)
1547 (rmail-show-message-1 n
))
1548 (if (rmail-summary-exists)
1549 (rmail-select-summary (rmail-update-summary)))
1550 (message "Message duplicated"))
1553 (defun rmail-input (filename)
1554 "Run Rmail on file FILENAME."
1555 (interactive "FRun rmail on RMAIL file: ")
1558 ;; This used to scan subdirectories recursively, but someone pointed out
1559 ;; that if the user wants that, person can put all the files in one dir.
1560 ;; And the recursive scan was slow. So I took it out.
1562 (defun rmail-find-all-files (start)
1563 "Return list of file in dir START that match `rmail-secondary-file-regexp'."
1564 (if (file-accessible-directory-p start
)
1566 (let* ((case-fold-search t
)
1567 (files (directory-files start t rmail-secondary-file-regexp
)))
1568 ;; Sort here instead of in directory-files
1569 ;; because this list is usually much shorter.
1570 (sort files
'string
<))))
1572 (defun rmail-list-to-menu (menu-name l action
&optional full-name
)
1573 (let ((menu (make-sparse-keymap menu-name
))
1581 (car item
) (cdr item
) action
1583 (concat full-name
"/"
1589 (list 'lambda
() '(interactive)
1593 (concat full-name
"/" item
)
1595 rmail-secondary-file-directory
)))))
1596 (define-key menu
(vector (intern name
))
1597 (cons name command
))))
1601 ;; This command is always "disabled" when it appears in a menu.
1602 (put 'rmail-disable-menu
'menu-enable
''nil
)
1604 (defun rmail-construct-io-menu ()
1605 (let ((files (rmail-find-all-files rmail-secondary-file-directory
)))
1608 (define-key rmail-mode-map
[menu-bar classify input-menu
]
1609 (cons "Input Rmail File"
1610 (rmail-list-to-menu "Input Rmail File"
1613 (define-key rmail-mode-map
[menu-bar classify output-menu
]
1614 (cons "Output Rmail File"
1615 (rmail-list-to-menu "Output Rmail File"
1619 (define-key rmail-mode-map
[menu-bar classify input-menu
]
1620 '("Input Rmail File" . rmail-disable-menu
))
1621 (define-key rmail-mode-map
[menu-bar classify output-menu
]
1622 '("Output Rmail File" . rmail-disable-menu
)))))
1625 ;;;; *** Rmail input ***
1627 (declare-function rmail-summary-goto-msg
"rmailsum" (&optional n nowarn skip-rmail
))
1628 (declare-function rmail-summary-mark-undeleted
"rmailsum" (n))
1629 (declare-function rmail-summary-mark-deleted
"rmailsum" (&optional n undel
))
1630 (declare-function rfc822-addresses
"rfc822" (header-text))
1631 (declare-function mail-abbrev-make-syntax-table
"mailabbrev.el" ())
1632 (declare-function mail-sendmail-delimit-header
"sendmail" ())
1633 (declare-function mail-header-end
"sendmail" ())
1635 ;; RLK feature not added in this version:
1636 ;; argument specifies inbox file or files in various ways.
1638 ;; In Babyl, the Mail: header in the preamble overrode rmail-inbox-list.
1639 ;; Mbox does not have this feature.
1640 (defun rmail-get-new-mail (&optional file-name
)
1641 "Move any new mail from this Rmail file's inbox files.
1642 The buffer-local variable `rmail-inbox-list' specifies the list
1643 of inbox files. By default, this is nil, except for your primary
1644 Rmail file `rmail-file-name'. In this case, when you first visit
1645 the Rmail file it is initialized using either
1646 `rmail-primary-inbox-list', or the \"MAIL\" environment variable,
1647 or the function `user-login-name' and the directory
1648 `rmail-spool-directory' (whose value depends on the operating system).
1650 The command `set-rmail-inbox-list' sets `rmail-inbox-list' to the
1653 You can also specify the file to get new mail from just for one
1654 instance of this command. In this case, the file of new mail is
1655 not changed or deleted. Noninteractively, you can pass the inbox
1656 file name as an argument. Interactively, a prefix argument
1657 causes us to read a file name and use that file as the inbox.
1659 If the variable `rmail-preserve-inbox' is non-nil, new mail will
1660 always be left in inbox files rather than deleted.
1662 Before doing anything, this runs `rmail-before-get-new-mail-hook'.
1663 Just before returning, it runs `rmail-after-get-new-mail-hook',
1664 whether or not there is new mail.
1666 If there is new mail, it runs `rmail-get-new-mail-hook', saves
1667 the updated file, and shows the first unseen message (which might
1668 not be a new one). It returns non-nil if it got any new messages."
1670 (list (if current-prefix-arg
1671 (read-file-name "Get new mail from file: "))))
1672 (run-hooks 'rmail-before-get-new-mail-hook
)
1673 ;; If the disk file has been changed from under us,
1674 ;; revert to it before we get new mail.
1675 (or (verify-visited-file-modtime (current-buffer))
1676 (find-file (buffer-file-name)))
1677 (set-buffer rmail-buffer
)
1678 (rmail-modify-format)
1679 (rmail-swap-buffers-maybe)
1680 (rmail-maybe-set-message-counters)
1682 ;; Get rid of all undo records for this buffer.
1683 (or (eq buffer-undo-list t
)
1684 (setq buffer-undo-list nil
))
1685 (let ((all-files (if file-name
(list file-name
) rmail-inbox-list
))
1686 (rmail-enable-multibyte (default-value 'enable-multibyte-characters
))
1690 ;; This loops if any members of the inbox list have the same
1691 ;; basename (see "name conflict" below).
1693 (let ((opoint (point))
1694 ;; If buffer has not changed yet, and has not been
1695 ;; saved yet, don't replace the old backup file now.
1696 (make-backup-files (and make-backup-files
1697 (buffer-modified-p)))
1698 (buffer-read-only nil
)
1699 ;; Don't make undo records while getting mail.
1700 (buffer-undo-list t
)
1701 delete-files success files file-last-names
)
1702 ;; Pull files off all-files onto files as long as there is
1703 ;; no name conflict. A conflict happens when two inbox
1704 ;; file names have the same last component.
1705 ;; The reason this careful handling is necessary seems
1706 ;; to be that rmail-insert-inbox-text uses .newmail-BASENAME.
1707 (while (and all-files
1708 (not (member (file-name-nondirectory (car all-files
))
1710 (setq files
(cons (car all-files
) files
)
1712 (cons (file-name-nondirectory (car all-files
)) files
))
1713 (setq all-files
(cdr all-files
)))
1714 ;; Put them back in their original order.
1715 (setq files
(nreverse files
))
1716 ;; In case of brain damage caused by require-final-newline.
1717 (goto-char (point-max))
1718 (skip-chars-backward " \t\n")
1719 (delete-region (point) (point-max))
1721 (rmail-get-new-mail-1 file-name files delete-files
)
1723 ;; Move to the first new message unless we have other unseen
1724 ;; messages before it.
1725 (if found
(rmail-show-message (rmail-first-unseen-message)))
1726 (run-hooks 'rmail-after-get-new-mail-hook
)
1728 ;; Don't leave the buffer screwed up if we get a disk-full error.
1729 (rmail-show-message))))
1731 (defvar rmail-use-spam-filter
)
1732 (declare-function rmail-get-new-mail-filter-spam
"rmail-spam-filter" (nnew))
1734 (defun rmail-get-new-mail-1 (file-name files delete-files
)
1735 "Return t if new messages are detected without error, nil otherwise."
1738 (let ((new-messages 0)
1739 (spam-filter-p (and (featurep 'rmail-spam-filter
)
1740 rmail-use-spam-filter
))
1742 result success suffix
)
1743 (narrow-to-region (point) (point))
1744 ;; Read in the contents of the inbox files, renaming them as
1745 ;; necessary, and adding to the list of files to delete
1748 (rmail-insert-inbox-text files nil
)
1749 (setq delete-files
(rmail-insert-inbox-text files t
)))
1750 ;; Scan the new text and convert each message to
1751 ;; Rmail/mbox format.
1752 (goto-char (point-min))
1753 (skip-chars-forward " \n")
1754 (narrow-to-region (point) (point-max))
1756 (setq new-messages
(rmail-add-mbox-headers)
1758 ;; Try to delete the garbage just inserted.
1759 (or success
(delete-region (point-min) (point-max)))
1760 ;; If we could not convert the file's inboxes, rename the
1761 ;; files we tried to read so we won't over and over again.
1762 (if (and (not file-name
) (not success
))
1763 (let ((delfiles delete-files
)
1766 (while (file-exists-p (format "RMAILOSE.%d" count
))
1767 (setq count
(1+ count
)))
1768 (rename-file (car delfiles
) (format "RMAILOSE.%d" count
))
1769 (setq delfiles
(cdr delfiles
))))))
1770 ;; Determine if there are messages.
1771 (unless (zerop new-messages
)
1772 ;; There are. Process them.
1773 (goto-char (point-min))
1774 (rmail-count-new-messages)
1775 (run-hooks 'rmail-get-new-mail-hook
)
1777 ;; Delete the old files, now that the Rmail file is saved.
1780 ;; First, try deleting.
1782 (delete-file (car delete-files
))
1784 ;; If we can't delete it, truncate it.
1785 (write-region (point) (point) (car delete-files
))))
1787 (setq delete-files
(cdr delete-files
)))
1788 (if (zerop new-messages
)
1789 (when (or file-name rmail-inbox-list
)
1790 (message "(No new mail has arrived)"))
1792 (setq blurb
(rmail-get-new-mail-filter-spam new-messages
))))
1793 (if (rmail-summary-exists)
1794 (rmail-select-summary (rmail-update-summary)))
1795 (setq suffix
(if (= 1 new-messages
) "" "s"))
1796 (message "%d new message%s read%s" new-messages suffix blurb
)
1797 ;; Establish the return value.
1798 (setq result
(> new-messages
0))
1801 (defun rmail-parse-url (file)
1802 "Parse the supplied URL. Return (list MAILBOX-NAME REMOTE PASSWORD GOT-PASSWORD)
1803 WHERE MAILBOX-NAME is the name of the mailbox suitable as argument to the
1804 actual version of `movemail', REMOTE is non-nil if MAILBOX-NAME refers to
1805 a remote mailbox, PASSWORD is the password if it should be
1806 supplied as a separate argument to `movemail' or nil otherwise, GOT-PASSWORD
1807 is non-nil if the user has supplied the password interactively.
1810 ((string-match "^\\([^:]+\\)://\\(\\([^:@]+\\)\\(:\\([^@]+\\)\\)?@\\)?.*" file
)
1811 (let (got-password supplied-password
1812 (proto (match-string 1 file
))
1813 (user (match-string 3 file
))
1814 (pass (match-string 5 file
))
1815 (host (substring file
(or (match-end 2)
1816 (+ 3 (match-end 1))))))
1819 (when rmail-remote-password-required
1820 (setq got-password
(not (rmail-have-password)))
1821 (setq supplied-password
(rmail-get-remote-password
1822 (string-equal proto
"imap"))))
1823 ;; The password is embedded. Strip it out since movemail
1824 ;; does not really like it, in spite of the movemail spec.
1825 (setq file
(concat proto
"://" user
"@" host
)))
1827 (if (rmail-movemail-variant-p 'emacs
)
1828 (if (string-equal proto
"pop")
1829 (list (concat "po:" user
":" host
)
1831 (or pass supplied-password
)
1833 (error "Emacs movemail does not support %s protocol" proto
))
1835 (or (string-equal proto
"pop") (string-equal proto
"imap"))
1836 (or supplied-password pass
)
1839 ((string-match "^po:\\([^:]+\\)\\(:\\(.*\\)\\)?" file
)
1840 (let (got-password supplied-password
1842 (user (match-string 1 file
))
1843 (host (match-string 3 file
)))
1845 (when rmail-remote-password-required
1846 (setq got-password
(not (rmail-have-password)))
1847 (setq supplied-password
(rmail-get-remote-password nil
)))
1849 (list file
"pop" supplied-password got-password
)))
1852 (list file nil nil nil
))))
1854 (defun rmail-unrmail-new-mail (from-file)
1855 "Replace newly read mail in Babyl format with equivalent mbox format.
1857 FROM-FILE is the Babyl file from which the new mail should be read."
1858 (let ((to-file (make-temp-file "rmail"))
1860 (unrmail from-file to-file
)
1861 (let ((inhibit-read-only t
)
1862 (coding-system-for-read 'raw-text
)
1863 (buffer-undo-list t
))
1864 (delete-region (point) (point-max))
1865 (setq size
(nth 1 (insert-file-contents to-file
)))
1866 (delete-file to-file
)
1869 (defun rmail-unrmail-new-mail-maybe (file size
)
1870 "If newly read mail from FILE is in Babyl format, convert it to mbox format.
1872 SIZE is the original size of the newly read mail.
1873 Value is the size of the newly read mail after conversion."
1874 ;; Detect previous Babyl format files.
1875 (let ((case-fold-search nil
)
1878 (cond ((looking-at "BABYL OPTIONS:")
1879 ;; The new mail is in Babyl version 5 format. Use unrmail
1881 (setq size
(rmail-unrmail-new-mail old-file
)))
1882 ((looking-at "Version: 5\n")
1883 ;; New mail is in Babyl format made by old version of
1884 ;; Rmail. Fix the babyl file header and use unrmail to
1886 (let ((buffer-read-only nil
)
1887 (write-region-annotate-functions nil
)
1888 (write-region-post-annotation-function nil
)
1889 (old-file (make-temp-file "rmail")))
1890 (insert "BABYL OPTIONS: -*- rmail -*-\n")
1892 (write-region (point) (point-max) old-file
)
1893 (setq size
(rmail-unrmail-new-mail old-file
))
1894 (delete-file old-file
))))
1897 (defun rmail-insert-inbox-text (files renamep
)
1898 ;; Detect a locked file now, so that we avoid moving mail
1899 ;; out of the real inbox file. (That could scare people.)
1900 (or (memq (file-locked-p buffer-file-name
) '(nil t
))
1901 (error "RMAIL file %s is locked"
1902 (file-name-nondirectory buffer-file-name
)))
1903 (let (file tofile delete-files movemail popmail got-password password
)
1905 ;; Handle remote mailbox names specially; don't expand as filenames
1906 ;; in case the userid contains a directory separator.
1907 (setq file
(car files
))
1908 (let ((url-data (rmail-parse-url file
)))
1909 (setq file
(nth 0 url-data
))
1910 (setq popmail
(nth 1 url-data
))
1911 (setq password
(nth 2 url-data
))
1912 (setq got-password
(nth 3 url-data
)))
1916 (setq file
(file-truename
1917 (substitute-in-file-name (expand-file-name file
)))))
1918 (setq tofile
(expand-file-name
1919 ;; Generate name to move to from inbox name,
1920 ;; in case of multiple inboxes that need moving.
1922 (file-name-nondirectory
1923 (if (memq system-type
'(windows-nt cygwin ms-dos
))
1924 ;; cannot have colons in file name
1925 (replace-regexp-in-string ":" "-" file
)
1927 ;; Use the directory of this rmail file
1928 ;; because it's a nuisance to use the homedir
1929 ;; if that is on a full disk and this rmail
1931 (file-name-directory
1932 (expand-file-name buffer-file-name
))))
1933 ;; Always use movemail to rename the file,
1934 ;; since there can be mailboxes in various directories.
1936 ;; On some systems, /usr/spool/mail/foo is a directory
1937 ;; and the actual inbox is /usr/spool/mail/foo/foo.
1938 (if (file-directory-p file
)
1939 (setq file
(expand-file-name (user-login-name)
1942 (message "Getting mail from the remote server ..."))
1943 ((and (file-exists-p tofile
)
1944 (/= 0 (nth 7 (file-attributes tofile
))))
1945 (message "Getting mail from %s..." tofile
))
1946 ((and (file-exists-p file
)
1947 (/= 0 (nth 7 (file-attributes file
))))
1948 (message "Getting mail from %s..." file
)))
1949 ;; Set TOFILE if have not already done so, and
1950 ;; rename or copy the file FILE to TOFILE if and as appropriate.
1951 (cond ((not renamep
)
1953 ((or (file-exists-p tofile
) (and (not popmail
)
1954 (not (file-exists-p file
))))
1958 (let ((errors (current-buffer)))
1959 (buffer-disable-undo errors
)
1962 (list (or rmail-movemail-program
"movemail") nil errors nil
)
1963 (if rmail-preserve-inbox
1966 (if (rmail-movemail-variant-p 'mailutils
)
1967 (append (list "--emacs") rmail-movemail-flags
)
1968 rmail-movemail-flags
)
1970 (if password
(list password
) nil
))))
1971 (apply 'call-process args
))
1972 (if (not (buffer-modified-p errors
))
1973 ;; No output => movemail won
1976 (subst-char-in-region (point-min) (point-max)
1978 (goto-char (point-max))
1979 (skip-chars-backward " \t")
1980 (delete-region (point) (point-max))
1981 (goto-char (point-min))
1982 (if (looking-at "movemail: ")
1983 (delete-region (point-min) (match-end 0)))
1985 ;; If we just read the password, most likely it is
1986 ;; wrong. Otherwise, see if there is a specific
1987 ;; reason to think that the problem is a wrong passwd.
1988 (if (or got-password
1989 (re-search-forward rmail-remote-password-error
1991 (rmail-set-remote-password nil
))
1993 ;; If using Mailutils, remove initial error code
1995 (when (rmail-movemail-variant-p 'mailutils
)
1996 (goto-char (point-min))
1997 (when (looking-at "[A-Z][A-Z0-9_]*:")
1998 (delete-region (point-min) (match-end 0))))
2000 (message "movemail: %s"
2001 (buffer-substring (point-min)
2007 ;; At this point, TOFILE contains the name to read:
2008 ;; Either the alternate name (if we renamed)
2009 ;; or the actual inbox (if not renaming).
2010 (if (file-exists-p tofile
)
2011 (let ((coding-system-for-read 'no-conversion
)
2013 (goto-char (point-max))
2015 ;; If new mail is in Babyl format, convert it to mbox.
2016 (rmail-unrmail-new-mail-maybe
2018 (nth 1 (insert-file-contents tofile
))))
2019 ;; Determine if a pair of newline message separators need
2020 ;; to be added to the new collection of messages. This is
2021 ;; the case for all new message collections added to a
2022 ;; non-empty mail file.
2023 (unless (zerop size
)
2025 (let ((start (point-min)))
2027 (unless (eq start
(point-min))
2030 (setq size
(+ 2 size
))))))
2031 (goto-char (point-max))
2032 (or (= (preceding-char) ?
\n)
2035 (if (not (and rmail-preserve-inbox
(string= file tofile
)))
2036 (setq delete-files
(cons tofile delete-files
)))))
2038 (setq files
(cdr files
)))
2041 ;; Decode the region specified by FROM and TO by CODING.
2042 ;; If CODING is nil or an invalid coding system, decode by `undecided'.
2043 (defun rmail-decode-region (from to coding
&optional destination
)
2044 (if (or (not coding
) (not (coding-system-p coding
)))
2045 (setq coding
'undecided
))
2046 ;; Use -dos decoding, to remove ^M characters left from base64 or
2047 ;; rogue qp-encoded text.
2048 (decode-coding-region
2049 from to
(coding-system-change-eol-conversion coding
1) destination
)
2050 ;; Don't reveal the fact we used -dos decoding, as users generally
2051 ;; will not expect the RMAIL buffer to use DOS EOL format.
2054 (setq buffer-file-coding-system
2055 (setq last-coding-system-used
2056 (coding-system-change-eol-conversion coding
0))))
2057 ((bufferp destination
)
2058 (with-current-buffer destination
2059 (setq buffer-file-coding-system
2060 (setq last-coding-system-used
2061 (coding-system-change-eol-conversion coding
0)))))))
2063 (defun rmail-ensure-blank-line ()
2064 "Ensure a message ends in a blank line.
2065 Call with point at the end of the message."
2068 (unless (looking-back "\n\n")
2071 (defun rmail-add-mbox-headers ()
2072 "Validate the RFC2822 format for the new messages.
2073 Point should be at the first new message.
2074 An error is signalled if the new messages are not RFC2822
2076 Unless an Rmail attribute header already exists, add it to the
2077 new messages. Return the number of new messages."
2083 (case-fold-search nil
)
2084 (delim (concat "\n\n" rmail-unix-mail-delimiter
))
2086 ;; Detect an empty inbox file.
2087 (unless (= start
(point-max))
2088 ;; Scan the new messages to establish a count and to ensure that
2089 ;; an attribute header is present.
2090 (if (looking-at rmail-unix-mail-delimiter
)
2092 ;; Determine if a new attribute header needs to be
2093 ;; added to the message.
2094 (if (search-forward "\n\n" nil t
)
2096 (setq count
(1+ count
))
2097 (narrow-to-region start
(point))
2098 (unless (mail-fetch-field rmail-attribute-header
)
2100 (insert rmail-attribute-header
": " value
"\n"))
2102 (rmail-error-bad-format))
2103 ;; Move to the next message.
2104 (if (not (re-search-forward delim nil
'move
))
2106 (goto-char (match-beginning 0))
2108 (setq start
(point)))
2109 (rmail-error-bad-format)))
2112 (defun rmail-get-header-1 (name)
2113 "Subroutine of `rmail-get-header'.
2114 Narrow to header, call `mail-fetch-field' to find header NAME."
2115 (if (search-forward "\n\n" nil t
)
2117 (narrow-to-region (point-min) (point))
2118 (mail-fetch-field name
))
2119 (rmail-error-bad-format)))
2121 (defun rmail-get-header (name &optional msgnum
)
2122 "Return the value of message header NAME, nil if it has none.
2123 MSGNUM specifies the message number to get it from.
2124 If MSGNUM is nil, use the current message."
2125 (rmail-apply-in-message msgnum
'rmail-get-header-1 name
))
2127 (defun rmail-set-header-1 (name value
)
2128 "Subroutine of `rmail-set-header'.
2129 Narrow to header, set header NAME to VALUE, replacing existing if present.
2130 VALUE nil means to remove NAME altogether."
2131 (if (search-forward "\n\n" nil t
)
2134 (narrow-to-region (point-min) (point))
2135 (goto-char (point-min))
2136 (if (re-search-forward (concat "^" (regexp-quote name
) ":") nil
'move
)
2139 (delete-region (point) (line-end-position))
2141 (delete-region (line-beginning-position)
2142 (line-beginning-position 2)))
2143 (if value
(insert name
": " value
"\n"))))
2144 (rmail-error-bad-format)))
2146 (defun rmail-set-header (name &optional msgnum value
)
2147 "Set message header NAME to VALUE in message number MSGNUM.
2148 If MSGNUM is nil, use the current message. NAME and VALUE are strings.
2149 VALUE may also be nil, meaning to remove the header."
2150 (rmail-apply-in-message msgnum
'rmail-set-header-1 name value
)
2151 (with-current-buffer rmail-buffer
2152 ;; Ensure header changes get saved.
2153 ;; (Note replacing a header with an identical copy modifies.)
2154 (set-buffer-modified-p t
)
2155 ;; However: don't save in mbox format over a Babyl file
2156 ;; merely because of this.
2157 (rmail-dont-modify-format)))
2159 ;;;; *** Rmail Attributes and Keywords ***
2161 (defun rmail-get-attr-names (&optional msg
)
2162 "Return the message attributes in a comma separated string.
2163 MSG specifies the message number to get it from.
2164 If MSG is nil, use the current message."
2165 (let ((value (rmail-get-header rmail-attribute-header msg
))
2166 (nmax (length rmail-attr-array
))
2169 (if (> (length value
) nmax
)
2170 (message "Warning: corrupt attribute header in message")
2171 (dotimes (index (length value
))
2172 (setq temp
(and (not (= ?-
(aref value index
)))
2173 (nth 1 (aref rmail-attr-array index
)))
2176 ((and temp result
) (format "%s, %s" result temp
))
2181 (defun rmail-get-keywords (&optional msg
)
2182 "Return the message keywords in a comma separated string.
2183 MSG, if non-nil, identifies the message number to use.
2184 If nil, that means the current message."
2185 (rmail-get-header rmail-keyword-header msg
))
2187 (defun rmail-get-labels (&optional msg
)
2188 "Return a string with the labels (attributes and keywords) of msg MSG.
2189 It is put in comma-separated form.
2190 MSG, if non-nil, identifies the message number to use.
2191 If nil, that means the current message."
2192 (or msg
(setq msg rmail-current-message
))
2193 (let (attr-names keywords
)
2194 ;; Combine the message attributes and keywords
2195 ;; into a comma-separated list.
2196 (setq attr-names
(rmail-get-attr-names msg
)
2197 keywords
(rmail-get-keywords msg
))
2198 (if (string= keywords
"")
2199 (setq keywords nil
))
2201 ;; FIXME ? old rmail did not have spaces in the comma-separated lists.
2202 ((and attr-names keywords
) (concat " " attr-names
"; " keywords
))
2203 (attr-names (concat " " attr-names
))
2204 (keywords (concat " " keywords
))
2207 (defun rmail-display-labels ()
2208 "Update the current messages's attributes and keywords in mode line."
2209 (let ((blurb (rmail-get-labels)))
2210 (setq mode-line-process
2212 rmail-current-message rmail-total-messages blurb
))
2213 ;; If rmail-enable-mime is non-nil, we may have to update
2214 ;; `mode-line-process' of rmail-view-buffer too.
2215 (if (and rmail-enable-mime
2216 (not (eq (current-buffer) rmail-view-buffer
))
2217 (buffer-live-p rmail-view-buffer
))
2218 (let ((mlp mode-line-process
))
2219 (with-current-buffer rmail-view-buffer
2220 (setq mode-line-process mlp
))))))
2222 (defun rmail-get-attr-value (attr state
)
2223 "Return the character value for ATTR.
2224 ATTR is a (numeric) index, an offset into the mbox attribute
2225 header value. STATE is one of nil, t, or a character value."
2227 ((numberp state
) state
)
2229 (t (nth 0 (aref rmail-attr-array attr
)))))
2231 (defun rmail-set-attribute-1 (attr state
)
2232 "Subroutine of `rmail-set-attribute'.
2233 Set Rmail attribute ATTR to STATE in `rmail-attribute-header',
2234 creating the header if necessary. Returns non-nil if a
2235 significant attribute change was made."
2236 (let ((limit (search-forward "\n\n" nil t
))
2237 (value (rmail-get-attr-value attr state
))
2238 (inhibit-read-only t
)
2240 (goto-char (point-min))
2241 (if (search-forward (concat rmail-attribute-header
": ") limit t
)
2242 ;; If this message already records attributes, just change the
2243 ;; value for this one.
2244 (let ((missing (- (+ (point) attr
) (line-end-position))))
2245 ;; Position point at this attribute, adding attributes if necessary.
2249 (insert-char ?- missing
)
2251 (forward-char attr
))
2252 ;; Change this attribute.
2253 (when (/= value
(char-after))
2257 ;; Otherwise add a header line to record the attributes and set
2258 ;; all but this one to no.
2259 (let ((header-value "--------"))
2260 (aset header-value attr value
)
2261 (goto-char (if limit
(1- limit
) (point-max)))
2262 (setq altered
(/= value ?-
))
2263 (insert rmail-attribute-header
": " header-value
"\n")))
2266 (defun rmail-set-attribute (attr state
&optional msgnum
)
2267 "Turn an attribute of a message on or off according to STATE.
2268 STATE is either nil or the character (numeric) value associated
2269 with the state (nil represents off and non-nil represents on).
2270 ATTR is either the index number of the attribute, or a string,
2271 both from `rmail-attr-array'. MSGNUM is message number to
2272 change; nil means current message."
2274 (nmax (length rmail-attr-array
)))
2275 (while (and (stringp attr
)
2277 (if (string-equal attr
(cadr (aref rmail-attr-array n
)))
2281 (error "Unknown attribute `%s'" attr
))
2282 ;; Ask for confirmation before setting any attribute except `unseen'
2283 ;; if it would force a format change.
2284 (unless (= attr rmail-unseen-attr-index
)
2285 (rmail-modify-format))
2286 (with-current-buffer rmail-buffer
2287 (or msgnum
(setq msgnum rmail-current-message
))
2289 ;; The "deleted" attribute is also stored in a special vector so
2291 (if (= attr rmail-deleted-attr-index
)
2292 (rmail-set-message-deleted-p msgnum state
))
2294 (rmail-apply-in-message msgnum
'rmail-set-attribute-1 attr state
)
2295 (if (= msgnum rmail-current-message
)
2296 (rmail-display-labels)))
2297 ;; Don't save in mbox format over a Babyl file
2298 ;; merely because of a change in `unseen' attribute.
2299 (if (= attr rmail-unseen-attr-index
)
2300 (rmail-dont-modify-format)
2301 ;; Otherwise, if we modified the file text via the view buffer,
2302 ;; mark the main buffer modified too.
2303 (set-buffer-modified-p t
))))))
2305 (defun rmail-message-attr-p (msg attrs
)
2306 "Return non-nil if message number MSG has attributes matching regexp ATTRS."
2307 (let ((value (rmail-get-header rmail-attribute-header msg
)))
2308 (and value
(string-match attrs value
))))
2310 (defun rmail-message-unseen-p (msgnum)
2311 "Return non-nil if message number MSGNUM has the unseen attribute."
2312 (rmail-message-attr-p msgnum
"......U"))
2314 ;; FIXME rmail-get-labels does some formatting (eg leading space, `;'
2315 ;; between attributes and labels), so this might not do what you want.
2316 ;; Eg see rmail-sort-by-labels. rmail-get-labels could have an
2317 ;; optional `noformat' argument.
2318 (defun rmail-message-labels-p (msg labels
)
2319 "Return non-nil if message number MSG has labels matching regexp LABELS."
2320 (string-match labels
(rmail-get-labels msg
)))
2322 ;;;; *** Rmail Message Selection And Support ***
2324 (defun rmail-msgend (n)
2325 "Return the start position for message number N."
2326 (marker-position (aref rmail-message-vector
(1+ n
))))
2328 (defun rmail-msgbeg (n)
2329 "Return the end position for message number N."
2330 (marker-position (aref rmail-message-vector n
)))
2332 (defun rmail-apply-in-message (msgnum function
&rest args
)
2333 "Call FUNCTION on ARGS while narrowed to message MSGNUM.
2334 Point is at the start of the message.
2335 This returns what the call to FUNCTION returns.
2336 If MSGNUM is nil, use the current message."
2337 (with-current-buffer rmail-buffer
2338 (or msgnum
(setq msgnum rmail-current-message
))
2340 (let (msgbeg msgend
)
2341 (setq msgbeg
(rmail-msgbeg msgnum
))
2342 (setq msgend
(rmail-msgend msgnum
))
2343 ;; All access to the rmail-buffer's local variables is now finished...
2345 ;; ... so it is ok to go to a different buffer.
2346 (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer
))
2351 (narrow-to-region msgbeg msgend
)
2352 (apply function args
))))))))
2354 ;; Unused (save for commented out code in rmailedit.el).
2355 (defun rmail-widen-to-current-msgbeg (function)
2356 "Call FUNCTION with point at start of internal data of current message.
2357 Assumes that bounds were previously narrowed to display the message in Rmail.
2358 The bounds are widened enough to move point where desired, then narrowed
2361 FUNCTION may not change the visible text of the message, but it may
2362 change the invisible header text."
2366 (narrow-to-region (rmail-msgbeg rmail-current-message
)
2368 (goto-char (point-min))
2370 ;; Note: we don't use save-restriction because that does not work right
2371 ;; if changes are made outside the saved restriction
2372 ;; before that restriction is restored.
2373 (narrow-to-region (rmail-msgbeg rmail-current-message
)
2374 (rmail-msgend rmail-current-message
)))))
2376 ;; Manage the message vectors and counters.
2378 (defun rmail-forget-messages ()
2380 (if (vectorp rmail-message-vector
)
2381 (let* ((v rmail-message-vector
)
2385 (move-marker (aref v i
) nil
)))))
2386 (setq rmail-message-vector nil
)
2387 (setq rmail-msgref-vector nil
)
2388 (setq rmail-deleted-vector nil
)))
2390 (defun rmail-maybe-set-message-counters ()
2391 (if (not (and rmail-deleted-vector
2392 rmail-message-vector
2393 rmail-current-message
2394 rmail-total-messages
))
2395 (rmail-set-message-counters)))
2397 (defun rmail-count-new-messages (&optional nomsg
)
2398 "Count the number of new messages.
2399 The buffer should be narrowed to include only the new messages.
2400 Output a helpful message unless NOMSG is non-nil."
2401 (let* ((case-fold-search nil
)
2405 (or nomsg
(message "Counting new messages..."))
2406 (goto-char (point-max))
2407 ;; Put at the end of messages-head
2408 ;; the entry for message N+1, which marks
2409 ;; the end of message N. (N = number of messages).
2410 (setq messages-head
(list (point-marker)))
2411 (rmail-set-message-counters-counter (point-min))
2412 (setq rmail-current-message
(1+ rmail-total-messages
))
2413 (setq rmail-total-messages
2414 (+ rmail-total-messages total-messages
))
2415 (setq rmail-message-vector
2416 (vconcat rmail-message-vector
(cdr messages-head
)))
2417 (aset rmail-message-vector
2418 rmail-current-message
(car messages-head
))
2419 (setq rmail-deleted-vector
2420 (concat rmail-deleted-vector deleted-head
))
2421 (setq rmail-summary-vector
2422 (vconcat rmail-summary-vector
(make-vector total-messages nil
)))
2423 (setq rmail-msgref-vector
2424 (vconcat rmail-msgref-vector
(make-vector total-messages nil
)))
2425 ;; Fill in the new elements of rmail-msgref-vector.
2426 (let ((i (1+ (- rmail-total-messages total-messages
))))
2427 (while (<= i rmail-total-messages
)
2428 (aset rmail-msgref-vector i
(list i
))
2430 (goto-char (point-min))
2431 (or nomsg
(message "Counting new messages...done (%d)" total-messages
))))
2433 (defun rmail-set-message-counters ()
2434 (rmail-forget-messages)
2438 (let* ((point-save (point))
2440 (messages-after-point)
2441 (case-fold-search nil
)
2444 ;; Determine how many messages follow point.
2445 (message "Counting messages...")
2446 (goto-char (point-max))
2447 ;; Put at the end of messages-head
2448 ;; the entry for message N+1, which marks
2449 ;; the end of message N. (N = number of messages).
2450 (setq messages-head
(list (point-marker)))
2451 (setq messages-after-point
2452 (or (rmail-set-message-counters-counter (min (point) point-save
))
2455 (setq rmail-total-messages total-messages
)
2456 (setq rmail-current-message
2458 (max 1 (- total-messages messages-after-point
))))
2460 ;; Make an element 0 in rmail-message-vector and rmail-deleted-vector
2461 ;; which will never be used.
2462 (push nil messages-head
)
2463 (push ?
0 deleted-head
)
2464 (setq rmail-message-vector
(apply 'vector messages-head
)
2465 rmail-deleted-vector
(concat deleted-head
))
2467 (setq rmail-summary-vector
(make-vector rmail-total-messages nil
)
2468 rmail-msgref-vector
(make-vector (1+ rmail-total-messages
) nil
))
2471 (while (<= i rmail-total-messages
)
2472 (aset rmail-msgref-vector i
(list i
))
2475 (while (<= i rmail-total-messages
)
2476 (rmail-set-message-deleted-p i
(rmail-message-attr-p i
".D"))
2478 (message "Counting messages...done")))))
2481 (defsubst rmail-collect-deleted
(message-end)
2482 "Collect the message deletion flags for each message.
2483 MESSAGE-END is the buffer position corresponding to the end of
2484 the message. Point is at the beginning of the message."
2485 ;; NOTE: This piece of code will be executed on a per-message basis.
2486 ;; In the face of thousands of messages, it has to be as fast as
2487 ;; possible, hence some brute force constant use is employed in
2488 ;; addition to inlining.
2491 (cons (if (and (search-forward (concat rmail-attribute-header
": ") message-end t
)
2494 ?\s
) deleted-head
))))
2496 (defun rmail-set-message-counters-counter (&optional spot-to-find
)
2497 "Collect the start positions of messages in list `messages-head'.
2498 Return the number of messages after the one containing SPOT-TO-FIND."
2499 (let ((start (point))
2500 messages-after-spot
)
2501 (while (search-backward "\n\nFrom " nil t
)
2503 (when (looking-at rmail-unix-mail-delimiter
)
2504 (if (and (<= (point) spot-to-find
)
2505 (null messages-after-spot
))
2506 (setq messages-after-spot total-messages
))
2507 (rmail-collect-deleted start
)
2508 (setq messages-head
(cons (point-marker) messages-head
)
2509 total-messages
(1+ total-messages
)
2511 ;; Show progress after every 20 messages or so.
2512 (if (zerop (% total-messages
20))
2513 (message "Counting messages...%d" total-messages
))))
2514 ;; Handle the first message, maybe.
2515 (goto-char (point-min))
2516 (unless (not (looking-at rmail-unix-mail-delimiter
))
2517 (if (and (<= (point) spot-to-find
)
2518 (null messages-after-spot
))
2519 (setq messages-after-spot total-messages
))
2520 (rmail-collect-deleted start
)
2521 (setq messages-head
(cons (point-marker) messages-head
)
2522 total-messages
(1+ total-messages
)))
2523 messages-after-spot
))
2525 ;; Display a message.
2527 ;;;; *** Rmail Message Formatting and Header Manipulation ***
2529 ;; This is used outside of rmail.
2530 (defun rmail-msg-is-pruned ()
2531 "Return nil if the current message is showing full headers."
2532 (with-current-buffer (if (rmail-buffers-swapped-p) rmail-view-buffer
2534 (eq rmail-header-style
'normal
)))
2536 (defun rmail-toggle-header (&optional arg
)
2537 "Toggle between showing full and normal message headers.
2538 With optional integer ARG, show the normal message header if ARG
2539 is greater than zero; otherwise, show it in full."
2541 (let ((rmail-header-style
2543 (if (> arg
0) 'normal
'full
)
2544 (if (rmail-msg-is-pruned) 'full
'normal
))))
2545 (rmail-show-message)))
2547 (defun rmail-beginning-of-message ()
2548 "Show current message starting from the beginning."
2550 (let ((rmail-show-message-hook '((lambda () (goto-char (point-min)))))
2551 (rmail-header-style (with-current-buffer (if (rmail-buffers-swapped-p)
2554 rmail-header-style
)))
2555 (rmail-show-message rmail-current-message
)))
2557 (defun rmail-end-of-message ()
2558 "Show bottom of current message."
2560 (let ((rmail-show-message-hook '((lambda ()
2561 (goto-char (point-max))
2562 (recenter (1- (window-height))))))
2563 (rmail-header-style (with-current-buffer (if (rmail-buffers-swapped-p)
2566 rmail-header-style
)))
2567 (rmail-show-message rmail-current-message
)))
2569 (defun rmail-unknown-mail-followup-to ()
2570 "Handle a \"Mail-Followup-To\" header field with an unknown mailing list.
2571 Ask the user whether to add that list name to `mail-mailing-lists'."
2572 ;; FIXME s-r not needed? Use rmail-get-header?
2573 ;; We have not narrowed to the headers at ths point?
2575 (let ((mail-followup-to (mail-fetch-field "mail-followup-to" nil t
)))
2576 (when mail-followup-to
2579 (mail-strip-quoted-names mail-followup-to
)
2580 ",[[:space:]]+" t
)))
2581 (dolist (addr addresses
)
2582 (when (and (not (member addr mail-mailing-lists
))
2584 ;; taken from rmailsum.el
2586 (or rmail-user-mail-address-regexp
2588 (regexp-quote (user-login-name))
2591 (or user-mail-address
2592 (concat (user-login-name) "@"
2593 (or mail-host-address
2598 (format "Add `%s' to `mail-mailing-lists'? "
2600 (customize-save-variable 'mail-mailing-lists
2601 (cons addr mail-mailing-lists
)))))))))
2603 (defun rmail-widen ()
2604 "Display the entire mailbox file."
2606 (rmail-swap-buffers-maybe)
2609 (defun rmail-no-mail-p ()
2610 "Return nil if there is mail, else \"No mail.\"."
2611 (if (zerop rmail-total-messages
)
2613 (with-current-buffer rmail-view-buffer
2617 (defun rmail-show-message (&optional n no-summary
)
2618 "Show message number N (prefix argument), counting from start of file.
2619 If summary buffer is currently displayed, update current message there also.
2620 N defaults to the current message."
2622 (or (eq major-mode
'rmail-mode
)
2623 (switch-to-buffer rmail-buffer
))
2624 ;; FIXME: Why do we swap the raw data back in?
2625 (rmail-swap-buffers-maybe)
2626 (rmail-maybe-set-message-counters)
2628 (let ((blurb (rmail-show-message-1 n
)))
2629 (or (zerop rmail-total-messages
)
2631 (when mail-mailing-lists
2632 (rmail-unknown-mail-followup-to))
2633 (if transient-mark-mode
(deactivate-mark))
2634 ;; If there is a summary buffer, try to move to this message
2635 ;; in that buffer. But don't complain if this message is
2636 ;; not mentioned in the summary. Don't do this at all if we
2637 ;; were called on behalf of cursor motion in the summary
2639 (and (rmail-summary-exists) (not no-summary
)
2640 (let ((curr-msg rmail-current-message
))
2641 (rmail-select-summary
2642 (rmail-summary-goto-msg curr-msg t t
))))
2643 (with-current-buffer rmail-buffer
2644 (rmail-auto-file))))
2648 (defun rmail-is-text-p ()
2649 "Return t if the region contains a text message, nil otherwise."
2651 (let ((text-regexp "\\(text\\|message\\)/")
2652 (content-type-header (mail-fetch-field "content-type")))
2653 ;; The message is text if either there is no content type header
2654 ;; (a default of "text/plain; charset=US-ASCII" is assumed) or
2655 ;; the base content type is either text or message.
2656 (or (not content-type-header
)
2657 (string-match text-regexp content-type-header
)))))
2659 (defcustom rmail-show-message-verbose-min
200000
2660 "Message size at which to show progress messages for displaying it."
2665 (defun rmail-show-message-1 (&optional msg
)
2666 "Show message MSG (default: current message) using `rmail-view-buffer'.
2667 Return text to display in the minibuffer if MSG is out of
2668 range (displaying a reasonable choice as well), nil otherwise.
2669 The current mail message becomes the message displayed."
2670 (let ((mbox-buf rmail-buffer
)
2671 (view-buf rmail-view-buffer
)
2672 blurb beg end body-start coding-system character-coding
2673 is-text-message header-style
)
2675 (setq msg rmail-current-message
))
2676 (unless (setq blurb
(rmail-no-mail-p))
2679 rmail-current-message
1
2680 blurb
"No previous message"))
2681 ((> msg rmail-total-messages
)
2682 (setq msg rmail-total-messages
2683 rmail-current-message rmail-total-messages
2684 blurb
"No following message"))
2685 (t (setq rmail-current-message msg
)))
2686 (with-current-buffer rmail-buffer
2687 (setq header-style rmail-header-style
)
2688 ;; Mark the message as seen
2689 (rmail-set-attribute rmail-unseen-attr-index nil
)
2690 ;; bracket the message in the mail
2691 ;; buffer and determine the coding system the transfer encoding.
2692 (rmail-swap-buffers-maybe)
2693 (setq beg
(rmail-msgbeg msg
)
2694 end
(rmail-msgend msg
))
2695 (when (> (- end beg
) rmail-show-message-verbose-min
)
2696 (message "Showing message %d" msg
))
2697 (narrow-to-region beg end
)
2699 (setq body-start
(search-forward "\n\n" nil t
))
2700 (narrow-to-region beg
(point))
2703 (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t
)
2704 (setq coding-system
(intern (match-string 1)))
2705 (setq coding-system
(rmail-get-coding-system))))
2706 (setq character-coding
(mail-fetch-field "content-transfer-encoding")
2707 is-text-message
(rmail-is-text-p))
2708 (if character-coding
2709 (setq character-coding
(downcase character-coding
)))
2710 (narrow-to-region beg end
)
2711 ;; Decode the message body into an empty view buffer using a
2712 ;; unibyte temporary buffer where the character decoding takes
2714 (with-current-buffer rmail-view-buffer
2715 ;; We give the view buffer a buffer-local value of
2716 ;; rmail-header-style based on the binding in effect when
2717 ;; this function is called; `rmail-toggle-headers' can
2718 ;; inspect this value to determine how to toggle.
2719 (set (make-local-variable 'rmail-header-style
) header-style
)
2721 (if (null character-coding
)
2722 ;; Do it directly since that is fast.
2723 (rmail-decode-region body-start end coding-system view-buf
)
2724 ;; Can this be done directly, skipping the temp buffer?
2726 (set-buffer-multibyte nil
)
2727 (insert-buffer-substring mbox-buf body-start end
)
2729 ((string= character-coding
"quoted-printable")
2730 (mail-unquote-printable-region (point-min) (point-max)
2732 ((and (string= character-coding
"base64") is-text-message
)
2733 (base64-decode-region (point-min) (point-max)))
2734 ((eq character-coding
'uuencode
)
2735 (error "uuencoded messages are not supported yet"))
2737 (rmail-decode-region (point-min) (point-max)
2738 coding-system view-buf
)))
2739 (with-current-buffer rmail-view-buffer
2740 ;; Unquote quoted From lines
2741 (goto-char (point-min))
2742 (while (re-search-forward "^>+From " nil t
)
2746 (goto-char (point-min)))
2747 ;; Copy the headers to the front of the message view buffer.
2748 (rmail-copy-headers beg end
)
2749 ;; Add the separator (blank line) between headers and body;
2750 ;; highlight the message, activate any URL like text and add
2751 ;; special highlighting for and quoted material.
2752 (with-current-buffer rmail-view-buffer
2754 (goto-char (point-min))
2755 (rmail-highlight-headers)
2756 ;(rmail-activate-urls)
2757 ;(rmail-process-quoted-material)
2759 ;; Update the mode-line with message status information and swap
2760 ;; the view buffer/mail buffer contents.
2761 (rmail-display-labels)
2762 (rmail-swap-buffers)
2763 (setq rmail-buffer-swapped t
)
2764 (run-hooks 'rmail-show-message-hook
)
2765 (when (> (- end beg
) rmail-show-message-verbose-min
)
2766 (message "Showing message %d...done" msg
))))
2769 (defun rmail-copy-headers (beg end
&optional ignored-headers
)
2770 "Copy displayed header fields to the message viewer buffer.
2771 BEG and END marks the start and end positions of the message in
2772 the mbox buffer. If the optional argument IGNORED-HEADERS is
2773 non-nil, ignore all header fields whose names match that regexp.
2774 Otherwise, if `rmail-displayed-headers' is non-nil, copy only
2775 those header fields whose names match that regexp. Otherwise,
2776 copy all header fields whose names do not match
2777 `rmail-ignored-headers' (unless they also match
2778 `rmail-nonignored-headers'). Moves point in the message viewer
2779 buffer to the end of the headers."
2780 (let ((header-start-regexp "\n[^ \t]")
2782 (with-current-buffer rmail-buffer
2783 (when (search-forward "\n\n" nil t
)
2786 ;; Put point right after the From header line.
2787 (narrow-to-region beg
(point))
2788 (goto-char (point-min))
2789 (unless (re-search-forward header-start-regexp nil t
)
2790 (rmail-error-bad-format))
2793 ;; Handle the case where all headers should be copied.
2794 ((eq rmail-header-style
'full
)
2795 (prepend-to-buffer rmail-view-buffer beg
(point-max))
2796 ;; rmail-show-message-1 expects this function to leave point
2797 ;; at the end of the headers.
2799 (let ((len (- (point-max) beg
)))
2800 (with-current-buffer rmail-view-buffer
2801 (goto-char (1+ len
)))))
2803 ;; Handle the case where the headers matching the displayed
2804 ;; headers regexp should be copied.
2805 ((and rmail-displayed-headers
(null ignored-headers
))
2808 (setq lim
(if (re-search-forward header-start-regexp nil t
)
2809 (1+ (match-beginning 0))
2811 (when (looking-at rmail-displayed-headers
)
2812 (append-to-buffer rmail-view-buffer
(point) lim
))
2814 ;; Handle the ignored headers.
2815 ((or ignored-headers
(setq ignored-headers rmail-ignored-headers
))
2816 (while (and ignored-headers
(not (eobp)))
2818 (setq lim
(if (re-search-forward header-start-regexp nil t
)
2819 (1+ (match-beginning 0))
2821 (if (and (looking-at ignored-headers
)
2822 (not (looking-at rmail-nonignored-headers
)))
2824 (append-to-buffer rmail-view-buffer
(point) lim
)
2826 (t (error "No headers selected for display!"))))))))
2828 (defun rmail-redecode-body (coding)
2829 "Decode the body of the current message using coding system CODING.
2830 This is useful with mail messages that have malformed or missing
2833 This function assumes that the current message is already decoded
2834 and displayed in the RMAIL buffer, but the coding system used to
2835 decode it was incorrect. It then decodes the message again,
2836 using the coding system CODING."
2837 (interactive "zCoding system for re-decoding this message: ")
2838 (when (not rmail-enable-mime
)
2839 (with-current-buffer rmail-buffer
2840 (rmail-swap-buffers-maybe)
2843 (let ((msgbeg (rmail-msgbeg rmail-current-message
))
2844 (msgend (rmail-msgend rmail-current-message
))
2845 (buffer-read-only nil
)
2846 body-start x-coding-header old-coding
)
2847 (narrow-to-region msgbeg msgend
)
2848 (goto-char (point-min))
2849 (unless (setq body-start
(search-forward "\n\n" (point-max) 1))
2850 (error "No message body"))
2853 ;; Narrow to headers
2854 (narrow-to-region (point-min) body-start
)
2855 (setq x-coding-header
(goto-char (point-min)))
2856 (if (not (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t
))
2857 (setq old-coding
(rmail-get-coding-system))
2858 (setq old-coding
(intern (match-string 1)))
2859 (setq x-coding-header
(point)))
2860 (check-coding-system old-coding
)
2861 ;; Make sure the new coding system uses the same EOL
2862 ;; conversion, to prevent ^M characters from popping up
2863 ;; all over the place.
2864 (let ((eol-type (coding-system-eol-type old-coding
)))
2865 (if (numberp eol-type
)
2867 (coding-system-change-eol-conversion coding eol-type
))))
2868 (when (not (coding-system-equal
2869 (coding-system-base old-coding
)
2870 (coding-system-base coding
)))
2871 ;; Rewrite the coding-system header.
2872 (goto-char x-coding-header
)
2873 (if (> (point) (point-min))
2874 (delete-region (line-beginning-position) (point))
2878 (insert "X-Coding-System: "
2879 (symbol-name coding
))))
2880 (rmail-show-message))))))
2882 (defun rmail-highlight-headers ()
2883 "Highlight the headers specified by `rmail-highlighted-headers'.
2884 Uses the face `rmail-highlight'."
2885 (if rmail-highlighted-headers
2887 (search-forward "\n\n" nil
'move
)
2889 (narrow-to-region (point-min) (point))
2890 (let ((case-fold-search t
)
2891 (inhibit-read-only t
)
2892 ;; List of overlays to reuse.
2893 (overlays rmail-overlay-list
))
2894 (goto-char (point-min))
2895 (while (re-search-forward rmail-highlighted-headers nil t
)
2896 (skip-chars-forward " \t")
2899 (while (progn (forward-line 1)
2900 (looking-at "[ \t]")))
2901 ;; Back up over newline, then trailing spaces or tabs
2903 (while (member (preceding-char) '(? ?
\t))
2906 ;; Reuse an overlay we already have.
2908 (setq overlay
(car overlays
)
2909 overlays
(cdr overlays
))
2910 (overlay-put overlay
'face
'rmail-highlight
)
2911 (move-overlay overlay beg
(point)))
2912 ;; Make a new overlay and add it to
2913 ;; rmail-overlay-list.
2914 (setq overlay
(make-overlay beg
(point)))
2915 (overlay-put overlay
'face
'rmail-highlight
)
2916 (setq rmail-overlay-list
2917 (cons overlay rmail-overlay-list
))))))))))
2919 (defun rmail-auto-file ()
2920 "Automatically move a message into a sub-folder based on criteria.
2921 Called when a new message is displayed."
2922 (if (or (zerop rmail-total-messages
)
2923 (rmail-message-attr-p rmail-current-message
"...F")
2924 (not (string= (buffer-file-name)
2925 (expand-file-name rmail-file-name
))))
2926 ;; Do nothing if the message has already been filed or if there
2929 ;; Find out some basics (common fields)
2930 (let ((from (mail-fetch-field "from"))
2931 (subj (mail-fetch-field "subject"))
2932 (to (concat (mail-fetch-field "to") "," (mail-fetch-field "cc")))
2933 (d rmail-automatic-folder-directives
)
2934 (directive-loop nil
)
2937 (setq folder
(car (car d
))
2938 directive-loop
(cdr (car d
)))
2939 (while (and (car directive-loop
)
2941 ((string= (car directive-loop
) "from") from
)
2942 ((string= (car directive-loop
) "to") to
)
2943 ((string= (car directive-loop
) "subject") subj
)
2944 (t (mail-fetch-field (car directive-loop
))))))
2945 (and f
(string-match (car (cdr directive-loop
)) f
))))
2946 (setq directive-loop
(cdr (cdr directive-loop
))))
2947 ;; If there are no directives left, then it was a complete match.
2948 (if (null directive-loop
)
2950 (rmail-delete-forward)
2951 (if (string= "/dev/null" folder
)
2952 (rmail-delete-message)
2953 (rmail-output folder
1)
2955 (setq d
(cdr d
))))))
2957 ;; Simple message motion commands.
2959 (defun rmail-next-message (n)
2960 "Show following message whether deleted or not.
2961 With prefix arg N, moves forward N messages, or backward if N is negative."
2963 (set-buffer rmail-buffer
)
2964 (rmail-maybe-set-message-counters)
2965 (rmail-show-message (+ rmail-current-message n
)))
2967 (defun rmail-previous-message (n)
2968 "Show previous message whether deleted or not.
2969 With prefix arg N, moves backward N messages, or forward if N is negative."
2971 (rmail-next-message (- n
)))
2973 (defun rmail-next-undeleted-message (n)
2974 "Show following non-deleted message.
2975 With prefix arg N, moves forward N non-deleted messages,
2976 or backward if N is negative.
2978 Returns t if a new message is being shown, nil otherwise."
2980 (set-buffer rmail-buffer
)
2981 (rmail-maybe-set-message-counters)
2982 (let ((lastwin rmail-current-message
)
2983 (current rmail-current-message
))
2984 (while (and (> n
0) (< current rmail-total-messages
))
2985 (setq current
(1+ current
))
2986 (if (not (rmail-message-deleted-p current
))
2987 (setq lastwin current n
(1- n
))))
2988 (while (and (< n
0) (> current
1))
2989 (setq current
(1- current
))
2990 (if (not (rmail-message-deleted-p current
))
2991 (setq lastwin current n
(1+ n
))))
2992 (if (/= lastwin rmail-current-message
)
2993 (progn (rmail-show-message lastwin
)
2996 (message "No previous nondeleted message"))
2998 (message "No following nondeleted message"))
3001 (defun rmail-previous-undeleted-message (n)
3002 "Show previous non-deleted message.
3003 With prefix argument N, moves backward N non-deleted messages,
3004 or forward if N is negative."
3006 (rmail-next-undeleted-message (- n
)))
3008 (defun rmail-first-message ()
3009 "Show first message in file."
3011 (rmail-maybe-set-message-counters)
3012 (rmail-show-message 1))
3014 (defun rmail-last-message ()
3015 "Show last message in file."
3017 (rmail-maybe-set-message-counters)
3018 (rmail-show-message rmail-total-messages
))
3020 (defun rmail-what-message ()
3021 "For debugging Rmail: find the message number that point is in."
3022 (let* ((high rmail-total-messages
)
3025 (where (with-current-buffer (if (rmail-buffers-swapped-p)
3029 (while (> (- high low
) 1)
3030 (if (>= where
(rmail-msgbeg mid
))
3033 (setq mid
(+ low
(/ (- high low
) 2))))
3034 (if (>= where
(rmail-msgbeg high
)) high low
)))
3036 ;; Searching in Rmail file.
3038 (defun rmail-search-message (msg regexp
)
3039 "Return non-nil, if for message number MSG, regexp REGEXP matches."
3040 ;; This is adequate because its only caller, rmail-search,
3041 ;; unswaps the buffers.
3042 (goto-char (rmail-msgbeg msg
))
3043 (if rmail-enable-mime
3044 (if rmail-search-mime-message-function
3045 (funcall rmail-search-mime-message-function msg regexp
)
3046 (error "You must set `rmail-search-mime-message-function'"))
3047 (re-search-forward regexp
(rmail-msgend msg
) t
)))
3049 (defvar rmail-search-last-regexp nil
)
3050 (defun rmail-search (regexp &optional n
)
3051 "Show message containing next match for REGEXP (but not the current msg).
3052 Prefix argument gives repeat count; negative argument means search
3053 backwards (through earlier messages).
3054 Interactively, empty argument means use same regexp used last time."
3056 (let* ((reversep (< (prefix-numeric-value current-prefix-arg
) 0))
3058 (concat (if reversep
"Reverse " "") "Rmail search (regexp"))
3062 (if rmail-search-last-regexp
3063 (concat ", default "
3064 rmail-search-last-regexp
"): ")
3066 (setq regexp
(read-string prompt
))
3067 (cond ((not (equal regexp
""))
3068 (setq rmail-search-last-regexp regexp
))
3069 ((not rmail-search-last-regexp
)
3070 (error "No previous Rmail search string")))
3071 (list rmail-search-last-regexp
3072 (prefix-numeric-value current-prefix-arg
))))
3074 (message "%sRmail search for %s..."
3075 (if (< n
0) "Reverse " "")
3077 (set-buffer rmail-buffer
)
3078 (let ((orig-message rmail-current-message
)
3079 (msg rmail-current-message
)
3081 (opoint (if (rmail-buffers-swapped-p) (point)))
3083 (rmail-swap-buffers-maybe)
3084 (rmail-maybe-set-message-counters)
3088 ;; Check messages one by one, advancing message number up or
3089 ;; down but searching forward through each message.
3091 (while (and (null found
) (> msg
1))
3093 found
(rmail-search-message msg regexp
)))
3094 (while (and (null found
) (< msg rmail-total-messages
))
3096 found
(rmail-search-message msg regexp
))))
3097 (setq n
(+ n
(if reversep
1 -
1))))
3100 (rmail-show-message msg
)
3101 ;; Search forward (if this is a normal search) or backward
3102 ;; (if this is a reverse search) through this message to
3103 ;; position point. This search may fail because REGEXP
3104 ;; was found in the hidden portion of this message. In
3105 ;; that case, move point to the beginning of visible
3109 (goto-char (point-max))
3110 (re-search-backward regexp nil
'move
))
3111 (goto-char (point-min))
3112 (re-search-forward regexp nil t
))
3113 (message "%sRmail search for %s...done"
3114 (if reversep
"Reverse " "")
3116 (rmail-show-message orig-message
)
3117 (if opoint
(goto-char opoint
))
3119 (message "Search failed: %s" regexp
)))))
3121 (defun rmail-search-backwards (regexp &optional n
)
3122 "Show message containing previous match for REGEXP.
3123 Prefix argument gives repeat count; negative argument means search
3124 forward (through later messages).
3125 Interactively, empty argument means use same regexp used last time."
3127 (let* ((reversep (>= (prefix-numeric-value current-prefix-arg
) 0))
3129 (concat (if reversep
"Reverse " "") "Rmail search (regexp"))
3133 (if rmail-search-last-regexp
3134 (concat ", default "
3135 rmail-search-last-regexp
"): ")
3137 (setq regexp
(read-string prompt
))
3138 (cond ((not (equal regexp
""))
3139 (setq rmail-search-last-regexp regexp
))
3140 ((not rmail-search-last-regexp
)
3141 (error "No previous Rmail search string")))
3142 (list rmail-search-last-regexp
3143 (prefix-numeric-value current-prefix-arg
))))
3144 (rmail-search regexp
(- (or n
1))))
3146 ;; Scan for attributes, and compare subjects.
3148 (defun rmail-first-unseen-message ()
3149 "Return message number of first message which has `unseen' attribute."
3150 (rmail-maybe-set-message-counters)
3155 (while (and (not found
) (<= current rmail-total-messages
))
3156 (if (rmail-message-attr-p current
"......U")
3157 (setq found current
))
3158 (setq current
(1+ current
))))
3161 (defun rmail-simplified-subject (&optional msgnum
)
3162 "Return the simplified subject of message MSGNUM (or current message).
3163 Simplifying the subject means stripping leading and trailing whitespace,
3164 and typical reply prefixes such as Re:."
3165 (let ((subject (or (rmail-get-header "Subject" msgnum
) "")))
3166 (if (string-match "\\`[ \t]+" subject
)
3167 (setq subject
(substring subject
(match-end 0))))
3168 (if (string-match rmail-reply-regexp subject
)
3169 (setq subject
(substring subject
(match-end 0))))
3170 (if (string-match "[ \t]+\\'" subject
)
3171 (setq subject
(substring subject
0 (match-beginning 0))))
3172 ;; If Subject is long, mailers will break it into several lines at
3173 ;; arbitrary places, so normalize whitespace by replacing every
3174 ;; run of whitespace characters with a single space.
3175 (setq subject
(replace-regexp-in-string "[ \t\n]+" " " subject
))
3178 (defun rmail-simplified-subject-regexp ()
3179 "Return a regular expression matching the current simplified subject.
3180 The idea is to match it against simplified subjects of other messages."
3181 (let ((subject (rmail-simplified-subject)))
3182 (setq subject
(regexp-quote subject
))
3183 ;; Hide commas so it will work ok if parsed as a comma-separated list
3186 (replace-regexp-in-string "," "\054" subject t t
))
3187 (concat "\\`" subject
"\\'")))
3189 (defun rmail-next-same-subject (n)
3190 "Go to the next mail message having the same subject header.
3191 With prefix argument N, do this N times.
3192 If N is negative, go backwards instead."
3194 (let ((subject (rmail-simplified-subject))
3196 (i rmail-current-message
)
3198 (while (and (/= n
0)
3200 (< i rmail-total-messages
)
3203 (while (and (not done
)
3205 (< i rmail-total-messages
)
3207 (setq i
(if forward
(1+ i
) (1- i
)))
3208 (setq done
(string-equal subject
(rmail-simplified-subject i
))))
3209 (if done
(setq found i
)))
3210 (setq n
(if forward
(1- n
) (1+ n
))))
3212 (rmail-show-message found
)
3213 (error "No %s message with same subject"
3214 (if forward
"following" "previous")))))
3216 (defun rmail-previous-same-subject (n)
3217 "Go to the previous mail message having the same subject header.
3218 With prefix argument N, do this N times.
3219 If N is negative, go forwards instead."
3221 (rmail-next-same-subject (- n
)))
3223 ;;;; *** Rmail Message Deletion Commands ***
3225 (defun rmail-message-deleted-p (n)
3226 "Return non-nil if message number N is deleted (in `rmail-deleted-vector')."
3227 (= (aref rmail-deleted-vector n
) ?D
))
3229 (defun rmail-set-message-deleted-p (n state
)
3230 "Set the deleted state of message number N (in `rmail-deleted-vector').
3231 STATE non-nil means mark as deleted."
3232 (aset rmail-deleted-vector n
(if state ?D ?\s
)))
3234 (defun rmail-delete-message ()
3235 "Delete this message and stay on it."
3237 (rmail-set-attribute rmail-deleted-attr-index t
)
3238 (run-hooks 'rmail-delete-message-hook
))
3240 (defun rmail-undelete-previous-message ()
3241 "Back up to deleted message, select it, and undelete it."
3243 (set-buffer rmail-buffer
)
3244 (let ((msg rmail-current-message
))
3245 (while (and (> msg
0)
3246 (not (rmail-message-deleted-p msg
)))
3247 (setq msg
(1- msg
)))
3249 (error "No previous deleted message")
3250 (if (/= msg rmail-current-message
)
3251 (rmail-show-message msg
))
3252 (rmail-set-attribute rmail-deleted-attr-index nil
)
3253 (if (rmail-summary-exists)
3254 (with-current-buffer rmail-summary-buffer
3255 (rmail-summary-mark-undeleted msg
)))
3256 (rmail-maybe-display-summary))))
3258 (defun rmail-delete-forward (&optional backward
)
3259 "Delete this message and move to next nondeleted one.
3260 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
3261 With prefix argument, delete and move backward.
3263 Returns t if a new message is displayed after the delete, or nil otherwise."
3265 (rmail-set-attribute rmail-deleted-attr-index t
)
3266 (run-hooks 'rmail-delete-message-hook
)
3267 (let ((del-msg rmail-current-message
))
3268 (if (rmail-summary-exists)
3269 (rmail-select-summary
3270 (rmail-summary-mark-deleted del-msg
)))
3271 (prog1 (rmail-next-undeleted-message (if backward -
1 1))
3272 (rmail-maybe-display-summary))))
3274 (defun rmail-delete-backward ()
3275 "Delete this message and move to previous nondeleted one.
3276 Deleted messages stay in the file until the \\[rmail-expunge] command is given."
3278 (rmail-delete-forward t
))
3282 ;; Compute the message number a given message would have after expunging.
3283 ;; The present number of the message is OLDNUM.
3284 ;; DELETEDVEC should be rmail-deleted-vector.
3285 ;; The value is nil for a message that would be deleted.
3286 (defun rmail-msg-number-after-expunge (deletedvec oldnum
)
3287 (if (or (null oldnum
) (= (aref deletedvec oldnum
) ?D
))
3292 (if (/= (aref deletedvec i
) ?D
)
3293 (setq newnum
(1+ newnum
)))
3297 (defun rmail-expunge-confirmed ()
3298 "Return t if expunge is needed and desirable.
3299 If `rmail-confirm-expunge' is non-nil, ask user to confirm."
3300 (set-buffer rmail-buffer
)
3301 (and (stringp rmail-deleted-vector
)
3302 (string-match "D" rmail-deleted-vector
)
3303 (if rmail-confirm-expunge
3304 (funcall rmail-confirm-expunge
3305 "Erase deleted messages from Rmail file? ")
3308 (defun rmail-only-expunge (&optional dont-show
)
3309 "Actually erase all deleted messages in the file."
3311 (rmail-swap-buffers-maybe)
3312 (set-buffer rmail-buffer
)
3313 (message "Expunging deleted messages...")
3314 ;; Discard all undo records for this buffer.
3315 (or (eq buffer-undo-list t
)
3316 (setq buffer-undo-list nil
))
3317 (rmail-maybe-set-message-counters)
3318 (let* ((omax (- (buffer-size) (point-max)))
3319 (omin (- (buffer-size) (point-min)))
3320 (opoint (if (and (> rmail-current-message
0)
3321 (rmail-message-deleted-p rmail-current-message
))
3323 (if rmail-enable-mime
3324 (with-current-buffer rmail-view-buffer
3325 (- (point)(point-min)))
3326 (- (point) (point-min)))))
3327 (messages-head (cons (aref rmail-message-vector
0) nil
))
3328 (messages-tail messages-head
)
3329 ;; Don't make any undo records for the expunging.
3330 (buffer-undo-list t
)
3335 (goto-char (point-min))
3339 (new-msgref (list (list 0)))
3340 (buffer-read-only nil
)
3341 (total rmail-total-messages
)
3342 (new-message-number rmail-current-message
)
3343 (messages rmail-message-vector
)
3344 (deleted rmail-deleted-vector
)
3345 (summary rmail-summary-vector
))
3346 (setq rmail-total-messages nil
3347 rmail-current-message nil
3348 rmail-message-vector nil
3349 rmail-deleted-vector nil
3350 rmail-summary-vector nil
)
3352 (while (<= number total
)
3353 (if (= (aref deleted number
) ?D
)
3355 (delete-region (aref messages number
)
3356 (aref messages
(1+ number
)))
3357 (move-marker (aref messages number
) nil
)
3358 (if (> new-message-number counter
)
3359 (setq new-message-number
(1- new-message-number
))))
3360 (setq counter
(1+ counter
))
3362 (setcdr messages-tail
3363 (cons (aref messages number
) nil
)))
3365 (cons (if (= counter number
) (aref summary
(1- number
)))
3368 (cons (aref rmail-msgref-vector number
)
3370 (setcar (car new-msgref
) counter
))
3371 (if (zerop (%
(setq number
(1+ number
)) 20))
3372 (message "Expunging deleted messages...%d" number
)))
3374 (setcdr messages-tail
3375 (cons (aref messages number
) nil
)))
3376 (setq rmail-current-message new-message-number
3377 rmail-total-messages counter
3378 rmail-message-vector
(apply 'vector messages-head
)
3379 rmail-deleted-vector
(make-string (1+ counter
) ?\s
)
3380 rmail-summary-vector
(vconcat (nreverse new-summary
))
3381 rmail-msgref-vector
(apply 'vector
(nreverse new-msgref
))
3383 (message "Expunging deleted messages...done")
3385 (narrow-to-region (- (buffer-size) omin
) (- (buffer-size) omax
)))
3387 (rmail-show-message (min rmail-current-message rmail-total-messages
)))
3388 (if rmail-enable-mime
3389 (goto-char (+ (point-min) opoint
))
3390 (goto-char (+ (point) opoint
))))))
3392 ;; The DONT-SHOW argument is new in 23. Does not seem very important.
3393 (defun rmail-expunge (&optional dont-show
)
3394 "Erase deleted messages from Rmail file and summary buffer.
3395 This always shows a message (so as not to leave the Rmail buffer
3396 unswapped), and always updates any summary (so that it remains
3397 consistent with the Rmail buffer). If DONT-SHOW is non-nil, it
3398 does not pop any summary buffer."
3400 (when (rmail-expunge-confirmed)
3401 (rmail-modify-format)
3402 (let ((was-deleted (rmail-message-deleted-p rmail-current-message
))
3403 (was-swapped (rmail-buffers-swapped-p)))
3404 (rmail-only-expunge t
)
3405 ;; We always update the summary buffer, so that the contents
3406 ;; remain consistent with the rmail buffer.
3407 ;; The only difference is, in the dont-show case, we use a
3408 ;; cut-down version of rmail-select-summary that does not pop
3409 ;; the summary buffer. It's only used by rmail-quit, which is
3410 ;; just going to bury any summary immediately after. If we made
3411 ;; rmail-quit bury the summary first, dont-show could be removed.
3412 ;; But the expunge might not be confirmed...
3413 (if (rmail-summary-exists)
3415 (let ((total rmail-total-messages
))
3416 (with-current-buffer rmail-summary-buffer
3417 (let ((rmail-total-messages total
))
3418 (rmail-update-summary))))
3419 (rmail-select-summary (rmail-update-summary))))
3420 ;; We always show a message, because (rmail-only-expunge t)
3421 ;; leaves the rmail buffer unswapped.
3422 ;; If we expunged the current message, a new one is current now,
3423 ;; so show it. If we weren't showing a message, show it.
3424 (if (or was-deleted
(not was-swapped
))
3425 (rmail-show-message-1 rmail-current-message
)
3426 ;; We can just show the same message that was being shown before.
3427 (rmail-display-labels)
3428 (rmail-swap-buffers)
3429 (setq rmail-buffer-swapped t
)))))
3431 ;;;; *** Rmail Mailing Commands ***
3433 (defun rmail-start-mail (&optional noerase to subject in-reply-to cc
3434 replybuffer sendactions same-window others
)
3437 ;; The function used here must behave like insert-buffer wrt
3438 ;; point and mark (see doc of sc-cite-original).
3439 (setq yank-action
(list 'insert-buffer replybuffer
)))
3440 (setq others
(cons (cons "cc" cc
) others
))
3441 (setq others
(cons (cons "in-reply-to" in-reply-to
) others
))
3443 (compose-mail to subject others
3445 yank-action sendactions
)
3446 (if rmail-mail-new-frame
3448 (compose-mail to subject others
3449 noerase
'switch-to-buffer-other-frame
3450 yank-action sendactions
)
3451 ;; This is not a standard frame parameter;
3452 ;; nothing except sendmail.el looks at it.
3453 (modify-frame-parameters (selected-frame)
3454 '((mail-dedicated-frame . t
))))
3455 (compose-mail to subject others
3456 noerase
'switch-to-buffer-other-window
3457 yank-action sendactions
)))))
3459 (defun rmail-mail ()
3460 "Send mail in another window.
3461 While composing the message, use \\[mail-yank-original] to yank the
3462 original message into it."
3464 (rmail-start-mail nil nil nil nil nil rmail-view-buffer
))
3466 ;; FIXME should complain if there is nothing to continue.
3467 (defun rmail-continue ()
3468 "Continue composing outgoing message previously being composed."
3470 (rmail-start-mail t
))
3472 (defun rmail-reply (just-sender)
3473 "Reply to the current message.
3474 Normally include CC: to all other recipients of original message;
3475 prefix argument means ignore them. While composing the reply,
3476 use \\[mail-yank-original] to yank the original message into it."
3478 (if (zerop rmail-current-message
)
3479 (error "There is no message to reply to"))
3480 (let (from reply-to cc subject date to message-id references
3481 resent-to resent-cc resent-reply-to
3482 (msgnum rmail-current-message
))
3483 (rmail-apply-in-message
3484 rmail-current-message
3486 (search-forward "\n\n" nil
'move
)
3487 (narrow-to-region (point-min) (point))
3488 (setq from
(mail-fetch-field "from")
3489 reply-to
(or (mail-fetch-field "mail-reply-to" nil t
)
3490 (mail-fetch-field "reply-to" nil t
)
3492 subject
(mail-fetch-field "subject")
3493 date
(mail-fetch-field "date")
3494 message-id
(mail-fetch-field "message-id")
3495 references
(mail-fetch-field "references" nil nil t
)
3496 resent-reply-to
(mail-fetch-field "resent-reply-to" nil t
)
3497 ;; Bug#512. It's inappropriate to reply to these addresses.
3498 ;;; resent-cc (and (not just-sender)
3499 ;;; (mail-fetch-field "resent-cc" nil t))
3500 ;;; resent-to (or (mail-fetch-field "resent-to" nil t) "")
3501 ;;; resent-subject (mail-fetch-field "resent-subject")
3502 ;;; resent-date (mail-fetch-field "resent-date")
3503 ;;; resent-message-id (mail-fetch-field "resent-message-id")
3506 (if (mail-fetch-field "mail-followup-to" nil t
)
3507 ;; If this header field is present, use it instead of the
3508 ;; To and CC fields.
3509 (setq to
(mail-fetch-field "mail-followup-to" nil t
))
3510 (setq cc
(or (mail-fetch-field "cc" nil t
) "")
3511 to
(or (mail-fetch-field "to" nil t
) ""))))))
3512 ;; Merge the resent-to and resent-cc into the to and cc.
3513 ;; Bug#512. It's inappropriate to reply to these addresses.
3514 ;;; (if (and resent-to (not (equal resent-to "")))
3515 ;;; (if (not (equal to ""))
3516 ;;; (setq to (concat to ", " resent-to))
3517 ;;; (setq to resent-to)))
3518 ;;; (if (and resent-cc (not (equal resent-cc "")))
3519 ;;; (if (not (equal cc ""))
3520 ;;; (setq cc (concat cc ", " resent-cc))
3521 ;;; (setq cc resent-cc)))
3522 ;; Add `Re: ' to subject if not there already.
3523 (and (stringp subject
)
3525 (concat rmail-reply-prefix
3526 (if (let ((case-fold-search t
))
3527 (string-match rmail-reply-regexp subject
))
3528 (substring subject
(match-end 0))
3532 ;; Using mail-strip-quoted-names is undesirable with newer mailers
3533 ;; since they can handle the names unstripped.
3534 ;; I don't know whether there are other mailers that still
3535 ;; need the names to be stripped.
3536 ;;; (mail-strip-quoted-names reply-to)
3537 ;; Remove unwanted names from reply-to, since Mail-Followup-To
3538 ;; header causes all the names in it to wind up in reply-to, not
3539 ;; in cc. But if what's left is an empty list, use the original.
3540 (let* ((reply-to-list (rmail-dont-reply-to reply-to
)))
3541 (if (string= reply-to-list
"") reply-to reply-to-list
))
3543 (rmail-make-in-reply-to-field from date message-id
)
3546 ;; mail-strip-quoted-names is NOT necessary for rmail-dont-reply-to
3548 (let* ((cc-list (rmail-dont-reply-to
3549 (mail-strip-quoted-names
3550 (if (null cc
) to
(concat to
", " cc
))))))
3551 (if (string= cc-list
"") nil cc-list
)))
3552 (if (rmail-buffers-swapped-p)
3555 (list (list 'rmail-mark-message
3557 (with-current-buffer rmail-buffer
3558 (aref rmail-msgref-vector msgnum
))
3559 rmail-answered-attr-index
))
3561 (if (or references message-id
)
3562 (list (cons "References" (if references
3564 (mapconcat 'identity references
" ")
3568 (defun rmail-mark-message (buffer msgnum-list attribute
)
3569 "Give BUFFER's message number in MSGNUM-LIST the attribute ATTRIBUTE.
3570 This is use in the send-actions for message buffers.
3571 MSGNUM-LIST is a list of the form (MSGNUM)
3572 which is an element of rmail-msgref-vector."
3573 (with-current-buffer buffer
3574 (if (car msgnum-list
)
3575 (rmail-set-attribute attribute t
(car msgnum-list
)))))
3577 (defun rmail-make-in-reply-to-field (from date message-id
)
3584 (let ((tem (car (rfc822-addresses from
))))
3588 (regexp-quote (if (string-match "@[^@]*\\'" tem
)
3590 (match-beginning 0))
3593 ;; missing From, or Message-ID is sufficiently informative
3595 (concat message-id
" (" tem
")"))
3596 ;; Copy TEM, discarding text properties.
3597 (setq tem
(copy-sequence tem
))
3598 (set-text-properties 0 (length tem
) nil tem
)
3599 (setq tem
(copy-sequence tem
))
3600 ;; Use prin1 to fake RFC822 quoting
3601 (let ((field (prin1-to-string tem
)))
3603 (concat field
"'s message of " date
)
3605 ((let* ((foo "[^][\000-\037()<>@,;:\\\" ]+")
3606 (bar "[^][\000-\037()<>@,;:\\\"]+"))
3607 ;; These strings both match all non-ASCII characters.
3608 (or (string-match (concat "\\`[ \t]*\\(" bar
3609 "\\)\\(<" foo
"@" foo
">\\)?[ \t]*\\'")
3610 ;; "Unix Loser <Foo@bar.edu>" => "Unix Loser"
3612 (string-match (concat "\\`[ \t]*<" foo
"@" foo
">[ \t]*(\\("
3613 bar
"\\))[ \t]*\\'")
3614 ;; "<Bugs@bar.edu>" (Losing Unix) => "Losing Unix"
3616 (let ((start (match-beginning 1))
3617 (end (match-end 1)))
3618 ;; Trim whitespace which above regexp match allows
3619 (while (and (< start end
)
3620 (memq (aref from start
) '(?
\t ?\s
)))
3621 (setq start
(1+ start
)))
3622 (while (and (< start end
)
3623 (memq (aref from
(1- end
)) '(?
\t ?\s
)))
3624 (setq end
(1- end
)))
3625 (let ((field (substring from start end
)))
3626 (if date
(setq field
(concat "message from " field
" on " date
)))
3628 ;; "<AA259@bar.edu> (message from Unix Loser on 1-Apr-89)"
3629 (concat message-id
" (" field
")")
3632 ;; If we can't kludge it simply, do it correctly
3633 (let ((mail-use-rfc822 t
))
3634 (rmail-make-in-reply-to-field from date message-id
)))))
3636 (defun rmail-forward (resend)
3637 "Forward the current message to another user.
3638 With prefix argument, \"resend\" the message instead of forwarding it;
3639 see the documentation of `rmail-resend'."
3642 (call-interactively 'rmail-resend
)
3643 (let ((forward-buffer rmail-buffer
)
3644 (msgnum rmail-current-message
)
3645 (subject (concat "["
3646 (let ((from (or (mail-fetch-field "From")
3647 (mail-fetch-field ">From"))))
3649 (concat (mail-strip-quoted-names from
) ": ")
3651 (or (mail-fetch-field "Subject") "")
3653 (if (rmail-start-mail
3654 nil nil subject nil nil nil
3655 (list (list 'rmail-mark-message
3657 (with-current-buffer rmail-buffer
3658 (aref rmail-msgref-vector msgnum
))
3659 rmail-forwarded-attr-index
))
3660 ;; If only one window, use it for the mail buffer.
3661 ;; Otherwise, use another window for the mail buffer
3662 ;; so that the Rmail buffer remains visible
3663 ;; and sending the mail will get back to it.
3664 (and (not rmail-mail-new-frame
) (one-window-p t
)))
3665 ;; The mail buffer is now current.
3667 ;; Insert after header separator--before signature if any.
3668 (goto-char (mail-text-start))
3669 (if (or rmail-enable-mime rmail-enable-mime-composing
)
3670 (funcall rmail-insert-mime-forwarded-message-function
3672 (insert "------- Start of forwarded message -------\n")
3673 ;; Quote lines with `- ' if they start with `-'.
3674 (let ((beg (point)) end
)
3675 (setq end
(point-marker))
3676 (set-marker-insertion-type end t
)
3677 (insert-buffer-substring forward-buffer
)
3679 (while (re-search-forward "^-" end t
)
3684 (skip-chars-backward "\n")
3687 (delete-region (point) end
)
3688 (set-marker end nil
))
3689 (insert "------- End of forwarded message -------\n"))
3692 (defun rmail-resend (address &optional from comment mail-alias-file
)
3693 "Resend current message to ADDRESSES.
3694 ADDRESSES should be a single address, a string consisting of several
3695 addresses separated by commas, or a list of addresses.
3697 Optional FROM is the address to resend the message from, and
3698 defaults from the value of `user-mail-address'.
3699 Optional COMMENT is a string to insert as a comment in the resent message.
3700 Optional ALIAS-FILE is alternate aliases file to be used by sendmail,
3701 typically for purposes of moderating a list."
3702 (interactive "sResend to: ")
3704 (require 'mailalias
)
3705 (unless (or (eq rmail-view-buffer
(current-buffer))
3706 (eq rmail-buffer
(current-buffer)))
3707 (error "Not an Rmail buffer"))
3708 (if (not from
) (setq from user-mail-address
))
3709 (let ((tembuf (generate-new-buffer " sendmail temp"))
3710 (case-fold-search nil
)
3711 (mail-personal-alias-file
3712 (or mail-alias-file mail-personal-alias-file
))
3713 (mailbuf rmail-buffer
))
3715 (with-current-buffer tembuf
3716 ;;>> Copy message into temp buffer
3717 (if rmail-enable-mime
3718 (if rmail-insert-mime-resent-message-function
3719 (funcall rmail-insert-mime-resent-message-function mailbuf
)
3720 (error "You must set `rmail-insert-mime-resent-message-function'"))
3721 (insert-buffer-substring mailbuf
))
3722 (goto-char (point-min))
3723 ;; Delete any Sender field, since that's not specifiable.
3724 ; Only delete Sender fields in the actual header.
3725 (re-search-forward "^$" nil
'move
)
3726 ; Using "while" here rather than "if" because some buggy mail
3727 ; software may have inserted multiple Sender fields.
3728 (while (re-search-backward "^Sender:" nil t
)
3732 (while (looking-at "[ \t]")
3734 (delete-region beg
(point))))
3735 ; Go back to the beginning of the buffer so the Resent- fields
3736 ; are inserted there.
3737 (goto-char (point-min))
3738 ;;>> Insert resent-from:
3739 (insert "Resent-From: " from
"\n")
3740 (insert "Resent-Date: " (mail-rfc822-date) "\n")
3741 ;;>> Insert resent-to: and bcc if need be.
3742 (let ((before (point)))
3744 (insert "Resent-Bcc: " (user-login-name) "\n"))
3745 (insert "Resent-To: " (if (stringp address
)
3747 (mapconcat 'identity address
",\n\t"))
3749 ;; Expand abbrevs in the recipients.
3751 (if (featurep 'mailabbrev
)
3752 (let ((end (point-marker))
3753 (local-abbrev-table mail-abbrevs
)
3754 (old-syntax-table (syntax-table)))
3755 (if (and (not (vectorp mail-abbrevs
))
3756 (file-exists-p mail-personal-alias-file
))
3757 (build-mail-abbrevs))
3758 (unless mail-abbrev-syntax-table
3759 (mail-abbrev-make-syntax-table))
3760 (set-syntax-table mail-abbrev-syntax-table
)
3762 (while (and (< (point) end
)
3763 (progn (forward-word 1)
3766 (set-syntax-table old-syntax-table
))
3767 (expand-mail-aliases before
(point)))))
3768 ;;>> Set up comment, if any.
3769 (if (and (sequencep comment
) (not (zerop (length comment
))))
3770 (let ((before (point))
3773 (or (eolp) (insert "\n"))
3774 (setq after
(point))
3776 (while (< (point) after
)
3777 (insert "Resent-Comment: ")
3779 ;; Don't expand aliases in the destination fields
3780 ;; of the original message.
3782 (funcall send-mail-function
)))
3783 (kill-buffer tembuf
))
3784 (with-current-buffer rmail-buffer
3785 (rmail-set-attribute rmail-resent-attr-index t rmail-current-message
))))
3787 (defvar mail-unsent-separator
3788 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
3789 "^ *---+ +Returned message +---+ *$\\|"
3790 "^ *---+ *Returned mail follows *---+ *$\\|"
3791 "^Start of returned message$\\|"
3792 "^---+ Below this line is a copy of the message.$\\|"
3793 "^ *---+ +Original message +---+ *$\\|"
3794 "^ *--+ +begin message +--+ *$\\|"
3795 "^ *---+ +Original message follows +---+ *$\\|"
3796 "^ *---+ +Your message follows +---+ *$\\|"
3797 "^|? *---+ +Message text follows: +---+ *|?$\\|"
3798 "^ *---+ +This is a copy of \\w+ message, including all the headers.*---+ *$")
3799 "A regexp that matches the separator before the text of a failed message.")
3801 (defvar mail-mime-unsent-header
"^Content-Type: message/rfc822 *$"
3802 "A regexp that matches the header of a MIME body part with a failed message.")
3804 ;; This is a cut-down version of rmail-clear-headers from Emacs 22.
3805 ;; It doesn't have the same functionality, hence the name change.
3806 (defun rmail-delete-headers (regexp)
3807 "Delete any mail headers matching REGEXP.
3808 The message should be narrowed to just the headers."
3810 (goto-char (point-min))
3811 (while (re-search-forward regexp nil t
)
3813 ;; This code from Emacs 22 doesn't seem right, since r-n-h is
3814 ;; just for display.
3815 ;;; (if (looking-at rmail-nonignored-headers)
3816 ;;; (forward-line 1)
3817 (delete-region (point)
3819 (if (re-search-forward "\n[^ \t]" nil t
)
3823 (defun rmail-retry-failure ()
3824 "Edit a mail message which is based on the contents of the current message.
3825 For a message rejected by the mail system, extract the interesting headers and
3826 the body of the original message.
3827 If the failed message is a MIME multipart message, it is searched for a
3828 body part with a header which matches the variable `mail-mime-unsent-header'.
3829 Otherwise, the variable `mail-unsent-separator' should match the string that
3830 delimits the returned original message.
3831 The variable `rmail-retry-ignored-headers' is a regular expression
3832 specifying headers which should not be copied into the new message."
3834 (require 'mail-utils
)
3835 (let ((rmail-this-buffer (current-buffer))
3836 (msgnum rmail-current-message
)
3837 bounce-start bounce-end bounce-indent resending
3838 (content-type (rmail-get-header "Content-Type")))
3840 (goto-char (point-min))
3841 (let ((case-fold-search t
))
3842 (if (and content-type
3844 ";[\n\t ]*boundary=\"?\\([-0-9a-z'()+_,./:=? ]+\\)\"?"
3846 ;; Handle a MIME multipart bounce message.
3849 (substring content-type
(match-beginning 1)
3851 (unless (re-search-forward mail-mime-unsent-header nil t
)
3852 (error "Cannot find beginning of header in failed message"))
3853 (unless (search-forward "\n\n" nil t
)
3854 (error "Cannot find start of Mime data in failed message"))
3855 (setq bounce-start
(point))
3856 (if (search-forward codestring nil t
)
3857 (setq bounce-end
(match-beginning 0))
3858 (setq bounce-end
(point-max))))
3860 (or (re-search-forward mail-unsent-separator nil t
)
3861 (error "Cannot parse this as a failure message"))
3862 (skip-chars-forward "\n")
3863 ;; Support a style of failure message in which the original
3864 ;; message is indented, and included within lines saying
3865 ;; `Start of returned message' and `End of returned message'.
3866 (if (looking-at " +Received:")
3868 (setq bounce-start
(point))
3869 (skip-chars-forward " ")
3870 (setq bounce-indent
(- (current-column)))
3871 (goto-char (point-max))
3872 (re-search-backward "^End of returned message$" nil t
)
3873 (setq bounce-end
(point)))
3874 ;; One message contained a few random lines before
3875 ;; the old message header. The first line of the
3876 ;; message started with two hyphens. A blank line
3877 ;; followed these random lines. The same line
3878 ;; beginning with two hyphens was possibly marking
3879 ;; the end of the message.
3880 (if (looking-at "^--")
3881 (let ((boundary (buffer-substring-no-properties
3883 (progn (end-of-line) (point)))))
3884 (search-forward "\n\n")
3885 (skip-chars-forward "\n")
3886 (setq bounce-start
(point))
3887 (goto-char (point-max))
3888 (search-backward (concat "\n\n" boundary
) bounce-start t
)
3889 (setq bounce-end
(point)))
3890 (setq bounce-start
(point)
3891 bounce-end
(point-max)))
3892 (unless (search-forward "\n\n" nil t
)
3893 (error "Cannot find end of header in failed message"))))))
3894 ;; We have found the message that bounced, within the current message.
3895 ;; Now start sending new message; default header fields from original.
3896 ;; Turn off the usual actions for initializing the message body
3897 ;; because we want to get only the text from the failure message.
3898 (let (mail-signature mail-setup-hook
)
3899 (if (rmail-start-mail nil nil nil nil nil rmail-this-buffer
3900 (list (list 'rmail-mark-message
3902 (aref rmail-msgref-vector msgnum
)
3903 rmail-retried-attr-index
)))
3904 ;; Insert original text as initial text of new draft message.
3905 ;; Bind inhibit-read-only since the header delimiter
3906 ;; of the previous message was probably read-only.
3907 (let ((inhibit-read-only t
))
3909 (insert-buffer-substring rmail-this-buffer
3910 bounce-start bounce-end
)
3911 (goto-char (point-min))
3913 (indent-rigidly (point-min) (point-max) bounce-indent
))
3914 (mail-sendmail-delimit-header)
3916 (narrow-to-region (point-min) (mail-header-end))
3917 (rmail-delete-headers rmail-retry-ignored-headers
)
3918 (rmail-delete-headers "^\\(sender\\|return-path\\|received\\):")
3919 (setq resending
(mail-fetch-field "resent-to"))
3922 (insert "Resent-Bcc: " (user-login-name) "\n")
3923 (insert "BCC: " (user-login-name) "\n"))))
3924 (goto-char (point-min))
3925 (mail-position-on-field (if resending
"Resent-To" "To") t
))))))
3927 (defun rmail-summary-exists ()
3928 "Non-nil if in an RMAIL buffer and an associated summary buffer exists.
3929 In fact, the non-nil value returned is the summary buffer itself."
3930 (and rmail-summary-buffer
(buffer-name rmail-summary-buffer
)
3931 rmail-summary-buffer
))
3933 (defun rmail-summary-displayed ()
3934 "t if in RMAIL buffer and an associated summary buffer is displayed."
3935 (and rmail-summary-buffer
(get-buffer-window rmail-summary-buffer
)))
3937 (defcustom rmail-redisplay-summary nil
3938 "Non-nil means Rmail should show the summary when it changes.
3939 This has an effect only if a summary buffer exists."
3941 :group
'rmail-summary
)
3943 (defcustom rmail-summary-window-size nil
3944 "Non-nil means specify the height for an Rmail summary window."
3945 :type
'(choice (const :tag
"Disabled" nil
) integer
)
3946 :group
'rmail-summary
)
3948 ;; Put the summary buffer back on the screen, if user wants that.
3949 (defun rmail-maybe-display-summary ()
3950 (let ((selected (selected-window))
3952 ;; If requested, make sure the summary is displayed.
3953 (and rmail-summary-buffer
(buffer-name rmail-summary-buffer
)
3954 rmail-redisplay-summary
3955 (if (get-buffer-window rmail-summary-buffer
0)
3956 ;; It's already in some frame; show that one.
3957 (let ((frame (window-frame
3958 (get-buffer-window rmail-summary-buffer
0))))
3959 (make-frame-visible frame
)
3960 (raise-frame frame
))
3961 (display-buffer rmail-summary-buffer
)))
3962 ;; If requested, set the height of the summary window.
3963 (and rmail-summary-buffer
(buffer-name rmail-summary-buffer
)
3964 rmail-summary-window-size
3965 (setq window
(get-buffer-window rmail-summary-buffer
))
3966 ;; Don't try to change the size if just one window in frame.
3967 (not (eq window
(frame-root-window (window-frame window
))))
3970 (select-window window
)
3971 (enlarge-window (- rmail-summary-window-size
(window-height))))
3972 (select-window selected
)))))
3974 ;;;; *** Rmail Local Fontification ***
3976 (defun rmail-fontify-buffer-function ()
3977 ;; This function's symbol is bound to font-lock-fontify-buffer-function.
3978 (add-hook 'rmail-show-message-hook
'rmail-fontify-message nil t
)
3979 ;; If we're already showing a message, fontify it now.
3980 (if rmail-current-message
(rmail-fontify-message))
3981 ;; Prevent Font Lock mode from kicking in.
3982 (setq font-lock-fontified t
))
3984 (defun rmail-unfontify-buffer-function ()
3985 ;; This function's symbol is bound to font-lock-fontify-unbuffer-function.
3986 (let ((modified (buffer-modified-p))
3987 (buffer-undo-list t
) (inhibit-read-only t
)
3988 before-change-functions after-change-functions
3989 buffer-file-name buffer-file-truename
)
3992 (remove-hook 'rmail-show-message-hook
'rmail-fontify-message t
)
3993 (remove-text-properties (point-min) (point-max) '(rmail-fontified nil
))
3994 (font-lock-default-unfontify-buffer)
3995 (and (not modified
) (buffer-modified-p)
3996 (restore-buffer-modified-p nil
)))))
3998 (defun rmail-fontify-message ()
3999 ;; Fontify the current message if it is not already fontified.
4000 (if (text-property-any (point-min) (point-max) 'rmail-fontified nil
)
4001 (let ((modified (buffer-modified-p))
4002 (buffer-undo-list t
) (inhibit-read-only t
)
4003 before-change-functions after-change-functions
4004 buffer-file-name buffer-file-truename
)
4007 (add-text-properties (point-min) (point-max) '(rmail-fontified t
))
4008 (font-lock-fontify-region (point-min) (point-max))
4009 (and (not modified
) (buffer-modified-p)
4010 (restore-buffer-modified-p nil
)))))))
4012 ;;; Speedbar support for RMAIL files.
4013 (eval-when-compile (require 'speedbar
))
4015 (defvar rmail-speedbar-match-folder-regexp
"^[A-Z0-9]+\\(\\.[A-Z0-9]+\\)?$"
4016 "*This regex is used to match folder names to be displayed in speedbar.
4017 Enabling this will permit speedbar to display your folders for easy
4018 browsing, and moving of messages.")
4020 (defvar rmail-speedbar-last-user nil
4021 "The last user to be displayed in the speedbar.")
4023 (defvar rmail-speedbar-key-map nil
4024 "Keymap used when in rmail display mode.")
4026 (defun rmail-install-speedbar-variables ()
4027 "Install those variables used by speedbar to enhance rmail."
4028 (if rmail-speedbar-key-map
4030 (setq rmail-speedbar-key-map
(speedbar-make-specialized-keymap))
4032 (define-key rmail-speedbar-key-map
"e" 'speedbar-edit-line
)
4033 (define-key rmail-speedbar-key-map
"r" 'speedbar-edit-line
)
4034 (define-key rmail-speedbar-key-map
"\C-m" 'speedbar-edit-line
)
4035 (define-key rmail-speedbar-key-map
"M"
4036 'rmail-speedbar-move-message-to-folder-on-line
)))
4039 (defvar rmail-speedbar-menu-items
4040 '(["Read Folder" speedbar-edit-line t
]
4041 ["Move message to folder" rmail-speedbar-move-message-to-folder-on-line
4042 (save-excursion (beginning-of-line)
4043 (looking-at "<M> "))])
4044 "Additional menu-items to add to speedbar frame.")
4046 ;; Make sure our special speedbar major mode is loaded
4047 (if (featurep 'speedbar
)
4048 (rmail-install-speedbar-variables)
4049 (add-hook 'speedbar-load-hook
'rmail-install-speedbar-variables
))
4051 (defun rmail-speedbar-buttons (buffer)
4052 "Create buttons for BUFFER containing rmail messages.
4053 Click on the address under Reply to: to reply to this person.
4054 Under Folders: Click a name to read it, or on the <M> to move the
4055 current message into that RMAIL folder."
4057 (with-current-buffer buffer
4058 (goto-char (point-min))
4059 (if (not (re-search-forward "^Reply-To: " nil t
))
4060 (if (not (re-search-forward "^From:? " nil t
))
4064 (setq from
(buffer-substring (point) (line-end-position)))))
4065 (goto-char (point-min))
4066 (if (and (looking-at "Reply to:")
4067 (equal from rmail-speedbar-last-user
))
4069 (setq rmail-speedbar-last-user from
)
4071 (insert "Reply To:\n")
4073 (speedbar-insert-button from
'speedbar-directory-face
'highlight
4074 'rmail-speedbar-button
'rmail-reply
))
4075 (insert "Folders:\n")
4076 (let* ((case-fold-search nil
)
4077 (df (directory-files (with-current-buffer buffer
4079 nil rmail-speedbar-match-folder-regexp
)))
4081 (when (file-regular-p file
)
4082 (speedbar-insert-button "<M>" 'speedbar-button-face
'highlight
4083 'rmail-speedbar-move-message file
)
4084 (speedbar-insert-button file
'speedbar-file-face
'highlight
4085 'rmail-speedbar-find-file nil t
)))))))
4087 (defun rmail-speedbar-button (text token indent
)
4088 "Execute an rmail command specified by TEXT.
4089 The command used is TOKEN. INDENT is not used."
4090 (speedbar-with-attached-buffer
4093 (defun rmail-speedbar-find-file (text token indent
)
4094 "Load in the rmail file TEXT.
4095 TOKEN and INDENT are not used."
4096 (speedbar-with-attached-buffer
4097 (message "Loading in RMAIL file %s..." text
)
4100 (defun rmail-speedbar-move-message-to-folder-on-line ()
4101 "If the current line is a folder, move current message to it."
4105 (if (re-search-forward "<M> " (line-end-position) t
)
4108 (speedbar-do-function-pointer)))))
4110 (defun rmail-speedbar-move-message (text token indent
)
4111 "From button TEXT, copy current message to the rmail file specified by TOKEN.
4112 TEXT and INDENT are not used."
4113 (speedbar-with-attached-buffer
4114 (message "Moving message to %s" token
)
4115 ;; expand-file-name is needed due to the unhelpful way in which
4116 ;; rmail-output expands non-absolute filenames against rmail-default-file.
4117 ;; What is the point of that, anyway?
4118 (rmail-output (expand-file-name token
))))
4120 ;; Functions for setting, getting and encoding the POP password.
4121 ;; The password is encoded to prevent it from being easily accessible
4122 ;; to "prying eyes." Obviously, this encoding isn't "real security,"
4123 ;; nor is it meant to be.
4126 (defun rmail-set-remote-password (password)
4127 "Set PASSWORD to be used for retrieving mail from a POP or IMAP server."
4128 (interactive "sPassword: ")
4130 (setq rmail-encoded-remote-password
4131 (rmail-encode-string password
(emacs-pid)))
4132 (setq rmail-remote-password nil
)
4133 (setq rmail-encoded-remote-password nil
)))
4135 (defun rmail-get-remote-password (imap)
4136 "Get the password for retrieving mail from a POP or IMAP server. If none
4137 has been set, then prompt the user for one."
4138 (when (not rmail-encoded-remote-password
)
4139 (if (not rmail-remote-password
)
4140 (setq rmail-remote-password
4141 (read-passwd (if imap
4143 "POP password: "))))
4144 (rmail-set-remote-password rmail-remote-password
)
4145 (setq rmail-remote-password nil
))
4146 (rmail-encode-string rmail-encoded-remote-password
(emacs-pid)))
4148 (defun rmail-have-password ()
4149 (or rmail-remote-password rmail-encoded-remote-password
))
4151 (defun rmail-encode-string (string mask
)
4152 "Encode STRING with integer MASK, by taking the exclusive OR of the
4153 lowest byte in the mask with the first character of string, the
4154 second-lowest-byte with the second character of the string, etc.,
4155 restarting at the lowest byte of the mask whenever it runs out.
4156 Returns the encoded string. Calling the function again with an
4157 encoded string (and the same mask) will decode the string."
4158 (setq mask
(abs mask
)) ; doesn't work if negative
4159 (let* ((string-vector (string-to-vector string
)) (i 0)
4160 (len (length string-vector
)) (curmask mask
) charmask
)
4163 (setq curmask mask
))
4164 (setq charmask
(% curmask
256))
4165 (setq curmask
(lsh curmask -
8))
4166 (aset string-vector i
(logxor charmask
(aref string-vector i
)))
4168 (concat string-vector
)))
4170 ;;;; Desktop support
4172 (defun rmail-restore-desktop-buffer (desktop-buffer-file-name
4174 desktop-buffer-misc
)
4175 "Restore an rmail buffer specified in a desktop file."
4176 (condition-case error
4178 (rmail-input desktop-buffer-file-name
)
4179 (if (eq major-mode
'rmail-mode
)
4183 (kill-buffer (current-buffer))
4186 (add-to-list 'desktop-buffer-mode-handlers
4187 '(rmail-mode . rmail-restore-desktop-buffer
))
4189 ;; We use this to record the encoding of the current message before
4190 ;; saving the message collection.
4191 (defvar rmail-message-encoding nil
)
4193 ;; Used in `write-region-annotate-functions' to write rmail files.
4194 (defun rmail-write-region-annotate (start end
)
4195 (when (and (null start
) (rmail-buffers-swapped-p))
4196 (setq rmail-message-encoding buffer-file-coding-system
)
4197 (set-buffer rmail-view-buffer
)
4201 ;; Used to restore the encoding of the buffer where we show the
4202 ;; current message, after we save the message collection. This is
4203 ;; needed because rmail-write-region-annotate switches buffers behind
4204 ;; save-file's back, with the side effect that last-coding-system-used
4205 ;; is assigned to buffer-file-coding-system of the wrong buffer.
4206 (defun rmail-after-save-hook ()
4207 (if (or (eq rmail-view-buffer
(current-buffer))
4208 (eq rmail-buffer
(current-buffer)))
4209 (with-current-buffer
4210 (if (rmail-buffers-swapped-p) rmail-buffer rmail-view-buffer
)
4211 (setq buffer-file-coding-system rmail-message-encoding
))))
4212 (add-hook 'after-save-hook
'rmail-after-save-hook
)
4215 ;;; Start of automatically extracted autoloads.
4217 ;;;### (autoloads (rmail-edit-current-message) "rmailedit" "rmailedit.el"
4218 ;;;;;; "60db8013bf16d7999914a16cda435287")
4219 ;;; Generated autoloads from rmailedit.el
4221 (autoload 'rmail-edit-current-message
"rmailedit" "\
4222 Edit the contents of this message.
4228 ;;;### (autoloads (rmail-next-labeled-message rmail-previous-labeled-message
4229 ;;;;;; rmail-read-label rmail-kill-label rmail-add-label) "rmailkwd"
4230 ;;;;;; "rmailkwd.el" "7027ce1ac922c0dd51262b641e4d42c1")
4231 ;;; Generated autoloads from rmailkwd.el
4233 (autoload 'rmail-add-label
"rmailkwd" "\
4234 Add LABEL to labels associated with current RMAIL message.
4235 Completes (see `rmail-read-label') over known labels when reading.
4236 LABEL may be a symbol or string. Only one label is allowed.
4240 (autoload 'rmail-kill-label
"rmailkwd" "\
4241 Remove LABEL from labels associated with current RMAIL message.
4242 Completes (see `rmail-read-label') over known labels when reading.
4243 LABEL may be a symbol or string. Only one label is allowed.
4247 (autoload 'rmail-read-label
"rmailkwd" "\
4248 Read a label with completion, prompting with PROMPT.
4249 Completions are chosen from `rmail-label-obarray'. The default
4250 is `rmail-last-label', if that is non-nil. Updates `rmail-last-label'
4251 according to the choice made, and returns a symbol.
4253 \(fn PROMPT)" nil nil
)
4255 (autoload 'rmail-previous-labeled-message
"rmailkwd" "\
4256 Show previous message with one of the labels LABELS.
4257 LABELS should be a comma-separated list of label names.
4258 If LABELS is empty, the last set of labels specified is used.
4259 With prefix argument N moves backward N messages with these labels.
4261 \(fn N LABELS)" t nil
)
4263 (autoload 'rmail-next-labeled-message
"rmailkwd" "\
4264 Show next message with one of the labels LABELS.
4265 LABELS should be a comma-separated list of label names.
4266 If LABELS is empty, the last set of labels specified is used.
4267 With prefix argument N moves forward N messages with these labels.
4269 \(fn N LABELS)" t nil
)
4273 ;;;### (autoloads (rmail-mime) "rmailmm" "rmailmm.el" "93033f2136fcd111e2b52a116ff4cf29")
4274 ;;; Generated autoloads from rmailmm.el
4276 (autoload 'rmail-mime
"rmailmm" "\
4277 Process the current Rmail message as a MIME message.
4278 This creates a temporary \"*RMAIL*\" buffer holding a decoded
4279 copy of the message. Inline content-types are handled according to
4280 `rmail-mime-media-type-handlers-alist'. By default, this
4281 displays text and multipart messages, and offers to download
4282 attachments as specfied by `rmail-mime-attachment-dirs-alist'.
4288 ;;;### (autoloads (set-rmail-inbox-list) "rmailmsc" "rmailmsc.el"
4289 ;;;;;; "b2a72d4e370f2d2b31b6f8f0794820e4")
4290 ;;; Generated autoloads from rmailmsc.el
4292 (autoload 'set-rmail-inbox-list
"rmailmsc" "\
4293 Set the inbox list of the current RMAIL file to FILE-NAME.
4294 You can specify one file name, or several names separated by commas.
4295 If FILE-NAME is empty, remove any existing inbox list.
4297 This applies only to the current session.
4299 \(fn FILE-NAME)" t nil
)
4303 ;;;### (autoloads (rmail-sort-by-labels rmail-sort-by-lines rmail-sort-by-correspondent
4304 ;;;;;; rmail-sort-by-recipient rmail-sort-by-author rmail-sort-by-subject
4305 ;;;;;; rmail-sort-by-date) "rmailsort" "rmailsort.el" "5a3b5ee477d2fbf79d0c566d776a7fd4")
4306 ;;; Generated autoloads from rmailsort.el
4308 (autoload 'rmail-sort-by-date
"rmailsort" "\
4309 Sort messages of current Rmail buffer by \"Date\" header.
4310 If prefix argument REVERSE is non-nil, sorts in reverse order.
4312 \(fn REVERSE)" t nil
)
4314 (autoload 'rmail-sort-by-subject
"rmailsort" "\
4315 Sort messages of current Rmail buffer by \"Subject\" header.
4316 Ignores any \"Re: \" prefix. If prefix argument REVERSE is
4317 non-nil, sorts in reverse order.
4319 \(fn REVERSE)" t nil
)
4321 (autoload 'rmail-sort-by-author
"rmailsort" "\
4322 Sort messages of current Rmail buffer by author.
4323 This uses either the \"From\" or \"Sender\" header, downcased.
4324 If prefix argument REVERSE is non-nil, sorts in reverse order.
4326 \(fn REVERSE)" t nil
)
4328 (autoload 'rmail-sort-by-recipient
"rmailsort" "\
4329 Sort messages of current Rmail buffer by recipient.
4330 This uses either the \"To\" or \"Apparently-To\" header, downcased.
4331 If prefix argument REVERSE is non-nil, sorts in reverse order.
4333 \(fn REVERSE)" t nil
)
4335 (autoload 'rmail-sort-by-correspondent
"rmailsort" "\
4336 Sort messages of current Rmail buffer by other correspondent.
4337 This uses either the \"From\", \"Sender\", \"To\", or
4338 \"Apparently-To\" header, downcased. Uses the first header not
4339 excluded by `rmail-dont-reply-to-names'. If prefix argument
4340 REVERSE is non-nil, sorts in reverse order.
4342 \(fn REVERSE)" t nil
)
4344 (autoload 'rmail-sort-by-lines
"rmailsort" "\
4345 Sort messages of current Rmail buffer by the number of lines.
4346 If prefix argument REVERSE is non-nil, sorts in reverse order.
4348 \(fn REVERSE)" t nil
)
4350 (autoload 'rmail-sort-by-labels
"rmailsort" "\
4351 Sort messages of current Rmail buffer by labels.
4352 LABELS is a comma-separated list of labels. The order of these
4353 labels specifies the order of messages: messages with the first
4354 label come first, messages with the second label come second, and
4355 so on. Messages that have none of these labels come last.
4356 If prefix argument REVERSE is non-nil, sorts in reverse order.
4358 \(fn REVERSE LABELS)" t nil
)
4362 ;;;### (autoloads (rmail-summary-by-senders rmail-summary-by-topic
4363 ;;;;;; rmail-summary-by-regexp rmail-summary-by-recipients rmail-summary-by-labels
4364 ;;;;;; rmail-summary) "rmailsum" "rmailsum.el" "26b95919c7e1f8c5609ce7323aee77ae")
4365 ;;; Generated autoloads from rmailsum.el
4367 (autoload 'rmail-summary
"rmailsum" "\
4368 Display a summary of all messages, one line per message.
4372 (autoload 'rmail-summary-by-labels
"rmailsum" "\
4373 Display a summary of all messages with one or more LABELS.
4374 LABELS should be a string containing the desired labels, separated by commas.
4376 \(fn LABELS)" t nil
)
4378 (autoload 'rmail-summary-by-recipients
"rmailsum" "\
4379 Display a summary of all messages with the given RECIPIENTS.
4380 Normally checks the To, From and Cc fields of headers;
4381 but if PRIMARY-ONLY is non-nil (prefix arg given),
4382 only look in the To and From fields.
4383 RECIPIENTS is a string of regexps separated by commas.
4385 \(fn RECIPIENTS &optional PRIMARY-ONLY)" t nil
)
4387 (autoload 'rmail-summary-by-regexp
"rmailsum" "\
4388 Display a summary of all messages according to regexp REGEXP.
4389 If the regular expression is found in the header of the message
4390 \(including in the date and other lines, as well as the subject line),
4391 Emacs will list the message in the summary.
4393 \(fn REGEXP)" t nil
)
4395 (autoload 'rmail-summary-by-topic
"rmailsum" "\
4396 Display a summary of all messages with the given SUBJECT.
4397 Normally checks just the Subject field of headers; but with prefix
4398 argument WHOLE-MESSAGE is non-nil, looks in the whole message.
4399 SUBJECT is a string of regexps separated by commas.
4401 \(fn SUBJECT &optional WHOLE-MESSAGE)" t nil
)
4403 (autoload 'rmail-summary-by-senders
"rmailsum" "\
4404 Display a summary of all messages whose \"From\" field matches SENDERS.
4405 SENDERS is a string of regexps separated by commas.
4407 \(fn SENDERS)" t nil
)
4411 ;;;### (autoloads (unforward-rmail-message undigestify-rmail-message)
4412 ;;;;;; "undigest" "undigest.el" "8cf8a8ffa48eeddf0bde388fa8de1783")
4413 ;;; Generated autoloads from undigest.el
4415 (autoload 'undigestify-rmail-message
"undigest" "\
4416 Break up a digest message into its constituent messages.
4417 Leaves original message, deleted, before the undigestified messages.
4421 (autoload 'unforward-rmail-message
"undigest" "\
4422 Extract a forwarded message from the containing message.
4423 This puts the forwarded message into a separate rmail message
4424 following the containing message.
4430 ;;; End of automatically extracted autoloads.
4435 ;; arch-tag: 65d257d3-c281-4a65-9c38-e61af95af2f0
4436 ;;; rmail.el ends here