Commit 13847f79 authored by Bastien Guerry's avatar Bastien Guerry
Browse files

Removed rmail.el, rmailedit.el, rmailkwd.el, rmailmm.el, rmailmsc.el,...

Removed rmail.el, rmailedit.el, rmailkwd.el, rmailmm.el, rmailmsc.el, rmailout.el, rmailsort.el, rmailsum.el.
parent 3a88a825
;;; rmail.el --- main code of "RMAIL" mail reader for Emacs
;; Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998,
;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
;; Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: mail
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
;; Souped up by shane@mit-ajax based on ideas of rlk@athena.mit.edu
;; New features include attribute and keyword support, message
;; selection by dispatch table, summary by attributes and keywords,
;; expunging by dispatch table, sticky options for file commands.
;; Extended by Bob Weiner of Motorola
;; New features include: rmail and rmail-summary buffers remain
;; synchronized and key bindings basically operate the same way in both
;; buffers, summary by topic or by regular expression, rmail-reply-prefix
;; variable, and a bury rmail buffer (wipe) command.
;;
(require 'mail-utils)
(eval-when-compile (require 'mule-util)) ; for detect-coding-with-priority
(defvar deleted-head)
(defvar font-lock-fontified)
(defvar mail-abbrev-syntax-table)
(defvar mail-abbrevs)
(defvar messages-head)
(defvar rmail-use-spam-filter)
(defvar rsf-beep)
(defvar rsf-sleep-after-message)
(defvar total-messages)
(defvar tool-bar-map)
; These variables now declared in paths.el.
;(defvar rmail-spool-directory "/usr/spool/mail/"
; "This is the name of the directory used by the system mailer for\n\
;delivering new mail. Its name should end with a slash.")
;(defvar rmail-file-name
; (expand-file-name "~/RMAIL")
; "")
(defgroup rmail nil
"Mail reader for Emacs."
:group 'mail)
(defgroup rmail-retrieve nil
"Rmail retrieval options."
:prefix "rmail-"
:group 'rmail)
(defgroup rmail-files nil
"Rmail files."
:prefix "rmail-"
:group 'rmail)
(defgroup rmail-headers nil
"Rmail header options."
:prefix "rmail-"
:group 'rmail)
(defgroup rmail-reply nil
"Rmail reply options."
:prefix "rmail-"
:group 'rmail)
(defgroup rmail-summary nil
"Rmail summary options."
:prefix "rmail-"
:prefix "rmail-summary-"
:group 'rmail)
(defgroup rmail-output nil
"Output message to a file."
:prefix "rmail-output-"
:prefix "rmail-"
:group 'rmail)
(defgroup rmail-edit nil
"Rmail editing."
:prefix "rmail-edit-"
:group 'rmail)
(defgroup rmail-obsolete nil
"Rmail obsolete customization variables."
:group 'rmail)
(defcustom rmail-movemail-program nil
"If non-nil, the file name of the `movemail' program."
:group 'rmail-retrieve
:type '(choice (const nil) string))
(defcustom rmail-pop-password nil
"*Password to use when reading mail from POP server.
Please use `rmail-remote-password' instead."
:type '(choice (string :tag "Password")
(const :tag "Not Required" nil))
:group 'rmail-obsolete)
(defcustom rmail-pop-password-required nil
"*Non-nil if a password is required when reading mail from a POP server.
Please use rmail-remote-password-required instead."
:type 'boolean
:group 'rmail-obsolete)
(defcustom rmail-remote-password nil
"*Password to use when reading mail from a remote server.
This setting is ignored for mailboxes whose URL already contains a password."
:type '(choice (string :tag "Password")
(const :tag "Not Required" nil))
:set-after '(rmail-pop-password)
:set #'(lambda (symbol value)
(set-default symbol
(if (and (not value)
(boundp 'rmail-pop-password)
rmail-pop-password)
rmail-pop-password
value))
(setq rmail-pop-password nil))
:group 'rmail-retrieve
:version "22.1")
(defcustom rmail-remote-password-required nil
"*Non-nil if a password is required when reading mail from a remote server."
:type 'boolean
:set-after '(rmail-pop-password-required)
:set #'(lambda (symbol value)
(set-default symbol
(if (and (not value)
(boundp 'rmail-pop-password-required)
rmail-pop-password-required)
rmail-pop-password-required
value))
(setq rmail-pop-password-required nil))
:group 'rmail-retrieve
:version "22.1")
(defcustom rmail-movemail-flags nil
"*List of flags to pass to movemail.
Most commonly used to specify `-g' to enable GSS-API authentication
or `-k' to enable Kerberos authentication."
:type '(repeat string)
:group 'rmail-retrieve
:version "20.3")
(defvar rmail-remote-password-error "invalid usercode or password\\|
unknown user name or bad password\\|Authentication failed\\|MU_ERR_AUTH_FAILURE"
"Regular expression matching incorrect-password POP or IMAP server error
messages.
If you get an incorrect-password error that this expression does not match,
please report it with \\[report-emacs-bug].")
(defvar rmail-encoded-remote-password nil)
(defcustom rmail-preserve-inbox nil
"*Non-nil means leave incoming mail in the user's inbox--don't delete it."
:type 'boolean
:group 'rmail-retrieve)
(defcustom rmail-movemail-search-path nil
"*List of directories to search for movemail (in addition to `exec-path')."
:group 'rmail-retrieve
:type '(repeat (directory)))
(declare-function mail-position-on-field "sendmail" (field &optional soft))
(declare-function mail-text-start "sendmail" ())
(declare-function rmail-update-summary "rmailsum" (&rest ignore))
(defun rmail-probe (prog)
"Determine what flavor of movemail PROG is.
We do this by executing it with `--version' and analyzing its output."
(with-temp-buffer
(let ((tbuf (current-buffer)))
(buffer-disable-undo tbuf)
(call-process prog nil tbuf nil "--version")
(if (not (buffer-modified-p tbuf))
;; Should not happen...
nil
(goto-char (point-min))
(cond
((looking-at ".*movemail: invalid option")
'emacs) ;; Possibly...
((looking-at "movemail (GNU Mailutils .*)")
'mailutils)
(t
;; FIXME:
'emacs))))))
(defun rmail-autodetect ()
"Determine the file name of the `movemail' program and return its flavor.
If `rmail-movemail-program' is non-nil, use it.
Otherwise, look for `movemail' in the directories in
`rmail-movemail-search-path', those in `exec-path', and `exec-directory'."
(if rmail-movemail-program
(rmail-probe rmail-movemail-program)
(catch 'scan
(dolist (dir (append rmail-movemail-search-path exec-path
(list exec-directory)))
(when (and dir (file-accessible-directory-p dir))
;; Previously, this didn't have to work on Windows, because
;; rmail-insert-inbox-text before r1.439 fell back to using
;; (expand-file-name "movemail" exec-directory) and just
;; assuming it would work.
;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2008-02/msg00087.html
(let ((progname (expand-file-name
(concat "movemail"
(if (memq system-type '(ms-dos windows-nt))
".exe")) dir)))
(when (and (not (file-directory-p progname))
(file-executable-p progname))
(let ((x (rmail-probe progname)))
(when x
(setq rmail-movemail-program progname)
(throw 'scan x))))))))))
(defvar rmail-movemail-variant-in-use nil
"The movemail variant currently in use. Known variants are:
`emacs' Means any implementation, compatible with the native Emacs one.
This is the default;
`mailutils' Means GNU mailutils implementation, capable of handling full
mail URLs as the source mailbox.")
;;;###autoload
(defun rmail-movemail-variant-p (&rest variants)
"Return t if the current movemail variant is any of VARIANTS.
Currently known variants are 'emacs and 'mailutils."
(when (not rmail-movemail-variant-in-use)
;; Autodetect
(setq rmail-movemail-variant-in-use (rmail-autodetect)))
(not (null (member rmail-movemail-variant-in-use variants))))
;; Call for effect, to set rmail-movemail-program (if not set by the
;; user), and rmail-movemail-variant-in-use. Used by various functions.
;; I'm not sure if M-x rmail is the only entry point to this package.
;; If so, this can be moved there.
(rmail-movemail-variant-p)
;;;###autoload
(defcustom rmail-dont-reply-to-names nil "\
*A regexp specifying addresses to prune from a reply message.
A value of nil means exclude your own email address as an address
plus whatever is specified by `rmail-default-dont-reply-to-names'."
:type '(choice regexp (const :tag "Your Name" nil))
:group 'rmail-reply)
;;;###autoload
(defvar rmail-default-dont-reply-to-names "\\`info-" "\
A regular expression specifying part of the default value of the
variable `rmail-dont-reply-to-names', for when the user does not set
`rmail-dont-reply-to-names' explicitly. (The other part of the default
value is the user's email address and name.)
It is useful to set this variable in the site customization file.")
;;;###autoload
(defcustom rmail-ignored-headers
(concat "^via:\\|^mail-from:\\|^origin:\\|^references:\\|^sender:"
"\\|^status:\\|^received:\\|^x400-originator:\\|^x400-recipients:"
"\\|^x400-received:\\|^x400-mts-identifier:\\|^x400-content-type:"
"\\|^\\(resent-\\|\\)message-id:\\|^summary-line:\\|^resent-date:"
"\\|^nntp-posting-host:\\|^path:\\|^x-char.*:\\|^x-face:\\|^face:"
"\\|^x-mailer:\\|^delivered-to:\\|^lines:"
"\\|^content-transfer-encoding:\\|^x-coding-system:"
"\\|^return-path:\\|^errors-to:\\|^return-receipt-to:"
"\\|^precedence:\\|^list-help:\\|^list-post:\\|^list-subscribe:"
"\\|^list-id:\\|^list-unsubscribe:\\|^list-archive:"
"\\|^content-length:\\|^nntp-posting-date:\\|^user-agent"
"\\|^importance:\\|^envelope-to:\\|^delivery-date\\|^openpgp:"
"\\|^mbox-line:\\|^cancel-lock:\\|^DomainKey-Signature:"
"\\|^resent-face:\\|^resent-x.*:\\|^resent-organization:\\|^resent-openpgp:"
"\\|^x-.*:")
"*Regexp to match header fields that Rmail should normally hide.
\(See also `rmail-nonignored-headers', which overrides this regexp.)
This variable is used for reformatting the message header,
which normally happens once for each message,
when you view the message for the first time in Rmail.
To make a change in this variable take effect
for a message that you have already viewed,
go to that message and type \\[rmail-toggle-header] twice."
:type 'regexp
:group 'rmail-headers)
(defcustom rmail-nonignored-headers "^x-spam-status:"
"*Regexp to match X header fields that Rmail should show.
This regexp overrides `rmail-ignored-headers'; if both this regexp
and that one match a certain header field, Rmail shows the field.
If this is nil, ignore all header fields in `rmail-ignored-headers'.
This variable is used for reformatting the message header,
which normally happens once for each message,
when you view the message for the first time in Rmail.
To make a change in this variable take effect
for a message that you have already viewed,
go to that message and type \\[rmail-toggle-header] twice."
:type '(choice (const nil) (regexp))
:group 'rmail-headers)
;;;###autoload
(defcustom rmail-displayed-headers nil
"*Regexp to match Header fields that Rmail should display.
If nil, display all header fields except those matched by
`rmail-ignored-headers'."
:type '(choice regexp (const :tag "All"))
:group 'rmail-headers)
;;;###autoload
(defcustom rmail-retry-ignored-headers "^x-authentication-warning:" "\
*Headers that should be stripped when retrying a failed message."
:type '(choice regexp (const nil :tag "None"))
:group 'rmail-headers)
;;;###autoload
(defcustom rmail-highlighted-headers "^From:\\|^Subject:" "\
*Regexp to match Header fields that Rmail should normally highlight.
A value of nil means don't highlight."
:type 'regexp
:group 'rmail-headers)
(defface rmail-highlight
'((t (:inherit highlight)))
"Face to use for highlighting the most important header fields."
:group 'rmail-headers
:version "22.1")
(defface rmail-header-name
'((t (:inherit font-lock-function-name-face)))
"Face to use for highlighting the header names."
:group 'rmail-headers
:version "23.1")
;;;###autoload
(defcustom rmail-delete-after-output nil "\
*Non-nil means automatically delete a message that is copied to a file."
:type 'boolean
:group 'rmail-files)
;;;###autoload
(defcustom rmail-primary-inbox-list nil "\
*List of files which are inboxes for user's primary mail file `~/RMAIL'.
nil means the default, which is (\"/usr/spool/mail/$USER\")
\(the name varies depending on the operating system,
and the value of the environment variable MAIL overrides it)."
;; Don't use backquote here, because we don't want to need it
;; at load time.
:type (list 'choice '(const :tag "Default" nil)
(list 'repeat ':value (list (or (getenv "MAIL")
(concat "/var/spool/mail/"
(getenv "USER"))))
'file))
:group 'rmail-retrieve
:group 'rmail-files)
;;;###autoload
(defcustom rmail-mail-new-frame nil
"*Non-nil means Rmail makes a new frame for composing outgoing mail.
This is handy if you want to preserve the window configuration of
the frame where you have the RMAIL buffer displayed."
:type 'boolean
:group 'rmail-reply)
;;;###autoload
(defcustom rmail-secondary-file-directory "~/"
"*Directory for additional secondary Rmail files."
:type 'directory
:group 'rmail-files)
;;;###autoload
(defcustom rmail-secondary-file-regexp "\\.xmail$"
"*Regexp for which files are secondary Rmail files."
:type 'regexp
:group 'rmail-files)
;;;###autoload
(defcustom rmail-confirm-expunge 'y-or-n-p
"*Whether and how to ask for confirmation before expunging deleted messages."
:type '(choice (const :tag "No confirmation" nil)
(const :tag "Confirm with y-or-n-p" y-or-n-p)
(const :tag "Confirm with yes-or-no-p" yes-or-no-p))
:version "21.1"
:group 'rmail-files)
;;;###autoload
(defvar rmail-mode-hook nil
"List of functions to call when Rmail is invoked.")
;;;###autoload
(defvar rmail-get-new-mail-hook nil
"List of functions to call when Rmail has retrieved new mail.")
;;;###autoload
(defcustom rmail-show-message-hook nil
"List of functions to call when Rmail displays a message."
:type 'hook
:options '(goto-address)
:group 'rmail)
;;;###autoload
(defvar rmail-quit-hook nil
"List of functions to call when quitting out of Rmail.")
;;;###autoload
(defvar rmail-delete-message-hook nil
"List of functions to call when Rmail deletes a message.
When the hooks are called, the message has been marked deleted but is
still the current message in the Rmail buffer.")
;; These may be altered by site-init.el to match the format of mmdf files
;; delimiting used on a given host (delim1 and delim2 from the config
;; files).
(defvar rmail-mmdf-delim1 "^\001\001\001\001\n"
"Regexp marking the start of an mmdf message.")
(defvar rmail-mmdf-delim2 "^\001\001\001\001\n"
"Regexp marking the end of an mmdf message.")
(defcustom rmail-message-filter nil
"If non-nil, a filter function for new messages in RMAIL.
Called with region narrowed to the message, including headers,
before obeying `rmail-ignored-headers'."
:group 'rmail-headers
:type '(choice (const nil) function))
(defcustom rmail-automatic-folder-directives nil
"List of directives specifying where to put a message.
Each element of the list is of the form:
(FOLDERNAME FIELD REGEXP [ FIELD REGEXP ] ... )
Where FOLDERNAME is the name of a BABYL format folder to put the
message. If any of the field regexp's are nil, then it is ignored.
If FOLDERNAME is \"/dev/null\", it is deleted.
If FOLDERNAME is nil then it is deleted, and skipped.
FIELD is the plain text name of a field in the message, such as
\"subject\" or \"from\". A FIELD of \"to\" will automatically include
all text from the \"cc\" field as well.
REGEXP is an expression to match in the preceeding specified FIELD.
FIELD/REGEXP pairs continue in the list.
examples:
(\"/dev/null\" \"from\" \"@spam.com\") ; delete all mail from spam.com
(\"RMS\" \"from\" \"rms@\") ; save all mail from RMS."
:group 'rmail
:version "21.1"
:type '(repeat (sexp :tag "Directive")))
(defvar rmail-reply-prefix "Re: "
"String to prepend to Subject line when replying to a message.")
;; Some mailers use "Re(2):" or "Re^2:" or "Re: Re:" or "Re[2]:".
;; This pattern should catch all the common variants.
;; rms: I deleted the change to delete tags in square brackets
;; because they mess up RT tags.
(defvar rmail-reply-regexp "\\`\\(Re\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?: *\\)*"
"Regexp to delete from Subject line before inserting `rmail-reply-prefix'.")
(defcustom rmail-display-summary nil
"*If non-nil, Rmail always displays the summary buffer."
:group 'rmail-summary
:type 'boolean)
(defvar rmail-inbox-list nil)
(put 'rmail-inbox-list 'permanent-local t)
(defvar rmail-keywords nil)
(put 'rmail-keywords 'permanent-local t)
(defvar rmail-buffer nil
"The RMAIL buffer related to the current buffer.
In an RMAIL buffer, this holds the RMAIL buffer itself.
In a summary buffer, this holds the RMAIL buffer it is a summary for.")
(put 'rmail-buffer 'permanent-local t)
;; Message counters and markers. Deleted flags.
(defvar rmail-current-message nil)
(put 'rmail-current-message 'permanent-local t)
(defvar rmail-total-messages nil)
(put 'rmail-total-messages 'permanent-local t)
(defvar rmail-message-vector nil)
(put 'rmail-message-vector 'permanent-local t)
(defvar rmail-deleted-vector nil)
(put 'rmail-deleted-vector 'permanent-local t)
(defvar rmail-msgref-vector nil
"In an Rmail buffer, a vector whose Nth element is a list (N).
When expunging renumbers messages, these lists are modified
by substituting the new message number into the existing list.")
(put 'rmail-msgref-vector 'permanent-local t)
(defvar rmail-overlay-list nil)
(put 'rmail-overlay-list 'permanent-local t)
;; These are used by autoloaded rmail-summary.
(defvar rmail-summary-buffer nil)
(put 'rmail-summary-buffer 'permanent-local t)
(defvar rmail-summary-vector nil)
(put 'rmail-summary-vector 'permanent-local t)
(defvar rmail-view-buffer nil
"Buffer which holds RMAIL message for MIME displaying.")
(put 'rmail-view-buffer 'permanent-local t)
;; `Sticky' default variables.
;; Last individual label specified to a or k.
(defvar rmail-last-label nil)
(put 'rmail-last-label 'permanent-local t)
;; Last set of values specified to C-M-n, C-M-p, C-M-s or C-M-l.
(defvar rmail-last-multi-labels nil)
(defvar rmail-last-regexp nil)
(put 'rmail-last-regexp 'permanent-local t)
(defcustom rmail-default-file "~/xmail"
"*Default file name for \\[rmail-output]."
:type 'file
:group 'rmail-files)
(defcustom rmail-default-rmail-file "~/XMAIL"
"*Default file name for \\[rmail-output-to-rmail-file]."
:type 'file
:group 'rmail-files)
(defcustom rmail-default-body-file "~/mailout"
"*Default file name for \\[rmail-output-body-to-file]."
:type 'file
:group 'rmail-files
:version "20.3")
;; Mule and MIME related variables.
;;;###autoload
(defvar rmail-file-coding-system nil
"Coding system used in RMAIL file.
This is set to nil by default.")
;;;###autoload
(defcustom rmail-enable-mime nil
"*If non-nil, RMAIL uses MIME feature.
If the value is t, RMAIL automatically shows MIME decoded message.
If the value is neither t nor nil, RMAIL does not show MIME decoded message
until a user explicitly requires it.
Even if the value is non-nil, you can't use MIME feature
if the feature specified by `rmail-mime-feature' is not available
in your session."
:type '(choice (const :tag "on" t)
(const :tag "off" nil)
(other :tag "when asked" ask))
:group 'rmail)
(defvar rmail-enable-mime-composing nil
"*If non-nil, RMAIL uses `rmail-insert-mime-forwarded-message-function' to forward.")
;;;###autoload
(defvar rmail-show-mime-function nil
"Function to show MIME decoded message of RMAIL file.
This function is called when `rmail-enable-mime' is non-nil.
It is called with no argument.")
;;;###autoload
(defvar rmail-insert-mime-forwarded-message-function nil
"Function to insert a message in MIME format so it can be forwarded.
This function is called if `rmail-enable-mime' or
`rmail-enable-mime-composing' is non-nil.
It is called with one argument FORWARD-BUFFER, which is a
buffer containing the message to forward. The current buffer
is the outgoing mail buffer.")
;;;###autoload
(defvar rmail-insert-mime-resent-message-function nil
"Function to insert a message in MIME format so it can be resent.
This function is called if `rmail-enable-mime' is non-nil.
It is called with one argument FORWARD-BUFFER, which is a
buffer containing the message to forward. The current buffer
is the outgoing mail buffer.")
;;;###autoload
(defvar rmail-search-mime-message-function nil
"Function to check if a regexp matches a MIME message.
This function is called if `rmail-enable-mime' is non-nil.
It is called with two arguments MSG and REGEXP, where
MSG is the message number, REGEXP is the regular expression.")
;;;###autoload
(defvar rmail-search-mime-header-function nil
"Function to check if a regexp matches a header of MIME message.
This function is called if `rmail-enable-mime' is non-nil.
It is called with three arguments MSG, REGEXP, and LIMIT, where
MSG is the message number,
REGEXP is the regular expression,
LIMIT is the position specifying the end of header.")
;;;###autoload
(defvar rmail-mime-feature 'rmail-mime
"Feature to require to load MIME support in Rmail.
When starting Rmail, if `rmail-enable-mime' is non-nil,
this feature is required with `require'.
The default value is `rmail-mime'. This feature is provided by
the rmail-mime package available at <http://www.m17n.org/rmail-mime/>.")
;;;###autoload
(defvar rmail-decode-mime-charset t
"*Non-nil means a message is decoded by MIME's charset specification.
If this variable is nil, or the message has not MIME specification,
the message is decoded as normal way.
If the variable `rmail-enable-mime' is non-nil, this variables is
ignored, and all the decoding work is done by a feature specified by
the variable `rmail-mime-feature'.")
;;;###autoload<