1 ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs
3 ;; Copyright (C) 1985-1988, 1993-1998, 2000-2011
4 ;; Free Software Foundation, Inc.
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;; Souped up by shane@mit-ajax based on ideas of rlk@athena.mit.edu
29 ;; New features include attribute and keyword support, message
30 ;; selection by dispatch table, summary by attributes and keywords,
31 ;; expunging by dispatch table, sticky options for file commands.
33 ;; Extended by Bob Weiner of Motorola
34 ;; New features include: rmail and rmail-summary buffers remain
35 ;; synchronized and key bindings basically operate the same way in both
36 ;; buffers, summary by topic or by regular expression, rmail-reply-prefix
37 ;; 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-dont-reply-to
"mail-utils" (destinations))
195 (declare-function rmail-update-summary
"rmailsum" (&rest ignore
))
197 (defun rmail-probe (prog)
198 "Determine what flavor of movemail PROG is.
199 We do this by executing it with `--version' and analyzing its output."
201 (let ((tbuf (current-buffer)))
202 (buffer-disable-undo tbuf
)
203 (call-process prog nil tbuf nil
"--version")
204 (if (not (buffer-modified-p tbuf
))
205 ;; Should not happen...
207 (goto-char (point-min))
209 ((looking-at ".*movemail: invalid option")
210 'emacs
) ;; Possibly...
211 ((looking-at "movemail (GNU Mailutils .*)")
217 (defun rmail-autodetect ()
218 "Determine the file name of the `movemail' program and return its flavor.
219 If `rmail-movemail-program' is non-nil, use it.
220 Otherwise, look for `movemail' in the directories in
221 `rmail-movemail-search-path', those in `exec-path', and `exec-directory'."
222 (if rmail-movemail-program
223 (rmail-probe rmail-movemail-program
)
225 (dolist (dir (append rmail-movemail-search-path exec-path
226 (list exec-directory
)))
227 (when (and dir
(file-accessible-directory-p dir
))
228 ;; Previously, this didn't have to work on Windows, because
229 ;; rmail-insert-inbox-text before r1.439 fell back to using
230 ;; (expand-file-name "movemail" exec-directory) and just
231 ;; assuming it would work.
232 ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2008-02/msg00087.html
233 (let ((progname (expand-file-name
235 (if (memq system-type
'(ms-dos windows-nt
))
237 (when (and (not (file-directory-p progname
))
238 (file-executable-p progname
))
239 (let ((x (rmail-probe progname
)))
241 (setq rmail-movemail-program progname
)
242 (throw 'scan x
))))))))))
244 (defvar rmail-movemail-variant-in-use nil
245 "The movemail variant currently in use. Known variants are:
247 `emacs' Means any implementation, compatible with the native Emacs one.
249 `mailutils' Means GNU mailutils implementation, capable of handling full
250 mail URLs as the source mailbox.")
253 (defun rmail-movemail-variant-p (&rest variants
)
254 "Return t if the current movemail variant is any of VARIANTS.
255 Currently known variants are 'emacs and 'mailutils."
256 (when (not rmail-movemail-variant-in-use
)
258 (setq rmail-movemail-variant-in-use
(rmail-autodetect)))
259 (not (null (member rmail-movemail-variant-in-use variants
))))
261 ;; Call for effect, to set rmail-movemail-program (if not set by the
262 ;; user), and rmail-movemail-variant-in-use. Used by various functions.
263 ;; I'm not sure if M-x rmail is the only entry point to this package.
264 ;; If so, this can be moved there.
265 (rmail-movemail-variant-p)
268 (defcustom rmail-user-mail-address-regexp nil
269 "Regexp matching user mail addresses.
270 If non-nil, this variable is used to identify the correspondent
271 when receiving new mail. If it matches the address of the sender,
272 the recipient is taken as correspondent of a mail.
273 If nil \(default value\), your `user-login-name' and `user-mail-address'
274 are used to exclude yourself as correspondent.
276 Usually you don't have to set this variable, except if you collect mails
277 sent by you under different user names.
278 Then it should be a regexp matching your mail addresses.
280 Setting this variable has an effect only before reading a mail."
281 :type
'(choice (const :tag
"None" nil
) regexp
)
282 :group
'rmail-retrieve
286 (defvaralias 'rmail-dont-reply-to-names
'mail-dont-reply-to-names
)
289 (defvar rmail-default-dont-reply-to-names nil
290 "Regexp specifying part of the default value of `mail-dont-reply-to-names'.
291 This is used when the user does not set `mail-dont-reply-to-names'
294 (make-obsolete-variable 'rmail-default-dont-reply-to-names
295 'mail-dont-reply-to-names
"24.1")
298 (defcustom rmail-ignored-headers
300 (concat "^via:\\|^mail-from:\\|^origin:\\|^references:\\|^sender:"
301 "\\|^status:\\|^received:\\|^x400-originator:\\|^x400-recipients:"
302 "\\|^x400-received:\\|^x400-mts-identifier:\\|^x400-content-type:"
303 "\\|^\\(resent-\\|\\)message-id:\\|^summary-line:\\|^resent-date:"
304 "\\|^nntp-posting-host:\\|^path:\\|^x-char.*:\\|^x-face:\\|^face:"
305 "\\|^x-mailer:\\|^delivered-to:\\|^lines:"
306 "\\|^content-transfer-encoding:\\|^x-coding-system:"
307 "\\|^return-path:\\|^errors-to:\\|^return-receipt-to:"
308 "\\|^precedence:\\|^mime-version:"
309 "\\|^list-owner:\\|^list-help:\\|^list-post:\\|^list-subscribe:"
310 "\\|^list-id:\\|^list-unsubscribe:\\|^list-archive:"
311 "\\|^content-length:\\|^nntp-posting-date:\\|^user-agent"
312 "\\|^importance:\\|^envelope-to:\\|^delivery-date\\|^openpgp:"
313 "\\|^mbox-line:\\|^cancel-lock:"
314 "\\|^DomainKey-Signature:\\|^dkim-signature:"
315 "\\|^resent-face:\\|^resent-x.*:\\|^resent-organization:\\|^resent-openpgp:"
317 "Regexp to match header fields that Rmail should normally hide.
318 \(See also `rmail-nonignored-headers', which overrides this regexp.)
319 This variable is used for reformatting the message header,
320 which normally happens once for each message,
321 when you view the message for the first time in Rmail.
322 To make a change in this variable take effect
323 for a message that you have already viewed,
324 go to that message and type \\[rmail-toggle-header] twice."
326 :group
'rmail-headers
)
328 (defcustom rmail-nonignored-headers
"^x-spam-status:"
329 "Regexp to match X header fields that Rmail should show.
330 This regexp overrides `rmail-ignored-headers'; if both this regexp
331 and that one match a certain header field, Rmail shows the field.
332 If this is nil, ignore all header fields in `rmail-ignored-headers'.
334 This variable is used for reformatting the message header,
335 which normally happens once for each message,
336 when you view the message for the first time in Rmail.
337 To make a change in this variable take effect
338 for a message that you have already viewed,
339 go to that message and type \\[rmail-toggle-header] twice."
340 :type
'(choice (const nil
) (regexp))
341 :group
'rmail-headers
)
344 (defcustom rmail-displayed-headers nil
345 "Regexp to match Header fields that Rmail should display.
346 If nil, display all header fields except those matched by
347 `rmail-ignored-headers'."
348 :type
'(choice regexp
(const :tag
"All"))
349 :group
'rmail-headers
)
352 (defcustom rmail-retry-ignored-headers
(purecopy "^x-authentication-warning:\\|^x-detected-operating-system:\\|^x-spam[-a-z]*:\\|content-type:\\|content-transfer-encoding:\\|mime-version:")
353 "Headers that should be stripped when retrying a failed message."
354 :type
'(choice regexp
(const nil
:tag
"None"))
355 :group
'rmail-headers
356 :version
"23.2") ; added x-detected-operating-system, x-spam
359 (defcustom rmail-highlighted-headers
(purecopy "^From:\\|^Subject:")
360 "Regexp to match Header fields that Rmail should normally highlight.
361 A value of nil means don't highlight. Uses the face `rmail-highlight'."
363 :group
'rmail-headers
)
365 (defface rmail-highlight
366 '((t (:inherit highlight
)))
367 "Face to use for highlighting the most important header fields.
368 The variable `rmail-highlighted-headers' specifies which headers."
369 :group
'rmail-headers
372 ;; This was removed in Emacs 23.1 with no notification, an unnecessary
373 ;; incompatible change.
374 (defcustom rmail-highlight-face
'rmail-highlight
375 "Face used by Rmail for highlighting headers."
376 ;; Note that nil doesn't actually mean use the default face, it
377 ;; means use either bold or highlight. It's not worth fixing this
378 ;; now that this is obsolete.
379 :type
'(choice (const :tag
"Default" nil
)
381 :group
'rmail-headers
)
382 (make-obsolete-variable 'rmail-highlight-face
383 "customize the face `rmail-highlight' instead."
386 (defface rmail-header-name
387 '((t (:inherit font-lock-function-name-face
)))
388 "Face to use for highlighting the header names.
389 The variable `rmail-font-lock-keywords' specifies which headers
391 :group
'rmail-headers
394 (defcustom rmail-delete-after-output nil
395 "Non-nil means automatically delete a message that is copied to a file."
400 (defcustom rmail-primary-inbox-list nil
401 "List of files that are inboxes for your primary mail file `rmail-file-name'.
402 If this is nil, uses the environment variable MAIL. If that is
403 unset, uses a file named by the function `user-login-name' in the
404 directory `rmail-spool-directory' (whose value depends on the
405 operating system). For example, \"/var/mail/USER\"."
406 ;; Don't use backquote here, because we don't want to need it at load time.
407 ;; (That must be an old comment - it's dumped these days.)
408 :type
(list 'choice
'(const :tag
"Default" nil
)
409 (list 'repeat
':value
(list (or (getenv "MAIL")
410 (concat rmail-spool-directory
413 :group
'rmail-retrieve
416 (defcustom rmail-mail-new-frame nil
417 "Non-nil means Rmail makes a new frame for composing outgoing mail.
418 This is handy if you want to preserve the window configuration of
419 the frame where you have the RMAIL buffer displayed."
424 (defcustom rmail-secondary-file-directory
(purecopy "~/")
425 "Directory for additional secondary Rmail files."
429 (defcustom rmail-secondary-file-regexp
(purecopy "\\.xmail$")
430 "Regexp for which files are secondary Rmail files."
434 (defcustom rmail-confirm-expunge
'y-or-n-p
435 "Whether and how to ask for confirmation before expunging deleted messages.
436 The value, if non-nil is a function to call with a question (string)
437 as argument, to ask the user that question."
438 :type
'(choice (const :tag
"No confirmation" nil
)
439 (const :tag
"Confirm with y-or-n-p" y-or-n-p
)
440 (const :tag
"Confirm with yes-or-no-p" yes-or-no-p
))
443 (put 'rmail-confirm-expunge
'risky-local-variable t
)
446 (defvar rmail-mode-hook nil
447 "List of functions to call when Rmail is invoked.")
449 (defvar rmail-get-new-mail-hook nil
450 "List of functions to call when Rmail has retrieved new mail.")
453 (defcustom rmail-show-message-hook nil
454 "List of functions to call when Rmail displays a message."
456 :options
'(goto-address)
459 (defvar rmail-quit-hook nil
460 "List of functions to call when quitting out of Rmail.")
462 (defvar rmail-delete-message-hook nil
463 "List of functions to call when Rmail deletes a message.
464 When the hooks are called, the message has been marked deleted but is
465 still the current message in the Rmail buffer.")
467 ;; These may be altered by site-init.el to match the format of mmdf files
468 ;; delimiting used on a given host (delim1 and delim2 from the config
471 (defvar rmail-mmdf-delim1
"^\001\001\001\001\n"
472 "Regexp marking the start of an mmdf message.")
473 (defvar rmail-mmdf-delim2
"^\001\001\001\001\n"
474 "Regexp marking the end of an mmdf message.")
476 ;; FIXME Post-mbox, this is now unused.
477 ;; In Emacs-22, this was called:
478 ;; i) the very first time a message was shown.
479 ;; ii) when toggling the headers to the normal state, every time.
480 ;; It's not clear what it should do now, since there is nothing that
481 ;; records when a message is shown for the first time (unseen is not
482 ;; necessarily the same thing).
483 (defcustom rmail-message-filter nil
484 "If non-nil, a filter function for new messages in RMAIL.
485 Called with region narrowed to the message, including headers,
486 before obeying `rmail-ignored-headers'."
487 :group
'rmail-headers
488 :type
'(choice (const nil
) function
))
490 (defcustom rmail-automatic-folder-directives nil
491 "List of directives specifying where to put a message.
492 Each element of the list is of the form:
494 (FOLDERNAME FIELD REGEXP [ FIELD REGEXP ] ... )
496 Where FOLDERNAME is the name of a folder to put the message.
497 If any of the field regexp's are nil, then it is ignored.
499 If FOLDERNAME is \"/dev/null\", it is deleted.
500 If FOLDERNAME is nil then it is deleted, and skipped.
502 FIELD is the plain text name of a field in the message, such as
503 \"subject\" or \"from\". A FIELD of \"to\" will automatically include
504 all text from the \"cc\" field as well.
506 REGEXP is an expression to match in the preceding specified FIELD.
507 FIELD/REGEXP pairs continue in the list.
510 (\"/dev/null\" \"from\" \"@spam.com\") ; delete all mail from spam.com
511 (\"RMS\" \"from\" \"rms@\") ; save all mail from RMS.
513 Note that this is only applied in the folder specifed by `rmail-file-name'."
516 :type
'(repeat (sexp :tag
"Directive")))
518 (defvar rmail-reply-prefix
"Re: "
519 "String to prepend to Subject line when replying to a message.")
521 ;; Some mailers use "Re(2):" or "Re^2:" or "Re: Re:" or "Re[2]:".
522 ;; This pattern should catch all the common variants.
523 ;; rms: I deleted the change to delete tags in square brackets
524 ;; because they mess up RT tags.
525 (defvar rmail-reply-regexp
"\\`\\(Re\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?: *\\)*"
526 "Regexp to delete from Subject line before inserting `rmail-reply-prefix'.")
528 (defcustom rmail-display-summary nil
529 "If non-nil, Rmail always displays the summary buffer."
530 :group
'rmail-summary
533 (defvar rmail-inbox-list nil
)
534 (put 'rmail-inbox-list
'permanent-local t
)
536 (defvar rmail-buffer nil
537 "The RMAIL buffer related to the current buffer.
538 In an RMAIL buffer, this holds the RMAIL buffer itself.
539 In a summary buffer, this holds the RMAIL buffer it is a summary for.")
540 (put 'rmail-buffer
'permanent-local t
)
542 (defvar rmail-was-converted nil
543 "Non-nil in an Rmail buffer that was just converted from Babyl format.")
544 (put 'rmail-was-converted
'permanent-local t
)
546 (defvar rmail-seriously-modified nil
547 "Non-nil in an Rmail buffer that has been modified in a major way.")
548 (put 'rmail-seriously-modified
'permanent-local t
)
550 ;; Message counters and markers. Deleted flags.
552 (defvar rmail-current-message nil
553 "Integer specifying the message currently being displayed in this folder.")
554 (put 'rmail-current-message
'permanent-local t
)
556 (defvar rmail-total-messages nil
557 "Integer specifying the total number of messages in this folder.
558 Includes deleted messages.")
559 (put 'rmail-total-messages
'permanent-local t
)
561 (defvar rmail-message-vector nil
562 "Vector of markers specifying the start and end of each message.
563 Element N and N+1 specify the start and end of message N.")
564 (put 'rmail-message-vector
'permanent-local t
)
566 (defvar rmail-deleted-vector nil
567 "A string of length `rmail-total-messages' plus one.
568 Character N is either a space or \"D\", according to whether
569 message N is deleted or not.")
570 (put 'rmail-deleted-vector
'permanent-local t
)
572 (defvar rmail-msgref-vector nil
573 "In an Rmail buffer, a vector whose Nth element is a list (N).
574 When expunging renumbers messages, these lists are modified
575 by substituting the new message number into the existing list.")
576 (put 'rmail-msgref-vector
'permanent-local t
)
578 (defvar rmail-overlay-list nil
)
579 (put 'rmail-overlay-list
'permanent-local t
)
581 ;; These are used by autoloaded rmail-summary.
583 (defvar rmail-summary-buffer nil
)
584 (put 'rmail-summary-buffer
'permanent-local t
)
585 (defvar rmail-summary-vector nil
586 "In an Rmail buffer, vector of (newline-terminated) strings.
587 Element N specifies the summary line for message N+1.")
588 (put 'rmail-summary-vector
'permanent-local t
)
590 ;; Rmail buffer swapping variables.
592 (defvar rmail-buffer-swapped nil
593 "If non-nil, `rmail-buffer' is swapped with `rmail-view-buffer'.")
594 (make-variable-buffer-local 'rmail-buffer-swapped
)
595 (put 'rmail-buffer-swapped
'permanent-local t
)
597 (defvar rmail-view-buffer nil
598 "Buffer which holds RMAIL message for MIME displaying.")
599 (make-variable-buffer-local 'rmail-view-buffer
)
600 (put 'rmail-view-buffer
'permanent-local t
)
602 ;; `Sticky' default variables.
604 ;; Last individual label specified to a or k.
605 (defvar rmail-last-label nil
)
607 ;; Last set of values specified to C-M-n, C-M-p, C-M-s or C-M-l.
608 (defvar rmail-last-multi-labels nil
)
610 (defvar rmail-last-regexp nil
)
611 (put 'rmail-last-regexp
'permanent-local t
)
613 (defcustom rmail-default-file
"~/xmail"
614 "Default file name for \\[rmail-output]."
617 (defcustom rmail-default-body-file
"~/mailout"
618 "Default file name for \\[rmail-output-body-to-file]."
623 ;; Mule and MIME related variables.
626 (defvar rmail-file-coding-system nil
627 "Coding system used in RMAIL file.
629 This is set to nil by default.")
631 (defcustom rmail-enable-mime t
632 "If non-nil, RMAIL uses MIME features.
633 If the value is t, RMAIL automatically shows MIME decoded message.
634 If the value is neither t nor nil, RMAIL does not show MIME decoded message
635 until a user explicitly requires it.
637 Even if the value is non-nil, you can't use MIME features
638 unless the feature specified by `rmail-mime-feature' is available."
639 :type
'(choice (const :tag
"on" t
)
640 (const :tag
"off" nil
)
641 (other :tag
"when asked" ask
))
645 (defvar rmail-enable-mime-composing nil
646 "*If non-nil, RMAIL uses `rmail-insert-mime-forwarded-message-function' to forward.")
649 (defvar rmail-show-mime-function nil
650 "Function to show MIME decoded message of RMAIL file.
651 This function is called when `rmail-enable-mime' is non-nil.
652 It is called with no argument.")
655 (defvar rmail-insert-mime-forwarded-message-function nil
656 "Function to insert a message in MIME format so it can be forwarded.
657 This function is called if `rmail-enable-mime' or
658 `rmail-enable-mime-composing' is non-nil.
659 It is called with one argument FORWARD-BUFFER, which is a
660 buffer containing the message to forward. The current buffer
661 is the outgoing mail buffer.")
663 (defvar rmail-insert-mime-resent-message-function nil
664 "Function to insert a message in MIME format so it can be resent.
665 This function is called by `rmail-resend' if `rmail-enable-mime' is non-nil.
666 It is called with one argument FORWARD-BUFFER, which is a
667 buffer containing the message to forward. The current buffer
668 is the outgoing mail buffer.")
670 ;; FIXME one might want to pass a LIMIT, as per
671 ;; rmail-search-mime-header-function.
672 (defvar rmail-search-mime-message-function nil
673 "Function to check if a regexp matches a MIME message.
674 This function is called by `rmail-search-message' if
675 `rmail-enable-mime' is non-nil. It is called (with point at the
676 start of the message) with two arguments MSG and REGEXP, where
677 MSG is the message number, REGEXP is the regular expression.")
679 (defvar rmail-search-mime-header-function nil
680 "Function to check if a regexp matches a header of MIME message.
681 This function is called by `rmail-message-regexp-p-1' if
682 `rmail-enable-mime' is non-nil. It is called (with point at the
683 start of the header) with three arguments MSG, REGEXP, and LIMIT,
684 where MSG is the message number, REGEXP is the regular
685 expression, LIMIT is the position specifying the end of header.")
687 (defvar rmail-mime-feature
'rmailmm
688 "Feature to require to load MIME support in Rmail.
689 When starting Rmail, if `rmail-enable-mime' is non-nil,
690 this feature is required with `require'.
692 The default value is `rmailmm'")
694 ;; FIXME this is unused.
695 (defvar rmail-decode-mime-charset t
696 "*Non-nil means a message is decoded by MIME's charset specification.
697 If this variable is nil, or the message has not MIME specification,
698 the message is decoded as normal way.
700 If the variable `rmail-enable-mime' is non-nil, this variable is
701 ignored, and all the decoding work is done by a feature specified by
702 the variable `rmail-mime-feature'.")
704 (defvar rmail-mime-charset-pattern
705 (concat "^content-type:[ \t]*text/plain;"
706 "\\(?:[ \t\n]*\\(?:format\\|delsp\\)=\"?[-a-z0-9]+\"?;\\)*"
707 "[ \t\n]*charset=\"?\\([^ \t\n\";]+\\)\"?")
708 "Regexp to match MIME-charset specification in a header of message.
709 The first parenthesized expression should match the MIME-charset name.")
712 (defvar rmail-unix-mail-delimiter
713 (let ((time-zone-regexp
714 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
715 "\\|[-+]?[0-9][0-9][0-9][0-9]"
721 ;; Many things can happen to an RFC 822 mailbox before it is put into
722 ;; a `From' line. The leading phrase can be stripped, e.g.
723 ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'. The <> can be stripped, e.g.
724 ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'. Everything starting with a CRLF
725 ;; can be removed, e.g.
726 ;; From: joe@y.z (Joe K
728 ;; can yield `From joe@y.z (Joe K Fri Mar 22 08:11:15 1996', and
731 ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
732 ;; The mailbox can be removed or be replaced by white space, e.g.
733 ;; From: "Joe User"{space}{tab}
735 ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
736 ;; where {space} and {tab} represent the Ascii space and tab characters.
737 ;; We want to match the results of any of these manglings.
738 ;; The following regexp rejects names whose first characters are
739 ;; obviously bogus, but after that anything goes.
740 "\\([^\0-\b\n-\r\^?].*\\)? "
742 ;; The time the message was sent.
743 "\\([^\0-\r \^?]+\\) +" ; day of the week
744 "\\([^\0-\r \^?]+\\) +" ; month
745 "\\([0-3]?[0-9]\\) +" ; day of month
746 "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *" ; time of day
748 ;; Perhaps a time zone, specified by an abbreviation, or by a
753 " \\([0-9][0-9]+\\) *"
755 ;; On some systems the time zone can appear after the year, too.
759 "\\(remote from .*\\)?"
762 "Regexp matching the delimiter of messages in UNIX mail format
763 \(UNIX From lines), minus the initial ^. Note that if you change
764 this expression, you must change the code in `rmail-nuke-pinhead-header'
765 that knows the exact ordering of the \\( \\) subexpressions.")
767 ;; FIXME the rmail-header-name headers ought to be customizable.
768 ;; It seems a bit arbitrary, for example, that all of the Date: line
770 (defvar rmail-font-lock-keywords
771 ;; These are all matched case-insensitively.
773 (let* ((cite-chars "[>|}]")
775 (cite-suffix (concat cite-prefix
"0-9_.@-`'\"")))
776 (list '("^\\(From\\|Sender\\|Resent-From\\):"
777 .
'rmail-header-name
)
778 '("^\\(Mail-\\)?Reply-To:.*$" .
'rmail-header-name
)
779 ;; FIXME Mail-Followup-To should probably be here too.
780 '("^Subject:" .
'rmail-header-name
)
781 '("^X-Spam-Status:" .
'rmail-header-name
)
782 '("^\\(To\\|Apparently-To\\|Cc\\|Newsgroups\\):"
783 .
'rmail-header-name
)
784 ;; Use MATCH-ANCHORED to effectively anchor the regexp left side.
786 (,(concat "\\=[ \t]*"
787 "\\(\\(\\([" cite-prefix
"]+[" cite-suffix
"]*\\)?"
788 "\\(" cite-chars
"[ \t]*\\)\\)+\\)"
790 (beginning-of-line) (end-of-line)
791 (1 font-lock-comment-delimiter-face nil t
)
792 (5 font-lock-comment-face nil t
)))
793 '("^\\(X-[a-z0-9-]+\\|In-reply-to\\|Date\\):.*\\(\n[ \t]+.*\\)*$"
794 .
'rmail-header-name
))))
795 "Additional expressions to highlight in Rmail mode.")
797 ;; Rmail does not expect horizontal splitting. (Bug#2282)
798 (defun rmail-pop-to-buffer (&rest args
)
799 "Like `pop-to-buffer', but with `split-width-threshold' set to nil."
800 (let (split-width-threshold)
801 (apply 'pop-to-buffer args
)))
803 ;; Perform BODY in the summary buffer
804 ;; in such a way that its cursor is properly updated in its own window.
805 (defmacro rmail-select-summary
(&rest body
)
806 `(let ((total rmail-total-messages
))
807 (if (rmail-summary-displayed)
808 (let ((window (selected-window)))
812 (rmail-pop-to-buffer rmail-summary-buffer
)
813 ;; rmail-total-messages is a buffer-local var
814 ;; in the rmail buffer.
815 ;; This way we make it available for the body
816 ;; even tho the rmail buffer is not current.
817 (let ((rmail-total-messages total
))
819 (select-window window
))))
820 (with-current-buffer rmail-summary-buffer
821 (let ((rmail-total-messages total
))
823 (rmail-maybe-display-summary)))
825 ;;;; *** Rmail Mode ***
827 (defun rmail-require-mime-maybe ()
828 "Require `rmail-mime-feature' if that is non-nil.
829 Signal an error and set `rmail-mime-feature' to nil if the feature
831 (when rmail-enable-mime
833 (require rmail-mime-feature
)
837 (format "Although MIME support is requested
838 by setting `rmail-enable-mime' to non-nil, the required feature
839 `%s' (the value of `rmail-mime-feature')
840 is not available in the current session.
841 So, the MIME support is turned off for the moment."
844 (setq rmail-enable-mime nil
)))))
848 (defun rmail (&optional file-name-arg
)
849 "Read and edit incoming mail.
850 Moves messages into file named by `rmail-file-name' and edits that
852 Type \\[describe-mode] once editing that file, for a list of RMAIL commands.
854 May be called with file name as argument; then performs rmail editing on
855 that file, but does not copy any new mail into the file.
856 Interactively, if you supply a prefix argument, then you
857 have a chance to specify a file name with the minibuffer.
859 If `rmail-display-summary' is non-nil, make a summary for this RMAIL file."
860 (interactive (if current-prefix-arg
861 (list (read-file-name "Run rmail on RMAIL file: "))))
862 (rmail-require-mime-maybe)
863 (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name
)))
864 ;; Use find-buffer-visiting, not get-file-buffer, for those users
865 ;; who have find-file-visit-truename set to t.
866 (existed (find-buffer-visiting file-name
))
867 run-mail-hook mail-buf msg-shown
)
868 ;; Determine if an existing mail file has been changed behind the
870 (if (and existed
(not (verify-visited-file-modtime existed
)))
871 ;; The mail file has been changed. Revisit it and reset the
872 ;; message state variables when in rmail mode.
874 (find-file file-name
)
875 (when (and (verify-visited-file-modtime existed
)
876 (eq major-mode
'rmail-mode
))
877 (rmail-swap-buffers-maybe)
878 (rmail-set-message-counters)))
879 ;; The mail file is either unchanged or not visited. Visit it.
881 (let ((enable-local-variables nil
)
882 ;; Force no-conversion by default, since that's what
883 ;; pre-mbox Rmail did with BABYL files (via
884 ;; auto-coding-regexp-alist).
885 (coding-system-for-read
886 (or coding-system-for-read
'no-conversion
)))
887 (find-file-noselect file-name
))))
888 ;; Ensure that the collection and view buffers are in sync and
889 ;; ensure that a message is not being edited.
890 (if (eq major-mode
'rmail-mode
)
891 (rmail-swap-buffers-maybe))
892 (if (eq major-mode
'rmail-edit-mode
)
893 (error "Exit Rmail Edit mode before getting new mail"))
894 (or (and existed
(> (buffer-size) 0))
895 (setq run-mail-hook t
))
896 ;; Ensure that the Rmail file is in mbox format, the buffer is in
897 ;; Rmail mode and has been scanned to find all the messages
898 ;; (setting the global message variables in the process).
899 (rmail-convert-file-maybe)
900 (unless (eq major-mode
'rmail-mode
)
902 (goto-char (point-max))
903 (rmail-maybe-set-message-counters)
904 (setq mail-buf rmail-buffer
)
905 ;; Show the first unread message and process summary mode.
907 ;; Only get new mail when there is not a file name argument.
908 (unless file-name-arg
909 (setq msg-shown
(rmail-get-new-mail)))
911 (set-buffer mail-buf
)
913 (rmail-show-message (rmail-first-unseen-message)))
914 (if rmail-display-summary
(rmail-summary))
915 (rmail-construct-io-menu)
917 (run-hooks 'rmail-mode-hook
))))))
919 (defun rmail-convert-file-maybe ()
920 "Determine if the file needs to be converted to mbox format."
922 (goto-char (point-min))
923 ;; Detect previous Babyl format files.
924 (let ((case-fold-search nil
))
925 (cond ((looking-at "BABYL OPTIONS:")
926 ;; The file is Babyl version 5. Use unrmail to convert
928 (rmail-convert-babyl-to-mbox))
929 ((looking-at "Version: 5\n")
930 ;; Losing babyl file made by old version of Rmail. Fix the
931 ;; babyl file header and use unrmail to convert to mbox
933 (let ((buffer-read-only nil
))
934 (insert "BABYL OPTIONS: -*- rmail -*-\n")
935 (rmail-convert-babyl-to-mbox)))
936 ((equal (point-min) (point-max))
937 (message "Empty Rmail file."))
938 ((looking-at "From "))
939 (t (error "Invalid mbox file")))))
941 (defun rmail-error-bad-format (&optional msgnum
)
942 "Report that the buffer is not in the mbox file format.
943 MSGNUM, if present, indicates the malformed message."
945 (error "Message %d is not a valid RFC2822 message" msgnum
)
946 (error "Message is not a valid RFC2822 message")))
948 (defun rmail-convert-babyl-to-mbox ()
949 "Convert the mail file from Babyl version 5 to mbox.
950 This function also reinitializes local variables used by Rmail."
951 (let ((old-file (make-temp-file "rmail"))
952 (new-file (make-temp-file "rmail")))
955 (kill-all-local-variables)
956 (write-region (point-min) (point-max) old-file
)
957 (unrmail old-file new-file
)
958 (message "Replacing BABYL format with mbox format...")
959 (let ((inhibit-read-only t
)
960 (coding-system-for-read 'raw-text
)
961 (buffer-undo-list t
))
963 (insert-file-contents new-file
)
964 ;; Rmail buffers need to be saved with Unix EOLs, or else
965 ;; the format will not be recognized.
966 (set-buffer-file-coding-system 'raw-text-unix
)
968 (rmail-perm-variables)
970 (setq rmail-was-converted t
)
971 (rmail-dont-modify-format)
972 (goto-char (point-max))
973 (rmail-set-message-counters))
974 (message "Replacing BABYL format with mbox format...done"))
975 (delete-file old-file
)
976 (delete-file new-file
))))
978 (defun rmail-get-coding-system ()
979 "Return a suitable coding system to use for the current mail message.
980 The buffer is expected to be narrowed to just the header of the message."
982 (goto-char (point-min))
983 (if (re-search-forward rmail-mime-charset-pattern nil t
)
984 (coding-system-from-name (match-string 1))
987 ;;; Set up Rmail mode keymaps
989 (defvar rmail-mode-map
990 (let ((map (make-keymap)))
991 (suppress-keymap map
)
992 (define-key map
"a" 'rmail-add-label
)
993 (define-key map
"b" 'rmail-bury
)
994 (define-key map
"c" 'rmail-continue
)
995 (define-key map
"d" 'rmail-delete-forward
)
996 (define-key map
"\C-d" 'rmail-delete-backward
)
997 (define-key map
"e" 'rmail-edit-current-message
)
998 ;; If you change this, change the rmail-resend menu-item's :keys.
999 (define-key map
"f" 'rmail-forward
)
1000 (define-key map
"g" 'rmail-get-new-mail
)
1001 (define-key map
"h" 'rmail-summary
)
1002 (define-key map
"i" 'rmail-input
)
1003 (define-key map
"j" 'rmail-show-message
)
1004 (define-key map
"k" 'rmail-kill-label
)
1005 (define-key map
"l" 'rmail-summary-by-labels
)
1006 (define-key map
"\e\C-h" 'rmail-summary
)
1007 (define-key map
"\e\C-l" 'rmail-summary-by-labels
)
1008 (define-key map
"\e\C-r" 'rmail-summary-by-recipients
)
1009 (define-key map
"\e\C-s" 'rmail-summary-by-regexp
)
1010 (define-key map
"\e\C-t" 'rmail-summary-by-topic
)
1011 (define-key map
"m" 'rmail-mail
)
1012 (define-key map
"\em" 'rmail-retry-failure
)
1013 (define-key map
"n" 'rmail-next-undeleted-message
)
1014 (define-key map
"\en" 'rmail-next-message
)
1015 (define-key map
"\e\C-n" 'rmail-next-labeled-message
)
1016 (define-key map
"o" 'rmail-output
)
1017 (define-key map
"\C-o" 'rmail-output-as-seen
)
1018 (define-key map
"p" 'rmail-previous-undeleted-message
)
1019 (define-key map
"\ep" 'rmail-previous-message
)
1020 (define-key map
"\e\C-p" 'rmail-previous-labeled-message
)
1021 (define-key map
"q" 'rmail-quit
)
1022 (define-key map
"r" 'rmail-reply
)
1023 ;; I find I can't live without the default M-r command -- rms.
1024 ;; (define-key rmail-mode-map "\er" 'rmail-search-backwards)
1025 (define-key map
"s" 'rmail-expunge-and-save
)
1026 (define-key map
"\es" 'rmail-search
)
1027 (define-key map
"t" 'rmail-toggle-header
)
1028 (define-key map
"u" 'rmail-undelete-previous-message
)
1029 (define-key map
"v" 'rmail-mime
)
1030 (define-key map
"w" 'rmail-output-body-to-file
)
1031 (define-key map
"\C-c\C-w" 'rmail-widen
)
1032 (define-key map
"x" 'rmail-expunge
)
1033 (define-key map
"." 'rmail-beginning-of-message
)
1034 (define-key map
"/" 'rmail-end-of-message
)
1035 (define-key map
"<" 'rmail-first-message
)
1036 (define-key map
">" 'rmail-last-message
)
1037 (define-key map
" " 'scroll-up
)
1038 (define-key map
"\177" 'scroll-down
)
1039 (define-key map
"?" 'describe-mode
)
1040 (define-key map
"\C-c\C-s\C-d" 'rmail-sort-by-date
)
1041 (define-key map
"\C-c\C-s\C-s" 'rmail-sort-by-subject
)
1042 (define-key map
"\C-c\C-s\C-a" 'rmail-sort-by-author
)
1043 (define-key map
"\C-c\C-s\C-r" 'rmail-sort-by-recipient
)
1044 (define-key map
"\C-c\C-s\C-c" 'rmail-sort-by-correspondent
)
1045 (define-key map
"\C-c\C-s\C-l" 'rmail-sort-by-lines
)
1046 (define-key map
"\C-c\C-s\C-k" 'rmail-sort-by-labels
)
1047 (define-key map
"\C-c\C-n" 'rmail-next-same-subject
)
1048 (define-key map
"\C-c\C-p" 'rmail-previous-same-subject
)
1051 (define-key map
[menu-bar
] (make-sparse-keymap))
1053 (define-key map
[menu-bar classify
]
1054 (cons "Classify" (make-sparse-keymap "Classify")))
1056 (define-key map
[menu-bar classify input-menu
]
1059 (define-key map
[menu-bar classify output-menu
]
1062 (define-key map
[menu-bar classify output-body
]
1063 '("Output body to file..." . rmail-output-body-to-file
))
1065 (define-key map
[menu-bar classify output-inbox
]
1066 '("Output..." . rmail-output
))
1068 (define-key map
[menu-bar classify output
]
1069 '("Output as seen..." . rmail-output-as-seen
))
1071 (define-key map
[menu-bar classify kill-label
]
1072 '("Kill Label..." . rmail-kill-label
))
1074 (define-key map
[menu-bar classify add-label
]
1075 '("Add Label..." . rmail-add-label
))
1077 (define-key map
[menu-bar summary
]
1078 (cons "Summary" (make-sparse-keymap "Summary")))
1080 (define-key map
[menu-bar summary senders
]
1081 '("By Senders..." . rmail-summary-by-senders
))
1083 (define-key map
[menu-bar summary labels
]
1084 '("By Labels..." . rmail-summary-by-labels
))
1086 (define-key map
[menu-bar summary recipients
]
1087 '("By Recipients..." . rmail-summary-by-recipients
))
1089 (define-key map
[menu-bar summary topic
]
1090 '("By Topic..." . rmail-summary-by-topic
))
1092 (define-key map
[menu-bar summary regexp
]
1093 '("By Regexp..." . rmail-summary-by-regexp
))
1095 (define-key map
[menu-bar summary all
]
1096 '("All" . rmail-summary
))
1098 (define-key map
[menu-bar mail
]
1099 (cons "Mail" (make-sparse-keymap "Mail")))
1101 (define-key map
[menu-bar mail rmail-get-new-mail
]
1102 '("Get New Mail" . rmail-get-new-mail
))
1104 (define-key map
[menu-bar mail lambda
]
1107 (define-key map
[menu-bar mail continue
]
1108 '("Continue" . rmail-continue
))
1110 (define-key map
[menu-bar mail resend
]
1111 '(menu-item "Resend..." rmail-resend
:keys
"C-u f"))
1113 (define-key map
[menu-bar mail forward
]
1114 '("Forward" . rmail-forward
))
1116 (define-key map
[menu-bar mail retry
]
1117 '("Retry" . rmail-retry-failure
))
1119 (define-key map
[menu-bar mail reply
]
1120 '("Reply" . rmail-reply
))
1122 (define-key map
[menu-bar mail mail
]
1123 '("Mail" . rmail-mail
))
1125 (define-key map
[menu-bar delete
]
1126 (cons "Delete" (make-sparse-keymap "Delete")))
1128 (define-key map
[menu-bar delete expunge
/save
]
1129 '("Expunge/Save" . rmail-expunge-and-save
))
1131 (define-key map
[menu-bar delete expunge
]
1132 '("Expunge" . rmail-expunge
))
1134 (define-key map
[menu-bar delete undelete
]
1135 '("Undelete" . rmail-undelete-previous-message
))
1137 (define-key map
[menu-bar delete delete
]
1138 '("Delete" . rmail-delete-forward
))
1140 (define-key map
[menu-bar move
]
1141 (cons "Move" (make-sparse-keymap "Move")))
1143 (define-key map
[menu-bar move search-back
]
1144 '("Search Back..." . rmail-search-backwards
))
1146 (define-key map
[menu-bar move search
]
1147 '("Search..." . rmail-search
))
1149 (define-key map
[menu-bar move previous
]
1150 '("Previous Nondeleted" . rmail-previous-undeleted-message
))
1152 (define-key map
[menu-bar move next
]
1153 '("Next Nondeleted" . rmail-next-undeleted-message
))
1155 (define-key map
[menu-bar move last
]
1156 '("Last" . rmail-last-message
))
1158 (define-key map
[menu-bar move first
]
1159 '("First" . rmail-first-message
))
1161 (define-key map
[menu-bar move previous
]
1162 '("Previous" . rmail-previous-message
))
1164 (define-key map
[menu-bar move next
]
1165 '("Next" . rmail-next-message
))
1168 "Keymap used in Rmail mode.")
1171 (defvar rmail-tool-bar-map
1172 (let ((map (make-sparse-keymap)))
1173 (tool-bar-local-item-from-menu 'rmail-get-new-mail
"mail/inbox"
1175 (tool-bar-local-item-from-menu 'rmail-next-undeleted-message
"right-arrow"
1177 (tool-bar-local-item-from-menu 'rmail-previous-undeleted-message
"left-arrow"
1179 (tool-bar-local-item-from-menu 'rmail-search
"search"
1181 (tool-bar-local-item-from-menu 'rmail-input
"open"
1183 (tool-bar-local-item-from-menu 'rmail-mail
"mail/compose"
1185 (tool-bar-local-item-from-menu 'rmail-reply
"mail/reply-all"
1187 (tool-bar-local-item-from-menu 'rmail-forward
"mail/forward"
1189 (tool-bar-local-item-from-menu 'rmail-delete-forward
"close"
1191 (tool-bar-local-item-from-menu 'rmail-output
"mail/move"
1193 (tool-bar-local-item-from-menu 'rmail-output-body-to-file
"mail/save"
1195 (tool-bar-local-item-from-menu 'rmail-expunge
"delete"
1201 ;; Rmail mode is suitable only for specially formatted data.
1202 (put 'rmail-mode
'mode-class
'special
)
1204 (defun rmail-mode-kill-summary ()
1205 (if rmail-summary-buffer
(kill-buffer rmail-summary-buffer
)))
1207 (defvar rmail-enable-multibyte
) ; dynamically bound
1210 (defun rmail-mode ()
1211 "Rmail Mode is used by \\<rmail-mode-map>\\[rmail] for editing Rmail files.
1212 All normal editing commands are turned off.
1213 Instead, these commands are available:
1215 \\[rmail-beginning-of-message] Move point to front of this message.
1216 \\[rmail-end-of-message] Move point to bottom of this message.
1217 \\[scroll-up] Scroll to next screen of this message.
1218 \\[scroll-down] Scroll to previous screen of this message.
1219 \\[rmail-next-undeleted-message] Move to Next non-deleted message.
1220 \\[rmail-previous-undeleted-message] Move to Previous non-deleted message.
1221 \\[rmail-next-message] Move to Next message whether deleted or not.
1222 \\[rmail-previous-message] Move to Previous message whether deleted or not.
1223 \\[rmail-first-message] Move to the first message in Rmail file.
1224 \\[rmail-last-message] Move to the last message in Rmail file.
1225 \\[rmail-show-message] Jump to message specified by numeric position in file.
1226 \\[rmail-search] Search for string and show message it is found in.
1227 \\[rmail-delete-forward] Delete this message, move to next nondeleted.
1228 \\[rmail-delete-backward] Delete this message, move to previous nondeleted.
1229 \\[rmail-undelete-previous-message] Undelete message. Tries current message, then earlier messages
1230 till a deleted message is found.
1231 \\[rmail-edit-current-message] Edit the current message. \\[rmail-cease-edit] to return to Rmail.
1232 \\[rmail-expunge] Expunge deleted messages.
1233 \\[rmail-expunge-and-save] Expunge and save the file.
1234 \\[rmail-quit] Quit Rmail: expunge, save, then switch to another buffer.
1235 \\[save-buffer] Save without expunging.
1236 \\[rmail-get-new-mail] Move new mail from system spool directory into this file.
1237 \\[rmail-mail] Mail a message (same as \\[mail-other-window]).
1238 \\[rmail-continue] Continue composing outgoing message started before.
1239 \\[rmail-reply] Reply to this message. Like \\[rmail-mail] but initializes some fields.
1240 \\[rmail-retry-failure] Send this message again. Used on a mailer failure message.
1241 \\[rmail-forward] Forward this message to another user.
1242 \\[rmail-output] Output (append) this message to another mail file.
1243 \\[rmail-output-as-seen] Output (append) this message to file as it's displayed.
1244 \\[rmail-output-body-to-file] Save message body to a file. Default filename comes from Subject line.
1245 \\[rmail-input] Input Rmail file. Run Rmail on that file.
1246 \\[rmail-add-label] Add label to message. It will be displayed in the mode line.
1247 \\[rmail-kill-label] Kill label. Remove a label from current message.
1248 \\[rmail-next-labeled-message] Move to Next message with specified label
1249 (label defaults to last one specified).
1250 Standard labels: filed, unseen, answered, forwarded, deleted.
1251 Any other label is present only if you add it with \\[rmail-add-label].
1252 \\[rmail-previous-labeled-message] Move to Previous message with specified label
1253 \\[rmail-summary] Show headers buffer, with a one line summary of each message.
1254 \\[rmail-summary-by-labels] Summarize only messages with particular label(s).
1255 \\[rmail-summary-by-recipients] Summarize only messages with particular recipient(s).
1256 \\[rmail-summary-by-regexp] Summarize only messages with particular regexp(s).
1257 \\[rmail-summary-by-topic] Summarize only messages with subject line regexp(s).
1258 \\[rmail-toggle-header] Toggle display of complete header."
1260 (let ((finding-rmail-file (not (eq major-mode
'rmail-mode
))))
1262 (when (and finding-rmail-file
1263 (null coding-system-for-read
)
1264 (default-value 'enable-multibyte-characters
))
1265 (let ((rmail-enable-multibyte t
))
1266 (rmail-require-mime-maybe)
1267 (rmail-convert-file-maybe)
1268 (goto-char (point-max))
1269 (set-buffer-multibyte t
)))
1270 (rmail-set-message-counters)
1271 (rmail-show-message rmail-total-messages
)
1272 (when finding-rmail-file
1273 (when rmail-display-summary
1275 (rmail-construct-io-menu))
1276 (run-mode-hooks 'rmail-mode-hook
)))
1278 (defun rmail-mode-2 ()
1279 (kill-all-local-variables)
1281 (rmail-perm-variables)
1284 (defun rmail-mode-1 ()
1285 (setq major-mode
'rmail-mode
)
1286 (setq mode-name
"RMAIL")
1287 (setq buffer-read-only t
)
1288 ;; No need to auto save RMAIL files in normal circumstances
1289 ;; because they contain no info except attribute changes
1290 ;; and deletion of messages.
1291 ;; The one exception is when messages are copied into another mbox buffer.
1292 ;; rmail-output enables auto save when you do that.
1293 (setq buffer-auto-save-file-name nil
)
1294 (use-local-map rmail-mode-map
)
1295 (set-syntax-table text-mode-syntax-table
)
1296 (setq local-abbrev-table text-mode-abbrev-table
)
1297 ;; Functions to support buffer swapping:
1298 (add-hook 'write-region-annotate-functions
1299 'rmail-write-region-annotate nil t
)
1300 (add-hook 'kill-buffer-hook
'rmail-mode-kill-buffer-hook nil t
)
1301 (add-hook 'change-major-mode-hook
'rmail-change-major-mode-hook nil t
))
1303 (defun rmail-generate-viewer-buffer ()
1304 "Return a reusable buffer suitable for viewing messages.
1305 Create the buffer if necessary."
1306 ;; We want to reuse any existing view buffer, so as not to create an
1307 ;; endless number of them. But we must avoid clashes if we visit
1308 ;; two different rmail files with the same basename (Bug#4593).
1309 (if (and (local-variable-p 'rmail-view-buffer
)
1310 (buffer-live-p rmail-view-buffer
))
1312 (generate-new-buffer
1313 (format " *message-viewer %s*"
1314 (file-name-nondirectory (or buffer-file-name
(buffer-name)))))))
1316 (defun rmail-swap-buffers ()
1317 "Swap text between current buffer and `rmail-view-buffer'.
1318 This function preserves the current buffer's modified flag, and also
1319 sets the current buffer's `buffer-file-coding-system' to that of
1320 `rmail-view-buffer'."
1321 (let ((modp-this (buffer-modified-p))
1323 (with-current-buffer rmail-view-buffer
(buffer-modified-p)))
1324 (coding-this buffer-file-coding-system
)
1326 (with-current-buffer rmail-view-buffer
1327 buffer-file-coding-system
)))
1328 (buffer-swap-text rmail-view-buffer
)
1329 (setq buffer-file-coding-system coding-that
)
1330 (with-current-buffer rmail-view-buffer
1331 (setq buffer-file-coding-system coding-this
)
1332 (restore-buffer-modified-p modp-that
))
1333 (restore-buffer-modified-p modp-this
)))
1335 (defun rmail-buffers-swapped-p ()
1336 "Return non-nil if the message collection is in `rmail-view-buffer'."
1337 ;; This is analogous to tar-data-swapped-p in tar-mode.el.
1338 (and (buffer-live-p rmail-view-buffer
)
1339 rmail-buffer-swapped
))
1341 (defun rmail-change-major-mode-hook ()
1342 ;; Bring the actual Rmail messages back into the main buffer.
1343 (when (rmail-buffers-swapped-p)
1344 (rmail-swap-buffers)
1345 (setq rmail-buffer-swapped nil
)))
1347 (defun rmail-swap-buffers-maybe ()
1348 "Determine if the Rmail buffer is showing a message.
1349 If so restore the actual mbox message collection."
1350 (with-current-buffer rmail-buffer
1351 (when (rmail-buffers-swapped-p)
1352 (rmail-swap-buffers)
1353 (setq rmail-buffer-swapped nil
))))
1355 (defun rmail-modify-format ()
1356 "Warn if important modifications would change Rmail file's format."
1357 (with-current-buffer rmail-buffer
1358 (and rmail-was-converted
1359 ;; If it's already modified, don't warn again.
1360 (not rmail-seriously-modified
)
1363 (message "After this, %s would be saved in mbox format. Proceed? "
1366 (setq rmail-seriously-modified t
)))
1368 (defun rmail-dont-modify-format ()
1369 (when (and rmail-was-converted
(not rmail-seriously-modified
))
1370 (set-buffer-modified-p nil
)
1371 (message "Marking buffer unmodified to avoid rewriting Babyl file as mbox file")))
1373 (defun rmail-mode-kill-buffer-hook ()
1374 (if (buffer-live-p rmail-view-buffer
) (kill-buffer rmail-view-buffer
)))
1376 ;; Set up the permanent locals associated with an Rmail file.
1377 (defun rmail-perm-variables ()
1378 (make-local-variable 'rmail-last-regexp
)
1379 (make-local-variable 'rmail-deleted-vector
)
1380 (make-local-variable 'rmail-buffer
)
1381 (make-local-variable 'rmail-was-converted
)
1382 (setq rmail-was-converted nil
)
1383 (make-local-variable 'rmail-seriously-modified
)
1384 (setq rmail-seriously-modified nil
)
1385 (setq rmail-buffer
(current-buffer))
1386 (set-buffer-multibyte nil
)
1387 (with-current-buffer (setq rmail-view-buffer
(rmail-generate-viewer-buffer))
1388 (setq buffer-undo-list t
)
1389 ;; Note that this does not erase the buffer. Should it?
1390 ;; It depends on how this is called. If somehow called with the
1391 ;; rmail buffers swapped, it would erase the message collection.
1392 (set (make-local-variable 'rmail-overlay-list
) nil
)
1393 (set-buffer-multibyte t
)
1394 ;; Force C-x C-s write Unix EOLs.
1395 (set-buffer-file-coding-system 'undecided-unix
))
1396 (make-local-variable 'rmail-summary-buffer
)
1397 (make-local-variable 'rmail-summary-vector
)
1398 (make-local-variable 'rmail-current-message
)
1399 (make-local-variable 'rmail-total-messages
)
1400 (setq rmail-total-messages
0)
1401 (make-local-variable 'rmail-message-vector
)
1402 (make-local-variable 'rmail-msgref-vector
)
1403 (make-local-variable 'rmail-inbox-list
)
1404 ;; Provide default set of inboxes for primary mail file ~/RMAIL.
1405 (and (null rmail-inbox-list
)
1406 (or (equal buffer-file-name
(expand-file-name rmail-file-name
))
1407 (equal buffer-file-truename
1408 (abbreviate-file-name (file-truename rmail-file-name
))))
1409 (setq rmail-inbox-list
1410 (or rmail-primary-inbox-list
1411 (list (or (getenv "MAIL")
1412 ;; FIXME expand-file-name?
1413 (concat rmail-spool-directory
1414 (user-login-name)))))))
1415 (set (make-local-variable 'tool-bar-map
) rmail-tool-bar-map
))
1417 ;; Set up the non-permanent locals associated with Rmail mode.
1418 (defun rmail-variables ()
1419 ;; Turn off undo. We turn it back on in rmail-edit.
1420 (setq buffer-undo-list t
)
1421 ;; Don't let a local variables list in a message cause confusion.
1422 (make-local-variable 'local-enable-local-variables
)
1423 (setq local-enable-local-variables nil
)
1424 ;; Don't turn off auto-saving based on the size of the buffer
1425 ;; because that code does not understand buffer-swapping.
1426 (make-local-variable 'auto-save-include-big-deletions
)
1427 (setq auto-save-include-big-deletions t
)
1428 (make-local-variable 'revert-buffer-function
)
1429 (setq revert-buffer-function
'rmail-revert
)
1430 (make-local-variable 'font-lock-defaults
)
1431 (setq font-lock-defaults
1432 '(rmail-font-lock-keywords
1434 (font-lock-maximum-size . nil
)
1435 (font-lock-fontify-buffer-function . rmail-fontify-buffer-function
)
1436 (font-lock-unfontify-buffer-function . rmail-unfontify-buffer-function
)
1437 (font-lock-inhibit-thing-lock .
(lazy-lock-mode fast-lock-mode
))))
1438 (make-local-variable 'require-final-newline
)
1439 (setq require-final-newline nil
)
1440 (make-local-variable 'version-control
)
1441 (setq version-control
'never
)
1442 (make-local-variable 'kill-buffer-hook
)
1443 (add-hook 'kill-buffer-hook
'rmail-mode-kill-summary
)
1444 (make-local-variable 'file-precious-flag
)
1445 (setq file-precious-flag t
)
1446 (make-local-variable 'desktop-save-buffer
)
1447 (setq desktop-save-buffer t
))
1449 ;; Handle M-x revert-buffer done in an rmail-mode buffer.
1450 (defun rmail-revert (arg noconfirm
)
1451 (set-buffer rmail-buffer
)
1452 (let* ((revert-buffer-function (default-value 'revert-buffer-function
))
1453 (rmail-enable-multibyte enable-multibyte-characters
)
1454 ;; See similar code in `rmail'.
1455 ;; FIXME needs updating?
1456 (coding-system-for-read (and rmail-enable-multibyte
'raw-text
))
1457 (before-revert-hook 'rmail-swap-buffers-maybe
))
1458 ;; Call our caller again, but this time it does the default thing.
1459 (when (revert-buffer arg noconfirm
)
1460 ;; If the user said "yes", and we changed something,
1461 ;; reparse the messages.
1462 (set-buffer rmail-buffer
)
1464 ;; Convert all or part to Babyl file if possible.
1465 (rmail-convert-file-maybe)
1466 ;; We have read the file as raw-text, so the buffer is set to
1467 ;; unibyte. Make it multibyte if necessary.
1468 (if (and rmail-enable-multibyte
1469 (not enable-multibyte-characters
))
1470 (set-buffer-multibyte t
))
1471 (goto-char (point-max))
1472 (rmail-set-message-counters)
1473 (rmail-show-message rmail-total-messages
)
1474 (run-hooks 'rmail-mode-hook
))))
1476 (defun rmail-expunge-and-save ()
1477 "Expunge and save RMAIL file."
1479 (set-buffer rmail-buffer
)
1481 ;; No need to swap buffers: rmail-write-region-annotate takes care of it.
1482 ;; (rmail-swap-buffers-maybe)
1484 (if (rmail-summary-exists)
1485 (rmail-select-summary (set-buffer-modified-p nil
))))
1487 (defun rmail-quit ()
1489 Hook `rmail-quit-hook' is run after expunging."
1491 (set-buffer rmail-buffer
)
1494 (when (boundp 'rmail-quit-hook
)
1495 (run-hooks 'rmail-quit-hook
))
1496 ;; Don't switch to the summary buffer even if it was recently visible.
1497 (when rmail-summary-buffer
1498 (with-current-buffer rmail-summary-buffer
1499 (set-buffer-modified-p nil
))
1500 (replace-buffer-in-windows rmail-summary-buffer
)
1501 (bury-buffer rmail-summary-buffer
))
1502 (let ((obuf (current-buffer)))
1504 (replace-buffer-in-windows obuf
)))
1506 (defun rmail-bury ()
1507 "Bury current Rmail buffer and its summary buffer."
1509 ;; This let var was called rmail-buffer, but that interfered
1510 ;; with the buffer-local var used in summary buffers.
1511 (let ((buffer-to-bury (current-buffer)))
1512 (if (rmail-summary-exists)
1514 (while (setq window
(get-buffer-window rmail-summary-buffer
))
1515 (quit-window nil window
))
1516 (bury-buffer rmail-summary-buffer
)))
1519 (defun rmail-duplicate-message ()
1520 "Create a duplicated copy of the current message.
1521 The duplicate copy goes into the Rmail file just after the original."
1522 ;; If we are in a summary buffer, switch to the Rmail buffer.
1523 ;; FIXME simpler to swap the contents, not the buffers?
1524 (set-buffer rmail-buffer
)
1525 (rmail-modify-format)
1526 (let ((buff (current-buffer))
1527 (n rmail-current-message
)
1528 (beg (rmail-msgbeg rmail-current-message
))
1529 (end (rmail-msgend rmail-current-message
)))
1530 (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer
))
1532 (let ((buffer-read-only nil
)
1533 (string (buffer-substring-no-properties beg end
)))
1537 (rmail-swap-buffers-maybe)
1538 (goto-char (point-max))
1539 (rmail-set-message-counters)
1540 (set-buffer-modified-p t
)
1541 (rmail-show-message-1 n
))
1542 (if (rmail-summary-exists)
1543 (rmail-select-summary (rmail-update-summary)))
1544 (message "Message duplicated"))
1547 (defun rmail-input (filename)
1548 "Run Rmail on file FILENAME."
1549 (interactive "FRun rmail on RMAIL file: ")
1552 ;; This used to scan subdirectories recursively, but someone pointed out
1553 ;; that if the user wants that, person can put all the files in one dir.
1554 ;; And the recursive scan was slow. So I took it out.
1556 (defun rmail-find-all-files (start)
1557 "Return list of file in dir START that match `rmail-secondary-file-regexp'."
1558 (if (file-accessible-directory-p start
)
1560 (let* ((case-fold-search t
)
1561 (files (directory-files start t rmail-secondary-file-regexp
)))
1562 ;; Sort here instead of in directory-files
1563 ;; because this list is usually much shorter.
1564 (sort files
'string
<))))
1566 (defun rmail-list-to-menu (menu-name l action
&optional full-name
)
1567 (let ((menu (make-sparse-keymap menu-name
))
1575 (car item
) (cdr item
) action
1577 (concat full-name
"/"
1583 (list 'lambda
() '(interactive)
1587 (concat full-name
"/" item
)
1589 rmail-secondary-file-directory
)))))
1590 (define-key menu
(vector (intern name
))
1591 (cons name command
))))
1595 ;; This command is always "disabled" when it appears in a menu.
1596 (put 'rmail-disable-menu
'menu-enable
''nil
)
1598 (defun rmail-construct-io-menu ()
1599 (let ((files (rmail-find-all-files rmail-secondary-file-directory
)))
1602 (define-key rmail-mode-map
[menu-bar classify input-menu
]
1603 (cons "Input Rmail File"
1604 (rmail-list-to-menu "Input Rmail File"
1607 (define-key rmail-mode-map
[menu-bar classify output-menu
]
1608 (cons "Output Rmail File"
1609 (rmail-list-to-menu "Output Rmail File"
1613 (define-key rmail-mode-map
[menu-bar classify input-menu
]
1614 '("Input Rmail File" . rmail-disable-menu
))
1615 (define-key rmail-mode-map
[menu-bar classify output-menu
]
1616 '("Output Rmail File" . rmail-disable-menu
)))))
1619 ;;;; *** Rmail input ***
1621 (declare-function rmail-summary-goto-msg
"rmailsum" (&optional n nowarn skip-rmail
))
1622 (declare-function rmail-summary-mark-undeleted
"rmailsum" (n))
1623 (declare-function rmail-summary-mark-deleted
"rmailsum" (&optional n undel
))
1624 (declare-function rfc822-addresses
"rfc822" (header-text))
1625 (declare-function mail-abbrev-make-syntax-table
"mailabbrev.el" ())
1627 ;; RLK feature not added in this version:
1628 ;; argument specifies inbox file or files in various ways.
1630 ;; In Babyl, the Mail: header in the preamble overrode rmail-inbox-list.
1631 ;; Mbox does not have this feature.
1632 (defun rmail-get-new-mail (&optional file-name
)
1633 "Move any new mail from this Rmail file's inbox files.
1634 The buffer-local variable `rmail-inbox-list' specifies the list
1635 of inbox files. By default, this is nil, except for your primary
1636 Rmail file `rmail-file-name'. In this case, when you first visit
1637 the Rmail file it is initialized using either
1638 `rmail-primary-inbox-list', or the \"MAIL\" environment variable,
1639 or the function `user-login-name' and the directory
1640 `rmail-spool-directory' (whose value depends on the operating system).
1642 The command `set-rmail-inbox-list' sets `rmail-inbox-list' to the
1645 You can also specify the file to get new mail from just for one
1646 instance of this command. In this case, the file of new mail is
1647 not changed or deleted. Noninteractively, you can pass the inbox
1648 file name as an argument. Interactively, a prefix argument
1649 causes us to read a file name and use that file as the inbox.
1651 If the variable `rmail-preserve-inbox' is non-nil, new mail will
1652 always be left in inbox files rather than deleted.
1654 Before doing anything, this runs `rmail-before-get-new-mail-hook'.
1655 Just before returning, it runs `rmail-after-get-new-mail-hook',
1656 whether or not there is new mail.
1658 If there is new mail, it runs `rmail-get-new-mail-hook', saves
1659 the updated file, and shows the first unseen message (which might
1660 not be a new one). It returns non-nil if it got any new messages."
1662 (list (if current-prefix-arg
1663 (read-file-name "Get new mail from file: "))))
1664 (run-hooks 'rmail-before-get-new-mail-hook
)
1665 ;; If the disk file has been changed from under us,
1666 ;; revert to it before we get new mail.
1667 (or (verify-visited-file-modtime (current-buffer))
1668 (find-file (buffer-file-name)))
1669 (set-buffer rmail-buffer
)
1670 (rmail-modify-format)
1671 (rmail-swap-buffers-maybe)
1672 (rmail-maybe-set-message-counters)
1674 ;; Get rid of all undo records for this buffer.
1675 (or (eq buffer-undo-list t
)
1676 (setq buffer-undo-list nil
))
1677 (let ((all-files (if file-name
(list file-name
) rmail-inbox-list
))
1678 (rmail-enable-multibyte (default-value 'enable-multibyte-characters
))
1682 ;; This loops if any members of the inbox list have the same
1683 ;; basename (see "name conflict" below).
1685 (let ((opoint (point))
1686 ;; If buffer has not changed yet, and has not been
1687 ;; saved yet, don't replace the old backup file now.
1688 (make-backup-files (and make-backup-files
1689 (buffer-modified-p)))
1690 (buffer-read-only nil
)
1691 ;; Don't make undo records while getting mail.
1692 (buffer-undo-list t
)
1693 delete-files success files file-last-names
)
1694 ;; Pull files off all-files onto files as long as there is
1695 ;; no name conflict. A conflict happens when two inbox
1696 ;; file names have the same last component.
1697 ;; The reason this careful handling is necessary seems
1698 ;; to be that rmail-insert-inbox-text uses .newmail-BASENAME.
1699 (while (and all-files
1700 (not (member (file-name-nondirectory (car all-files
))
1702 (setq files
(cons (car all-files
) files
)
1704 (cons (file-name-nondirectory (car all-files
)) files
))
1705 (setq all-files
(cdr all-files
)))
1706 ;; Put them back in their original order.
1707 (setq files
(nreverse files
))
1708 ;; In case of brain damage caused by require-final-newline.
1709 (goto-char (point-max))
1710 (skip-chars-backward " \t\n")
1711 (delete-region (point) (point-max))
1713 (rmail-get-new-mail-1 file-name files delete-files
)
1715 ;; Move to the first new message unless we have other unseen
1716 ;; messages before it.
1717 (if found
(rmail-show-message (rmail-first-unseen-message)))
1718 (run-hooks 'rmail-after-get-new-mail-hook
)
1720 ;; Don't leave the buffer screwed up if we get a disk-full error.
1721 (rmail-show-message))))
1723 (defvar rmail-use-spam-filter
)
1724 (declare-function rmail-get-new-mail-filter-spam
"rmail-spam-filter" (nnew))
1726 (defun rmail-get-new-mail-1 (file-name files delete-files
)
1727 "Return t if new messages are detected without error, nil otherwise."
1730 (let ((new-messages 0)
1731 (spam-filter-p (and (featurep 'rmail-spam-filter
)
1732 rmail-use-spam-filter
))
1734 result success suffix
)
1735 (narrow-to-region (point) (point))
1736 ;; Read in the contents of the inbox files, renaming them as
1737 ;; necessary, and adding to the list of files to delete
1740 (rmail-insert-inbox-text files nil
)
1741 (setq delete-files
(rmail-insert-inbox-text files t
)))
1742 ;; Scan the new text and convert each message to
1743 ;; Rmail/mbox format.
1744 (goto-char (point-min))
1745 (skip-chars-forward " \n")
1746 (narrow-to-region (point) (point-max))
1748 (setq new-messages
(rmail-add-mbox-headers)
1750 ;; Try to delete the garbage just inserted.
1751 (or success
(delete-region (point-min) (point-max)))
1752 ;; If we could not convert the file's inboxes, rename the
1753 ;; files we tried to read so we won't over and over again.
1754 (if (and (not file-name
) (not success
))
1755 (let ((delfiles delete-files
)
1758 (while (file-exists-p (format "RMAILOSE.%d" count
))
1759 (setq count
(1+ count
)))
1760 (rename-file (car delfiles
) (format "RMAILOSE.%d" count
))
1761 (setq delfiles
(cdr delfiles
))))))
1762 ;; Determine if there are messages.
1763 (unless (zerop new-messages
)
1764 ;; There are. Process them.
1765 (goto-char (point-min))
1766 (rmail-count-new-messages)
1767 (run-hooks 'rmail-get-new-mail-hook
)
1769 ;; Delete the old files, now that the Rmail file is saved.
1772 ;; First, try deleting.
1774 (delete-file (car delete-files
))
1776 ;; If we can't delete it, truncate it.
1777 (write-region (point) (point) (car delete-files
))))
1779 (setq delete-files
(cdr delete-files
)))
1780 (if (zerop new-messages
)
1781 (when (or file-name rmail-inbox-list
)
1782 (message "(No new mail has arrived)"))
1784 (setq blurb
(rmail-get-new-mail-filter-spam new-messages
))))
1785 (if (rmail-summary-exists)
1786 (rmail-select-summary (rmail-update-summary)))
1787 (setq suffix
(if (= 1 new-messages
) "" "s"))
1788 (message "%d new message%s read%s" new-messages suffix blurb
)
1789 ;; Establish the return value.
1790 (setq result
(> new-messages
0))
1793 (defun rmail-parse-url (file)
1794 "Parse the supplied URL. Return (list MAILBOX-NAME REMOTE PASSWORD GOT-PASSWORD)
1795 WHERE MAILBOX-NAME is the name of the mailbox suitable as argument to the
1796 actual version of `movemail', REMOTE is non-nil if MAILBOX-NAME refers to
1797 a remote mailbox, PASSWORD is the password if it should be
1798 supplied as a separate argument to `movemail' or nil otherwise, GOT-PASSWORD
1799 is non-nil if the user has supplied the password interactively.
1802 ((string-match "^\\([^:]+\\)://\\(\\([^:@]+\\)\\(:\\([^@]+\\)\\)?@\\)?.*" file
)
1803 (let (got-password supplied-password
1804 (proto (match-string 1 file
))
1805 (user (match-string 3 file
))
1806 (pass (match-string 5 file
))
1807 (host (substring file
(or (match-end 2)
1808 (+ 3 (match-end 1))))))
1811 (when rmail-remote-password-required
1812 (setq got-password
(not (rmail-have-password)))
1813 (setq supplied-password
(rmail-get-remote-password
1814 (string-equal proto
"imap"))))
1815 ;; The password is embedded. Strip it out since movemail
1816 ;; does not really like it, in spite of the movemail spec.
1817 (setq file
(concat proto
"://" user
"@" host
)))
1819 (if (rmail-movemail-variant-p 'emacs
)
1820 (if (string-equal proto
"pop")
1821 (list (concat "po:" user
":" host
)
1823 (or pass supplied-password
)
1825 (error "Emacs movemail does not support %s protocol" proto
))
1827 (or (string-equal proto
"pop") (string-equal proto
"imap"))
1828 (or supplied-password pass
)
1831 ((string-match "^po:\\([^:]+\\)\\(:\\(.*\\)\\)?" file
)
1832 (let (got-password supplied-password
1834 (user (match-string 1 file
))
1835 (host (match-string 3 file
)))
1837 (when rmail-remote-password-required
1838 (setq got-password
(not (rmail-have-password)))
1839 (setq supplied-password
(rmail-get-remote-password nil
)))
1841 (list file
"pop" supplied-password got-password
)))
1844 (list file nil nil nil
))))
1846 (defun rmail-unrmail-new-mail (from-file)
1847 "Replace newly read mail in Babyl format with equivalent mbox format.
1849 FROM-FILE is the Babyl file from which the new mail should be read."
1850 (let ((to-file (make-temp-file "rmail"))
1852 (unrmail from-file to-file
)
1853 (let ((inhibit-read-only t
)
1854 (coding-system-for-read 'raw-text
)
1855 (buffer-undo-list t
))
1856 (delete-region (point) (point-max))
1857 (setq size
(nth 1 (insert-file-contents to-file
)))
1858 (delete-file to-file
)
1861 (defun rmail-unrmail-new-mail-maybe (file size
)
1862 "If newly read mail from FILE is in Babyl format, convert it to mbox format.
1864 SIZE is the original size of the newly read mail.
1865 Value is the size of the newly read mail after conversion."
1866 ;; Detect previous Babyl format files.
1867 (let ((case-fold-search nil
)
1870 (cond ((looking-at "BABYL OPTIONS:")
1871 ;; The new mail is in Babyl version 5 format. Use unrmail
1873 (setq size
(rmail-unrmail-new-mail old-file
)))
1874 ((looking-at "Version: 5\n")
1875 ;; New mail is in Babyl format made by old version of
1876 ;; Rmail. Fix the babyl file header and use unrmail to
1878 (let ((buffer-read-only nil
)
1879 (write-region-annotate-functions nil
)
1880 (write-region-post-annotation-function nil
)
1881 (old-file (make-temp-file "rmail")))
1882 (insert "BABYL OPTIONS: -*- rmail -*-\n")
1884 (write-region (point) (point-max) old-file
)
1885 (setq size
(rmail-unrmail-new-mail old-file
))
1886 (delete-file old-file
))))
1889 (defun rmail-insert-inbox-text (files renamep
)
1890 ;; Detect a locked file now, so that we avoid moving mail
1891 ;; out of the real inbox file. (That could scare people.)
1892 (or (memq (file-locked-p buffer-file-name
) '(nil t
))
1893 (error "RMAIL file %s is locked"
1894 (file-name-nondirectory buffer-file-name
)))
1895 (let (file tofile delete-files movemail popmail got-password password
)
1897 ;; Handle remote mailbox names specially; don't expand as filenames
1898 ;; in case the userid contains a directory separator.
1899 (setq file
(car files
))
1900 (let ((url-data (rmail-parse-url file
)))
1901 (setq file
(nth 0 url-data
))
1902 (setq popmail
(nth 1 url-data
))
1903 (setq password
(nth 2 url-data
))
1904 (setq got-password
(nth 3 url-data
)))
1908 (setq file
(file-truename
1909 (substitute-in-file-name (expand-file-name file
)))))
1910 (setq tofile
(expand-file-name
1911 ;; Generate name to move to from inbox name,
1912 ;; in case of multiple inboxes that need moving.
1914 (file-name-nondirectory
1915 (if (memq system-type
'(windows-nt cygwin ms-dos
))
1916 ;; cannot have colons in file name
1917 (replace-regexp-in-string ":" "-" file
)
1919 ;; Use the directory of this rmail file
1920 ;; because it's a nuisance to use the homedir
1921 ;; if that is on a full disk and this rmail
1923 (file-name-directory
1924 (expand-file-name buffer-file-name
))))
1925 ;; Always use movemail to rename the file,
1926 ;; since there can be mailboxes in various directories.
1928 ;; On some systems, /usr/spool/mail/foo is a directory
1929 ;; and the actual inbox is /usr/spool/mail/foo/foo.
1930 (if (file-directory-p file
)
1931 (setq file
(expand-file-name (user-login-name)
1934 (message "Getting mail from the remote server ..."))
1935 ((and (file-exists-p tofile
)
1936 (/= 0 (nth 7 (file-attributes tofile
))))
1937 (message "Getting mail from %s..." tofile
))
1938 ((and (file-exists-p file
)
1939 (/= 0 (nth 7 (file-attributes file
))))
1940 (message "Getting mail from %s..." file
)))
1941 ;; Set TOFILE if have not already done so, and
1942 ;; rename or copy the file FILE to TOFILE if and as appropriate.
1943 (cond ((not renamep
)
1945 ((or (file-exists-p tofile
) (and (not popmail
)
1946 (not (file-exists-p file
))))
1950 (let ((errors (current-buffer)))
1951 (buffer-disable-undo errors
)
1954 (list (or rmail-movemail-program
"movemail") nil errors nil
)
1955 (if rmail-preserve-inbox
1958 (if (rmail-movemail-variant-p 'mailutils
)
1959 (append (list "--emacs") rmail-movemail-flags
)
1960 rmail-movemail-flags
)
1962 (if password
(list password
) nil
))))
1963 (apply 'call-process args
))
1964 (if (not (buffer-modified-p errors
))
1965 ;; No output => movemail won
1968 (subst-char-in-region (point-min) (point-max)
1970 (goto-char (point-max))
1971 (skip-chars-backward " \t")
1972 (delete-region (point) (point-max))
1973 (goto-char (point-min))
1974 (if (looking-at "movemail: ")
1975 (delete-region (point-min) (match-end 0)))
1977 ;; If we just read the password, most likely it is
1978 ;; wrong. Otherwise, see if there is a specific
1979 ;; reason to think that the problem is a wrong passwd.
1980 (if (or got-password
1981 (re-search-forward rmail-remote-password-error
1983 (rmail-set-remote-password nil
))
1985 ;; If using Mailutils, remove initial error code
1987 (when (rmail-movemail-variant-p 'mailutils
)
1988 (goto-char (point-min))
1989 (when (looking-at "[A-Z][A-Z0-9_]*:")
1990 (delete-region (point-min) (match-end 0))))
1992 (message "movemail: %s"
1993 (buffer-substring (point-min)
1999 ;; At this point, TOFILE contains the name to read:
2000 ;; Either the alternate name (if we renamed)
2001 ;; or the actual inbox (if not renaming).
2002 (if (file-exists-p tofile
)
2003 (let ((coding-system-for-read 'no-conversion
)
2005 (goto-char (point-max))
2007 ;; If new mail is in Babyl format, convert it to mbox.
2008 (rmail-unrmail-new-mail-maybe
2010 (nth 1 (insert-file-contents tofile
))))
2011 ;; Determine if a pair of newline message separators need
2012 ;; to be added to the new collection of messages. This is
2013 ;; the case for all new message collections added to a
2014 ;; non-empty mail file.
2015 (unless (zerop size
)
2017 (let ((start (point-min)))
2019 (unless (eq start
(point-min))
2022 (setq size
(+ 2 size
))))))
2023 (goto-char (point-max))
2024 (or (= (preceding-char) ?
\n)
2027 (if (not (and rmail-preserve-inbox
(string= file tofile
)))
2028 (setq delete-files
(cons tofile delete-files
)))))
2030 (setq files
(cdr files
)))
2033 ;; Decode the region specified by FROM and TO by CODING.
2034 ;; If CODING is nil or an invalid coding system, decode by `undecided'.
2035 (defun rmail-decode-region (from to coding
&optional destination
)
2036 (if (or (not coding
) (not (coding-system-p coding
)))
2037 (setq coding
'undecided
))
2038 ;; Use -dos decoding, to remove ^M characters left from base64 or
2039 ;; rogue qp-encoded text.
2040 (decode-coding-region
2041 from to
(coding-system-change-eol-conversion coding
1) destination
)
2042 ;; Don't reveal the fact we used -dos decoding, as users generally
2043 ;; will not expect the RMAIL buffer to use DOS EOL format.
2046 (setq buffer-file-coding-system
2047 (setq last-coding-system-used
2048 (coding-system-change-eol-conversion coding
0))))
2049 ((bufferp destination
)
2050 (with-current-buffer destination
2051 (setq buffer-file-coding-system
2052 (setq last-coding-system-used
2053 (coding-system-change-eol-conversion coding
0)))))))
2055 (defun rmail-ensure-blank-line ()
2056 "Ensure a message ends in a blank line.
2057 Call with point at the end of the message."
2060 (unless (looking-back "\n\n")
2063 (defun rmail-add-mbox-headers ()
2064 "Validate the RFC2822 format for the new messages.
2065 Point should be at the first new message.
2066 An error is signalled if the new messages are not RFC2822
2068 Unless an Rmail attribute header already exists, add it to the
2069 new messages. Return the number of new messages."
2075 (case-fold-search nil
)
2076 (delim (concat "\n\n" rmail-unix-mail-delimiter
))
2078 ;; Detect an empty inbox file.
2079 (unless (= start
(point-max))
2080 ;; Scan the new messages to establish a count and to ensure that
2081 ;; an attribute header is present.
2082 (if (looking-at rmail-unix-mail-delimiter
)
2084 ;; Determine if a new attribute header needs to be
2085 ;; added to the message.
2086 (if (search-forward "\n\n" nil t
)
2088 (setq count
(1+ count
))
2089 (narrow-to-region start
(point))
2090 (unless (mail-fetch-field rmail-attribute-header
)
2092 (insert rmail-attribute-header
": " value
"\n"))
2094 (rmail-error-bad-format))
2095 ;; Move to the next message.
2096 (if (not (re-search-forward delim nil
'move
))
2098 (goto-char (match-beginning 0))
2100 (setq start
(point)))
2101 (rmail-error-bad-format)))
2104 (defun rmail-get-header-1 (name)
2105 "Subroutine of `rmail-get-header'.
2106 Narrow to header, call `mail-fetch-field' to find header NAME."
2107 (if (search-forward "\n\n" nil t
)
2109 (narrow-to-region (point-min) (point))
2110 (mail-fetch-field name
))
2111 (rmail-error-bad-format)))
2113 (defun rmail-get-header (name &optional msgnum
)
2114 "Return the value of message header NAME, nil if it has none.
2115 MSGNUM specifies the message number to get it from.
2116 If MSGNUM is nil, use the current message."
2117 (rmail-apply-in-message msgnum
'rmail-get-header-1 name
))
2119 (defun rmail-set-header-1 (name value
)
2120 "Subroutine of `rmail-set-header'.
2121 Narrow to header, set header NAME to VALUE, replacing existing if present.
2122 VALUE nil means to remove NAME altogether."
2123 (if (search-forward "\n\n" nil t
)
2126 (narrow-to-region (point-min) (point))
2127 (goto-char (point-min))
2128 (if (re-search-forward (concat "^" (regexp-quote name
) ":") nil
'move
)
2131 (delete-region (point) (line-end-position))
2133 (delete-region (line-beginning-position)
2134 (line-beginning-position 2)))
2135 (if value
(insert name
": " value
"\n"))))
2136 (rmail-error-bad-format)))
2138 (defun rmail-set-header (name &optional msgnum value
)
2139 "Set message header NAME to VALUE in message number MSGNUM.
2140 If MSGNUM is nil, use the current message. NAME and VALUE are strings.
2141 VALUE may also be nil, meaning to remove the header."
2142 (rmail-apply-in-message msgnum
'rmail-set-header-1 name value
)
2143 (with-current-buffer rmail-buffer
2144 ;; Ensure header changes get saved.
2145 ;; (Note replacing a header with an identical copy modifies.)
2146 (set-buffer-modified-p t
)
2147 ;; However: don't save in mbox format over a Babyl file
2148 ;; merely because of this.
2149 (rmail-dont-modify-format)))
2151 ;;;; *** Rmail Attributes and Keywords ***
2153 (defun rmail-get-attr-names (&optional msg
)
2154 "Return the message attributes in a comma separated string.
2155 MSG specifies the message number to get it from.
2156 If MSG is nil, use the current message."
2157 (let ((value (rmail-get-header rmail-attribute-header msg
))
2158 (nmax (length rmail-attr-array
))
2161 (if (> (length value
) nmax
)
2162 (message "Warning: corrupt attribute header in message")
2163 (dotimes (index (length value
))
2164 (setq temp
(and (not (= ?-
(aref value index
)))
2165 (nth 1 (aref rmail-attr-array index
)))
2168 ((and temp result
) (format "%s, %s" result temp
))
2173 (defun rmail-get-keywords (&optional msg
)
2174 "Return the message keywords in a comma separated string.
2175 MSG, if non-nil, identifies the message number to use.
2176 If nil, that means the current message."
2177 (rmail-get-header rmail-keyword-header msg
))
2179 (defun rmail-get-labels (&optional msg
)
2180 "Return a string with the labels (attributes and keywords) of msg MSG.
2181 It is put in comma-separated form.
2182 MSG, if non-nil, identifies the message number to use.
2183 If nil, that means the current message."
2184 (or msg
(setq msg rmail-current-message
))
2185 (let (attr-names keywords
)
2186 ;; Combine the message attributes and keywords
2187 ;; into a comma-separated list.
2188 (setq attr-names
(rmail-get-attr-names msg
)
2189 keywords
(rmail-get-keywords msg
))
2190 (if (string= keywords
"")
2191 (setq keywords nil
))
2193 ;; FIXME ? old rmail did not have spaces in the comma-separated lists.
2194 ((and attr-names keywords
) (concat " " attr-names
"; " keywords
))
2195 (attr-names (concat " " attr-names
))
2196 (keywords (concat " " keywords
))
2199 (defun rmail-display-labels ()
2200 "Update the current messages's attributes and keywords in mode line."
2201 (let ((blurb (rmail-get-labels)))
2202 (setq mode-line-process
2204 rmail-current-message rmail-total-messages blurb
))))
2206 (defun rmail-get-attr-value (attr state
)
2207 "Return the character value for ATTR.
2208 ATTR is a (numeric) index, an offset into the mbox attribute
2209 header value. STATE is one of nil, t, or a character value."
2211 ((numberp state
) state
)
2213 (t (nth 0 (aref rmail-attr-array attr
)))))
2215 (defun rmail-set-attribute-1 (attr state
)
2216 "Subroutine of `rmail-set-attribute'.
2217 Set Rmail attribute ATTR to STATE in `rmail-attribute-header',
2218 creating the header if necessary. Returns non-nil if a
2219 significant attribute change was made."
2220 (let ((limit (search-forward "\n\n" nil t
))
2221 (value (rmail-get-attr-value attr state
))
2222 (inhibit-read-only t
)
2224 (goto-char (point-min))
2225 (if (search-forward (concat rmail-attribute-header
": ") limit t
)
2226 ;; If this message already records attributes, just change the
2227 ;; value for this one.
2228 (let ((missing (- (+ (point) attr
) (line-end-position))))
2229 ;; Position point at this attribute, adding attributes if necessary.
2233 (insert-char ?- missing
)
2235 (forward-char attr
))
2236 ;; Change this attribute.
2237 (when (/= value
(char-after))
2241 ;; Otherwise add a header line to record the attributes and set
2242 ;; all but this one to no.
2243 (let ((header-value "--------"))
2244 (aset header-value attr value
)
2245 (goto-char (if limit
(1- limit
) (point-max)))
2246 (setq altered
(/= value ?-
))
2247 (insert rmail-attribute-header
": " header-value
"\n")))
2250 (defun rmail-set-attribute (attr state
&optional msgnum
)
2251 "Turn an attribute of a message on or off according to STATE.
2252 STATE is either nil or the character (numeric) value associated
2253 with the state (nil represents off and non-nil represents on).
2254 ATTR is either the index number of the attribute, or a string,
2255 both from `rmail-attr-array'. MSGNUM is message number to
2256 change; nil means current message."
2258 (nmax (length rmail-attr-array
)))
2259 (while (and (stringp attr
)
2261 (if (string-equal attr
(cadr (aref rmail-attr-array n
)))
2265 (error "Unknown attribute `%s'" attr
))
2266 ;; Ask for confirmation before setting any attribute except `unseen'
2267 ;; if it would force a format change.
2268 (unless (= attr rmail-unseen-attr-index
)
2269 (rmail-modify-format))
2270 (with-current-buffer rmail-buffer
2271 (or msgnum
(setq msgnum rmail-current-message
))
2273 ;; The "deleted" attribute is also stored in a special vector so
2275 (if (= attr rmail-deleted-attr-index
)
2276 (rmail-set-message-deleted-p msgnum state
))
2278 (rmail-apply-in-message msgnum
'rmail-set-attribute-1 attr state
)
2279 (if (= msgnum rmail-current-message
)
2280 (rmail-display-labels)))
2281 ;; Don't save in mbox format over a Babyl file
2282 ;; merely because of a change in `unseen' attribute.
2283 (if (= attr rmail-unseen-attr-index
)
2284 (rmail-dont-modify-format)
2285 ;; Otherwise, if we modified the file text via the view buffer,
2286 ;; mark the main buffer modified too.
2287 (set-buffer-modified-p t
))))))
2289 (defun rmail-message-attr-p (msg attrs
)
2290 "Return non-nil if message number MSG has attributes matching regexp ATTRS."
2291 (let ((value (rmail-get-header rmail-attribute-header msg
)))
2292 (and value
(string-match attrs value
))))
2294 (defun rmail-message-unseen-p (msgnum)
2295 "Return non-nil if message number MSGNUM has the unseen attribute."
2296 (rmail-message-attr-p msgnum
"......U"))
2298 ;; FIXME rmail-get-labels does some formatting (eg leading space, `;'
2299 ;; between attributes and labels), so this might not do what you want.
2300 ;; Eg see rmail-sort-by-labels. rmail-get-labels could have an
2301 ;; optional `noformat' argument.
2302 (defun rmail-message-labels-p (msg labels
)
2303 "Return non-nil if message number MSG has labels matching regexp LABELS."
2304 (string-match labels
(rmail-get-labels msg
)))
2306 ;;;; *** Rmail Message Selection And Support ***
2308 (defun rmail-msgend (n)
2309 "Return the end position for message number N."
2310 (marker-position (aref rmail-message-vector
(1+ n
))))
2312 (defun rmail-msgbeg (n)
2313 "Return the start position for message number N."
2314 (marker-position (aref rmail-message-vector n
)))
2316 (defun rmail-apply-in-message (msgnum function
&rest args
)
2317 "Call FUNCTION on ARGS while narrowed to message MSGNUM.
2318 Point is at the start of the message.
2319 This returns what the call to FUNCTION returns.
2320 If MSGNUM is nil, use the current message."
2321 (with-current-buffer rmail-buffer
2322 (or msgnum
(setq msgnum rmail-current-message
))
2324 (let (msgbeg msgend
)
2325 (setq msgbeg
(rmail-msgbeg msgnum
))
2326 (setq msgend
(rmail-msgend msgnum
))
2327 ;; All access to the rmail-buffer's local variables is now finished...
2329 ;; ... so it is ok to go to a different buffer.
2330 (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer
))
2335 (narrow-to-region msgbeg msgend
)
2336 (apply function args
))))))))
2338 ;; Unused (save for commented out code in rmailedit.el).
2339 (defun rmail-widen-to-current-msgbeg (function)
2340 "Call FUNCTION with point at start of internal data of current message.
2341 Assumes that bounds were previously narrowed to display the message in Rmail.
2342 The bounds are widened enough to move point where desired, then narrowed
2345 FUNCTION may not change the visible text of the message, but it may
2346 change the invisible header text."
2350 (narrow-to-region (rmail-msgbeg rmail-current-message
)
2352 (goto-char (point-min))
2354 ;; Note: we don't use save-restriction because that does not work right
2355 ;; if changes are made outside the saved restriction
2356 ;; before that restriction is restored.
2357 (narrow-to-region (rmail-msgbeg rmail-current-message
)
2358 (rmail-msgend rmail-current-message
)))))
2360 ;; Manage the message vectors and counters.
2362 (defun rmail-forget-messages ()
2364 (if (vectorp rmail-message-vector
)
2365 (let* ((v rmail-message-vector
)
2369 (move-marker (aref v i
) nil
)))))
2370 (setq rmail-message-vector nil
)
2371 (setq rmail-msgref-vector nil
)
2372 (setq rmail-deleted-vector nil
)))
2374 (defun rmail-maybe-set-message-counters ()
2375 (if (not (and rmail-deleted-vector
2376 rmail-message-vector
2377 rmail-current-message
2378 rmail-total-messages
))
2379 (rmail-set-message-counters)))
2381 (defun rmail-count-new-messages (&optional nomsg
)
2382 "Count the number of new messages.
2383 The buffer should be narrowed to include only the new messages.
2384 Output a helpful message unless NOMSG is non-nil."
2385 (let* ((case-fold-search nil
)
2389 (or nomsg
(message "Counting new messages..."))
2390 (goto-char (point-max))
2391 ;; Put at the end of messages-head
2392 ;; the entry for message N+1, which marks
2393 ;; the end of message N. (N = number of messages).
2394 (setq messages-head
(list (point-marker)))
2395 (rmail-set-message-counters-counter (point-min))
2396 (setq rmail-current-message
(1+ rmail-total-messages
))
2397 (setq rmail-total-messages
2398 (+ rmail-total-messages total-messages
))
2399 (setq rmail-message-vector
2400 (vconcat rmail-message-vector
(cdr messages-head
)))
2401 (aset rmail-message-vector
2402 rmail-current-message
(car messages-head
))
2403 (setq rmail-deleted-vector
2404 (concat rmail-deleted-vector deleted-head
))
2405 (setq rmail-summary-vector
2406 (vconcat rmail-summary-vector
(make-vector total-messages nil
)))
2407 (setq rmail-msgref-vector
2408 (vconcat rmail-msgref-vector
(make-vector total-messages nil
)))
2409 ;; Fill in the new elements of rmail-msgref-vector.
2410 (let ((i (1+ (- rmail-total-messages total-messages
))))
2411 (while (<= i rmail-total-messages
)
2412 (aset rmail-msgref-vector i
(list i
))
2414 (goto-char (point-min))
2415 (or nomsg
(message "Counting new messages...done (%d)" total-messages
))))
2417 (defun rmail-set-message-counters ()
2418 (rmail-forget-messages)
2422 (let* ((point-save (point))
2424 (messages-after-point)
2425 (case-fold-search nil
)
2428 ;; Determine how many messages follow point.
2429 (message "Counting messages...")
2430 (goto-char (point-max))
2431 ;; Put at the end of messages-head
2432 ;; the entry for message N+1, which marks
2433 ;; the end of message N. (N = number of messages).
2434 (setq messages-head
(list (point-marker)))
2435 (setq messages-after-point
2436 (or (rmail-set-message-counters-counter (min (point) point-save
))
2439 (setq rmail-total-messages total-messages
)
2440 (setq rmail-current-message
2442 (max 1 (- total-messages messages-after-point
))))
2444 ;; Make an element 0 in rmail-message-vector and rmail-deleted-vector
2445 ;; which will never be used.
2446 (push nil messages-head
)
2447 (push ?
0 deleted-head
)
2448 (setq rmail-message-vector
(apply 'vector messages-head
)
2449 rmail-deleted-vector
(concat deleted-head
))
2451 (setq rmail-summary-vector
(make-vector rmail-total-messages nil
)
2452 rmail-msgref-vector
(make-vector (1+ rmail-total-messages
) nil
))
2455 (while (<= i rmail-total-messages
)
2456 (aset rmail-msgref-vector i
(list i
))
2459 (while (<= i rmail-total-messages
)
2460 (rmail-set-message-deleted-p i
(rmail-message-attr-p i
".D"))
2462 (message "Counting messages...done")))))
2465 (defsubst rmail-collect-deleted
(message-end)
2466 "Collect the message deletion flags for each message.
2467 MESSAGE-END is the buffer position corresponding to the end of
2468 the message. Point is at the beginning of the message."
2469 ;; NOTE: This piece of code will be executed on a per-message basis.
2470 ;; In the face of thousands of messages, it has to be as fast as
2471 ;; possible, hence some brute force constant use is employed in
2472 ;; addition to inlining.
2475 (cons (if (and (search-forward (concat rmail-attribute-header
": ") message-end t
)
2478 ?\s
) deleted-head
))))
2480 (defun rmail-set-message-counters-counter (&optional spot-to-find
)
2481 "Collect the start positions of messages in list `messages-head'.
2482 Return the number of messages after the one containing SPOT-TO-FIND."
2483 (let ((start (point))
2484 messages-after-spot
)
2485 (while (search-backward "\n\nFrom " nil t
)
2487 (when (looking-at rmail-unix-mail-delimiter
)
2488 (if (and (<= (point) spot-to-find
)
2489 (null messages-after-spot
))
2490 (setq messages-after-spot total-messages
))
2491 (rmail-collect-deleted start
)
2492 (setq messages-head
(cons (point-marker) messages-head
)
2493 total-messages
(1+ total-messages
)
2495 ;; Show progress after every 20 messages or so.
2496 (if (zerop (% total-messages
20))
2497 (message "Counting messages...%d" total-messages
))))
2498 ;; Handle the first message, maybe.
2499 (goto-char (point-min))
2500 (unless (not (looking-at rmail-unix-mail-delimiter
))
2501 (if (and (<= (point) spot-to-find
)
2502 (null messages-after-spot
))
2503 (setq messages-after-spot total-messages
))
2504 (rmail-collect-deleted start
)
2505 (setq messages-head
(cons (point-marker) messages-head
)
2506 total-messages
(1+ total-messages
)))
2507 messages-after-spot
))
2509 ;; Display a message.
2511 ;;;; *** Rmail Message Formatting and Header Manipulation ***
2513 ;; This is used outside of rmail.
2514 (defun rmail-msg-is-pruned ()
2515 "Return nil if the current message is showing full headers."
2516 (with-current-buffer (if (rmail-buffers-swapped-p) rmail-view-buffer
2518 (eq rmail-header-style
'normal
)))
2520 (defun rmail-toggle-header (&optional arg
)
2521 "Toggle between showing full and normal message headers.
2522 With optional integer ARG, show the normal message header if ARG
2523 is greater than zero; otherwise, show it in full."
2525 (let ((rmail-header-style
2527 (if (> arg
0) 'normal
'full
)
2528 (if (rmail-msg-is-pruned) 'full
'normal
))))
2529 (rmail-show-message)))
2531 (defun rmail-beginning-of-message ()
2532 "Show current message starting from the beginning."
2534 (let ((rmail-show-message-hook '((lambda () (goto-char (point-min)))))
2535 (rmail-header-style (with-current-buffer (if (rmail-buffers-swapped-p)
2538 rmail-header-style
)))
2539 (rmail-show-message rmail-current-message
)))
2541 (defun rmail-end-of-message ()
2542 "Show bottom of current message."
2544 (let ((rmail-show-message-hook '((lambda ()
2545 (goto-char (point-max))
2546 (recenter (1- (window-height))))))
2547 (rmail-header-style (with-current-buffer (if (rmail-buffers-swapped-p)
2550 rmail-header-style
)))
2551 (rmail-show-message rmail-current-message
)))
2553 (defun rmail-unknown-mail-followup-to ()
2554 "Handle a \"Mail-Followup-To\" header field with an unknown mailing list.
2555 Ask the user whether to add that list name to `mail-mailing-lists'."
2556 ;; FIXME s-r not needed? Use rmail-get-header?
2557 ;; We have not narrowed to the headers at ths point?
2559 (let ((mail-followup-to (mail-fetch-field "mail-followup-to" nil t
)))
2560 (when mail-followup-to
2563 (mail-strip-quoted-names mail-followup-to
)
2564 ",[[:space:]]+" t
)))
2565 (dolist (addr addresses
)
2566 (when (and (not (member addr mail-mailing-lists
))
2568 ;; taken from rmailsum.el
2570 (or rmail-user-mail-address-regexp
2572 (regexp-quote (user-login-name))
2575 (or user-mail-address
2576 (concat (user-login-name) "@"
2577 (or mail-host-address
2582 (format "Add `%s' to `mail-mailing-lists'? "
2584 (customize-save-variable 'mail-mailing-lists
2585 (cons addr mail-mailing-lists
)))))))))
2587 (defun rmail-widen ()
2588 "Display the entire mailbox file."
2590 (rmail-swap-buffers-maybe)
2593 (defun rmail-no-mail-p ()
2594 "Return nil if there is mail, else \"No mail.\"."
2595 (if (zerop rmail-total-messages
)
2597 (with-current-buffer rmail-view-buffer
2601 (defun rmail-show-message (&optional n no-summary
)
2602 "Show message number N (prefix argument), counting from start of file.
2603 If summary buffer is currently displayed, update current message there also.
2604 N defaults to the current message."
2606 (or (eq major-mode
'rmail-mode
)
2607 (switch-to-buffer rmail-buffer
))
2608 ;; FIXME: Why do we swap the raw data back in?
2609 (rmail-swap-buffers-maybe)
2610 (rmail-maybe-set-message-counters)
2612 (let ((blurb (rmail-show-message-1 n
)))
2613 (or (zerop rmail-total-messages
)
2615 (when mail-mailing-lists
2616 (rmail-unknown-mail-followup-to))
2617 (if transient-mark-mode
(deactivate-mark))
2618 ;; If there is a summary buffer, try to move to this message
2619 ;; in that buffer. But don't complain if this message is
2620 ;; not mentioned in the summary. Don't do this at all if we
2621 ;; were called on behalf of cursor motion in the summary
2623 (and (rmail-summary-exists) (not no-summary
)
2624 (let ((curr-msg rmail-current-message
))
2625 (rmail-select-summary
2626 (rmail-summary-goto-msg curr-msg t t
))))
2627 (with-current-buffer rmail-buffer
2628 (rmail-auto-file))))
2632 (defun rmail-is-text-p ()
2633 "Return t if the region contains a text message, nil otherwise."
2635 (let ((text-regexp "\\(text\\|message\\)/")
2636 (content-type-header (mail-fetch-field "content-type")))
2637 ;; The message is text if either there is no content type header
2638 ;; (a default of "text/plain; charset=US-ASCII" is assumed) or
2639 ;; the base content type is either text or message.
2640 (or (not content-type-header
)
2641 (string-match text-regexp content-type-header
)))))
2643 (defcustom rmail-show-message-verbose-min
200000
2644 "Message size at which to show progress messages for displaying it."
2649 (defun rmail-show-message-1 (&optional msg
)
2650 "Show message MSG (default: current message) using `rmail-view-buffer'.
2651 Return text to display in the minibuffer if MSG is out of
2652 range (displaying a reasonable choice as well), nil otherwise.
2653 The current mail message becomes the message displayed."
2654 (let ((mbox-buf rmail-buffer
)
2655 (view-buf rmail-view-buffer
)
2656 blurb beg end body-start coding-system character-coding
2657 is-text-message header-style
)
2659 (setq msg rmail-current-message
))
2660 (unless (setq blurb
(rmail-no-mail-p))
2663 rmail-current-message
1
2664 blurb
"No previous message"))
2665 ((> msg rmail-total-messages
)
2666 (setq msg rmail-total-messages
2667 rmail-current-message rmail-total-messages
2668 blurb
"No following message"))
2669 (t (setq rmail-current-message msg
)))
2670 (with-current-buffer rmail-buffer
2671 (setq header-style rmail-header-style
)
2672 ;; Mark the message as seen
2673 (rmail-set-attribute rmail-unseen-attr-index nil
)
2674 ;; bracket the message in the mail
2675 ;; buffer and determine the coding system the transfer encoding.
2676 (rmail-swap-buffers-maybe)
2677 (setq beg
(rmail-msgbeg msg
)
2678 end
(rmail-msgend msg
))
2679 (when (> (- end beg
) rmail-show-message-verbose-min
)
2680 (message "Showing message %d" msg
))
2681 (narrow-to-region beg end
)
2683 (with-current-buffer rmail-view-buffer
2684 ;; We give the view buffer a buffer-local value of
2685 ;; rmail-header-style based on the binding in effect when
2686 ;; this function is called; `rmail-toggle-headers' can
2687 ;; inspect this value to determine how to toggle.
2688 (set (make-local-variable 'rmail-header-style
) header-style
))
2689 (if (and rmail-enable-mime
2690 (re-search-forward "mime-version: 1.0" nil t
))
2691 (let ((rmail-buffer mbox-buf
)
2692 (rmail-view-buffer view-buf
))
2693 (funcall rmail-show-mime-function
))
2694 (setq body-start
(search-forward "\n\n" nil t
))
2695 (narrow-to-region beg
(point))
2698 (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t
)
2699 (setq coding-system
(intern (match-string 1)))
2700 (setq coding-system
(rmail-get-coding-system))))
2701 (setq character-coding
(mail-fetch-field "content-transfer-encoding")
2702 is-text-message
(rmail-is-text-p))
2703 (if character-coding
2704 (setq character-coding
(downcase character-coding
)))
2705 (narrow-to-region beg end
)
2706 ;; Decode the message body into an empty view buffer using a
2707 ;; unibyte temporary buffer where the character decoding takes
2709 (with-current-buffer rmail-view-buffer
2711 (if (null character-coding
)
2712 ;; Do it directly since that is fast.
2713 (rmail-decode-region body-start end coding-system view-buf
)
2714 ;; Can this be done directly, skipping the temp buffer?
2716 (set-buffer-multibyte nil
)
2717 (insert-buffer-substring mbox-buf body-start end
)
2719 ((string= character-coding
"quoted-printable")
2721 (or (mail-unquote-printable-region (point-min) (point-max)
2723 (message "Malformed MIME quoted-printable message")))
2724 ((and (string= character-coding
"base64") is-text-message
)
2726 (base64-decode-region (point-min) (point-max))
2727 (error (message "%s" (cdr err
)))))
2728 ((eq character-coding
'uuencode
)
2729 (error "uuencoded messages are not supported yet"))
2731 (rmail-decode-region (point-min) (point-max)
2732 coding-system view-buf
)))
2733 (with-current-buffer rmail-view-buffer
2734 ;; Prepare the separator (blank line) before the body.
2735 (goto-char (point-min))
2737 ;; Unquote quoted From lines
2738 (while (re-search-forward "^>+From " nil t
)
2742 (goto-char (point-min)))
2743 ;; Copy the headers to the front of the message view buffer.
2744 (rmail-copy-headers beg end
))
2745 ;; highlight the message, activate any URL like text and add
2746 ;; special highlighting for and quoted material.
2747 (with-current-buffer rmail-view-buffer
2748 (goto-char (point-min))
2749 (rmail-highlight-headers)
2750 ;(rmail-activate-urls)
2751 ;(rmail-process-quoted-material)
2753 ;; Update the mode-line with message status information and swap
2754 ;; the view buffer/mail buffer contents.
2755 (rmail-display-labels)
2756 (rmail-swap-buffers)
2757 (setq rmail-buffer-swapped t
)
2758 (run-hooks 'rmail-show-message-hook
)
2759 (when (> (- end beg
) rmail-show-message-verbose-min
)
2760 (message "Showing message %d...done" msg
))))
2763 (defun rmail-copy-headers (beg end
&optional ignored-headers
)
2764 "Copy displayed header fields to the message viewer buffer.
2765 BEG and END marks the start and end positions of the message in
2766 the mbox buffer. If the optional argument IGNORED-HEADERS is
2767 non-nil, ignore all header fields whose names match that regexp.
2768 Otherwise, if `rmail-displayed-headers' is non-nil, copy only
2769 those header fields whose names match that regexp. Otherwise,
2770 copy all header fields whose names do not match
2771 `rmail-ignored-headers' (unless they also match
2772 `rmail-nonignored-headers'). Moves point in the message viewer
2773 buffer to the end of the headers."
2774 (let ((header-start-regexp "\n[^ \t]")
2776 (with-current-buffer rmail-buffer
2777 (when (search-forward "\n\n" nil t
)
2780 ;; Put point right after the From header line.
2781 (narrow-to-region beg
(point))
2782 (goto-char (point-min))
2783 (unless (re-search-forward header-start-regexp nil t
)
2784 (rmail-error-bad-format))
2787 ;; Handle the case where all headers should be copied.
2788 ((eq rmail-header-style
'full
)
2789 (prepend-to-buffer rmail-view-buffer beg
(point-max))
2790 ;; rmail-show-message-1 expects this function to leave point
2791 ;; at the end of the headers.
2793 (let ((len (- (point-max) beg
)))
2794 (with-current-buffer rmail-view-buffer
2795 (goto-char (1+ len
)))))
2797 ;; Handle the case where the headers matching the displayed
2798 ;; headers regexp should be copied.
2799 ((and rmail-displayed-headers
(null ignored-headers
))
2802 (setq lim
(if (re-search-forward header-start-regexp nil t
)
2803 (1+ (match-beginning 0))
2805 (when (looking-at rmail-displayed-headers
)
2806 (append-to-buffer rmail-view-buffer
(point) lim
))
2808 ;; Handle the ignored headers.
2809 ((or ignored-headers
(setq ignored-headers rmail-ignored-headers
))
2810 (while (and ignored-headers
(not (eobp)))
2812 (setq lim
(if (re-search-forward header-start-regexp nil t
)
2813 (1+ (match-beginning 0))
2815 (if (and (looking-at ignored-headers
)
2816 (not (looking-at rmail-nonignored-headers
)))
2818 (append-to-buffer rmail-view-buffer
(point) lim
)
2820 (t (error "No headers selected for display!"))))))))
2822 (defun rmail-redecode-body (coding)
2823 "Decode the body of the current message using coding system CODING.
2824 This is useful with mail messages that have malformed or missing
2827 This function assumes that the current message is already decoded
2828 and displayed in the RMAIL buffer, but the coding system used to
2829 decode it was incorrect. It then decodes the message again,
2830 using the coding system CODING."
2831 (interactive "zCoding system for re-decoding this message: ")
2832 (when (not rmail-enable-mime
)
2833 (with-current-buffer rmail-buffer
2834 (rmail-swap-buffers-maybe)
2837 (let ((msgbeg (rmail-msgbeg rmail-current-message
))
2838 (msgend (rmail-msgend rmail-current-message
))
2839 (buffer-read-only nil
)
2840 body-start x-coding-header old-coding
)
2841 (narrow-to-region msgbeg msgend
)
2842 (goto-char (point-min))
2843 (unless (setq body-start
(search-forward "\n\n" (point-max) 1))
2844 (error "No message body"))
2847 ;; Narrow to headers
2848 (narrow-to-region (point-min) body-start
)
2849 (setq x-coding-header
(goto-char (point-min)))
2850 (if (not (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t
))
2851 (setq old-coding
(rmail-get-coding-system))
2852 (setq old-coding
(intern (match-string 1)))
2853 (setq x-coding-header
(point)))
2854 (check-coding-system old-coding
)
2855 ;; Make sure the new coding system uses the same EOL
2856 ;; conversion, to prevent ^M characters from popping up
2857 ;; all over the place.
2858 (let ((eol-type (coding-system-eol-type old-coding
)))
2859 (if (numberp eol-type
)
2861 (coding-system-change-eol-conversion coding eol-type
))))
2862 (when (not (coding-system-equal
2863 (coding-system-base old-coding
)
2864 (coding-system-base coding
)))
2865 ;; Rewrite the coding-system header.
2866 (goto-char x-coding-header
)
2867 (if (> (point) (point-min))
2868 (delete-region (line-beginning-position) (point))
2872 (insert "X-Coding-System: "
2873 (symbol-name coding
))))
2874 (rmail-show-message))))))
2876 (defun rmail-highlight-headers ()
2877 "Highlight the headers specified by `rmail-highlighted-headers'.
2878 Uses the face specified by `rmail-highlight-face'."
2879 (if rmail-highlighted-headers
2881 (search-forward "\n\n" nil
'move
)
2883 (narrow-to-region (point-min) (point))
2884 (let ((case-fold-search t
)
2885 (inhibit-read-only t
)
2886 ;; When rmail-highlight-face is removed, just
2887 ;; use 'rmail-highlight here.
2888 (face (or rmail-highlight-face
2889 (if (face-differs-from-default-p 'bold
)
2891 ;; List of overlays to reuse.
2892 (overlays rmail-overlay-list
))
2893 (goto-char (point-min))
2894 (while (re-search-forward rmail-highlighted-headers nil t
)
2895 (skip-chars-forward " \t")
2898 (while (progn (forward-line 1)
2899 (looking-at "[ \t]")))
2900 ;; Back up over newline, then trailing spaces or tabs
2902 (while (member (preceding-char) '(? ?
\t))
2905 ;; Reuse an overlay we already have.
2907 (setq overlay
(car overlays
)
2908 overlays
(cdr overlays
))
2909 (overlay-put overlay
'face face
)
2910 (move-overlay overlay beg
(point)))
2911 ;; Make a new overlay and add it to
2912 ;; rmail-overlay-list.
2913 (setq overlay
(make-overlay beg
(point)))
2914 (overlay-put overlay
'face face
)
2915 (setq rmail-overlay-list
2916 (cons overlay rmail-overlay-list
))))))))))
2918 (defun rmail-auto-file ()
2919 "Automatically move a message into a sub-folder based on criteria.
2920 Called when a new message is displayed."
2921 (if (or (zerop rmail-total-messages
)
2922 (rmail-message-attr-p rmail-current-message
"...F")
2923 (not (string= (buffer-file-name)
2924 (expand-file-name rmail-file-name
))))
2925 ;; Do nothing if the message has already been filed or if there
2928 ;; Find out some basics (common fields)
2929 (let ((from (mail-fetch-field "from"))
2930 (subj (mail-fetch-field "subject"))
2931 (to (concat (mail-fetch-field "to") "," (mail-fetch-field "cc")))
2932 (d rmail-automatic-folder-directives
)
2933 (directive-loop nil
)
2936 (setq folder
(car (car d
))
2937 directive-loop
(cdr (car d
)))
2938 (while (and (car directive-loop
)
2940 ((string= (car directive-loop
) "from") from
)
2941 ((string= (car directive-loop
) "to") to
)
2942 ((string= (car directive-loop
) "subject") subj
)
2943 (t (mail-fetch-field (car directive-loop
))))))
2944 (and f
(string-match (car (cdr directive-loop
)) f
))))
2945 (setq directive-loop
(cdr (cdr directive-loop
))))
2946 ;; If there are no directives left, then it was a complete match.
2947 (if (null directive-loop
)
2949 (rmail-delete-forward)
2950 (if (string= "/dev/null" folder
)
2951 (rmail-delete-message)
2952 (rmail-output folder
1)
2954 (setq d
(cdr d
))))))
2956 ;; Simple message motion commands.
2958 (defun rmail-next-message (n)
2959 "Show following message whether deleted or not.
2960 With prefix arg N, moves forward N messages, or backward if N is negative."
2962 (set-buffer rmail-buffer
)
2963 (rmail-maybe-set-message-counters)
2964 (rmail-show-message (+ rmail-current-message n
)))
2966 (defun rmail-previous-message (n)
2967 "Show previous message whether deleted or not.
2968 With prefix arg N, moves backward N messages, or forward if N is negative."
2970 (rmail-next-message (- n
)))
2972 (defun rmail-next-undeleted-message (n)
2973 "Show following non-deleted message.
2974 With prefix arg N, moves forward N non-deleted messages,
2975 or backward if N is negative.
2977 Returns t if a new message is being shown, nil otherwise."
2979 (set-buffer rmail-buffer
)
2980 (rmail-maybe-set-message-counters)
2981 (let ((lastwin rmail-current-message
)
2982 (current rmail-current-message
))
2983 (while (and (> n
0) (< current rmail-total-messages
))
2984 (setq current
(1+ current
))
2985 (if (not (rmail-message-deleted-p current
))
2986 (setq lastwin current n
(1- n
))))
2987 (while (and (< n
0) (> current
1))
2988 (setq current
(1- current
))
2989 (if (not (rmail-message-deleted-p current
))
2990 (setq lastwin current n
(1+ n
))))
2991 (if (/= lastwin rmail-current-message
)
2992 (progn (rmail-show-message lastwin
)
2995 (message "No previous nondeleted message"))
2997 (message "No following nondeleted message"))
3000 (defun rmail-previous-undeleted-message (n)
3001 "Show previous non-deleted message.
3002 With prefix argument N, moves backward N non-deleted messages,
3003 or forward if N is negative."
3005 (rmail-next-undeleted-message (- n
)))
3007 (defun rmail-first-message ()
3008 "Show first message in file."
3010 (rmail-maybe-set-message-counters)
3011 (rmail-show-message 1))
3013 (defun rmail-last-message ()
3014 "Show last message in file."
3016 (rmail-maybe-set-message-counters)
3017 (rmail-show-message rmail-total-messages
))
3019 (defun rmail-what-message ()
3020 "For debugging Rmail: find the message number that point is in."
3021 (let* ((high rmail-total-messages
)
3024 (where (with-current-buffer (if (rmail-buffers-swapped-p)
3028 (while (> (- high low
) 1)
3029 (if (>= where
(rmail-msgbeg mid
))
3032 (setq mid
(+ low
(/ (- high low
) 2))))
3033 (if (>= where
(rmail-msgbeg high
)) high low
)))
3035 ;; Searching in Rmail file.
3037 (defun rmail-search-message (msg regexp
)
3038 "Return non-nil, if for message number MSG, regexp REGEXP matches."
3039 ;; This is adequate because its only caller, rmail-search,
3040 ;; unswaps the buffers.
3041 (goto-char (rmail-msgbeg msg
))
3042 (if rmail-enable-mime
3043 (if rmail-search-mime-message-function
3044 (funcall rmail-search-mime-message-function msg regexp
)
3045 (error "You must set `rmail-search-mime-message-function'"))
3046 (re-search-forward regexp
(rmail-msgend msg
) t
)))
3048 (defvar rmail-search-last-regexp nil
)
3049 (defun rmail-search (regexp &optional n
)
3050 "Show message containing next match for REGEXP (but not the current msg).
3051 Prefix argument gives repeat count; negative argument means search
3052 backwards (through earlier messages).
3053 Interactively, empty argument means use same regexp used last time."
3055 (let* ((reversep (< (prefix-numeric-value current-prefix-arg
) 0))
3057 (concat (if reversep
"Reverse " "") "Rmail search (regexp"))
3061 (if rmail-search-last-regexp
3062 (concat ", default "
3063 rmail-search-last-regexp
"): ")
3065 (setq regexp
(read-string prompt
))
3066 (cond ((not (equal regexp
""))
3067 (setq rmail-search-last-regexp regexp
))
3068 ((not rmail-search-last-regexp
)
3069 (error "No previous Rmail search string")))
3070 (list rmail-search-last-regexp
3071 (prefix-numeric-value current-prefix-arg
))))
3073 (message "%sRmail search for %s..."
3074 (if (< n
0) "Reverse " "")
3076 (set-buffer rmail-buffer
)
3077 (let ((orig-message rmail-current-message
)
3078 (msg rmail-current-message
)
3080 (opoint (if (rmail-buffers-swapped-p) (point)))
3082 (rmail-swap-buffers-maybe)
3083 (rmail-maybe-set-message-counters)
3087 ;; Check messages one by one, advancing message number up or
3088 ;; down but searching forward through each message.
3090 (while (and (null found
) (> msg
1))
3092 found
(rmail-search-message msg regexp
)))
3093 (while (and (null found
) (< msg rmail-total-messages
))
3095 found
(rmail-search-message msg regexp
))))
3096 (setq n
(+ n
(if reversep
1 -
1))))
3099 (rmail-show-message msg
)
3100 ;; Search forward (if this is a normal search) or backward
3101 ;; (if this is a reverse search) through this message to
3102 ;; position point. This search may fail because REGEXP
3103 ;; was found in the hidden portion of this message. In
3104 ;; that case, move point to the beginning of visible
3108 (goto-char (point-max))
3109 (re-search-backward regexp nil
'move
))
3110 (goto-char (point-min))
3111 (re-search-forward regexp nil t
))
3112 (message "%sRmail search for %s...done"
3113 (if reversep
"Reverse " "")
3115 (rmail-show-message orig-message
)
3116 (if opoint
(goto-char opoint
))
3118 (message "Search failed: %s" regexp
)))))
3120 (defun rmail-search-backwards (regexp &optional n
)
3121 "Show message containing previous match for REGEXP.
3122 Prefix argument gives repeat count; negative argument means search
3123 forward (through later messages).
3124 Interactively, empty argument means use same regexp used last time."
3126 (let* ((reversep (>= (prefix-numeric-value current-prefix-arg
) 0))
3128 (concat (if reversep
"Reverse " "") "Rmail search (regexp"))
3132 (if rmail-search-last-regexp
3133 (concat ", default "
3134 rmail-search-last-regexp
"): ")
3136 (setq regexp
(read-string prompt
))
3137 (cond ((not (equal regexp
""))
3138 (setq rmail-search-last-regexp regexp
))
3139 ((not rmail-search-last-regexp
)
3140 (error "No previous Rmail search string")))
3141 (list rmail-search-last-regexp
3142 (prefix-numeric-value current-prefix-arg
))))
3143 (rmail-search regexp
(- (or n
1))))
3145 ;; Scan for attributes, and compare subjects.
3147 (defun rmail-first-unseen-message ()
3148 "Return message number of first message which has `unseen' attribute."
3149 (rmail-maybe-set-message-counters)
3154 (while (and (not found
) (<= current rmail-total-messages
))
3155 (if (rmail-message-attr-p current
"......U")
3156 (setq found current
))
3157 (setq current
(1+ current
))))
3160 (defun rmail-simplified-subject (&optional msgnum
)
3161 "Return the simplified subject of message MSGNUM (or current message).
3162 Simplifying the subject means stripping leading and trailing whitespace,
3163 and typical reply prefixes such as Re:."
3164 (let ((subject (or (rmail-get-header "Subject" msgnum
) "")))
3165 (if (string-match "\\`[ \t]+" subject
)
3166 (setq subject
(substring subject
(match-end 0))))
3167 (if (string-match rmail-reply-regexp subject
)
3168 (setq subject
(substring subject
(match-end 0))))
3169 (if (string-match "[ \t]+\\'" subject
)
3170 (setq subject
(substring subject
0 (match-beginning 0))))
3171 ;; If Subject is long, mailers will break it into several lines at
3172 ;; arbitrary places, so normalize whitespace by replacing every
3173 ;; run of whitespace characters with a single space.
3174 (setq subject
(replace-regexp-in-string "[ \t\n]+" " " subject
))
3177 (defun rmail-simplified-subject-regexp ()
3178 "Return a regular expression matching the current simplified subject.
3179 The idea is to match it against simplified subjects of other messages."
3180 (let ((subject (rmail-simplified-subject)))
3181 (setq subject
(regexp-quote subject
))
3182 ;; Hide commas so it will work ok if parsed as a comma-separated list
3185 (replace-regexp-in-string "," "\054" subject t t
))
3186 (concat "\\`" subject
"\\'")))
3188 (defun rmail-next-same-subject (n)
3189 "Go to the next mail message having the same subject header.
3190 With prefix argument N, do this N times.
3191 If N is negative, go backwards instead."
3193 (let ((subject (rmail-simplified-subject))
3195 (i rmail-current-message
)
3197 (while (and (/= n
0)
3199 (< i rmail-total-messages
)
3202 (while (and (not done
)
3204 (< i rmail-total-messages
)
3206 (setq i
(if forward
(1+ i
) (1- i
)))
3207 (setq done
(string-equal subject
(rmail-simplified-subject i
))))
3208 (if done
(setq found i
)))
3209 (setq n
(if forward
(1- n
) (1+ n
))))
3211 (rmail-show-message found
)
3212 (error "No %s message with same subject"
3213 (if forward
"following" "previous")))))
3215 (defun rmail-previous-same-subject (n)
3216 "Go to the previous mail message having the same subject header.
3217 With prefix argument N, do this N times.
3218 If N is negative, go forwards instead."
3220 (rmail-next-same-subject (- n
)))
3222 ;;;; *** Rmail Message Deletion Commands ***
3224 (defun rmail-message-deleted-p (n)
3225 "Return non-nil if message number N is deleted (in `rmail-deleted-vector')."
3226 (= (aref rmail-deleted-vector n
) ?D
))
3228 (defun rmail-set-message-deleted-p (n state
)
3229 "Set the deleted state of message number N (in `rmail-deleted-vector').
3230 STATE non-nil means mark as deleted."
3231 (aset rmail-deleted-vector n
(if state ?D ?\s
)))
3233 (defun rmail-delete-message ()
3234 "Delete this message and stay on it."
3236 (rmail-set-attribute rmail-deleted-attr-index t
)
3237 (run-hooks 'rmail-delete-message-hook
))
3239 (defun rmail-undelete-previous-message ()
3240 "Back up to deleted message, select it, and undelete it."
3242 (set-buffer rmail-buffer
)
3243 (let ((msg rmail-current-message
))
3244 (while (and (> msg
0)
3245 (not (rmail-message-deleted-p msg
)))
3246 (setq msg
(1- msg
)))
3248 (error "No previous deleted message")
3249 (if (/= msg rmail-current-message
)
3250 (rmail-show-message msg
))
3251 (rmail-set-attribute rmail-deleted-attr-index nil
)
3252 (if (rmail-summary-exists)
3253 (with-current-buffer rmail-summary-buffer
3254 (rmail-summary-mark-undeleted msg
)))
3255 (rmail-maybe-display-summary))))
3257 (defun rmail-delete-forward (&optional backward
)
3258 "Delete this message and move to next nondeleted one.
3259 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
3260 With prefix argument, delete and move backward.
3262 Returns t if a new message is displayed after the delete, or nil otherwise."
3264 (rmail-set-attribute rmail-deleted-attr-index t
)
3265 (run-hooks 'rmail-delete-message-hook
)
3266 (let ((del-msg rmail-current-message
))
3267 (if (rmail-summary-exists)
3268 (rmail-select-summary
3269 (rmail-summary-mark-deleted del-msg
)))
3270 (prog1 (rmail-next-undeleted-message (if backward -
1 1))
3271 (rmail-maybe-display-summary))))
3273 (defun rmail-delete-backward ()
3274 "Delete this message and move to previous nondeleted one.
3275 Deleted messages stay in the file until the \\[rmail-expunge] command is given."
3277 (rmail-delete-forward t
))
3281 ;; Compute the message number a given message would have after expunging.
3282 ;; The present number of the message is OLDNUM.
3283 ;; DELETEDVEC should be rmail-deleted-vector.
3284 ;; The value is nil for a message that would be deleted.
3285 (defun rmail-msg-number-after-expunge (deletedvec oldnum
)
3286 (if (or (null oldnum
) (= (aref deletedvec oldnum
) ?D
))
3291 (if (/= (aref deletedvec i
) ?D
)
3292 (setq newnum
(1+ newnum
)))
3296 (defun rmail-expunge-confirmed ()
3297 "Return t if expunge is needed and desirable.
3298 If `rmail-confirm-expunge' is non-nil, ask user to confirm."
3299 (set-buffer rmail-buffer
)
3300 (and (stringp rmail-deleted-vector
)
3301 (string-match "D" rmail-deleted-vector
)
3302 (if rmail-confirm-expunge
3303 (funcall rmail-confirm-expunge
3304 "Erase deleted messages from Rmail file? ")
3307 (defun rmail-only-expunge (&optional dont-show
)
3308 "Actually erase all deleted messages in the file."
3310 (rmail-swap-buffers-maybe)
3311 (set-buffer rmail-buffer
)
3312 (message "Expunging deleted messages...")
3313 ;; Discard all undo records for this buffer.
3314 (or (eq buffer-undo-list t
)
3315 (setq buffer-undo-list nil
))
3316 (rmail-maybe-set-message-counters)
3317 (let* ((omax (- (buffer-size) (point-max)))
3318 (omin (- (buffer-size) (point-min)))
3319 (opoint (if (and (> rmail-current-message
0)
3320 (rmail-message-deleted-p rmail-current-message
))
3322 (if rmail-enable-mime
3323 (with-current-buffer rmail-view-buffer
3324 (- (point)(point-min)))
3325 (- (point) (point-min)))))
3326 (messages-head (cons (aref rmail-message-vector
0) nil
))
3327 (messages-tail messages-head
)
3328 ;; Don't make any undo records for the expunging.
3329 (buffer-undo-list t
)
3334 (goto-char (point-min))
3338 (new-msgref (list (list 0)))
3339 (buffer-read-only nil
)
3340 (total rmail-total-messages
)
3341 (new-message-number rmail-current-message
)
3342 (messages rmail-message-vector
)
3343 (deleted rmail-deleted-vector
)
3344 (summary rmail-summary-vector
))
3345 (setq rmail-total-messages nil
3346 rmail-current-message nil
3347 rmail-message-vector nil
3348 rmail-deleted-vector nil
3349 rmail-summary-vector nil
)
3351 (while (<= number total
)
3352 (if (= (aref deleted number
) ?D
)
3354 (delete-region (aref messages number
)
3355 (aref messages
(1+ number
)))
3356 (move-marker (aref messages number
) nil
)
3357 (if (> new-message-number counter
)
3358 (setq new-message-number
(1- new-message-number
))))
3359 (setq counter
(1+ counter
))
3361 (setcdr messages-tail
3362 (cons (aref messages number
) nil
)))
3364 (cons (if (= counter number
) (aref summary
(1- number
)))
3367 (cons (aref rmail-msgref-vector number
)
3369 (setcar (car new-msgref
) counter
))
3370 (if (zerop (%
(setq number
(1+ number
)) 20))
3371 (message "Expunging deleted messages...%d" number
)))
3373 (setcdr messages-tail
3374 (cons (aref messages number
) nil
)))
3375 (setq rmail-current-message new-message-number
3376 rmail-total-messages counter
3377 rmail-message-vector
(apply 'vector messages-head
)
3378 rmail-deleted-vector
(make-string (1+ counter
) ?\s
)
3379 rmail-summary-vector
(vconcat (nreverse new-summary
))
3380 rmail-msgref-vector
(apply 'vector
(nreverse new-msgref
))
3382 (message "Expunging deleted messages...done")
3384 (narrow-to-region (- (buffer-size) omin
) (- (buffer-size) omax
)))
3386 (rmail-show-message (min rmail-current-message rmail-total-messages
)))
3387 (if rmail-enable-mime
3388 (goto-char (+ (point-min) opoint
))
3389 (goto-char (+ (point) opoint
))))))
3391 ;; The DONT-SHOW argument is new in 23. Does not seem very important.
3392 (defun rmail-expunge (&optional dont-show
)
3393 "Erase deleted messages from Rmail file and summary buffer.
3394 This always shows a message (so as not to leave the Rmail buffer
3395 unswapped), and always updates any summary (so that it remains
3396 consistent with the Rmail buffer). If DONT-SHOW is non-nil, it
3397 does not pop any summary buffer."
3399 (when (rmail-expunge-confirmed)
3400 (rmail-modify-format)
3401 (let ((was-deleted (rmail-message-deleted-p rmail-current-message
))
3402 (was-swapped (rmail-buffers-swapped-p)))
3403 (rmail-only-expunge t
)
3404 ;; We always update the summary buffer, so that the contents
3405 ;; remain consistent with the rmail buffer.
3406 ;; The only difference is, in the dont-show case, we use a
3407 ;; cut-down version of rmail-select-summary that does not pop
3408 ;; the summary buffer. It's only used by rmail-quit, which is
3409 ;; just going to bury any summary immediately after. If we made
3410 ;; rmail-quit bury the summary first, dont-show could be removed.
3411 ;; But the expunge might not be confirmed...
3412 (if (rmail-summary-exists)
3414 (let ((total rmail-total-messages
))
3415 (with-current-buffer rmail-summary-buffer
3416 (let ((rmail-total-messages total
))
3417 (rmail-update-summary))))
3418 (rmail-select-summary (rmail-update-summary))))
3419 ;; We always show a message, because (rmail-only-expunge t)
3420 ;; leaves the rmail buffer unswapped.
3421 ;; If we expunged the current message, a new one is current now,
3422 ;; so show it. If we weren't showing a message, show it.
3423 (if (or was-deleted
(not was-swapped
))
3424 (rmail-show-message-1 rmail-current-message
)
3425 ;; We can just show the same message that was being shown before.
3426 (rmail-display-labels)
3427 (rmail-swap-buffers)
3428 (setq rmail-buffer-swapped t
)))))
3430 ;;;; *** Rmail Mailing Commands ***
3432 (defun rmail-start-mail (&optional noerase to subject in-reply-to cc
3433 replybuffer sendactions same-window
3435 (let ((switch-function
3436 (cond (same-window nil
)
3437 (rmail-mail-new-frame 'switch-to-buffer-other-frame
)
3438 (t 'switch-to-buffer-other-window
)))
3441 ;; The function used here must behave like insert-buffer wrt
3442 ;; point and mark (see doc of sc-cite-original).
3443 (setq yank-action
(list 'insert-buffer replybuffer
)))
3444 (push (cons "cc" cc
) other-headers
)
3445 (push (cons "in-reply-to" in-reply-to
) other-headers
)
3447 (mapcar #'(lambda (elt)
3448 (cons (car elt
) (if (stringp (cdr elt
))
3449 (rfc2047-decode-string (cdr elt
)))))
3451 (if (stringp to
) (setq to
(rfc2047-decode-string to
)))
3452 (if (stringp in-reply-to
)
3453 (setq in-reply-to
(rfc2047-decode-string in-reply-to
)))
3454 (if (stringp cc
) (setq cc
(rfc2047-decode-string cc
)))
3455 (if (stringp subject
) (setq subject
(rfc2047-decode-string subject
)))
3457 (compose-mail to subject other-headers noerase
3458 switch-function yank-action sendactions
3459 '(rmail-mail-return))
3460 (if (eq switch-function
'switch-to-buffer-other-frame
)
3461 ;; This is not a standard frame parameter; nothing except
3462 ;; sendmail.el looks at it.
3463 (modify-frame-parameters (selected-frame)
3464 '((mail-dedicated-frame . t
)))))))
3466 (defun rmail-mail-return ()
3468 ;; If there is only one visible frame with no special handling,
3469 ;; consider deleting the mail window to return to Rmail.
3470 ((or (null (delq (selected-frame) (visible-frame-list)))
3471 (not (or (window-dedicated-p (frame-selected-window))
3472 (and pop-up-frames
(one-window-p))
3473 (cdr (assq 'mail-dedicated-frame
3474 (frame-parameters))))))
3475 (let (rmail-flag summary-buffer
)
3476 (and (not (one-window-p))
3477 (with-current-buffer
3478 (window-buffer (next-window (selected-window) 'not
))
3479 (setq rmail-flag
(eq major-mode
'rmail-mode
))
3480 (setq summary-buffer
3481 (and (boundp 'mail-bury-selects-summary
)
3482 mail-bury-selects-summary
3483 (boundp 'rmail-summary-buffer
)
3484 rmail-summary-buffer
3485 (buffer-name rmail-summary-buffer
)
3486 (not (get-buffer-window rmail-summary-buffer
))
3487 rmail-summary-buffer
))))
3489 ;; If the Rmail buffer has a summary, show that.
3490 (if summary-buffer
(switch-to-buffer summary-buffer
)
3492 ;; If the frame was probably made for this buffer, the user
3493 ;; probably wants to delete it now.
3494 ((display-multi-frame-p)
3495 (delete-frame (selected-frame)))
3496 ;; The previous frame is where normally they have the Rmail buffer
3498 (t (other-frame -
1))))
3500 (defun rmail-mail ()
3501 "Send mail in another window.
3502 While composing the message, use \\[mail-yank-original] to yank the
3503 original message into it."
3505 (rmail-start-mail nil nil nil nil nil rmail-view-buffer
))
3507 ;; FIXME should complain if there is nothing to continue.
3508 (defun rmail-continue ()
3509 "Continue composing outgoing message previously being composed."
3511 (rmail-start-mail t
))
3513 (defun rmail-reply (just-sender)
3514 "Reply to the current message.
3515 Normally include CC: to all other recipients of original message;
3516 prefix argument means ignore them. While composing the reply,
3517 use \\[mail-yank-original] to yank the original message into it."
3519 (if (zerop rmail-current-message
)
3520 (error "There is no message to reply to"))
3521 (let (from reply-to cc subject date to message-id references
3522 resent-to resent-cc resent-reply-to
3523 (msgnum rmail-current-message
))
3524 (rmail-apply-in-message
3525 rmail-current-message
3527 (search-forward "\n\n" nil
'move
)
3528 (narrow-to-region (point-min) (point))
3529 (setq from
(mail-fetch-field "from")
3530 reply-to
(or (mail-fetch-field "mail-reply-to" nil t
)
3531 (mail-fetch-field "reply-to" nil t
)
3533 subject
(mail-fetch-field "subject")
3534 date
(mail-fetch-field "date")
3535 message-id
(mail-fetch-field "message-id")
3536 references
(mail-fetch-field "references" nil nil t
)
3537 resent-reply-to
(mail-fetch-field "resent-reply-to" nil t
)
3538 ;; Bug#512. It's inappropriate to reply to these addresses.
3539 ;;; resent-cc (and (not just-sender)
3540 ;;; (mail-fetch-field "resent-cc" nil t))
3541 ;;; resent-to (or (mail-fetch-field "resent-to" nil t) "")
3542 ;;; resent-subject (mail-fetch-field "resent-subject")
3543 ;;; resent-date (mail-fetch-field "resent-date")
3544 ;;; resent-message-id (mail-fetch-field "resent-message-id")
3547 (if (mail-fetch-field "mail-followup-to" nil t
)
3548 ;; If this header field is present, use it instead of the
3549 ;; To and CC fields.
3550 (setq to
(mail-fetch-field "mail-followup-to" nil t
))
3551 (setq cc
(or (mail-fetch-field "cc" nil t
) "")
3552 to
(or (mail-fetch-field "to" nil t
) ""))))))
3553 ;; Merge the resent-to and resent-cc into the to and cc.
3554 ;; Bug#512. It's inappropriate to reply to these addresses.
3555 ;;; (if (and resent-to (not (equal resent-to "")))
3556 ;;; (if (not (equal to ""))
3557 ;;; (setq to (concat to ", " resent-to))
3558 ;;; (setq to resent-to)))
3559 ;;; (if (and resent-cc (not (equal resent-cc "")))
3560 ;;; (if (not (equal cc ""))
3561 ;;; (setq cc (concat cc ", " resent-cc))
3562 ;;; (setq cc resent-cc)))
3563 ;; Add `Re: ' to subject if not there already.
3564 (and (stringp subject
)
3566 (concat rmail-reply-prefix
3567 (if (let ((case-fold-search t
))
3568 (string-match rmail-reply-regexp subject
))
3569 (substring subject
(match-end 0))
3573 ;; Using mail-strip-quoted-names is undesirable with newer mailers
3574 ;; since they can handle the names unstripped.
3575 ;; I don't know whether there are other mailers that still
3576 ;; need the names to be stripped.
3577 ;;; (mail-strip-quoted-names reply-to)
3578 ;; Remove unwanted names from reply-to, since Mail-Followup-To
3579 ;; header causes all the names in it to wind up in reply-to, not
3580 ;; in cc. But if what's left is an empty list, use the original.
3581 (let* ((reply-to-list (mail-dont-reply-to reply-to
)))
3582 (if (string= reply-to-list
"") reply-to reply-to-list
))
3584 (rmail-make-in-reply-to-field from date message-id
)
3587 ;; `mail-dont-reply-to' doesn't need `mail-strip-quoted-names'.
3588 (let* ((cc-list (mail-dont-reply-to
3589 (mail-strip-quoted-names
3590 (if (null cc
) to
(concat to
", " cc
))))))
3591 (if (string= cc-list
"") nil cc-list
)))
3592 (if (rmail-buffers-swapped-p)
3595 (list (list 'rmail-mark-message
3597 (with-current-buffer rmail-buffer
3598 (aref rmail-msgref-vector msgnum
))
3599 rmail-answered-attr-index
))
3601 (if (or references message-id
)
3602 (list (cons "References" (if references
3604 (mapconcat 'identity references
" ")
3608 (defun rmail-mark-message (buffer msgnum-list attribute
)
3609 "Give BUFFER's message number in MSGNUM-LIST the attribute ATTRIBUTE.
3610 This is use in the send-actions for message buffers.
3611 MSGNUM-LIST is a list of the form (MSGNUM)
3612 which is an element of rmail-msgref-vector."
3613 (with-current-buffer buffer
3614 (if (car msgnum-list
)
3615 (rmail-set-attribute attribute t
(car msgnum-list
)))))
3617 (defun rmail-make-in-reply-to-field (from date message-id
)
3624 (let ((tem (car (rfc822-addresses from
))))
3628 (regexp-quote (if (string-match "@[^@]*\\'" tem
)
3630 (match-beginning 0))
3633 ;; missing From, or Message-ID is sufficiently informative
3635 (concat message-id
" (" tem
")"))
3636 ;; Copy TEM, discarding text properties.
3637 (setq tem
(copy-sequence tem
))
3638 (set-text-properties 0 (length tem
) nil tem
)
3639 (setq tem
(copy-sequence tem
))
3640 ;; Use prin1 to fake RFC822 quoting
3641 (let ((field (prin1-to-string tem
)))
3643 (concat field
"'s message of " date
)
3645 ((let* ((foo "[^][\000-\037()<>@,;:\\\" ]+")
3646 (bar "[^][\000-\037()<>@,;:\\\"]+"))
3647 ;; These strings both match all non-ASCII characters.
3648 (or (string-match (concat "\\`[ \t]*\\(" bar
3649 "\\)\\(<" foo
"@" foo
">\\)?[ \t]*\\'")
3650 ;; "Unix Loser <Foo@bar.edu>" => "Unix Loser"
3652 (string-match (concat "\\`[ \t]*<" foo
"@" foo
">[ \t]*(\\("
3653 bar
"\\))[ \t]*\\'")
3654 ;; "<Bugs@bar.edu>" (Losing Unix) => "Losing Unix"
3656 (let ((start (match-beginning 1))
3657 (end (match-end 1)))
3658 ;; Trim whitespace which above regexp match allows
3659 (while (and (< start end
)
3660 (memq (aref from start
) '(?
\t ?\s
)))
3661 (setq start
(1+ start
)))
3662 (while (and (< start end
)
3663 (memq (aref from
(1- end
)) '(?
\t ?\s
)))
3664 (setq end
(1- end
)))
3665 (let ((field (substring from start end
)))
3666 (if date
(setq field
(concat "message from " field
" on " date
)))
3668 ;; "<AA259@bar.edu> (message from Unix Loser on 1-Apr-89)"
3669 (concat message-id
" (" field
")")
3672 ;; If we can't kludge it simply, do it correctly
3673 (let ((mail-use-rfc822 t
))
3674 (rmail-make-in-reply-to-field from date message-id
)))))
3676 (defun rmail-forward (resend)
3677 "Forward the current message to another user.
3678 With prefix argument, \"resend\" the message instead of forwarding it;
3679 see the documentation of `rmail-resend'."
3682 (call-interactively 'rmail-resend
)
3683 (let ((forward-buffer rmail-buffer
)
3684 (msgnum rmail-current-message
)
3685 (subject (concat "["
3686 (let ((from (or (mail-fetch-field "From")
3687 (mail-fetch-field ">From"))))
3689 (concat (mail-strip-quoted-names from
) ": ")
3691 (or (mail-fetch-field "Subject") "")
3693 (if (rmail-start-mail
3694 nil nil subject nil nil nil
3695 (list (list 'rmail-mark-message
3697 (with-current-buffer rmail-buffer
3698 (aref rmail-msgref-vector msgnum
))
3699 rmail-forwarded-attr-index
))
3700 ;; If only one window, use it for the mail buffer.
3701 ;; Otherwise, use another window for the mail buffer
3702 ;; so that the Rmail buffer remains visible
3703 ;; and sending the mail will get back to it.
3704 (and (not rmail-mail-new-frame
) (one-window-p t
)))
3705 ;; The mail buffer is now current.
3707 ;; Insert after header separator--before signature if any.
3710 (if (or rmail-enable-mime rmail-enable-mime-composing
)
3711 (funcall rmail-insert-mime-forwarded-message-function
3713 (insert "------- Start of forwarded message -------\n")
3714 ;; Quote lines with `- ' if they start with `-'.
3715 (let ((beg (point)) end
)
3716 (setq end
(point-marker))
3717 (set-marker-insertion-type end t
)
3718 (insert-buffer-substring forward-buffer
)
3720 (while (re-search-forward "^-" end t
)
3725 (skip-chars-backward "\n")
3728 (delete-region (point) end
)
3729 (set-marker end nil
))
3730 (insert "------- End of forwarded message -------\n"))
3733 (defun rmail-resend (address &optional from comment mail-alias-file
)
3734 "Resend current message to ADDRESSES.
3735 ADDRESSES should be a single address, a string consisting of several
3736 addresses separated by commas, or a list of addresses.
3738 Optional FROM is the address to resend the message from, and
3739 defaults from the value of `user-mail-address'.
3740 Optional COMMENT is a string to insert as a comment in the resent message.
3741 Optional ALIAS-FILE is alternate aliases file to be used by sendmail,
3742 typically for purposes of moderating a list."
3743 (interactive "sResend to: ")
3745 (require 'mailalias
)
3746 (unless (or (eq rmail-view-buffer
(current-buffer))
3747 (eq rmail-buffer
(current-buffer)))
3748 (error "Not an Rmail buffer"))
3749 (if (not from
) (setq from user-mail-address
))
3750 (let ((tembuf (generate-new-buffer " sendmail temp"))
3751 (case-fold-search nil
)
3752 (mail-personal-alias-file
3753 (or mail-alias-file mail-personal-alias-file
))
3754 (mailbuf rmail-buffer
))
3756 (with-current-buffer tembuf
3757 ;;>> Copy message into temp buffer
3758 (if rmail-enable-mime
3759 (if rmail-insert-mime-resent-message-function
3760 (funcall rmail-insert-mime-resent-message-function mailbuf
)
3761 (error "You must set `rmail-insert-mime-resent-message-function'"))
3762 (insert-buffer-substring mailbuf
))
3763 (goto-char (point-min))
3764 ;; Delete any Sender field, since that's not specifiable.
3765 ; Only delete Sender fields in the actual header.
3766 (re-search-forward "^$" nil
'move
)
3767 ; Using "while" here rather than "if" because some buggy mail
3768 ; software may have inserted multiple Sender fields.
3769 (while (re-search-backward "^Sender:" nil t
)
3773 (while (looking-at "[ \t]")
3775 (delete-region beg
(point))))
3776 ; Go back to the beginning of the buffer so the Resent- fields
3777 ; are inserted there.
3778 (goto-char (point-min))
3779 ;;>> Insert resent-from:
3780 (insert "Resent-From: " from
"\n")
3781 (insert "Resent-Date: " (mail-rfc822-date) "\n")
3782 ;;>> Insert resent-to: and bcc if need be.
3783 (let ((before (point)))
3785 (insert "Resent-Bcc: " (user-login-name) "\n"))
3786 (insert "Resent-To: " (if (stringp address
)
3788 (mapconcat 'identity address
",\n\t"))
3790 ;; Expand abbrevs in the recipients.
3792 (if (featurep 'mailabbrev
)
3793 (let ((end (point-marker))
3794 (local-abbrev-table mail-abbrevs
)
3795 (old-syntax-table (syntax-table)))
3796 (if (and (not (vectorp mail-abbrevs
))
3797 (file-exists-p mail-personal-alias-file
))
3798 (build-mail-abbrevs))
3799 (unless mail-abbrev-syntax-table
3800 (mail-abbrev-make-syntax-table))
3801 (set-syntax-table mail-abbrev-syntax-table
)
3803 (while (and (< (point) end
)
3804 (progn (forward-word 1)
3807 (set-syntax-table old-syntax-table
))
3808 (expand-mail-aliases before
(point)))))
3809 ;;>> Set up comment, if any.
3810 (if (and (sequencep comment
) (not (zerop (length comment
))))
3811 (let ((before (point))
3814 (or (eolp) (insert "\n"))
3815 (setq after
(point))
3817 (while (< (point) after
)
3818 (insert "Resent-Comment: ")
3820 ;; Don't expand aliases in the destination fields
3821 ;; of the original message.
3823 (funcall send-mail-function
)))
3824 (kill-buffer tembuf
))
3825 (with-current-buffer rmail-buffer
3826 (rmail-set-attribute rmail-resent-attr-index t rmail-current-message
))))
3828 (defvar mail-unsent-separator
3829 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
3830 "^ *---+ +Returned message +---+ *$\\|"
3831 "^ *---+ *Returned mail follows *---+ *$\\|"
3832 "^Start of returned message$\\|"
3833 "^---+ Below this line is a copy of the message.$\\|"
3834 "^ *---+ +Original message +---+ *$\\|"
3835 "^ *--+ +begin message +--+ *$\\|"
3836 "^ *---+ +Original message follows +---+ *$\\|"
3837 "^ *---+ +Your message follows +---+ *$\\|"
3838 "^|? *---+ +Message text follows: +---+ *|?$\\|"
3839 "^ *---+ +This is a copy of \\w+ message, including all the headers.*---+ *$")
3840 "A regexp that matches the separator before the text of a failed message.")
3842 (defvar mail-mime-unsent-header
"^Content-Type: message/rfc822 *$"
3843 "A regexp that matches the header of a MIME body part with a failed message.")
3845 ;; This is a cut-down version of rmail-clear-headers from Emacs 22.
3846 ;; It doesn't have the same functionality, hence the name change.
3847 (defun rmail-delete-headers (regexp)
3848 "Delete any mail headers matching REGEXP.
3849 The message should be narrowed to just the headers."
3851 (goto-char (point-min))
3852 (while (re-search-forward regexp nil t
)
3854 ;; This code from Emacs 22 doesn't seem right, since r-n-h is
3855 ;; just for display.
3856 ;;; (if (looking-at rmail-nonignored-headers)
3857 ;;; (forward-line 1)
3858 (delete-region (point)
3860 (if (re-search-forward "\n[^ \t]" nil t
)
3864 (autoload 'mail-position-on-field
"sendmail")
3866 (defun rmail-retry-failure ()
3867 "Edit a mail message which is based on the contents of the current message.
3868 For a message rejected by the mail system, extract the interesting headers and
3869 the body of the original message.
3870 If the failed message is a MIME multipart message, it is searched for a
3871 body part with a header which matches the variable `mail-mime-unsent-header'.
3872 Otherwise, the variable `mail-unsent-separator' should match the string that
3873 delimits the returned original message.
3874 The variable `rmail-retry-ignored-headers' is a regular expression
3875 specifying headers which should not be copied into the new message."
3877 (require 'mail-utils
)
3878 (let ((rmail-this-buffer (current-buffer))
3879 (msgnum rmail-current-message
)
3880 bounce-start bounce-end bounce-indent resending
3881 (content-type (rmail-get-header "Content-Type")))
3883 (goto-char (point-min))
3884 (let ((case-fold-search t
))
3885 (if (and content-type
3887 ";[\n\t ]*boundary=\"?\\([-0-9a-z'()+_,./:=? ]+\\)\"?"
3889 ;; Handle a MIME multipart bounce message.
3892 (substring content-type
(match-beginning 1)
3894 (unless (re-search-forward mail-mime-unsent-header nil t
)
3895 (error "Cannot find beginning of header in failed message"))
3896 (unless (search-forward "\n\n" nil t
)
3897 (error "Cannot find start of Mime data in failed message"))
3898 (setq bounce-start
(point))
3899 (if (search-forward codestring nil t
)
3900 (setq bounce-end
(match-beginning 0))
3901 (setq bounce-end
(point-max))))
3903 (or (re-search-forward mail-unsent-separator nil t
)
3904 (error "Cannot parse this as a failure message"))
3905 (skip-chars-forward "\n")
3906 ;; Support a style of failure message in which the original
3907 ;; message is indented, and included within lines saying
3908 ;; `Start of returned message' and `End of returned message'.
3909 (if (looking-at " +Received:")
3911 (setq bounce-start
(point))
3912 (skip-chars-forward " ")
3913 (setq bounce-indent
(- (current-column)))
3914 (goto-char (point-max))
3915 (re-search-backward "^End of returned message$" nil t
)
3916 (setq bounce-end
(point)))
3917 ;; One message contained a few random lines before
3918 ;; the old message header. The first line of the
3919 ;; message started with two hyphens. A blank line
3920 ;; followed these random lines. The same line
3921 ;; beginning with two hyphens was possibly marking
3922 ;; the end of the message.
3923 (if (looking-at "^--")
3924 (let ((boundary (buffer-substring-no-properties
3926 (progn (end-of-line) (point)))))
3927 (search-forward "\n\n")
3928 (skip-chars-forward "\n")
3929 (setq bounce-start
(point))
3930 (goto-char (point-max))
3931 (search-backward (concat "\n\n" boundary
) bounce-start t
)
3932 (setq bounce-end
(point)))
3933 (setq bounce-start
(point)
3934 bounce-end
(point-max)))
3935 (unless (search-forward "\n\n" nil t
)
3936 (error "Cannot find end of header in failed message"))))))
3937 ;; We have found the message that bounced, within the current message.
3938 ;; Now start sending new message; default header fields from original.
3939 ;; Turn off the usual actions for initializing the message body
3940 ;; because we want to get only the text from the failure message.
3941 (let (mail-signature mail-setup-hook
)
3942 (if (rmail-start-mail nil nil nil nil nil rmail-this-buffer
3943 (list (list 'rmail-mark-message
3945 (aref rmail-msgref-vector msgnum
)
3946 rmail-retried-attr-index
)))
3947 ;; Insert original text as initial text of new draft message.
3948 ;; Bind inhibit-read-only since the header delimiter
3949 ;; of the previous message was probably read-only.
3950 (let ((inhibit-read-only t
)
3953 (insert-buffer-substring rmail-this-buffer
3954 bounce-start bounce-end
)
3955 (goto-char (point-min))
3957 (indent-rigidly (point-min) (point-max) bounce-indent
))
3960 (insert mail-header-separator
)
3962 (narrow-to-region (point-min) eoh
)
3963 (rmail-delete-headers rmail-retry-ignored-headers
)
3964 (rmail-delete-headers "^\\(sender\\|return-path\\|received\\):")
3965 (setq resending
(mail-fetch-field "resent-to"))
3968 (insert "Resent-Bcc: " (user-login-name) "\n")
3969 (insert "BCC: " (user-login-name) "\n"))))
3970 (goto-char (point-min))
3971 (mail-position-on-field (if resending
"Resent-To" "To") t
))))))
3973 (defun rmail-summary-exists ()
3974 "Non-nil if in an RMAIL buffer and an associated summary buffer exists.
3975 In fact, the non-nil value returned is the summary buffer itself."
3976 (and rmail-summary-buffer
(buffer-name rmail-summary-buffer
)
3977 rmail-summary-buffer
))
3979 (defun rmail-summary-displayed ()
3980 "t if in RMAIL buffer and an associated summary buffer is displayed."
3981 (and rmail-summary-buffer
(get-buffer-window rmail-summary-buffer
)))
3983 (defcustom rmail-redisplay-summary nil
3984 "Non-nil means Rmail should show the summary when it changes.
3985 This has an effect only if a summary buffer exists."
3987 :group
'rmail-summary
)
3989 (defcustom rmail-summary-window-size nil
3990 "Non-nil means specify the height for an Rmail summary window."
3991 :type
'(choice (const :tag
"Disabled" nil
) integer
)
3992 :group
'rmail-summary
)
3994 ;; Put the summary buffer back on the screen, if user wants that.
3995 (defun rmail-maybe-display-summary ()
3996 (let ((selected (selected-window))
3998 ;; If requested, make sure the summary is displayed.
3999 (and rmail-summary-buffer
(buffer-name rmail-summary-buffer
)
4000 rmail-redisplay-summary
4001 (if (get-buffer-window rmail-summary-buffer
0)
4002 ;; It's already in some frame; show that one.
4003 (let ((frame (window-frame
4004 (get-buffer-window rmail-summary-buffer
0))))
4005 (make-frame-visible frame
)
4006 (raise-frame frame
))
4007 (display-buffer rmail-summary-buffer
)))
4008 ;; If requested, set the height of the summary window.
4009 (and rmail-summary-buffer
(buffer-name rmail-summary-buffer
)
4010 rmail-summary-window-size
4011 (setq window
(get-buffer-window rmail-summary-buffer
))
4012 ;; Don't try to change the size if just one window in frame.
4013 (not (eq window
(frame-root-window (window-frame window
))))
4016 (select-window window
)
4017 (enlarge-window (- rmail-summary-window-size
(window-height))))
4018 (select-window selected
)))))
4020 ;;;; *** Rmail Local Fontification ***
4022 (defun rmail-fontify-buffer-function ()
4023 ;; This function's symbol is bound to font-lock-fontify-buffer-function.
4024 (add-hook 'rmail-show-message-hook
'rmail-fontify-message nil t
)
4025 ;; If we're already showing a message, fontify it now.
4026 (if rmail-current-message
(rmail-fontify-message))
4027 ;; Prevent Font Lock mode from kicking in.
4028 (setq font-lock-fontified t
))
4030 (defun rmail-unfontify-buffer-function ()
4031 ;; This function's symbol is bound to font-lock-fontify-unbuffer-function.
4032 (let ((modified (buffer-modified-p))
4033 (buffer-undo-list t
) (inhibit-read-only t
)
4034 before-change-functions after-change-functions
4035 buffer-file-name buffer-file-truename
)
4038 (remove-hook 'rmail-show-message-hook
'rmail-fontify-message t
)
4039 (remove-text-properties (point-min) (point-max) '(rmail-fontified nil
))
4040 (font-lock-default-unfontify-buffer)
4041 (and (not modified
) (buffer-modified-p)
4042 (restore-buffer-modified-p nil
)))))
4044 (defun rmail-fontify-message ()
4045 ;; Fontify the current message if it is not already fontified.
4046 (if (text-property-any (point-min) (point-max) 'rmail-fontified nil
)
4047 (let ((modified (buffer-modified-p))
4048 (buffer-undo-list t
) (inhibit-read-only t
)
4049 before-change-functions after-change-functions
4050 buffer-file-name buffer-file-truename
)
4053 (add-text-properties (point-min) (point-max) '(rmail-fontified t
))
4054 (font-lock-fontify-region (point-min) (point-max))
4055 (and (not modified
) (buffer-modified-p)
4056 (restore-buffer-modified-p nil
)))))))
4058 ;;; Speedbar support for RMAIL files.
4059 (eval-when-compile (require 'speedbar
))
4061 (defvar rmail-speedbar-match-folder-regexp
"^[A-Z0-9]+\\(\\.[A-Z0-9]+\\)?$"
4062 "*This regex is used to match folder names to be displayed in speedbar.
4063 Enabling this will permit speedbar to display your folders for easy
4064 browsing, and moving of messages.")
4066 (defvar rmail-speedbar-last-user nil
4067 "The last user to be displayed in the speedbar.")
4069 (defvar rmail-speedbar-key-map nil
4070 "Keymap used when in rmail display mode.")
4072 (defun rmail-install-speedbar-variables ()
4073 "Install those variables used by speedbar to enhance rmail."
4074 (if rmail-speedbar-key-map
4076 (setq rmail-speedbar-key-map
(speedbar-make-specialized-keymap))
4078 (define-key rmail-speedbar-key-map
"e" 'speedbar-edit-line
)
4079 (define-key rmail-speedbar-key-map
"r" 'speedbar-edit-line
)
4080 (define-key rmail-speedbar-key-map
"\C-m" 'speedbar-edit-line
)
4081 (define-key rmail-speedbar-key-map
"M"
4082 'rmail-speedbar-move-message-to-folder-on-line
)))
4085 (defvar rmail-speedbar-menu-items
4086 '(["Read Folder" speedbar-edit-line t
]
4087 ["Move message to folder" rmail-speedbar-move-message-to-folder-on-line
4088 (save-excursion (beginning-of-line)
4089 (looking-at "<M> "))])
4090 "Additional menu-items to add to speedbar frame.")
4092 ;; Make sure our special speedbar major mode is loaded
4093 (if (featurep 'speedbar
)
4094 (rmail-install-speedbar-variables)
4095 (add-hook 'speedbar-load-hook
'rmail-install-speedbar-variables
))
4097 (defun rmail-speedbar-buttons (buffer)
4098 "Create buttons for BUFFER containing rmail messages.
4099 Click on the address under Reply to: to reply to this person.
4100 Under Folders: Click a name to read it, or on the <M> to move the
4101 current message into that RMAIL folder."
4103 (with-current-buffer buffer
4104 (goto-char (point-min))
4105 (if (not (re-search-forward "^Reply-To: " nil t
))
4106 (if (not (re-search-forward "^From:? " nil t
))
4110 (setq from
(buffer-substring (point) (line-end-position)))))
4111 (goto-char (point-min))
4112 (if (and (looking-at "Reply to:")
4113 (equal from rmail-speedbar-last-user
))
4115 (setq rmail-speedbar-last-user from
)
4117 (insert "Reply To:\n")
4119 (speedbar-insert-button from
'speedbar-directory-face
'highlight
4120 'rmail-speedbar-button
'rmail-reply
))
4121 (insert "Folders:\n")
4122 (let* ((case-fold-search nil
)
4123 (df (directory-files (with-current-buffer buffer
4125 nil rmail-speedbar-match-folder-regexp
)))
4127 (when (file-regular-p file
)
4128 (speedbar-insert-button "<M>" 'speedbar-button-face
'highlight
4129 'rmail-speedbar-move-message file
)
4130 (speedbar-insert-button file
'speedbar-file-face
'highlight
4131 'rmail-speedbar-find-file nil t
)))))))
4133 (defun rmail-speedbar-button (text token indent
)
4134 "Execute an rmail command specified by TEXT.
4135 The command used is TOKEN. INDENT is not used."
4136 (speedbar-with-attached-buffer
4139 (defun rmail-speedbar-find-file (text token indent
)
4140 "Load in the rmail file TEXT.
4141 TOKEN and INDENT are not used."
4142 (speedbar-with-attached-buffer
4143 (message "Loading in RMAIL file %s..." text
)
4146 (defun rmail-speedbar-move-message-to-folder-on-line ()
4147 "If the current line is a folder, move current message to it."
4151 (if (re-search-forward "<M> " (line-end-position) t
)
4154 (speedbar-do-function-pointer)))))
4156 (defun rmail-speedbar-move-message (text token indent
)
4157 "From button TEXT, copy current message to the rmail file specified by TOKEN.
4158 TEXT and INDENT are not used."
4159 (speedbar-with-attached-buffer
4160 (message "Moving message to %s" token
)
4161 ;; expand-file-name is needed due to the unhelpful way in which
4162 ;; rmail-output expands non-absolute filenames against rmail-default-file.
4163 ;; What is the point of that, anyway?
4164 (rmail-output (expand-file-name token
))))
4166 ;; Functions for setting, getting and encoding the POP password.
4167 ;; The password is encoded to prevent it from being easily accessible
4168 ;; to "prying eyes." Obviously, this encoding isn't "real security,"
4169 ;; nor is it meant to be.
4172 (defun rmail-set-remote-password (password)
4173 "Set PASSWORD to be used for retrieving mail from a POP or IMAP server."
4174 (interactive "sPassword: ")
4176 (setq rmail-encoded-remote-password
4177 (rmail-encode-string password
(emacs-pid)))
4178 (setq rmail-remote-password nil
)
4179 (setq rmail-encoded-remote-password nil
)))
4181 (defun rmail-get-remote-password (imap)
4182 "Get the password for retrieving mail from a POP or IMAP server. If none
4183 has been set, then prompt the user for one."
4184 (when (not rmail-encoded-remote-password
)
4185 (if (not rmail-remote-password
)
4186 (setq rmail-remote-password
4187 (read-passwd (if imap
4189 "POP password: "))))
4190 (rmail-set-remote-password rmail-remote-password
)
4191 (setq rmail-remote-password nil
))
4192 (rmail-encode-string rmail-encoded-remote-password
(emacs-pid)))
4194 (defun rmail-have-password ()
4195 (or rmail-remote-password rmail-encoded-remote-password
))
4197 (defun rmail-encode-string (string mask
)
4198 "Encode STRING with integer MASK, by taking the exclusive OR of the
4199 lowest byte in the mask with the first character of string, the
4200 second-lowest-byte with the second character of the string, etc.,
4201 restarting at the lowest byte of the mask whenever it runs out.
4202 Returns the encoded string. Calling the function again with an
4203 encoded string (and the same mask) will decode the string."
4204 (setq mask
(abs mask
)) ; doesn't work if negative
4205 (let* ((string-vector (string-to-vector string
)) (i 0)
4206 (len (length string-vector
)) (curmask mask
) charmask
)
4209 (setq curmask mask
))
4210 (setq charmask
(% curmask
256))
4211 (setq curmask
(lsh curmask -
8))
4212 (aset string-vector i
(logxor charmask
(aref string-vector i
)))
4214 (concat string-vector
)))
4216 ;;;; Desktop support
4218 (defun rmail-restore-desktop-buffer (desktop-buffer-file-name
4220 desktop-buffer-misc
)
4221 "Restore an rmail buffer specified in a desktop file."
4222 (condition-case error
4224 (rmail-input desktop-buffer-file-name
)
4225 (if (eq major-mode
'rmail-mode
)
4229 (kill-buffer (current-buffer))
4232 (add-to-list 'desktop-buffer-mode-handlers
4233 '(rmail-mode . rmail-restore-desktop-buffer
))
4235 ;; We use this to record the encoding of the current message before
4236 ;; saving the message collection.
4237 (defvar rmail-message-encoding nil
)
4239 ;; Used in `write-region-annotate-functions' to write rmail files.
4240 (defun rmail-write-region-annotate (start end
)
4241 (when (and (null start
) (rmail-buffers-swapped-p))
4242 (setq rmail-message-encoding buffer-file-coding-system
)
4243 (set-buffer rmail-view-buffer
)
4247 ;; Used to restore the encoding of the buffer where we show the
4248 ;; current message, after we save the message collection. This is
4249 ;; needed because rmail-write-region-annotate switches buffers behind
4250 ;; save-file's back, with the side effect that last-coding-system-used
4251 ;; is assigned to buffer-file-coding-system of the wrong buffer.
4252 (defun rmail-after-save-hook ()
4253 (if (or (eq rmail-view-buffer
(current-buffer))
4254 (eq rmail-buffer
(current-buffer)))
4255 (with-current-buffer
4256 (if (rmail-buffers-swapped-p) rmail-buffer rmail-view-buffer
)
4257 (setq buffer-file-coding-system rmail-message-encoding
))))
4258 (add-hook 'after-save-hook
'rmail-after-save-hook
)
4261 ;;; Start of automatically extracted autoloads.
4263 ;;;### (autoloads (rmail-edit-current-message) "rmailedit" "rmailedit.el"
4264 ;;;;;; "090ad9432c3bf9a6098bb9c3d7c71baf")
4265 ;;; Generated autoloads from rmailedit.el
4267 (autoload 'rmail-edit-current-message
"rmailedit" "\
4268 Edit the contents of this message.
4274 ;;;### (autoloads (rmail-next-labeled-message rmail-previous-labeled-message
4275 ;;;;;; rmail-read-label rmail-kill-label rmail-add-label) "rmailkwd"
4276 ;;;;;; "rmailkwd.el" "08c288c88cfe7be50830122c064e3884")
4277 ;;; Generated autoloads from rmailkwd.el
4279 (autoload 'rmail-add-label
"rmailkwd" "\
4280 Add LABEL to labels associated with current RMAIL message.
4281 Completes (see `rmail-read-label') over known labels when reading.
4282 LABEL may be a symbol or string. Only one label is allowed.
4286 (autoload 'rmail-kill-label
"rmailkwd" "\
4287 Remove LABEL from labels associated with current RMAIL message.
4288 Completes (see `rmail-read-label') over known labels when reading.
4289 LABEL may be a symbol or string. Only one label is allowed.
4293 (autoload 'rmail-read-label
"rmailkwd" "\
4294 Read a label with completion, prompting with PROMPT.
4295 Completions are chosen from `rmail-label-obarray'. The default
4296 is `rmail-last-label', if that is non-nil. Updates `rmail-last-label'
4297 according to the choice made, and returns a symbol.
4299 \(fn PROMPT)" nil nil
)
4301 (autoload 'rmail-previous-labeled-message
"rmailkwd" "\
4302 Show previous message with one of the labels LABELS.
4303 LABELS should be a comma-separated list of label names.
4304 If LABELS is empty, the last set of labels specified is used.
4305 With prefix argument N moves backward N messages with these labels.
4307 \(fn N LABELS)" t nil
)
4309 (autoload 'rmail-next-labeled-message
"rmailkwd" "\
4310 Show next message with one of the labels LABELS.
4311 LABELS should be a comma-separated list of label names.
4312 If LABELS is empty, the last set of labels specified is used.
4313 With prefix argument N moves forward N messages with these labels.
4315 \(fn N LABELS)" t nil
)
4319 ;;;### (autoloads (rmail-mime) "rmailmm" "rmailmm.el" "c530622b53038152ca84f2ec9313bd7a")
4320 ;;; Generated autoloads from rmailmm.el
4322 (autoload 'rmail-mime
"rmailmm" "\
4323 Toggle displaying of a MIME message.
4325 The actualy behavior depends on the value of `rmail-enable-mime'.
4327 If `rmail-enable-mime' is t (default), this command change the
4328 displaying of a MIME message between decoded presentation form
4331 With ARG, toggle the displaying of the current MIME entity only.
4333 If `rmail-enable-mime' is nil, this creates a temporary
4334 \"*RMAIL*\" buffer holding a decoded copy of the message. Inline
4335 content-types are handled according to
4336 `rmail-mime-media-type-handlers-alist'. By default, this
4337 displays text and multipart messages, and offers to download
4338 attachments as specfied by `rmail-mime-attachment-dirs-alist'.
4340 \(fn &optional ARG)" t nil
)
4344 ;;;### (autoloads (set-rmail-inbox-list) "rmailmsc" "rmailmsc.el"
4345 ;;;;;; "ca19b2f8a3e8aa01aa75ca7413f8a5ef")
4346 ;;; Generated autoloads from rmailmsc.el
4348 (autoload 'set-rmail-inbox-list
"rmailmsc" "\
4349 Set the inbox list of the current RMAIL file to FILE-NAME.
4350 You can specify one file name, or several names separated by commas.
4351 If FILE-NAME is empty, remove any existing inbox list.
4353 This applies only to the current session.
4355 \(fn FILE-NAME)" t nil
)
4359 ;;;### (autoloads (rmail-sort-by-labels rmail-sort-by-lines rmail-sort-by-correspondent
4360 ;;;;;; rmail-sort-by-recipient rmail-sort-by-author rmail-sort-by-subject
4361 ;;;;;; rmail-sort-by-date) "rmailsort" "rmailsort.el" "ad1c98fe868c0e5804cf945d6c980d0b")
4362 ;;; Generated autoloads from rmailsort.el
4364 (autoload 'rmail-sort-by-date
"rmailsort" "\
4365 Sort messages of current Rmail buffer by \"Date\" header.
4366 If prefix argument REVERSE is non-nil, sorts in reverse order.
4368 \(fn REVERSE)" t nil
)
4370 (autoload 'rmail-sort-by-subject
"rmailsort" "\
4371 Sort messages of current Rmail buffer by \"Subject\" header.
4372 Ignores any \"Re: \" prefix. If prefix argument REVERSE is
4373 non-nil, sorts in reverse order.
4375 \(fn REVERSE)" t nil
)
4377 (autoload 'rmail-sort-by-author
"rmailsort" "\
4378 Sort messages of current Rmail buffer by author.
4379 This uses either the \"From\" or \"Sender\" header, downcased.
4380 If prefix argument REVERSE is non-nil, sorts in reverse order.
4382 \(fn REVERSE)" t nil
)
4384 (autoload 'rmail-sort-by-recipient
"rmailsort" "\
4385 Sort messages of current Rmail buffer by recipient.
4386 This uses either the \"To\" or \"Apparently-To\" header, downcased.
4387 If prefix argument REVERSE is non-nil, sorts in reverse order.
4389 \(fn REVERSE)" t nil
)
4391 (autoload 'rmail-sort-by-correspondent
"rmailsort" "\
4392 Sort messages of current Rmail buffer by other correspondent.
4393 This uses either the \"From\", \"Sender\", \"To\", or
4394 \"Apparently-To\" header, downcased. Uses the first header not
4395 excluded by `mail-dont-reply-to-names'. If prefix argument
4396 REVERSE is non-nil, sorts in reverse order.
4398 \(fn REVERSE)" t nil
)
4400 (autoload 'rmail-sort-by-lines
"rmailsort" "\
4401 Sort messages of current Rmail buffer by the number of lines.
4402 If prefix argument REVERSE is non-nil, sorts in reverse order.
4404 \(fn REVERSE)" t nil
)
4406 (autoload 'rmail-sort-by-labels
"rmailsort" "\
4407 Sort messages of current Rmail buffer by labels.
4408 LABELS is a comma-separated list of labels. The order of these
4409 labels specifies the order of messages: messages with the first
4410 label come first, messages with the second label come second, and
4411 so on. Messages that have none of these labels come last.
4412 If prefix argument REVERSE is non-nil, sorts in reverse order.
4414 \(fn REVERSE LABELS)" t nil
)
4418 ;;;### (autoloads (rmail-summary-by-senders rmail-summary-by-topic
4419 ;;;;;; rmail-summary-by-regexp rmail-summary-by-recipients rmail-summary-by-labels
4420 ;;;;;; rmail-summary) "rmailsum" "rmailsum.el" "3817e21639db697abe5832d3223ecfc2")
4421 ;;; Generated autoloads from rmailsum.el
4423 (autoload 'rmail-summary
"rmailsum" "\
4424 Display a summary of all messages, one line per message.
4428 (autoload 'rmail-summary-by-labels
"rmailsum" "\
4429 Display a summary of all messages with one or more LABELS.
4430 LABELS should be a string containing the desired labels, separated by commas.
4432 \(fn LABELS)" t nil
)
4434 (autoload 'rmail-summary-by-recipients
"rmailsum" "\
4435 Display a summary of all messages with the given RECIPIENTS.
4436 Normally checks the To, From and Cc fields of headers;
4437 but if PRIMARY-ONLY is non-nil (prefix arg given),
4438 only look in the To and From fields.
4439 RECIPIENTS is a string of regexps separated by commas.
4441 \(fn RECIPIENTS &optional PRIMARY-ONLY)" t nil
)
4443 (autoload 'rmail-summary-by-regexp
"rmailsum" "\
4444 Display a summary of all messages according to regexp REGEXP.
4445 If the regular expression is found in the header of the message
4446 \(including in the date and other lines, as well as the subject line),
4447 Emacs will list the message in the summary.
4449 \(fn REGEXP)" t nil
)
4451 (autoload 'rmail-summary-by-topic
"rmailsum" "\
4452 Display a summary of all messages with the given SUBJECT.
4453 Normally checks just the Subject field of headers; but with prefix
4454 argument WHOLE-MESSAGE is non-nil, looks in the whole message.
4455 SUBJECT is a string of regexps separated by commas.
4457 \(fn SUBJECT &optional WHOLE-MESSAGE)" t nil
)
4459 (autoload 'rmail-summary-by-senders
"rmailsum" "\
4460 Display a summary of all messages whose \"From\" field matches SENDERS.
4461 SENDERS is a string of regexps separated by commas.
4463 \(fn SENDERS)" t nil
)
4467 ;;;### (autoloads (unforward-rmail-message undigestify-rmail-message)
4468 ;;;;;; "undigest" "undigest.el" "41e6a48ea63224385c447a944528feb6")
4469 ;;; Generated autoloads from undigest.el
4471 (autoload 'undigestify-rmail-message
"undigest" "\
4472 Break up a digest message into its constituent messages.
4473 Leaves original message, deleted, before the undigestified messages.
4477 (autoload 'unforward-rmail-message
"undigest" "\
4478 Extract a forwarded message from the containing message.
4479 This puts the forwarded message into a separate rmail message
4480 following the containing message.
4486 ;;; End of automatically extracted autoloads.
4491 ;;; rmail.el ends here