view lisp/mail/mbox-trunk-annotations/rmail.el.annotation @ 98117:3c5d54685977

*** empty log message ***
author Glenn Morris <rgm@gnu.org>
date Wed, 10 Sep 2008 02:31:58 +0000
parents 513ae63d6175
children
line wrap: on
line source

1.348        (pj       15-Jul-01): ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs
1.12         (eric     30-May-92): 
1.407        (ttn      06-Aug-05): ;; Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1996, 1997, 1998,
1.444        (miles    08-Jan-08): ;;   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
1.440        (gm       12-Oct-07): ;;   Free Software Foundation, Inc.
1.18         (eric     22-Jul-92): 
1.13         (eric     16-Jul-92): ;; Maintainer: FSF
1.15         (eric     17-Jul-92): ;; Keywords: mail
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; This file is part of GNU Emacs.
1.1          (roland   13-May-91): 
1.454        (gm       06-May-08): ;; GNU Emacs is free software: you can redistribute it and/or modify
1.1          (roland   13-May-91): ;; it under the terms of the GNU General Public License as published by
1.454        (gm       06-May-08): ;; the Free Software Foundation, either version 3 of the License, or
1.454        (gm       06-May-08): ;; (at your option) any later version.
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; GNU Emacs is distributed in the hope that it will be useful,
1.1          (roland   13-May-91): ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
1.1          (roland   13-May-91): ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1.1          (roland   13-May-91): ;; GNU General Public License for more details.
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; You should have received a copy of the GNU General Public License
1.454        (gm       06-May-08): ;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
1.1          (roland   13-May-91): 
1.348        (pj       15-Jul-01): ;;; Commentary:
1.348        (pj       15-Jul-01): 
1.13         (eric     16-Jul-92): ;;; Code:
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; Souped up by shane@mit-ajax based on ideas of rlk@athena.mit.edu
1.1          (roland   13-May-91): ;;   New features include attribute and keyword support, message
1.1          (roland   13-May-91): ;;   selection by dispatch table, summary by attributes and keywords,
1.1          (roland   13-May-91): ;;   expunging by dispatch table, sticky options for file commands.
1.1          (roland   13-May-91): 
1.39         (rms      09-Mar-93): ;; Extended by Bob Weiner of Motorola
1.39         (rms      09-Mar-93): ;;   New features include: rmail and rmail-summary buffers remain
1.39         (rms      09-Mar-93): ;;   synchronized and key bindings basically operate the same way in both
1.39         (rms      09-Mar-93): ;;   buffers, summary by topic or by regular expression, rmail-reply-prefix
1.39         (rms      09-Mar-93): ;;   variable, and a bury rmail buffer (wipe) command.
1.39         (rms      09-Mar-93): ;;
1.39         (rms      09-Mar-93): 
1.1          (roland   13-May-91): (require 'mail-utils)
1.349        (eliz     16-Sep-01): (eval-when-compile (require 'mule-util)) ; for detect-coding-with-priority
1.39         (rms      09-Mar-93): 
1.414        (lektu    29-Aug-05): (defvar deleted-head)
1.414        (lektu    29-Aug-05): (defvar font-lock-fontified)
1.414        (lektu    29-Aug-05): (defvar mail-abbrev-syntax-table)
1.414        (lektu    29-Aug-05): (defvar mail-abbrevs)
1.414        (lektu    29-Aug-05): (defvar messages-head)
1.414        (lektu    29-Aug-05): (defvar rmail-use-spam-filter)
1.414        (lektu    29-Aug-05): (defvar rsf-beep)
1.414        (lektu    29-Aug-05): (defvar rsf-sleep-after-message)
1.414        (lektu    29-Aug-05): (defvar total-messages)
1.423        (eliz     25-Mar-06): (defvar tool-bar-map)
1.414        (lektu    29-Aug-05): 
1.39         (rms      09-Mar-93): ; These variables now declared in paths.el.
1.1          (roland   13-May-91): ;(defvar rmail-spool-directory "/usr/spool/mail/"
1.1          (roland   13-May-91): ;  "This is the name of the directory used by the system mailer for\n\
1.200        (rms      12-Oct-96): ;delivering new mail.  Its name should end with a slash.")
1.1          (roland   13-May-91): ;(defvar rmail-file-name
1.1          (roland   13-May-91): ;  (expand-file-name "~/RMAIL")
1.1          (roland   13-May-91): ;  "")
1.1          (roland   13-May-91): 
1.219        (rms      03-May-97): (defgroup rmail nil
1.219        (rms      03-May-97):   "Mail reader for Emacs."
1.219        (rms      03-May-97):   :group 'mail)
1.219        (rms      03-May-97): 
1.219        (rms      03-May-97): (defgroup rmail-retrieve nil
1.219        (rms      03-May-97):   "Rmail retrieval options."
1.219        (rms      03-May-97):   :prefix "rmail-"
1.219        (rms      03-May-97):   :group 'rmail)
1.219        (rms      03-May-97): 
1.219        (rms      03-May-97): (defgroup rmail-files nil
1.219        (rms      03-May-97):   "Rmail files."
1.219        (rms      03-May-97):   :prefix "rmail-"
1.219        (rms      03-May-97):   :group 'rmail)
1.219        (rms      03-May-97): 
1.219        (rms      03-May-97): (defgroup rmail-headers nil
1.219        (rms      03-May-97):   "Rmail header options."
1.219        (rms      03-May-97):   :prefix "rmail-"
1.219        (rms      03-May-97):   :group 'rmail)
1.219        (rms      03-May-97): 
1.219        (rms      03-May-97): (defgroup rmail-reply nil
1.219        (rms      03-May-97):   "Rmail reply options."
1.219        (rms      03-May-97):   :prefix "rmail-"
1.219        (rms      03-May-97):   :group 'rmail)
1.219        (rms      03-May-97): 
1.219        (rms      03-May-97): (defgroup rmail-summary nil
1.219        (rms      03-May-97):   "Rmail summary options."
1.219        (rms      03-May-97):   :prefix "rmail-"
1.219        (rms      03-May-97):   :prefix "rmail-summary-"
1.219        (rms      03-May-97):   :group 'rmail)
1.219        (rms      03-May-97): 
1.219        (rms      03-May-97): (defgroup rmail-output nil
1.219        (rms      03-May-97):   "Output message to a file."
1.219        (rms      03-May-97):   :prefix "rmail-output-"
1.219        (rms      03-May-97):   :prefix "rmail-"
1.219        (rms      03-May-97):   :group 'rmail)
1.219        (rms      03-May-97): 
1.337        (gerd     07-May-01): (defgroup rmail-edit nil
1.337        (gerd     07-May-01):   "Rmail editing."
1.337        (gerd     07-May-01):   :prefix "rmail-edit-"
1.337        (gerd     07-May-01):   :group 'rmail)
1.337        (gerd     07-May-01): 
1.395        (eliz     15-Jan-05): (defgroup rmail-obsolete nil
1.395        (eliz     15-Jan-05):   "Rmail obsolete customization variables."
1.395        (eliz     15-Jan-05):   :group 'rmail)
1.219        (rms      03-May-97): 
1.259        (kwzh     08-Apr-98): (defcustom rmail-movemail-program nil
1.397        (rms      18-Mar-05):   "If non-nil, the file name of the `movemail' program."
1.259        (kwzh     08-Apr-98):   :group 'rmail-retrieve
1.286        (schwab   18-Sep-98):   :type '(choice (const nil) string))
1.110        (rms      13-Jul-94): 
1.219        (rms      03-May-97): (defcustom rmail-pop-password nil
1.397        (rms      18-Mar-05):   "*Password to use when reading mail from POP server.
1.397        (rms      18-Mar-05): Please use `rmail-remote-password' instead."
1.219        (rms      03-May-97):   :type '(choice (string :tag "Password")
1.219        (rms      03-May-97): 		 (const :tag "Not Required" nil))
1.395        (eliz     15-Jan-05):   :group 'rmail-obsolete)
1.219        (rms      03-May-97): 
1.219        (rms      03-May-97): (defcustom rmail-pop-password-required nil
1.407        (ttn      06-Aug-05):   "*Non-nil if a password is required when reading mail from a POP server.
1.397        (rms      18-Mar-05): Please use rmail-remote-password-required instead."
1.219        (rms      03-May-97):   :type 'boolean
1.395        (eliz     15-Jan-05):   :group 'rmail-obsolete)
1.395        (eliz     15-Jan-05): 
1.395        (eliz     15-Jan-05): (defcustom rmail-remote-password nil
1.397        (rms      18-Mar-05):   "*Password to use when reading mail from a remote server.
1.397        (rms      18-Mar-05): This setting is ignored for mailboxes whose URL already contains a password."
1.395        (eliz     15-Jan-05):   :type '(choice (string :tag "Password")
1.395        (eliz     15-Jan-05): 		 (const :tag "Not Required" nil))
1.395        (eliz     15-Jan-05):   :set-after '(rmail-pop-password)
1.395        (eliz     15-Jan-05):   :set #'(lambda (symbol value)
1.396        (kfstorm  09-Feb-05): 	   (set-default symbol
1.395        (eliz     15-Jan-05): 			(if (and (not value)
1.395        (eliz     15-Jan-05):                                  (boundp 'rmail-pop-password)
1.395        (eliz     15-Jan-05): 				 rmail-pop-password)
1.395        (eliz     15-Jan-05): 			    rmail-pop-password
1.395        (eliz     15-Jan-05): 			  value))
1.395        (eliz     15-Jan-05): 	   (setq rmail-pop-password nil))
1.395        (eliz     15-Jan-05):   :group 'rmail-retrieve
1.396        (kfstorm  09-Feb-05):   :version "22.1")
1.395        (eliz     15-Jan-05): 
1.395        (eliz     15-Jan-05): (defcustom rmail-remote-password-required nil
1.395        (eliz     15-Jan-05):   "*Non-nil if a password is required when reading mail from a remote server."
1.395        (eliz     15-Jan-05):   :type 'boolean
1.395        (eliz     15-Jan-05):   :set-after '(rmail-pop-password-required)
1.395        (eliz     15-Jan-05):   :set #'(lambda (symbol value)
1.396        (kfstorm  09-Feb-05): 	   (set-default symbol
1.395        (eliz     15-Jan-05): 			(if (and (not value)
1.395        (eliz     15-Jan-05):                                  (boundp 'rmail-pop-password-required)
1.395        (eliz     15-Jan-05): 				 rmail-pop-password-required)
1.395        (eliz     15-Jan-05): 			    rmail-pop-password-required
1.395        (eliz     15-Jan-05): 			  value))
1.395        (eliz     15-Jan-05): 	   (setq rmail-pop-password-required nil))
1.395        (eliz     15-Jan-05):   :group 'rmail-retrieve
1.396        (kfstorm  09-Feb-05):   :version "22.1")
1.183        (rms      26-Apr-96): 
1.256        (kwzh     06-Apr-98): (defcustom rmail-movemail-flags nil
1.257        (kwzh     06-Apr-98):   "*List of flags to pass to movemail.
1.257        (kwzh     06-Apr-98): Most commonly used to specify `-g' to enable GSS-API authentication
1.257        (kwzh     06-Apr-98): or `-k' to enable Kerberos authentication."
1.260        (schwab   14-Apr-98):   :type '(repeat string)
1.262        (done     20-Apr-98):   :group 'rmail-retrieve
1.262        (done     20-Apr-98):   :version "20.3")
1.256        (kwzh     06-Apr-98): 
1.395        (eliz     15-Jan-05): (defvar rmail-remote-password-error "invalid usercode or password\\|
1.395        (eliz     15-Jan-05): unknown user name or bad password\\|Authentication failed\\|MU_ERR_AUTH_FAILURE"
1.395        (eliz     15-Jan-05):   "Regular expression matching incorrect-password POP or IMAP server error
1.395        (eliz     15-Jan-05): messages.
1.230        (rms      25-Jul-97): If you get an incorrect-password error that this expression does not match,
1.230        (rms      25-Jul-97): please report it with \\[report-emacs-bug].")
1.230        (rms      25-Jul-97): 
1.395        (eliz     15-Jan-05): (defvar rmail-encoded-remote-password nil)
1.284        (rms      05-Aug-98): 
1.219        (rms      03-May-97): (defcustom rmail-preserve-inbox nil
1.397        (rms      18-Mar-05):   "*Non-nil means leave incoming mail in the user's inbox--don't delete it."
1.219        (rms      03-May-97):   :type 'boolean
1.219        (rms      03-May-97):   :group 'rmail-retrieve)
1.205        (rms      21-Jan-97): 
1.395        (eliz     15-Jan-05): (defcustom rmail-movemail-search-path nil
1.395        (eliz     15-Jan-05):     "*List of directories to search for movemail (in addition to `exec-path')."
1.395        (eliz     15-Jan-05):     :group 'rmail-retrieve
1.395        (eliz     15-Jan-05):     :type '(repeat (directory)))
1.395        (eliz     15-Jan-05): 
1.442        (dann     25-Nov-07): (declare-function mail-position-on-field "sendmail" (field &optional soft))
1.442        (dann     25-Nov-07): (declare-function mail-text-start "sendmail" ())
1.442        (dann     25-Nov-07): (declare-function rmail-update-summary "rmailsum" (&rest ignore))
1.442        (dann     25-Nov-07): 
1.395        (eliz     15-Jan-05): (defun rmail-probe (prog)
1.397        (rms      18-Mar-05):   "Determine what flavor of movemail PROG is.
1.397        (rms      18-Mar-05): We do this by executing it with `--version' and analyzing its output."
1.395        (eliz     15-Jan-05):   (with-temp-buffer
1.395        (eliz     15-Jan-05):     (let ((tbuf (current-buffer)))
1.395        (eliz     15-Jan-05):       (buffer-disable-undo tbuf)
1.395        (eliz     15-Jan-05):       (call-process prog nil tbuf nil "--version")
1.395        (eliz     15-Jan-05):       (if (not (buffer-modified-p tbuf))
1.395        (eliz     15-Jan-05): 	  ;; Should not happen...
1.395        (eliz     15-Jan-05): 	  nil
1.395        (eliz     15-Jan-05): 	(goto-char (point-min))
1.395        (eliz     15-Jan-05): 	(cond
1.395        (eliz     15-Jan-05): 	 ((looking-at ".*movemail: invalid option")
1.395        (eliz     15-Jan-05): 	  'emacs)    ;; Possibly...
1.395        (eliz     15-Jan-05): 	 ((looking-at "movemail (GNU Mailutils .*)")
1.395        (eliz     15-Jan-05): 	  'mailutils)
1.395        (eliz     15-Jan-05): 	 (t
1.395        (eliz     15-Jan-05): 	  ;; FIXME:
1.395        (eliz     15-Jan-05): 	  'emacs))))))
1.395        (eliz     15-Jan-05): 
1.395        (eliz     15-Jan-05): (defun rmail-autodetect ()
1.438        (schwab   20-Aug-07):   "Determine the file name of the `movemail' program and return its flavor.
1.397        (rms      18-Mar-05): If `rmail-movemail-program' is non-nil, use it.
1.397        (rms      18-Mar-05): Otherwise, look for `movemail' in the directories in
1.397        (rms      18-Mar-05): `rmail-movemail-search-path', those in `exec-path', and `exec-directory'."
1.395        (eliz     15-Jan-05):   (if rmail-movemail-program
1.395        (eliz     15-Jan-05):       (rmail-probe rmail-movemail-program)
1.395        (eliz     15-Jan-05):     (catch 'scan
1.395        (eliz     15-Jan-05):       (dolist (dir (append rmail-movemail-search-path exec-path
1.395        (eliz     15-Jan-05): 			   (list exec-directory)))
1.395        (eliz     15-Jan-05): 	(when (and dir (file-accessible-directory-p dir))
1.452        (gm       20-Feb-08): 	  ;; Previously, this didn't have to work on Windows, because
1.452        (gm       20-Feb-08): 	  ;; rmail-insert-inbox-text before r1.439 fell back to using
1.452        (gm       20-Feb-08): 	  ;; (expand-file-name "movemail" exec-directory) and just
1.452        (gm       20-Feb-08): 	  ;; assuming it would work.
1.452        (gm       20-Feb-08): 	  ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2008-02/msg00087.html
1.452        (gm       20-Feb-08): 	  (let ((progname (expand-file-name
1.452        (gm       20-Feb-08): 			   (concat "movemail"
1.452        (gm       20-Feb-08): 				   (if (memq system-type '(ms-dos windows-nt))
1.452        (gm       20-Feb-08): 				       ".exe")) dir)))
1.395        (eliz     15-Jan-05): 	    (when (and (not (file-directory-p progname))
1.395        (eliz     15-Jan-05): 		       (file-executable-p progname))
1.395        (eliz     15-Jan-05): 	      (let ((x (rmail-probe progname)))
1.395        (eliz     15-Jan-05): 		(when x
1.395        (eliz     15-Jan-05): 		  (setq rmail-movemail-program progname)
1.395        (eliz     15-Jan-05): 		  (throw 'scan x))))))))))
1.395        (eliz     15-Jan-05): 
1.395        (eliz     15-Jan-05): (defvar rmail-movemail-variant-in-use nil
1.395        (eliz     15-Jan-05):   "The movemail variant currently in use. Known variants are:
1.395        (eliz     15-Jan-05): 
1.395        (eliz     15-Jan-05):   `emacs'     Means any implementation, compatible with the native Emacs one.
1.395        (eliz     15-Jan-05):               This is the default;
1.395        (eliz     15-Jan-05):   `mailutils' Means GNU mailutils implementation, capable of handling full
1.435        (ttn      09-Jun-07): mail URLs as the source mailbox.")
1.395        (eliz     15-Jan-05): 
1.395        (eliz     15-Jan-05): ;;;###autoload
1.395        (eliz     15-Jan-05): (defun rmail-movemail-variant-p (&rest variants)
1.395        (eliz     15-Jan-05):   "Return t if the current movemail variant is any of VARIANTS.
1.395        (eliz     15-Jan-05): Currently known variants are 'emacs and 'mailutils."
1.395        (eliz     15-Jan-05):   (when (not rmail-movemail-variant-in-use)
1.395        (eliz     15-Jan-05):     ;; Autodetect
1.395        (eliz     15-Jan-05):     (setq rmail-movemail-variant-in-use (rmail-autodetect)))
1.395        (eliz     15-Jan-05):   (not (null (member rmail-movemail-variant-in-use variants))))
1.395        (eliz     15-Jan-05): 
1.439        (gm       22-Aug-07): ;; Call for effect, to set rmail-movemail-program (if not set by the
1.439        (gm       22-Aug-07): ;; user), and rmail-movemail-variant-in-use. Used by various functions.
1.439        (gm       22-Aug-07): ;; I'm not sure if M-x rmail is the only entry point to this package.
1.439        (gm       22-Aug-07): ;; If so, this can be moved there.
1.439        (gm       22-Aug-07): (rmail-movemail-variant-p)
1.439        (gm       22-Aug-07): 
1.1          (roland   13-May-91): ;;;###autoload
1.219        (rms      03-May-97): (defcustom rmail-dont-reply-to-names nil "\
1.356        (pmr-sav  19-Mar-02): *A regexp specifying addresses to prune from a reply message.
1.356        (pmr-sav  19-Mar-02): A value of nil means exclude your own email address as an address
1.283        (rms      28-Jul-98): plus whatever is specified by `rmail-default-dont-reply-to-names'."
1.219        (rms      03-May-97):   :type '(choice regexp (const :tag "Your Name" nil))
1.219        (rms      03-May-97):   :group 'rmail-reply)
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;###autoload
1.384        (uid65627 16-Feb-04): (defvar rmail-default-dont-reply-to-names "\\`info-" "\
1.384        (uid65627 16-Feb-04): A regular expression specifying part of the default value of the
1.384        (uid65627 16-Feb-04): variable `rmail-dont-reply-to-names', for when the user does not set
1.1          (roland   13-May-91): `rmail-dont-reply-to-names' explicitly.  (The other part of the default
1.356        (pmr-sav  19-Mar-02): value is the user's email address and name.)
1.53         (rms      30-Jun-93): It is useful to set this variable in the site customization file.")
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;###autoload
1.328        (gerd     29-Jan-01): (defcustom rmail-ignored-headers
1.399        (rms      17-Apr-05):   (concat "^via:\\|^mail-from:\\|^origin:\\|^references:\\|^sender:"
1.328        (gerd     29-Jan-01): 	  "\\|^status:\\|^received:\\|^x400-originator:\\|^x400-recipients:"
1.328        (gerd     29-Jan-01): 	  "\\|^x400-received:\\|^x400-mts-identifier:\\|^x400-content-type:"
1.328        (gerd     29-Jan-01): 	  "\\|^\\(resent-\\|\\)message-id:\\|^summary-line:\\|^resent-date:"
1.371        (jpw      15-May-03): 	  "\\|^nntp-posting-host:\\|^path:\\|^x-char.*:\\|^x-face:\\|^face:"
1.408        (rms      09-Aug-05): 	  "\\|^x-mailer:\\|^delivered-to:\\|^lines:"
1.328        (gerd     29-Jan-01): 	  "\\|^content-transfer-encoding:\\|^x-coding-system:"
1.328        (gerd     29-Jan-01): 	  "\\|^return-path:\\|^errors-to:\\|^return-receipt-to:"
1.328        (gerd     29-Jan-01): 	  "\\|^precedence:\\|^list-help:\\|^list-post:\\|^list-subscribe:"
1.328        (gerd     29-Jan-01): 	  "\\|^list-id:\\|^list-unsubscribe:\\|^list-archive:"
1.413        (rms      15-Aug-05): 	  "\\|^content-length:\\|^nntp-posting-date:\\|^user-agent"
1.413        (rms      15-Aug-05): 	  "\\|^importance:\\|^envelope-to:\\|^delivery-date\\|^openpgp:"
1.421        (rms      11-Mar-06): 	  "\\|^mbox-line:\\|^cancel-lock:\\|^DomainKey-Signature:"
1.413        (rms      15-Aug-05): 	  "\\|^resent-face:\\|^resent-x.*:\\|^resent-organization:\\|^resent-openpgp:"
1.413        (rms      15-Aug-05): 
1.413        (rms      15-Aug-05): 	  "\\|^x-.*:")
1.302        (rms      05-Apr-99):   "*Regexp to match header fields that Rmail should normally hide.
1.413        (rms      15-Aug-05): \(See also `rmail-nonignored-headers', which overrides this regexp.)
1.413        (rms      15-Aug-05): This variable is used for reformatting the message header,
1.413        (rms      15-Aug-05): which normally happens once for each message,
1.413        (rms      15-Aug-05): when you view the message for the first time in Rmail.
1.413        (rms      15-Aug-05): To make a change in this variable take effect
1.413        (rms      15-Aug-05): for a message that you have already viewed,
1.413        (rms      15-Aug-05): go to that message and type \\[rmail-toggle-header] twice."
1.413        (rms      15-Aug-05):   :type 'regexp
1.413        (rms      15-Aug-05):   :group 'rmail-headers)
1.413        (rms      15-Aug-05): 
1.413        (rms      15-Aug-05): (defcustom rmail-nonignored-headers "^x-spam-status:"
1.413        (rms      15-Aug-05):   "*Regexp to match X header fields that Rmail should show.
1.413        (rms      15-Aug-05): This regexp overrides `rmail-ignored-headers'; if both this regexp
1.413        (rms      15-Aug-05): and that one match a certain header field, Rmail shows the field.
1.448        (bastien1 10-Feb-08): If this is nil, ignore all header fields in `rmail-ignored-headers'.
1.413        (rms      15-Aug-05): 
1.302        (rms      05-Apr-99): This variable is used for reformatting the message header,
1.302        (rms      05-Apr-99): which normally happens once for each message,
1.302        (rms      05-Apr-99): when you view the message for the first time in Rmail.
1.302        (rms      05-Apr-99): To make a change in this variable take effect
1.302        (rms      05-Apr-99): for a message that you have already viewed,
1.302        (rms      05-Apr-99): go to that message and type \\[rmail-toggle-header] twice."
1.448        (bastien1 10-Feb-08):   :type '(choice (const nil) (regexp))
1.219        (rms      03-May-97):   :group 'rmail-headers)
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;###autoload
1.219        (rms      03-May-97): (defcustom rmail-displayed-headers nil
1.150        (rms      14-Apr-95):   "*Regexp to match Header fields that Rmail should display.
1.150        (rms      14-Apr-95): If nil, display all header fields except those matched by
1.219        (rms      03-May-97): `rmail-ignored-headers'."
1.219        (rms      03-May-97):   :type '(choice regexp (const :tag "All"))
1.219        (rms      03-May-97):   :group 'rmail-headers)
1.150        (rms      14-Apr-95): 
1.150        (rms      14-Apr-95): ;;;###autoload
1.330        (rms      06-Mar-01): (defcustom rmail-retry-ignored-headers "^x-authentication-warning:" "\
1.219        (rms      03-May-97): *Headers that should be stripped when retrying a failed message."
1.219        (rms      03-May-97):   :type '(choice regexp (const nil :tag "None"))
1.219        (rms      03-May-97):   :group 'rmail-headers)
1.128        (rms      23-Sep-94): 
1.128        (rms      23-Sep-94): ;;;###autoload
1.219        (rms      03-May-97): (defcustom rmail-highlighted-headers "^From:\\|^Subject:" "\
1.112        (rms      30-Jul-94): *Regexp to match Header fields that Rmail should normally highlight.
1.451        (bastien1 13-Feb-08): A value of nil means don't highlight."
1.219        (rms      03-May-97):   :type 'regexp
1.219        (rms      03-May-97):   :group 'rmail-headers)
1.97         (rms      23-Apr-94): 
1.421        (rms      11-Mar-06): (defface rmail-highlight
1.446        (miles    01-Feb-08):   '((t (:inherit highlight)))
1.421        (rms      11-Mar-06):   "Face to use for highlighting the most important header fields."
1.421        (rms      11-Mar-06):   :group 'rmail-headers
1.421        (rms      11-Mar-06):   :version "22.1")
1.421        (rms      11-Mar-06): 
1.451        (bastien1 13-Feb-08): (defface rmail-header-name
1.451        (bastien1 13-Feb-08):   '((t (:inherit font-lock-function-name-face)))
1.451        (bastien1 13-Feb-08):   "Face to use for highlighting the header names."
1.451        (bastien1 13-Feb-08):   :group 'rmail-headers
1.451        (bastien1 13-Feb-08):   :version "23.1")
1.112        (rms      30-Jul-94): 
1.112        (rms      30-Jul-94): ;;;###autoload
1.219        (rms      03-May-97): (defcustom rmail-delete-after-output nil "\
1.219        (rms      03-May-97): *Non-nil means automatically delete a message that is copied to a file."
1.219        (rms      03-May-97):   :type 'boolean
1.219        (rms      03-May-97):   :group 'rmail-files)
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;###autoload
1.219        (rms      03-May-97): (defcustom rmail-primary-inbox-list nil "\
1.40         (rms      29-Mar-93): *List of files which are inboxes for user's primary mail file `~/RMAIL'.
1.370        (lektu    06-May-03): nil means the default, which is (\"/usr/spool/mail/$USER\")
1.40         (rms      29-Mar-93): \(the name varies depending on the operating system,
1.219        (rms      03-May-97): and the value of the environment variable MAIL overrides it)."
1.223        (rms      15-May-97):   ;; Don't use backquote here, because we don't want to need it
1.223        (rms      15-May-97):   ;; at load time.
1.223        (rms      15-May-97):   :type (list 'choice '(const :tag "Default" nil)
1.285        (kwzh     04-Sep-98): 	      (list 'repeat ':value (list (or (getenv "MAIL")
1.285        (kwzh     04-Sep-98): 					      (concat "/var/spool/mail/"
1.285        (kwzh     04-Sep-98): 						      (getenv "USER"))))
1.223        (rms      15-May-97): 		    'file))
1.219        (rms      03-May-97):   :group 'rmail-retrieve
1.219        (rms      03-May-97):   :group 'rmail-files)
1.219        (rms      03-May-97): 
1.219        (rms      03-May-97): ;;;###autoload
1.219        (rms      03-May-97): (defcustom rmail-mail-new-frame nil
1.390        (eliz     24-Apr-04):   "*Non-nil means Rmail makes a new frame for composing outgoing mail.
1.390        (eliz     24-Apr-04): This is handy if you want to preserve the window configuration of
1.390        (eliz     24-Apr-04): the frame where you have the RMAIL buffer displayed."
1.219        (rms      03-May-97):   :type 'boolean
1.219        (rms      03-May-97):   :group 'rmail-reply)
1.219        (rms      03-May-97): 
1.219        (rms      03-May-97): ;;;###autoload
1.219        (rms      03-May-97): (defcustom rmail-secondary-file-directory "~/"
1.219        (rms      03-May-97):   "*Directory for additional secondary Rmail files."
1.219        (rms      03-May-97):   :type 'directory
1.219        (rms      03-May-97):   :group 'rmail-files)
1.219        (rms      03-May-97): ;;;###autoload
1.219        (rms      03-May-97): (defcustom rmail-secondary-file-regexp "\\.xmail$"
1.219        (rms      03-May-97):   "*Regexp for which files are secondary Rmail files."
1.219        (rms      03-May-97):   :type 'regexp
1.219        (rms      03-May-97):   :group 'rmail-files)
1.91         (rms      18-Mar-94): 
1.161        (rms      10-Nov-95): ;;;###autoload
1.322        (gerd     22-Nov-00): (defcustom rmail-confirm-expunge 'y-or-n-p
1.313        (gerd     24-Mar-00):   "*Whether and how to ask for confirmation before expunging deleted messages."
1.313        (gerd     24-Mar-00):   :type '(choice (const :tag "No confirmation" nil)
1.313        (gerd     24-Mar-00): 		 (const :tag "Confirm with y-or-n-p" y-or-n-p)
1.313        (gerd     24-Mar-00): 		 (const :tag "Confirm with yes-or-no-p" yes-or-no-p))
1.313        (gerd     24-Mar-00):   :version "21.1"
1.313        (gerd     24-Mar-00):   :group 'rmail-files)
1.313        (gerd     24-Mar-00): 
1.313        (gerd     24-Mar-00): ;;;###autoload
1.161        (rms      10-Nov-95): (defvar rmail-mode-hook nil
1.161        (rms      10-Nov-95):   "List of functions to call when Rmail is invoked.")
1.161        (rms      10-Nov-95): 
1.161        (rms      10-Nov-95): ;;;###autoload
1.161        (rms      10-Nov-95): (defvar rmail-get-new-mail-hook nil
1.161        (rms      10-Nov-95):   "List of functions to call when Rmail has retrieved new mail.")
1.161        (rms      10-Nov-95): 
1.161        (rms      10-Nov-95): ;;;###autoload
1.315        (fx       14-May-00): (defcustom rmail-show-message-hook nil
1.315        (fx       14-May-00):   "List of functions to call when Rmail displays a message."
1.315        (fx       14-May-00):   :type 'hook
1.360        (rms      19-May-02):   :options '(goto-address)
1.315        (fx       14-May-00):   :group 'rmail)
1.161        (rms      10-Nov-95): 
1.161        (rms      10-Nov-95): ;;;###autoload
1.312        (gerd     02-Mar-00): (defvar rmail-quit-hook nil
1.312        (gerd     02-Mar-00):   "List of functions to call when quitting out of Rmail.")
1.312        (gerd     02-Mar-00): 
1.312        (gerd     02-Mar-00): ;;;###autoload
1.161        (rms      10-Nov-95): (defvar rmail-delete-message-hook nil
1.161        (rms      10-Nov-95):   "List of functions to call when Rmail deletes a message.
1.161        (rms      10-Nov-95): When the hooks are called, the message has been marked deleted but is
1.161        (rms      10-Nov-95): still the current message in the Rmail buffer.")
1.161        (rms      10-Nov-95): 
1.39         (rms      09-Mar-93): ;; These may be altered by site-init.el to match the format of mmdf files
1.39         (rms      09-Mar-93): ;;  delimiting used on a given host (delim1 and delim2 from the config
1.39         (rms      09-Mar-93): ;;  files).
1.1          (roland   13-May-91): 
1.226        (rms      01-Jun-97): (defvar rmail-mmdf-delim1 "^\001\001\001\001\n"
1.368        (jpw      06-Jan-03):   "Regexp marking the start of an mmdf message.")
1.226        (rms      01-Jun-97): (defvar rmail-mmdf-delim2 "^\001\001\001\001\n"
1.368        (jpw      06-Jan-03):   "Regexp marking the end of an mmdf message.")
1.1          (roland   13-May-91): 
1.259        (kwzh     08-Apr-98): (defcustom rmail-message-filter nil
1.193        (rms      06-Aug-96):   "If non-nil, a filter function for new messages in RMAIL.
1.193        (rms      06-Aug-96): Called with region narrowed to the message, including headers,
1.259        (kwzh     08-Apr-98): before obeying `rmail-ignored-headers'."
1.259        (kwzh     08-Apr-98):   :group 'rmail-headers
1.432        (jpw      24-Feb-07):   :type '(choice (const nil) function))
1.1          (roland   13-May-91): 
1.317        (fx       24-May-00): (defcustom rmail-automatic-folder-directives nil
1.317        (fx       24-May-00):   "List of directives specifying where to put a message.
1.317        (fx       24-May-00): Each element of the list is of the form:
1.317        (fx       24-May-00): 
1.317        (fx       24-May-00):   (FOLDERNAME FIELD REGEXP [ FIELD REGEXP ] ... )
1.317        (fx       24-May-00): 
1.317        (fx       24-May-00): Where FOLDERNAME is the name of a BABYL format folder to put the
1.317        (fx       24-May-00): message.  If any of the field regexp's are nil, then it is ignored.
1.317        (fx       24-May-00): 
1.317        (fx       24-May-00): If FOLDERNAME is \"/dev/null\", it is deleted.
1.317        (fx       24-May-00): If FOLDERNAME is nil then it is deleted, and skipped.
1.317        (fx       24-May-00): 
1.317        (fx       24-May-00): FIELD is the plain text name of a field in the message, such as
1.317        (fx       24-May-00): \"subject\" or \"from\".  A FIELD of \"to\" will automatically include
1.317        (fx       24-May-00): all text from the \"cc\" field as well.
1.317        (fx       24-May-00): 
1.317        (fx       24-May-00): REGEXP is an expression to match in the preceeding specified FIELD.
1.317        (fx       24-May-00): FIELD/REGEXP pairs continue in the list.
1.317        (fx       24-May-00): 
1.317        (fx       24-May-00): examples:
1.317        (fx       24-May-00):   (\"/dev/null\" \"from\" \"@spam.com\") ; delete all mail from spam.com
1.323        (gerd     27-Nov-00):   (\"RMS\" \"from\" \"rms@\") ; save all mail from RMS."
1.323        (gerd     27-Nov-00):   :group 'rmail
1.323        (gerd     27-Nov-00):   :version "21.1"
1.323        (gerd     27-Nov-00):   :type '(repeat (sexp :tag "Directive")))
1.358        (pot      06-May-02): 
1.39         (rms      09-Mar-93): (defvar rmail-reply-prefix "Re: "
1.39         (rms      09-Mar-93):   "String to prepend to Subject line when replying to a message.")
1.39         (rms      09-Mar-93): 
1.211        (kwzh     23-Feb-97): ;; Some mailers use "Re(2):" or "Re^2:" or "Re: Re:" or "Re[2]:".
1.422        (rms      18-Mar-06): ;; This pattern should catch all the common variants.
1.422        (rms      18-Mar-06): ;; rms: I deleted the change to delete tags in square brackets
1.422        (rms      18-Mar-06): ;; because they mess up RT tags.
1.422        (rms      18-Mar-06): (defvar rmail-reply-regexp "\\`\\(Re\\(([0-9]+)\\|\\[[0-9]+\\]\\|\\^[0-9]+\\)?: *\\)*"
1.193        (rms      06-Aug-96):   "Regexp to delete from Subject line before inserting `rmail-reply-prefix'.")
1.143        (kwzh     03-Feb-95): 
1.259        (kwzh     08-Apr-98): (defcustom rmail-display-summary nil
1.259        (kwzh     08-Apr-98):   "*If non-nil, Rmail always displays the summary buffer."
1.259        (kwzh     08-Apr-98):   :group 'rmail-summary
1.259        (kwzh     08-Apr-98):   :type 'boolean)
1.259        (kwzh     08-Apr-98): 
1.259        (kwzh     08-Apr-98): (defvar rmail-inbox-list nil)
1.259        (kwzh     08-Apr-98): (put 'rmail-inbox-list 'permanent-local t)
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defvar rmail-keywords nil)
1.259        (kwzh     08-Apr-98): (put 'rmail-keywords 'permanent-local t)
1.1          (roland   13-May-91): 
1.234        (rms      24-Aug-97): (defvar rmail-buffer nil
1.234        (rms      24-Aug-97):   "The RMAIL buffer related to the current buffer.
1.234        (rms      24-Aug-97): In an RMAIL buffer, this holds the RMAIL buffer itself.
1.234        (rms      24-Aug-97): In a summary buffer, this holds the RMAIL buffer it is a summary for.")
1.234        (rms      24-Aug-97): (put 'rmail-buffer 'permanent-local t)
1.234        (rms      24-Aug-97): 
1.1          (roland   13-May-91): ;; Message counters and markers.  Deleted flags.
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defvar rmail-current-message nil)
1.259        (kwzh     08-Apr-98): (put 'rmail-current-message 'permanent-local t)
1.259        (kwzh     08-Apr-98): 
1.1          (roland   13-May-91): (defvar rmail-total-messages nil)
1.259        (kwzh     08-Apr-98): (put 'rmail-total-messages 'permanent-local t)
1.259        (kwzh     08-Apr-98): 
1.1          (roland   13-May-91): (defvar rmail-message-vector nil)
1.259        (kwzh     08-Apr-98): (put 'rmail-message-vector 'permanent-local t)
1.259        (kwzh     08-Apr-98): 
1.1          (roland   13-May-91): (defvar rmail-deleted-vector nil)
1.259        (kwzh     08-Apr-98): (put 'rmail-deleted-vector 'permanent-local t)
1.259        (kwzh     08-Apr-98): 
1.218        (rms      02-May-97): (defvar rmail-msgref-vector nil
1.218        (rms      02-May-97):   "In an Rmail buffer, a vector whose Nth element is a list (N).
1.218        (rms      02-May-97): When expunging renumbers messages, these lists are modified
1.218        (rms      02-May-97): by substituting the new message number into the existing list.")
1.259        (kwzh     08-Apr-98): (put 'rmail-msgref-vector 'permanent-local t)
1.1          (roland   13-May-91): 
1.98         (rms      24-Apr-94): (defvar rmail-overlay-list nil)
1.259        (kwzh     08-Apr-98): (put 'rmail-overlay-list 'permanent-local t)
1.132        (rms      07-Oct-94): 
1.1          (roland   13-May-91): ;; These are used by autoloaded rmail-summary.
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defvar rmail-summary-buffer nil)
1.234        (rms      24-Aug-97): (put 'rmail-summary-buffer 'permanent-local t)
1.1          (roland   13-May-91): (defvar rmail-summary-vector nil)
1.234        (rms      24-Aug-97): (put 'rmail-summary-vector 'permanent-local t)
1.1          (roland   13-May-91): 
1.259        (kwzh     08-Apr-98): (defvar rmail-view-buffer nil
1.259        (kwzh     08-Apr-98):   "Buffer which holds RMAIL message for MIME displaying.")
1.259        (kwzh     08-Apr-98): (put 'rmail-view-buffer 'permanent-local t)
1.259        (kwzh     08-Apr-98): 
1.1          (roland   13-May-91): ;; `Sticky' default variables.
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; Last individual label specified to a or k.
1.1          (roland   13-May-91): (defvar rmail-last-label nil)
1.259        (kwzh     08-Apr-98): (put 'rmail-last-label 'permanent-local t)
1.259        (kwzh     08-Apr-98): 
1.39         (rms      09-Mar-93): ;; Last set of values specified to C-M-n, C-M-p, C-M-s or C-M-l.
1.1          (roland   13-May-91): (defvar rmail-last-multi-labels nil)
1.259        (kwzh     08-Apr-98): 
1.39         (rms      09-Mar-93): (defvar rmail-last-regexp nil)
1.259        (kwzh     08-Apr-98): (put 'rmail-last-regexp 'permanent-local t)
1.259        (kwzh     08-Apr-98): 
1.219        (rms      03-May-97): (defcustom rmail-default-file "~/xmail"
1.219        (rms      03-May-97):   "*Default file name for \\[rmail-output]."
1.219        (rms      03-May-97):   :type 'file
1.219        (rms      03-May-97):   :group 'rmail-files)
1.219        (rms      03-May-97): (defcustom rmail-default-rmail-file "~/XMAIL"
1.219        (rms      03-May-97):   "*Default file name for \\[rmail-output-to-rmail-file]."
1.219        (rms      03-May-97):   :type 'file
1.219        (rms      03-May-97):   :group 'rmail-files)
1.270        (rms      23-May-98): (defcustom rmail-default-body-file "~/mailout"
1.270        (rms      23-May-98):   "*Default file name for \\[rmail-output-body-to-file]."
1.270        (rms      23-May-98):   :type 'file
1.270        (rms      23-May-98):   :group 'rmail-files
1.270        (rms      23-May-98):   :version "20.3")
1.10         (jimb     19-Apr-92): 
1.259        (kwzh     08-Apr-98): ;; Mule and MIME related variables.
1.259        (kwzh     08-Apr-98): 
1.259        (kwzh     08-Apr-98): ;;;###autoload
1.259        (kwzh     08-Apr-98): (defvar rmail-file-coding-system nil
1.259        (kwzh     08-Apr-98):   "Coding system used in RMAIL file.
1.259        (kwzh     08-Apr-98): 
1.259        (kwzh     08-Apr-98): This is set to nil by default.")
1.259        (kwzh     08-Apr-98): 
1.259        (kwzh     08-Apr-98): ;;;###autoload
1.259        (kwzh     08-Apr-98): (defcustom rmail-enable-mime nil
1.259        (kwzh     08-Apr-98):   "*If non-nil, RMAIL uses MIME feature.
1.259        (kwzh     08-Apr-98): If the value is t, RMAIL automatically shows MIME decoded message.
1.259        (kwzh     08-Apr-98): If the value is neither t nor nil, RMAIL does not show MIME decoded message
1.419        (handa    19-Jan-06): until a user explicitly requires it.
1.419        (handa    19-Jan-06): 
1.419        (handa    19-Jan-06): Even if the value is non-nil, you can't use MIME feature
1.419        (handa    19-Jan-06): if the feature specified by `rmail-mime-feature' is not available
1.419        (handa    19-Jan-06): in your session."
1.259        (kwzh     08-Apr-98):   :type '(choice (const :tag "on" t)
1.259        (kwzh     08-Apr-98): 		 (const :tag "off" nil)
1.278        (schwab   24-Jun-98): 		 (other :tag "when asked" ask))
1.259        (kwzh     08-Apr-98):   :group 'rmail)
1.259        (kwzh     08-Apr-98): 
1.350        (zsh      25-Nov-01): (defvar rmail-enable-mime-composing nil
1.350        (zsh      25-Nov-01):   "*If non-nil, RMAIL uses `rmail-insert-mime-forwarded-message-function' to forward.")
1.350        (zsh      25-Nov-01): 
1.259        (kwzh     08-Apr-98): ;;;###autoload
1.259        (kwzh     08-Apr-98): (defvar rmail-show-mime-function nil
1.339        (gerd     08-May-01):   "Function to show MIME decoded message of RMAIL file.
1.339        (gerd     08-May-01): This function is called when `rmail-enable-mime' is non-nil.
1.339        (gerd     08-May-01): It is called with no argument.")
1.339        (gerd     08-May-01): 
1.339        (gerd     08-May-01): ;;;###autoload
1.339        (gerd     08-May-01): (defvar rmail-insert-mime-forwarded-message-function nil
1.339        (gerd     08-May-01):   "Function to insert a message in MIME format so it can be forwarded.
1.358        (pot      06-May-02): This function is called if `rmail-enable-mime' or
1.350        (zsh      25-Nov-01): `rmail-enable-mime-composing' is non-nil.
1.339        (gerd     08-May-01): It is called with one argument FORWARD-BUFFER, which is a
1.339        (gerd     08-May-01): buffer containing the message to forward.  The current buffer
1.339        (gerd     08-May-01): is the outgoing mail buffer.")
1.339        (gerd     08-May-01): 
1.339        (gerd     08-May-01): ;;;###autoload
1.342        (gerd     31-May-01): (defvar rmail-insert-mime-resent-message-function nil
1.342        (gerd     31-May-01):   "Function to insert a message in MIME format so it can be resent.
1.342        (gerd     31-May-01): This function is called if `rmail-enable-mime' is non-nil.
1.342        (gerd     31-May-01): It is called with one argument FORWARD-BUFFER, which is a
1.342        (gerd     31-May-01): buffer containing the message to forward.  The current buffer
1.342        (gerd     31-May-01): is the outgoing mail buffer.")
1.342        (gerd     31-May-01): 
1.342        (gerd     31-May-01): ;;;###autoload
1.339        (gerd     08-May-01): (defvar rmail-search-mime-message-function nil
1.339        (gerd     08-May-01):   "Function to check if a regexp matches a MIME message.
1.339        (gerd     08-May-01): This function is called if `rmail-enable-mime' is non-nil.
1.339        (gerd     08-May-01): It is called with two arguments MSG and REGEXP, where
1.339        (gerd     08-May-01): MSG is the message number, REGEXP is the regular expression.")
1.339        (gerd     08-May-01): 
1.339        (gerd     08-May-01): ;;;###autoload
1.339        (gerd     08-May-01): (defvar rmail-search-mime-header-function nil
1.339        (gerd     08-May-01):   "Function to check if a regexp matches a header of MIME message.
1.339        (gerd     08-May-01): This function is called if `rmail-enable-mime' is non-nil.
1.362        (rms      17-Aug-02): It is called with three arguments MSG, REGEXP, and LIMIT, where
1.339        (gerd     08-May-01): MSG is the message number,
1.339        (gerd     08-May-01): REGEXP is the regular expression,
1.339        (gerd     08-May-01): LIMIT is the position specifying the end of header.")
1.259        (kwzh     08-Apr-98): 
1.259        (kwzh     08-Apr-98): ;;;###autoload
1.259        (kwzh     08-Apr-98): (defvar rmail-mime-feature 'rmail-mime
1.267        (rms      19-May-98):   "Feature to require to load MIME support in Rmail.
1.267        (rms      19-May-98): When starting Rmail, if `rmail-enable-mime' is non-nil,
1.419        (handa    19-Jan-06): this feature is required with `require'.
1.419        (handa    19-Jan-06): 
1.419        (handa    19-Jan-06): The default value is `rmail-mime'.  This feature is provided by
1.419        (handa    19-Jan-06): the rmail-mime package available at <http://www.m17n.org/rmail-mime/>.")
1.295        (rms      28-Jan-99): 
1.295        (rms      28-Jan-99): ;;;###autoload
1.295        (rms      28-Jan-99): (defvar rmail-decode-mime-charset t
1.295        (rms      28-Jan-99):   "*Non-nil means a message is decoded by MIME's charset specification.
1.295        (rms      28-Jan-99): If this variable is nil, or the message has not MIME specification,
1.295        (rms      28-Jan-99): the message is decoded as normal way.
1.295        (rms      28-Jan-99): 
1.295        (rms      28-Jan-99): If the variable `rmail-enable-mime' is non-nil, this variables is
1.295        (rms      28-Jan-99): ignored, and all the decoding work is done by a feature specified by
1.295        (rms      28-Jan-99): the variable `rmail-mime-feature'.")
1.295        (rms      28-Jan-99): 
1.295        (rms      28-Jan-99): ;;;###autoload
1.295        (rms      28-Jan-99): (defvar rmail-mime-charset-pattern
1.429        (eliz     07-Oct-06):   (concat "^content-type:[ \t]*text/plain;"
1.426        (eliz     20-May-06): 	  "\\(?:[ \t\n]*\\(?:format\\|delsp\\)=\"?[-a-z0-9]+\"?;\\)*"
1.424        (rms      10-Apr-06): 	  "[ \t\n]*charset=\"?\\([^ \t\n\";]+\\)\"?")
1.295        (rms      28-Jan-99):   "Regexp to match MIME-charset specification in a header of message.
1.295        (rms      28-Jan-99): The first parenthesized expression should match the MIME-charset name.")
1.295        (rms      28-Jan-99): 
1.259        (kwzh     08-Apr-98): 
1.11         (jimb     24-Apr-92): ;;; Regexp matching the delimiter of messages in UNIX mail format
1.11         (jimb     24-Apr-92): ;;; (UNIX From lines), minus the initial ^.  Note that if you change
1.11         (jimb     24-Apr-92): ;;; this expression, you must change the code in rmail-nuke-pinhead-header
1.11         (jimb     24-Apr-92): ;;; that knows the exact ordering of the \\( \\) subexpressions.
1.10         (jimb     19-Apr-92): (defvar rmail-unix-mail-delimiter
1.24         (jimb     13-Sep-92):   (let ((time-zone-regexp
1.158        (rms      30-Jul-95): 	 (concat "\\([A-Z]?[A-Z]?[A-Z][A-Z]\\( DST\\)?"
1.24         (jimb     13-Sep-92): 		 "\\|[-+]?[0-9][0-9][0-9][0-9]"
1.24         (jimb     13-Sep-92): 		 "\\|"
1.24         (jimb     13-Sep-92): 		 "\\) *")))
1.24         (jimb     13-Sep-92):     (concat
1.24         (jimb     13-Sep-92):      "From "
1.24         (jimb     13-Sep-92): 
1.188        (rms      28-Jun-96):      ;; Many things can happen to an RFC 822 mailbox before it is put into
1.188        (rms      28-Jun-96):      ;; a `From' line.  The leading phrase can be stripped, e.g.
1.188        (rms      28-Jun-96):      ;; `Joe <@w.x:joe@y.z>' -> `<@w.x:joe@y.z>'.  The <> can be stripped, e.g.
1.188        (rms      28-Jun-96):      ;; `<@x.y:joe@y.z>' -> `@x.y:joe@y.z'.  Everything starting with a CRLF
1.188        (rms      28-Jun-96):      ;; can be removed, e.g.
1.188        (rms      28-Jun-96):      ;;		From: joe@y.z (Joe	K
1.188        (rms      28-Jun-96):      ;;			User)
1.188        (rms      28-Jun-96):      ;; can yield `From joe@y.z (Joe 	K Fri Mar 22 08:11:15 1996', and
1.188        (rms      28-Jun-96):      ;;		From: Joe User
1.188        (rms      28-Jun-96):      ;;			<joe@y.z>
1.188        (rms      28-Jun-96):      ;; can yield `From Joe User Fri Mar 22 08:11:15 1996'.
1.192        (eggert   03-Aug-96):      ;; The mailbox can be removed or be replaced by white space, e.g.
1.192        (eggert   03-Aug-96):      ;;		From: "Joe User"{space}{tab}
1.192        (eggert   03-Aug-96):      ;;			<joe@y.z>
1.192        (eggert   03-Aug-96):      ;; can yield `From {space}{tab} Fri Mar 22 08:11:15 1996',
1.192        (eggert   03-Aug-96):      ;; where {space} and {tab} represent the Ascii space and tab characters.
1.188        (rms      28-Jun-96):      ;; We want to match the results of any of these manglings.
1.188        (rms      28-Jun-96):      ;; The following regexp rejects names whose first characters are
1.188        (rms      28-Jun-96):      ;; obviously bogus, but after that anything goes.
1.192        (eggert   03-Aug-96):      "\\([^\0-\b\n-\r\^?].*\\)? "
1.24         (jimb     13-Sep-92): 
1.24         (jimb     13-Sep-92):      ;; The time the message was sent.
1.188        (rms      28-Jun-96):      "\\([^\0-\r \^?]+\\) +"				; day of the week
1.188        (rms      28-Jun-96):      "\\([^\0-\r \^?]+\\) +"				; month
1.188        (rms      28-Jun-96):      "\\([0-3]?[0-9]\\) +"				; day of month
1.188        (rms      28-Jun-96):      "\\([0-2][0-9]:[0-5][0-9]\\(:[0-6][0-9]\\)?\\) *"	; time of day
1.24         (jimb     13-Sep-92): 
1.24         (jimb     13-Sep-92):      ;; Perhaps a time zone, specified by an abbreviation, or by a
1.24         (jimb     13-Sep-92):      ;; numeric offset.
1.24         (jimb     13-Sep-92):      time-zone-regexp
1.24         (jimb     13-Sep-92): 
1.24         (jimb     13-Sep-92):      ;; The year.
1.188        (rms      28-Jun-96):      " \\([0-9][0-9]+\\) *"
1.24         (jimb     13-Sep-92): 
1.24         (jimb     13-Sep-92):      ;; On some systems the time zone can appear after the year, too.
1.24         (jimb     13-Sep-92):      time-zone-regexp
1.24         (jimb     13-Sep-92): 
1.96         (kwzh     23-Apr-94):      ;; Old uucp cruft.
1.96         (kwzh     23-Apr-94):      "\\(remote from .*\\)?"
1.24         (jimb     13-Sep-92): 
1.24         (jimb     13-Sep-92):      "\n"))
1.24         (jimb     13-Sep-92):   nil)
1.24         (jimb     13-Sep-92): 
1.450        (bastien1 12-Feb-08): (defvar rmail-font-lock-keywords
1.367        (rms      06-Jan-03):   ;; These are all matched case-insensitively.
1.450        (bastien1 12-Feb-08):   (eval-when-compile
1.259        (kwzh     08-Apr-98):     (let* ((cite-chars "[>|}]")
1.367        (rms      06-Jan-03): 	   (cite-prefix "a-z")
1.259        (kwzh     08-Apr-98): 	   (cite-suffix (concat cite-prefix "0-9_.@-`'\"")))
1.367        (rms      06-Jan-03):       (list '("^\\(From\\|Sender\\|Resent-From\\):"
1.451        (bastien1 13-Feb-08): 	      . 'rmail-header-name)
1.451        (bastien1 13-Feb-08): 	    '("^Reply-To:.*$" . 'rmail-header-name)
1.451        (bastien1 13-Feb-08): 	    '("^Subject:" . 'rmail-header-name)
1.451        (bastien1 13-Feb-08): 	    '("^X-Spam-Status:" . 'rmail-header-name)
1.259        (kwzh     08-Apr-98): 	    '("^\\(To\\|Apparently-To\\|Cc\\|Newsgroups\\):"
1.451        (bastien1 13-Feb-08): 	      . 'rmail-header-name)
1.259        (kwzh     08-Apr-98): 	    ;; Use MATCH-ANCHORED to effectively anchor the regexp left side.
1.259        (kwzh     08-Apr-98): 	    `(,cite-chars
1.259        (kwzh     08-Apr-98): 	      (,(concat "\\=[ \t]*"
1.401        (rms      24-Apr-05): 			"\\(\\(\\([" cite-prefix "]+[" cite-suffix "]*\\)?"
1.401        (rms      24-Apr-05): 			"\\(" cite-chars "[ \t]*\\)\\)+\\)"
1.259        (kwzh     08-Apr-98): 			"\\(.*\\)")
1.259        (kwzh     08-Apr-98): 	       (beginning-of-line) (end-of-line)
1.401        (rms      24-Apr-05): 	       (1 font-lock-comment-delimiter-face nil t)
1.401        (rms      24-Apr-05): 	       (5 font-lock-comment-face nil t)))
1.367        (rms      06-Jan-03): 	    '("^\\(X-[a-z0-9-]+\\|In-reply-to\\|Date\\):.*\\(\n[ \t]+.*\\)*$"
1.451        (bastien1 13-Feb-08): 	      . 'rmail-header-name))))
1.450        (bastien1 12-Feb-08):   "Additional expressions to highlight in Rmail mode.")
1.259        (kwzh     08-Apr-98): 
1.39         (rms      09-Mar-93): ;; Perform BODY in the summary buffer
1.39         (rms      09-Mar-93): ;; in such a way that its cursor is properly updated in its own window.
1.39         (rms      09-Mar-93): (defmacro rmail-select-summary (&rest body)
1.309        (gerd     15-Nov-99):   `(let ((total rmail-total-messages))
1.309        (gerd     15-Nov-99):      (if (rmail-summary-displayed)
1.309        (gerd     15-Nov-99): 	 (let ((window (selected-window)))
1.309        (gerd     15-Nov-99): 	   (save-excursion
1.309        (gerd     15-Nov-99): 	     (unwind-protect
1.309        (gerd     15-Nov-99): 		 (progn
1.309        (gerd     15-Nov-99): 		   (pop-to-buffer rmail-summary-buffer)
1.309        (gerd     15-Nov-99): 		   ;; rmail-total-messages is a buffer-local var
1.309        (gerd     15-Nov-99): 		   ;; in the rmail buffer.
1.309        (gerd     15-Nov-99): 		   ;; This way we make it available for the body
1.309        (gerd     15-Nov-99): 		   ;; even tho the rmail buffer is not current.
1.309        (gerd     15-Nov-99): 		   (let ((rmail-total-messages total))
1.309        (gerd     15-Nov-99): 		     ,@body))
1.309        (gerd     15-Nov-99): 	       (select-window window))))
1.309        (gerd     15-Nov-99):        (save-excursion
1.309        (gerd     15-Nov-99): 	 (set-buffer rmail-summary-buffer)
1.309        (gerd     15-Nov-99): 	 (let ((rmail-total-messages total))
1.309        (gerd     15-Nov-99): 	   ,@body)))
1.309        (gerd     15-Nov-99):      (rmail-maybe-display-summary)))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;; *** Rmail Mode ***
1.1          (roland   13-May-91): 
1.340        (gerd     17-May-01): ;; This variable is dynamically bound.  The defvar is here to placate
1.340        (gerd     17-May-01): ;; the byte compiler.
1.340        (gerd     17-May-01): 
1.247        (handa    20-Feb-98): (defvar rmail-enable-multibyte nil)
1.247        (handa    20-Feb-98): 
1.340        (gerd     17-May-01): 
1.340        (gerd     17-May-01): (defun rmail-require-mime-maybe ()
1.340        (gerd     17-May-01):   "Require `rmail-mime-feature' if that is non-nil.
1.340        (gerd     17-May-01): Signal an error and set `rmail-mime-feature' to nil if the feature
1.340        (gerd     17-May-01): isn't provided."
1.340        (gerd     17-May-01):   (when rmail-enable-mime
1.340        (gerd     17-May-01):     (condition-case err
1.340        (gerd     17-May-01): 	(require rmail-mime-feature)
1.340        (gerd     17-May-01):       (error
1.419        (handa    19-Jan-06):        (display-warning
1.419        (handa    19-Jan-06): 	:warning
1.419        (handa    19-Jan-06): 	(format "Although MIME support is requested
1.419        (handa    19-Jan-06): by setting `rmail-enable-mime' to non-nil, the required feature
1.419        (handa    19-Jan-06): `%s' (the value of `rmail-mime-feature')
1.419        (handa    19-Jan-06): is not available in the current session.
1.419        (handa    19-Jan-06): So, the MIME support is turned off for the moment." 
1.419        (handa    19-Jan-06): 		rmail-mime-feature))
1.340        (gerd     17-May-01):        (setq rmail-enable-mime nil)))))
1.340        (gerd     17-May-01): 
1.340        (gerd     17-May-01): 
1.1          (roland   13-May-91): ;;;###autoload
1.1          (roland   13-May-91): (defun rmail (&optional file-name-arg)
1.1          (roland   13-May-91):   "Read and edit incoming mail.
1.68         (rms      09-Oct-93): Moves messages into file named by `rmail-file-name' (a babyl format file)
1.1          (roland   13-May-91):  and edits that file in RMAIL Mode.
1.1          (roland   13-May-91): Type \\[describe-mode] once editing that file, for a list of RMAIL commands.
1.1          (roland   13-May-91): 
1.73         (rms      23-Dec-93): May be called with file name as argument; then performs rmail editing on
1.73         (rms      23-Dec-93): that file, but does not copy any new mail into the file.
1.73         (rms      23-Dec-93): Interactively, if you supply a prefix argument, then you
1.113        (rms      30-Jul-94): have a chance to specify a file name with the minibuffer.
1.113        (rms      30-Jul-94): 
1.113        (rms      30-Jul-94): If `rmail-display-summary' is non-nil, make a summary for this RMAIL file."
1.1          (roland   13-May-91):   (interactive (if current-prefix-arg
1.165        (rms      23-Dec-95): 		   (list (read-file-name "Run rmail on RMAIL file: "))))
1.340        (gerd     17-May-01):   (rmail-require-mime-maybe)
1.1          (roland   13-May-91):   (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name)))
1.354        (eliz     03-Feb-02): 	 ;; Use find-buffer-visiting, not get-file-buffer, for those users
1.354        (eliz     03-Feb-02): 	 ;; who have find-file-visit-truename set to t.
1.354        (eliz     03-Feb-02): 	 (existed (find-buffer-visiting file-name))
1.349        (eliz     16-Sep-01): 	 ;; This binding is necessary because we must decide if we
1.248        (handa    20-Feb-98): 	 ;; need code conversion while the buffer is unibyte
1.248        (handa    20-Feb-98): 	 ;; (i.e. enable-multibyte-characters is nil).
1.280        (rms      09-Jul-98):          (rmail-enable-multibyte
1.358        (pot      06-May-02):           (if existed
1.280        (rms      09-Jul-98): 	      (with-current-buffer existed enable-multibyte-characters)
1.280        (rms      09-Jul-98):             (default-value 'enable-multibyte-characters)))
1.247        (handa    20-Feb-98): 	 ;; Since the file may contain messages of different encodings
1.247        (handa    20-Feb-98): 	 ;; at the tail (non-BYBYL part), we can't decode them at once
1.247        (handa    20-Feb-98): 	 ;; on reading.  So, at first, we read the file without text
1.247        (handa    20-Feb-98): 	 ;; code conversion, then decode the messages one by one by
1.247        (handa    20-Feb-98): 	 ;; rmail-decode-babyl-format or
1.247        (handa    20-Feb-98): 	 ;; rmail-convert-to-babyl-format.
1.247        (handa    20-Feb-98): 	 (coding-system-for-read (and rmail-enable-multibyte 'raw-text))
1.237        (kwzh     15-Oct-97): 	 run-mail-hook msg-shown)
1.1          (roland   13-May-91):     ;; Like find-file, but in the case where a buffer existed
1.1          (roland   13-May-91):     ;; and the file was reverted, recompute the message-data.
1.263        (rms      22-Apr-98):     ;; We used to bind enable-local-variables to nil here,
1.263        (rms      22-Apr-98):     ;; but that should not be needed now that rmail-mode
1.263        (rms      22-Apr-98):     ;; sets it locally to nil.
1.263        (rms      22-Apr-98):     ;; (Binding a variable locally with let is not safe if it has
1.263        (rms      22-Apr-98):     ;; buffer-local bindings.)
1.1          (roland   13-May-91):     (if (and existed (not (verify-visited-file-modtime existed)))
1.1          (roland   13-May-91): 	(progn
1.263        (rms      22-Apr-98): 	  (find-file file-name)
1.39         (rms      09-Mar-93): 	  (if (and (verify-visited-file-modtime existed)
1.39         (rms      09-Mar-93): 		   (eq major-mode 'rmail-mode))
1.1          (roland   13-May-91): 	      (progn (rmail-forget-messages)
1.1          (roland   13-May-91): 		     (rmail-set-message-counters))))
1.358        (pot      06-May-02):       (switch-to-buffer
1.276        (rms      13-Jun-98):        (let ((enable-local-variables nil))
1.276        (rms      13-Jun-98): 	 (find-file-noselect file-name))))
1.39         (rms      09-Mar-93):     (if (eq major-mode 'rmail-edit-mode)
1.243        (rms      19-Jan-98): 	(error "Exit Rmail Edit mode before getting new mail"))
1.1          (roland   13-May-91):     (if (and existed (> (buffer-size) 0))
1.1          (roland   13-May-91): 	;; Buffer not new and not empty; ensure in proper mode, but that's all.
1.1          (roland   13-May-91): 	(or (eq major-mode 'rmail-mode)
1.200        (rms      12-Oct-96): 	    (progn (rmail-mode-2)
1.200        (rms      12-Oct-96): 		   (setq run-mail-hook t)))
1.200        (rms      12-Oct-96):       (setq run-mail-hook t)
1.1          (roland   13-May-91):       (rmail-mode-2)
1.1          (roland   13-May-91):       ;; Convert all or part to Babyl file if possible.
1.1          (roland   13-May-91):       (rmail-convert-file)
1.274        (rms      06-Jun-98):       (goto-char (point-max)))
1.277        (rms      15-Jun-98):     ;; As we have read a file by raw-text, the buffer is set to
1.277        (rms      15-Jun-98):     ;; unibyte.  We must make it multibyte if necessary.
1.277        (rms      15-Jun-98):     (if (and rmail-enable-multibyte
1.277        (rms      15-Jun-98): 	     (not enable-multibyte-characters))
1.277        (rms      15-Jun-98): 	(set-buffer-multibyte t))
1.275        (rms      11-Jun-98):     ;; If necessary, scan to find all the messages.
1.275        (rms      11-Jun-98):     (rmail-maybe-set-message-counters)
1.242        (kwzh     18-Jan-98):     (unwind-protect
1.274        (rms      06-Jun-98): 	(unless (and (not file-name-arg)
1.274        (rms      06-Jun-98): 		     (rmail-get-new-mail))
1.274        (rms      06-Jun-98): 	  (rmail-show-message (rmail-first-unseen-message)))
1.242        (kwzh     18-Jan-98):       (progn
1.242        (kwzh     18-Jan-98): 	(if rmail-display-summary (rmail-summary))
1.242        (kwzh     18-Jan-98): 	(rmail-construct-io-menu)
1.242        (kwzh     18-Jan-98): 	(if run-mail-hook
1.242        (kwzh     18-Jan-98): 	    (run-hooks 'rmail-mode-hook))))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; Given the value of MAILPATH, return a list of inbox file names.
1.1          (roland   13-May-91): ;; This is turned off because it is not clear that the user wants
1.1          (roland   13-May-91): ;; all these inboxes to feed into the primary rmail file.
1.1          (roland   13-May-91): ; (defun rmail-convert-mailpath (string)
1.1          (roland   13-May-91): ;   (let (idx list)
1.1          (roland   13-May-91): ;     (while (setq idx (string-match "[%:]" string))
1.1          (roland   13-May-91): ;       (let ((this (substring string 0 idx)))
1.1          (roland   13-May-91): ; 	(setq string (substring string (1+ idx)))
1.1          (roland   13-May-91): ; 	(setq list (cons (if (string-match "%" this)
1.1          (roland   13-May-91): ; 			     (substring this 0 (string-match "%" this))
1.1          (roland   13-May-91): ; 			   this)
1.1          (roland   13-May-91): ; 			 list))))
1.1          (roland   13-May-91): ;     list))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
1.1          (roland   13-May-91): ; will not cause emacs 18.55 problems.
1.1          (roland   13-May-91): 
1.265        (rms      12-May-98): ;; This calls rmail-decode-babyl-format if the file is already Babyl.
1.265        (rms      12-May-98): 
1.1          (roland   13-May-91): (defun rmail-convert-file ()
1.1          (roland   13-May-91):   (let (convert)
1.1          (roland   13-May-91):     (widen)
1.1          (roland   13-May-91):     (goto-char (point-min))
1.1          (roland   13-May-91):     ;; If file doesn't start like a Babyl file,
1.1          (roland   13-May-91):     ;; convert it to one, by adding a header and converting each message.
1.1          (roland   13-May-91):     (cond ((looking-at "BABYL OPTIONS:"))
1.1          (roland   13-May-91): 	  ((looking-at "Version: 5\n")
1.1          (roland   13-May-91): 	   ;; Losing babyl file made by old version of Rmail.
1.1          (roland   13-May-91): 	   ;; Just fix the babyl file header; don't make a new one,
1.1          (roland   13-May-91): 	   ;; so we don't lose the Labels: file attribute, etc.
1.1          (roland   13-May-91): 	   (let ((buffer-read-only nil))
1.1          (roland   13-May-91): 	     (insert "BABYL OPTIONS: -*- rmail -*-\n")))
1.66         (bfox     21-Sep-93): 	  ((equal (point-min) (point-max))
1.66         (bfox     21-Sep-93): 	   ;; Empty RMAIL file.  Just insert the header.
1.66         (bfox     21-Sep-93): 	   (rmail-insert-rmail-file-header))
1.1          (roland   13-May-91): 	  (t
1.66         (bfox     21-Sep-93): 	   ;; Non-empty file in non-RMAIL format.  Add header and convert.
1.1          (roland   13-May-91): 	   (setq convert t)
1.1          (roland   13-May-91): 	   (rmail-insert-rmail-file-header)))
1.1          (roland   13-May-91):     ;; If file was not a Babyl file or if there are
1.1          (roland   13-May-91):     ;; Unix format messages added at the end,
1.1          (roland   13-May-91):     ;; convert file as necessary.
1.1          (roland   13-May-91):     (if (or convert
1.63         (rms      07-Sep-93): 	    (save-excursion
1.63         (rms      07-Sep-93): 	      (goto-char (point-max))
1.159        (rms      12-Aug-95): 	      (search-backward "\n\^_")
1.159        (rms      12-Aug-95): 	      (forward-char 2)
1.63         (rms      07-Sep-93): 	      (looking-at "\n*From ")))
1.1          (roland   13-May-91): 	(let ((buffer-read-only nil))
1.1          (roland   13-May-91): 	  (message "Converting to Babyl format...")
1.63         (rms      07-Sep-93): 	  ;; If file needs conversion, convert it all,
1.63         (rms      07-Sep-93): 	  ;; except for the BABYL header.
1.63         (rms      07-Sep-93): 	  ;; (rmail-convert-to-babyl-format would delete the header.)
1.63         (rms      07-Sep-93): 	  (goto-char (point-min))
1.63         (rms      07-Sep-93): 	  (search-forward "\n\^_" nil t)
1.64         (rms      11-Sep-93): 	  (narrow-to-region (point) (point-max))
1.1          (roland   13-May-91): 	  (rmail-convert-to-babyl-format)
1.247        (handa    20-Feb-98): 	  (message "Converting to Babyl format...done"))
1.247        (handa    20-Feb-98):       (if (and (not rmail-enable-mime)
1.247        (handa    20-Feb-98): 	       rmail-enable-multibyte)
1.247        (handa    20-Feb-98): 	  ;; We still have to decode BABYL part.
1.247        (handa    20-Feb-98): 	  (rmail-decode-babyl-format)))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-insert-rmail-file-header ()
1.1          (roland   13-May-91):   (let ((buffer-read-only nil))
1.265        (rms      12-May-98):     ;; -*-rmail-*- is here so that visiting the file normally
1.265        (rms      12-May-98):     ;; recognizes it as an Rmail file.
1.1          (roland   13-May-91):     (insert "BABYL OPTIONS: -*- rmail -*-
1.1          (roland   13-May-91): Version: 5
1.1          (roland   13-May-91): Labels:
1.1          (roland   13-May-91): Note:   This is the header of an rmail file.
1.1          (roland   13-May-91): Note:   If you are seeing it in rmail,
1.1          (roland   13-May-91): Note:    it means the file has no messages in it.\n\^_")))
1.1          (roland   13-May-91): 
1.361        (lektu    02-Jul-02): ;; Decode Babyl formatted part at the head of current buffer by
1.247        (handa    20-Feb-98): ;; rmail-file-coding-system, or if it is nil, do auto conversion.
1.212        (handa    26-Feb-97): 
1.212        (handa    26-Feb-97): (defun rmail-decode-babyl-format ()
1.212        (handa    26-Feb-97):   (let ((modifiedp (buffer-modified-p))
1.212        (handa    26-Feb-97): 	(buffer-read-only nil)
1.265        (rms      12-May-98): 	(coding-system rmail-file-coding-system)
1.247        (handa    20-Feb-98): 	from to)
1.212        (handa    26-Feb-97):     (goto-char (point-min))
1.265        (rms      12-May-98):     (search-forward "\n\^_" nil t)	; Skip BABYL header.
1.247        (handa    20-Feb-98):     (setq from (point))
1.247        (handa    20-Feb-98):     (goto-char (point-max))
1.247        (handa    20-Feb-98):     (search-backward "\n\^_" from 'mv)
1.247        (handa    20-Feb-98):     (setq to (point))
1.265        (rms      12-May-98):     (unless (and coding-system
1.265        (rms      12-May-98): 		 (coding-system-p coding-system))
1.349        (eliz     16-Sep-01):       (setq coding-system
1.447        (miles    01-Feb-08): 	    ;; If rmail-file-coding-system is nil, Emacs 21 writes
1.447        (miles    01-Feb-08): 	    ;; RMAIL files in emacs-mule, Emacs 22 in utf-8, but
1.447        (miles    01-Feb-08): 	    ;; earlier versions did that with the current buffer's
1.447        (miles    01-Feb-08): 	    ;; encoding.  So we want to favor detection of emacs-mule
1.447        (miles    01-Feb-08): 	    ;; (whose normal priority is quite low) and utf-8, but
1.447        (miles    01-Feb-08): 	    ;; still allow detection of other encodings if they won't
1.447        (miles    01-Feb-08): 	    ;; fit.  The call to with-coding-priority below achieves
1.447        (miles    01-Feb-08): 	    ;; that.
1.447        (miles    01-Feb-08): 	    (with-coding-priority '(emacs-mule utf-8)
1.447        (miles    01-Feb-08): 	      (detect-coding-region from to 'highest))))
1.447        (miles    01-Feb-08):     (unless (eq (coding-system-type coding-system) 'undecided)
1.303        (rms      07-Apr-99):       (set-buffer-modified-p t)		; avoid locking when decoding
1.352        (rms      11-Jan-02):       (let ((buffer-undo-list t))
1.352        (rms      11-Jan-02): 	(decode-coding-region from to coding-system))
1.303        (rms      07-Apr-99):       (setq coding-system last-coding-system-used))
1.265        (rms      12-May-98):     (set-buffer-modified-p modifiedp)
1.265        (rms      12-May-98):     (setq buffer-file-coding-system nil)
1.265        (rms      12-May-98):     (setq save-buffer-coding-system
1.265        (rms      12-May-98): 	  (or coding-system 'undecided))))
1.212        (handa    26-Feb-97): 
1.259        (kwzh     08-Apr-98): (defvar rmail-mode-map nil)
1.1          (roland   13-May-91): (if rmail-mode-map
1.1          (roland   13-May-91):     nil
1.1          (roland   13-May-91):   (setq rmail-mode-map (make-keymap))
1.1          (roland   13-May-91):   (suppress-keymap rmail-mode-map)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "a"      'rmail-add-label)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "b"      'rmail-bury)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "c"      'rmail-continue)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "d"      'rmail-delete-forward)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "\C-d"   'rmail-delete-backward)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "e"      'rmail-edit-current-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "f"      'rmail-forward)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "g"      'rmail-get-new-mail)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "h"      'rmail-summary)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "i"      'rmail-input)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "j"      'rmail-show-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "k"      'rmail-kill-label)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "l"      'rmail-summary-by-labels)
1.1          (roland   13-May-91):   (define-key rmail-mode-map "\e\C-h" 'rmail-summary)
1.1          (roland   13-May-91):   (define-key rmail-mode-map "\e\C-l" 'rmail-summary-by-labels)
1.1          (roland   13-May-91):   (define-key rmail-mode-map "\e\C-r" 'rmail-summary-by-recipients)
1.1          (roland   13-May-91):   (define-key rmail-mode-map "\e\C-s" 'rmail-summary-by-regexp)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "\e\C-t" 'rmail-summary-by-topic)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "m"      'rmail-mail)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "\em"    'rmail-retry-failure)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "n"      'rmail-next-undeleted-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "\en"    'rmail-next-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "\e\C-n" 'rmail-next-labeled-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "o"      'rmail-output-to-rmail-file)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "\C-o"   'rmail-output)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "p"      'rmail-previous-undeleted-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "\ep"    'rmail-previous-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "\e\C-p" 'rmail-previous-labeled-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "q"      'rmail-quit)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "r"      'rmail-reply)
1.35         (rms      21-Oct-92): ;; I find I can't live without the default M-r command -- rms.
1.39         (rms      09-Mar-93): ;;  (define-key rmail-mode-map "\er"  'rmail-search-backwards)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "s"      'rmail-expunge-and-save)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "\es"    'rmail-search)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "t"      'rmail-toggle-header)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "u"      'rmail-undelete-previous-message)
1.216        (rms      05-Apr-97):   (define-key rmail-mode-map "w"      'rmail-output-body-to-file)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "x"      'rmail-expunge)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "."      'rmail-beginning-of-message)
1.410        (eliz     12-Aug-05):   (define-key rmail-mode-map "/"      'rmail-end-of-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "<"      'rmail-first-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map ">"      'rmail-last-message)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map " "      'scroll-up)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "\177"   'scroll-down)
1.39         (rms      09-Mar-93):   (define-key rmail-mode-map "?"      'describe-mode)
1.52         (rms      22-Jun-93):   (define-key rmail-mode-map "\C-c\C-s\C-d" 'rmail-sort-by-date)
1.52         (rms      22-Jun-93):   (define-key rmail-mode-map "\C-c\C-s\C-s" 'rmail-sort-by-subject)
1.52         (rms      22-Jun-93):   (define-key rmail-mode-map "\C-c\C-s\C-a" 'rmail-sort-by-author)
1.52         (rms      22-Jun-93):   (define-key rmail-mode-map "\C-c\C-s\C-r" 'rmail-sort-by-recipient)
1.52         (rms      22-Jun-93):   (define-key rmail-mode-map "\C-c\C-s\C-c" 'rmail-sort-by-correspondent)
1.52         (rms      22-Jun-93):   (define-key rmail-mode-map "\C-c\C-s\C-l" 'rmail-sort-by-lines)
1.338        (gerd     07-May-01):   (define-key rmail-mode-map "\C-c\C-s\C-k" 'rmail-sort-by-labels)
1.144        (rms      05-Feb-95):   (define-key rmail-mode-map "\C-c\C-n" 'rmail-next-same-subject)
1.144        (rms      05-Feb-95):   (define-key rmail-mode-map "\C-c\C-p" 'rmail-previous-same-subject)
1.39         (rms      09-Mar-93):   )
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar] (make-sparse-keymap))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar classify]
1.50         (rms      22-Jun-93):   (cons "Classify" (make-sparse-keymap "Classify")))
1.50         (rms      22-Jun-93): 
1.92         (rms      23-Mar-94): (define-key rmail-mode-map [menu-bar classify input-menu]
1.126        (rms      19-Sep-94):   nil)
1.92         (rms      23-Mar-94): 
1.92         (rms      23-Mar-94): (define-key rmail-mode-map [menu-bar classify output-menu]
1.126        (rms      19-Sep-94):   nil)
1.216        (rms      05-Apr-97): 
1.216        (rms      05-Apr-97): (define-key rmail-mode-map [menu-bar classify output-body]
1.216        (rms      05-Apr-97):   '("Output body to file..." . rmail-output-body-to-file))
1.92         (rms      23-Mar-94): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar classify output-inbox]
1.117        (rms      02-Aug-94):   '("Output (inbox)..." . rmail-output))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar classify output]
1.117        (rms      02-Aug-94):   '("Output (Rmail)..." . rmail-output-to-rmail-file))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar classify kill-label]
1.117        (rms      02-Aug-94):   '("Kill Label..." . rmail-kill-label))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar classify add-label]
1.117        (rms      02-Aug-94):   '("Add Label..." . rmail-add-label))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar summary]
1.50         (rms      22-Jun-93):   (cons "Summary" (make-sparse-keymap "Summary")))
1.50         (rms      22-Jun-93): 
1.156        (rms      30-Jun-95): (define-key rmail-mode-map [menu-bar summary senders]
1.156        (rms      30-Jun-95):   '("By Senders..." . rmail-summary-by-senders))
1.156        (rms      30-Jun-95): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar summary labels]
1.117        (rms      02-Aug-94):   '("By Labels..." . rmail-summary-by-labels))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar summary recipients]
1.117        (rms      02-Aug-94):   '("By Recipients..." . rmail-summary-by-recipients))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar summary topic]
1.117        (rms      02-Aug-94):   '("By Topic..." . rmail-summary-by-topic))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar summary regexp]
1.117        (rms      02-Aug-94):   '("By Regexp..." . rmail-summary-by-regexp))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar summary all]
1.50         (rms      22-Jun-93):   '("All" . rmail-summary))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar mail]
1.50         (rms      22-Jun-93):   (cons "Mail" (make-sparse-keymap "Mail")))
1.50         (rms      22-Jun-93): 
1.116        (rms      02-Aug-94): (define-key rmail-mode-map [menu-bar mail rmail-get-new-mail]
1.108        (rms      12-Jul-94):   '("Get New Mail" . rmail-get-new-mail))
1.108        (rms      12-Jul-94): 
1.108        (rms      12-Jul-94): (define-key rmail-mode-map [menu-bar mail lambda]
1.109        (rms      13-Jul-94):   '("----"))
1.108        (rms      12-Jul-94): 
1.108        (rms      12-Jul-94): (define-key rmail-mode-map [menu-bar mail continue]
1.50         (rms      22-Jun-93):   '("Continue" . rmail-continue))
1.114        (rms      31-Jul-94): 
1.114        (rms      31-Jul-94): (define-key rmail-mode-map [menu-bar mail resend]
1.117        (rms      02-Aug-94):   '("Re-send..." . rmail-resend))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar mail forward]
1.50         (rms      22-Jun-93):   '("Forward" . rmail-forward))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar mail retry]
1.50         (rms      22-Jun-93):   '("Retry" . rmail-retry-failure))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar mail reply]
1.50         (rms      22-Jun-93):   '("Reply" . rmail-reply))
1.1          (roland   13-May-91): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar mail mail]
1.50         (rms      22-Jun-93):   '("Mail" . rmail-mail))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar delete]
1.50         (rms      22-Jun-93):   (cons "Delete" (make-sparse-keymap "Delete")))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar delete expunge/save]
1.50         (rms      22-Jun-93):   '("Expunge/Save" . rmail-expunge-and-save))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar delete expunge]
1.50         (rms      22-Jun-93):   '("Expunge" . rmail-expunge))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar delete undelete]
1.50         (rms      22-Jun-93):   '("Undelete" . rmail-undelete-previous-message))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar delete delete]
1.50         (rms      22-Jun-93):   '("Delete" . rmail-delete-forward))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar move]
1.50         (rms      22-Jun-93):   (cons "Move" (make-sparse-keymap "Move")))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar move search-back]
1.140        (rms      18-Dec-94):   '("Search Back..." . rmail-search-backwards))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar move search]
1.117        (rms      02-Aug-94):   '("Search..." . rmail-search))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar move previous]
1.50         (rms      22-Jun-93):   '("Previous Nondeleted" . rmail-previous-undeleted-message))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar move next]
1.50         (rms      22-Jun-93):   '("Next Nondeleted" . rmail-next-undeleted-message))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar move last]
1.50         (rms      22-Jun-93):   '("Last" . rmail-last-message))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar move first]
1.50         (rms      22-Jun-93):   '("First" . rmail-first-message))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar move previous]
1.50         (rms      22-Jun-93):   '("Previous" . rmail-previous-message))
1.50         (rms      22-Jun-93): 
1.50         (rms      22-Jun-93): (define-key rmail-mode-map [menu-bar move next]
1.50         (rms      22-Jun-93):   '("Next" . rmail-next-message))
1.423        (eliz     25-Mar-06): 
1.423        (eliz     25-Mar-06): ;; Rmail toolbar
1.423        (eliz     25-Mar-06): (defvar rmail-tool-bar-map
1.423        (eliz     25-Mar-06):   (if (display-graphic-p)
1.423        (eliz     25-Mar-06):       (let ((map (make-sparse-keymap)))
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-get-new-mail "mail/inbox"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-next-undeleted-message "right-arrow"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-previous-undeleted-message "left-arrow"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-search "search"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-input "open"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-mail "mail/compose"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-reply "mail/reply-all"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-forward "mail/forward"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-delete-forward "close"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-output "mail/move"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-output-body-to-file "mail/save"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	(tool-bar-local-item-from-menu 'rmail-expunge "delete"
1.423        (eliz     25-Mar-06): 				       map rmail-mode-map)
1.423        (eliz     25-Mar-06): 	map)))
1.423        (eliz     25-Mar-06): 
1.423        (eliz     25-Mar-06): 
1.50         (rms      22-Jun-93): 
1.1          (roland   13-May-91): ;; Rmail mode is suitable only for specially formatted data.
1.1          (roland   13-May-91): (put 'rmail-mode 'mode-class 'special)
1.1          (roland   13-May-91): 
1.127        (rms      21-Sep-94): (defun rmail-mode-kill-summary ()
1.127        (rms      21-Sep-94):   (if rmail-summary-buffer (kill-buffer rmail-summary-buffer)))
1.127        (rms      21-Sep-94): 
1.34         (jimb     11-Oct-92): ;;;###autoload
1.1          (roland   13-May-91): (defun rmail-mode ()
1.1          (roland   13-May-91):   "Rmail Mode is used by \\<rmail-mode-map>\\[rmail] for editing Rmail files.
1.1          (roland   13-May-91): All normal editing commands are turned off.
1.1          (roland   13-May-91): Instead, these commands are available:
1.1          (roland   13-May-91): 
1.410        (eliz     12-Aug-05): \\[rmail-beginning-of-message]	Move point to front of this message.
1.410        (eliz     12-Aug-05): \\[rmail-end-of-message]	Move point to bottom of this message.
1.1          (roland   13-May-91): \\[scroll-up]	Scroll to next screen of this message.
1.1          (roland   13-May-91): \\[scroll-down]	Scroll to previous screen of this message.
1.1          (roland   13-May-91): \\[rmail-next-undeleted-message]	Move to Next non-deleted message.
1.1          (roland   13-May-91): \\[rmail-previous-undeleted-message]	Move to Previous non-deleted message.
1.1          (roland   13-May-91): \\[rmail-next-message]	Move to Next message whether deleted or not.
1.1          (roland   13-May-91): \\[rmail-previous-message]	Move to Previous message whether deleted or not.
1.1          (roland   13-May-91): \\[rmail-first-message]	Move to the first message in Rmail file.
1.1          (roland   13-May-91): \\[rmail-last-message]	Move to the last message in Rmail file.
1.1          (roland   13-May-91): \\[rmail-show-message]	Jump to message specified by numeric position in file.
1.1          (roland   13-May-91): \\[rmail-search]	Search for string and show message it is found in.
1.1          (roland   13-May-91): \\[rmail-delete-forward]	Delete this message, move to next nondeleted.
1.1          (roland   13-May-91): \\[rmail-delete-backward]	Delete this message, move to previous nondeleted.
1.1          (roland   13-May-91): \\[rmail-undelete-previous-message]	Undelete message.  Tries current message, then earlier messages
1.1          (roland   13-May-91): 	till a deleted message is found.
1.39         (rms      09-Mar-93): \\[rmail-edit-current-message]	Edit the current message.  \\[rmail-cease-edit] to return to Rmail.
1.1          (roland   13-May-91): \\[rmail-expunge]	Expunge deleted messages.
1.1          (roland   13-May-91): \\[rmail-expunge-and-save]	Expunge and save the file.
1.1          (roland   13-May-91): \\[rmail-quit]       Quit Rmail: expunge, save, then switch to another buffer.
1.1          (roland   13-May-91): \\[save-buffer] Save without expunging.
1.40         (rms      29-Mar-93): \\[rmail-get-new-mail]	Move new mail from system spool directory into this file.
1.1          (roland   13-May-91): \\[rmail-mail]	Mail a message (same as \\[mail-other-window]).
1.1          (roland   13-May-91): \\[rmail-continue]	Continue composing outgoing message started before.
1.39         (rms      09-Mar-93): \\[rmail-reply]	Reply to this message.  Like \\[rmail-mail] but initializes some fields.
1.39         (rms      09-Mar-93): \\[rmail-retry-failure]	Send this message again.  Used on a mailer failure message.
1.1          (roland   13-May-91): \\[rmail-forward]	Forward this message to another user.
1.1          (roland   13-May-91): \\[rmail-output-to-rmail-file]       Output this message to an Rmail file (append it).
1.1          (roland   13-May-91): \\[rmail-output]	Output this message to a Unix-format mail file (append it).
1.258        (stephen  07-Apr-98): \\[rmail-output-body-to-file]	Save message body to a file.  Default filename comes from Subject line.
1.1          (roland   13-May-91): \\[rmail-input]	Input Rmail file.  Run Rmail on that file.
1.1          (roland   13-May-91): \\[rmail-add-label]	Add label to message.  It will be displayed in the mode line.
1.1          (roland   13-May-91): \\[rmail-kill-label]	Kill label.  Remove a label from current message.
1.1          (roland   13-May-91): \\[rmail-next-labeled-message]   Move to Next message with specified label
1.1          (roland   13-May-91):           (label defaults to last one specified).
1.1          (roland   13-May-91):           Standard labels: filed, unseen, answered, forwarded, deleted.
1.39         (rms      09-Mar-93):           Any other label is present only if you add it with \\[rmail-add-label].
1.1          (roland   13-May-91): \\[rmail-previous-labeled-message]   Move to Previous message with specified label
1.1          (roland   13-May-91): \\[rmail-summary]	Show headers buffer, with a one line summary of each message.
1.39         (rms      09-Mar-93): \\[rmail-summary-by-labels]	Summarize only messages with particular label(s).
1.39         (rms      09-Mar-93): \\[rmail-summary-by-recipients]   Summarize only messages with particular recipient(s).
1.39         (rms      09-Mar-93): \\[rmail-summary-by-regexp]   Summarize only messages with particular regexp(s).
1.39         (rms      09-Mar-93): \\[rmail-summary-by-topic]   Summarize only messages with subject line regexp(s).
1.39         (rms      09-Mar-93): \\[rmail-toggle-header]	Toggle display of complete header."
1.1          (roland   13-May-91):   (interactive)
1.340        (gerd     17-May-01):   (let ((finding-rmail-file (not (eq major-mode 'rmail-mode))))
1.340        (gerd     17-May-01):     (rmail-mode-2)
1.340        (gerd     17-May-01):     (when (and finding-rmail-file
1.340        (gerd     17-May-01): 	       (null coding-system-for-read)
1.340        (gerd     17-May-01): 	       default-enable-multibyte-characters)
1.340        (gerd     17-May-01):       (let ((rmail-enable-multibyte t))
1.340        (gerd     17-May-01): 	(rmail-require-mime-maybe)
1.340        (gerd     17-May-01): 	(rmail-convert-file)
1.340        (gerd     17-May-01): 	(goto-char (point-max))
1.340        (gerd     17-May-01): 	(set-buffer-multibyte t)))
1.340        (gerd     17-May-01):     (rmail-set-message-counters)
1.340        (gerd     17-May-01):     (rmail-show-message rmail-total-messages)
1.340        (gerd     17-May-01):     (when finding-rmail-file
1.340        (gerd     17-May-01):       (when rmail-display-summary
1.340        (gerd     17-May-01): 	(rmail-summary))
1.340        (gerd     17-May-01):       (rmail-construct-io-menu))
1.404        (lute     26-May-05):     (run-mode-hooks 'rmail-mode-hook)))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-mode-2 ()
1.1          (roland   13-May-91):   (kill-all-local-variables)
1.1          (roland   13-May-91):   (rmail-mode-1)
1.259        (kwzh     08-Apr-98):   (rmail-perm-variables)
1.200        (rms      12-Oct-96):   (rmail-variables))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-mode-1 ()
1.1          (roland   13-May-91):   (setq major-mode 'rmail-mode)
1.1          (roland   13-May-91):   (setq mode-name "RMAIL")
1.1          (roland   13-May-91):   (setq buffer-read-only t)
1.75         (rms      24-Dec-93):   ;; No need to auto save RMAIL files in normal circumstances
1.75         (rms      24-Dec-93):   ;; because they contain no info except attribute changes
1.75         (rms      24-Dec-93):   ;; and deletion of messages.
1.75         (rms      24-Dec-93):   ;; The one exception is when messages are copied into an Rmail mode buffer.
1.75         (rms      24-Dec-93):   ;; rmail-output-to-rmail-file enables auto save when you do that.
1.1          (roland   13-May-91):   (setq buffer-auto-save-file-name nil)
1.235        (rms      26-Aug-97):   (setq mode-line-modified "--")
1.1          (roland   13-May-91):   (use-local-map rmail-mode-map)
1.1          (roland   13-May-91):   (set-syntax-table text-mode-syntax-table)
1.1          (roland   13-May-91):   (setq local-abbrev-table text-mode-abbrev-table))
1.1          (roland   13-May-91): 
1.259        (kwzh     08-Apr-98): ;; Set up the permanent locals associated with an Rmail file.
1.259        (kwzh     08-Apr-98): (defun rmail-perm-variables ()
1.1          (roland   13-May-91):   (make-local-variable 'rmail-last-label)
1.39         (rms      09-Mar-93):   (make-local-variable 'rmail-last-regexp)
1.1          (roland   13-May-91):   (make-local-variable 'rmail-deleted-vector)
1.212        (handa    26-Feb-97):   (make-local-variable 'rmail-buffer)
1.212        (handa    26-Feb-97):   (setq rmail-buffer (current-buffer))
1.212        (handa    26-Feb-97):   (make-local-variable 'rmail-view-buffer)
1.212        (handa    26-Feb-97):   (setq rmail-view-buffer rmail-buffer)
1.1          (roland   13-May-91):   (make-local-variable 'rmail-summary-buffer)
1.1          (roland   13-May-91):   (make-local-variable 'rmail-summary-vector)
1.1          (roland   13-May-91):   (make-local-variable 'rmail-current-message)
1.1          (roland   13-May-91):   (make-local-variable 'rmail-total-messages)
1.98         (rms      24-Apr-94):   (make-local-variable 'rmail-overlay-list)
1.98         (rms      24-Apr-94):   (setq rmail-overlay-list nil)
1.1          (roland   13-May-91):   (make-local-variable 'rmail-message-vector)
1.218        (rms      02-May-97):   (make-local-variable 'rmail-msgref-vector)
1.1          (roland   13-May-91):   (make-local-variable 'rmail-inbox-list)
1.1          (roland   13-May-91):   (setq rmail-inbox-list (rmail-parse-file-inboxes))
1.47         (rms      07-Jun-93):   ;; Provide default set of inboxes for primary mail file ~/RMAIL.
1.47         (rms      07-Jun-93):   (and (null rmail-inbox-list)
1.54         (rms      06-Jul-93):        (or (equal buffer-file-name (expand-file-name rmail-file-name))
1.72         (rms      26-Nov-93): 	   (equal buffer-file-truename
1.72         (rms      26-Nov-93): 		  (abbreviate-file-name (file-truename rmail-file-name))))
1.47         (rms      07-Jun-93):        (setq rmail-inbox-list
1.47         (rms      07-Jun-93): 	     (or rmail-primary-inbox-list
1.47         (rms      07-Jun-93): 		 (list (or (getenv "MAIL")
1.47         (rms      07-Jun-93): 			   (concat rmail-spool-directory
1.86         (kwzh     11-Feb-94): 				   (user-login-name)))))))
1.1          (roland   13-May-91):   (make-local-variable 'rmail-keywords)
1.423        (eliz     25-Mar-06):   (set (make-local-variable 'tool-bar-map) rmail-tool-bar-map)
1.1          (roland   13-May-91):   ;; this gets generated as needed
1.104        (rms      19-May-94):   (setq rmail-keywords nil))
1.1          (roland   13-May-91): 
1.259        (kwzh     08-Apr-98): ;; Set up the non-permanent locals associated with Rmail mode.
1.259        (kwzh     08-Apr-98): (defun rmail-variables ()
1.265        (rms      12-May-98):   (make-local-variable 'save-buffer-coding-system)
1.265        (rms      12-May-98):   ;; If we don't already have a value for save-buffer-coding-system,
1.265        (rms      12-May-98):   ;; get it from buffer-file-coding-system, and clear that
1.265        (rms      12-May-98):   ;; because it should be determined in rmail-show-message.
1.265        (rms      12-May-98):   (unless save-buffer-coding-system
1.265        (rms      12-May-98):     (setq save-buffer-coding-system (or buffer-file-coding-system 'undecided))
1.265        (rms      12-May-98):     (setq buffer-file-coding-system nil))
1.259        (kwzh     08-Apr-98):   ;; Don't let a local variables list in a message cause confusion.
1.276        (rms      13-Jun-98):   (make-local-variable 'local-enable-local-variables)
1.276        (rms      13-Jun-98):   (setq local-enable-local-variables nil)
1.259        (kwzh     08-Apr-98):   (make-local-variable 'revert-buffer-function)
1.259        (kwzh     08-Apr-98):   (setq revert-buffer-function 'rmail-revert)
1.259        (kwzh     08-Apr-98):   (make-local-variable 'font-lock-defaults)
1.259        (kwzh     08-Apr-98):   (setq font-lock-defaults
1.265        (rms      12-May-98): 	'(rmail-font-lock-keywords
1.367        (rms      06-Jan-03): 	  t t nil nil
1.265        (rms      12-May-98): 	  (font-lock-maximum-size . nil)
1.265        (rms      12-May-98): 	  (font-lock-fontify-buffer-function . rmail-fontify-buffer-function)
1.265        (rms      12-May-98): 	  (font-lock-unfontify-buffer-function . rmail-unfontify-buffer-function)
1.265        (rms      12-May-98): 	  (font-lock-inhibit-thing-lock . (lazy-lock-mode fast-lock-mode))))
1.259        (kwzh     08-Apr-98):   (make-local-variable 'require-final-newline)
1.259        (kwzh     08-Apr-98):   (setq require-final-newline nil)
1.259        (kwzh     08-Apr-98):   (make-local-variable 'version-control)
1.259        (kwzh     08-Apr-98):   (setq version-control 'never)
1.259        (kwzh     08-Apr-98):   (make-local-variable 'kill-buffer-hook)
1.259        (kwzh     08-Apr-98):   (add-hook 'kill-buffer-hook 'rmail-mode-kill-summary)
1.259        (kwzh     08-Apr-98):   (make-local-variable 'file-precious-flag)
1.391        (lh       26-Apr-04):   (setq file-precious-flag t)
1.391        (lh       26-Apr-04):   (make-local-variable 'desktop-save-buffer)
1.391        (lh       26-Apr-04):   (setq desktop-save-buffer t))
1.259        (kwzh     08-Apr-98): 
1.1          (roland   13-May-91): ;; Handle M-x revert-buffer done in an rmail-mode buffer.
1.1          (roland   13-May-91): (defun rmail-revert (arg noconfirm)
1.342        (gerd     31-May-01):   (set-buffer rmail-buffer)
1.280        (rms      09-Jul-98):   (let* ((revert-buffer-function (default-value 'revert-buffer-function))
1.280        (rms      09-Jul-98): 	 (rmail-enable-multibyte enable-multibyte-characters)
1.280        (rms      09-Jul-98): 	 ;; See similar code in `rmail'.
1.280        (rms      09-Jul-98): 	 (coding-system-for-read (and rmail-enable-multibyte 'raw-text)))
1.1          (roland   13-May-91):     ;; Call our caller again, but this time it does the default thing.
1.1          (roland   13-May-91):     (if (revert-buffer arg noconfirm)
1.1          (roland   13-May-91): 	;; If the user said "yes", and we changed something,
1.1          (roland   13-May-91): 	;; reparse the messages.
1.243        (rms      19-Jan-98): 	(progn
1.342        (gerd     31-May-01): 	  (set-buffer rmail-buffer)
1.342        (gerd     31-May-01):   	  (rmail-mode-2)
1.280        (rms      09-Jul-98): 	  ;; Convert all or part to Babyl file if possible.
1.1          (roland   13-May-91): 	  (rmail-convert-file)
1.280        (rms      09-Jul-98): 	  ;; We have read the file as raw-text, so the buffer is set to
1.280        (rms      09-Jul-98): 	  ;; unibyte.  Make it multibyte if necessary.
1.280        (rms      09-Jul-98): 	  (if (and rmail-enable-multibyte
1.280        (rms      09-Jul-98): 		   (not enable-multibyte-characters))
1.280        (rms      09-Jul-98): 	      (set-buffer-multibyte t))
1.1          (roland   13-May-91): 	  (goto-char (point-max))
1.280        (rms      09-Jul-98): 	  (rmail-set-message-counters)
1.280        (rms      09-Jul-98): 	  (rmail-show-message rmail-total-messages)
1.280        (rms      09-Jul-98): 	  (run-hooks 'rmail-mode-hook)))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; Return a list of files from this buffer's Mail: option.
1.1          (roland   13-May-91): ;; Does not assume that messages have been parsed.
1.1          (roland   13-May-91): ;; Just returns nil if buffer does not look like Babyl format.
1.1          (roland   13-May-91): (defun rmail-parse-file-inboxes ()
1.1          (roland   13-May-91):   (save-excursion
1.1          (roland   13-May-91):     (save-restriction
1.1          (roland   13-May-91):       (widen)
1.1          (roland   13-May-91):       (goto-char 1)
1.1          (roland   13-May-91):       (cond ((looking-at "BABYL OPTIONS:")
1.1          (roland   13-May-91): 	     (search-forward "\n\^_" nil 'move)
1.1          (roland   13-May-91): 	     (narrow-to-region 1 (point))
1.1          (roland   13-May-91): 	     (goto-char 1)
1.1          (roland   13-May-91): 	     (if (search-forward "\nMail:" nil t)
1.1          (roland   13-May-91): 		 (progn
1.1          (roland   13-May-91): 		   (narrow-to-region (point) (progn (end-of-line) (point)))
1.1          (roland   13-May-91): 		   (goto-char (point-min))
1.1          (roland   13-May-91): 		   (mail-parse-comma-list))))))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-expunge-and-save ()
1.1          (roland   13-May-91):   "Expunge and save RMAIL file."
1.1          (roland   13-May-91):   (interactive)
1.1          (roland   13-May-91):   (rmail-expunge)
1.339        (gerd     08-May-01):   (set-buffer rmail-buffer)
1.85         (kwzh     09-Feb-94):   (save-buffer)
1.85         (kwzh     09-Feb-94):   (if (rmail-summary-exists)
1.85         (kwzh     09-Feb-94):       (rmail-select-summary (set-buffer-modified-p nil))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-quit ()
1.294        (rms      18-Jan-99):   "Quit out of RMAIL.
1.294        (rms      18-Jan-99): Hook `rmail-quit-hook' is run after expunging."
1.1          (roland   13-May-91):   (interactive)
1.1          (roland   13-May-91):   (rmail-expunge-and-save)
1.294        (rms      18-Jan-99):   (when (boundp 'rmail-quit-hook)
1.294        (rms      18-Jan-99):     (run-hooks 'rmail-quit-hook))
1.1          (roland   13-May-91):   ;; Don't switch to the summary buffer even if it was recently visible.
1.251        (rms      08-Mar-98):   (when rmail-summary-buffer
1.251        (rms      08-Mar-98):     (replace-buffer-in-windows rmail-summary-buffer)
1.251        (rms      08-Mar-98):     (bury-buffer rmail-summary-buffer))
1.339        (gerd     08-May-01):   (if rmail-enable-mime
1.339        (gerd     08-May-01):       (let ((obuf rmail-buffer)
1.339        (gerd     08-May-01): 	    (ovbuf rmail-view-buffer))
1.339        (gerd     08-May-01): 	(set-buffer rmail-view-buffer)
1.339        (gerd     08-May-01): 	(quit-window)
1.339        (gerd     08-May-01): 	(replace-buffer-in-windows ovbuf)
1.339        (gerd     08-May-01): 	(replace-buffer-in-windows obuf)
1.339        (gerd     08-May-01): 	(bury-buffer obuf))
1.339        (gerd     08-May-01):     (let ((obuf (current-buffer)))
1.339        (gerd     08-May-01):       (quit-window)
1.339        (gerd     08-May-01):       (replace-buffer-in-windows obuf))))
1.1          (roland   13-May-91): 
1.147        (rms      12-Mar-95): (defun rmail-bury ()
1.147        (rms      12-Mar-95):   "Bury current Rmail buffer and its summary buffer."
1.147        (rms      12-Mar-95):   (interactive)
1.147        (rms      12-Mar-95):   ;; This let var was called rmail-buffer, but that interfered
1.147        (rms      12-Mar-95):   ;; with the buffer-local var used in summary buffers.
1.147        (rms      12-Mar-95):   (let ((buffer-to-bury (current-buffer)))
1.147        (rms      12-Mar-95):     (if (rmail-summary-exists)
1.147        (rms      12-Mar-95): 	(let (window)
1.147        (rms      12-Mar-95): 	  (while (setq window (get-buffer-window rmail-summary-buffer))
1.251        (rms      08-Mar-98): 	    (quit-window nil window))
1.147        (rms      12-Mar-95): 	  (bury-buffer rmail-summary-buffer)))
1.251        (rms      08-Mar-98):     (quit-window)))
1.147        (rms      12-Mar-95): 
1.147        (rms      12-Mar-95): (defun rmail-duplicate-message ()
1.147        (rms      12-Mar-95):   "Create a duplicated copy of the current message.
1.147        (rms      12-Mar-95): The duplicate copy goes into the Rmail file just after the
1.147        (rms      12-Mar-95): original copy."
1.147        (rms      12-Mar-95):   (interactive)
1.147        (rms      12-Mar-95):   (widen)
1.147        (rms      12-Mar-95):   (let ((buffer-read-only nil)
1.147        (rms      12-Mar-95): 	(number rmail-current-message)
1.147        (rms      12-Mar-95): 	(string (buffer-substring (rmail-msgbeg rmail-current-message)
1.147        (rms      12-Mar-95): 				  (rmail-msgend rmail-current-message))))
1.147        (rms      12-Mar-95):     (goto-char (rmail-msgend rmail-current-message))
1.147        (rms      12-Mar-95):     (insert string)
1.147        (rms      12-Mar-95):     (rmail-forget-messages)
1.147        (rms      12-Mar-95):     (rmail-show-message number)
1.147        (rms      12-Mar-95):     (message "Message duplicated")))
1.147        (rms      12-Mar-95): 
1.1          (roland   13-May-91): ;;;###autoload
1.1          (roland   13-May-91): (defun rmail-input (filename)
1.39         (rms      09-Mar-93):   "Run Rmail on file FILENAME."
1.1          (roland   13-May-91):   (interactive "FRun rmail on RMAIL file: ")
1.1          (roland   13-May-91):   (rmail filename))
1.1          (roland   13-May-91): 
1.198        (rms      19-Sep-96): 
1.198        (rms      19-Sep-96): ;; This used to scan subdirectories recursively, but someone pointed out
1.198        (rms      19-Sep-96): ;; that if the user wants that, person can put all the files in one dir.
1.198        (rms      19-Sep-96): ;; And the recursive scan was slow.  So I took it out.
1.198        (rms      19-Sep-96): ;; rms, Sep 1996.
1.126        (rms      19-Sep-94): (defun rmail-find-all-files (start)
1.198        (rms      19-Sep-96):   "Return list of file in dir START that match `rmail-secondary-file-regexp'."
1.126        (rms      19-Sep-94):   (if (file-accessible-directory-p start)
1.135        (rms      11-Oct-94):       ;; Don't sort here.
1.198        (rms      19-Sep-96):       (let* ((case-fold-search t)
1.198        (rms      19-Sep-96): 	     (files (directory-files start t rmail-secondary-file-regexp)))
1.135        (rms      11-Oct-94): 	;; Sort here instead of in directory-files
1.135        (rms      11-Oct-94): 	;; because this list is usually much shorter.
1.198        (rms      19-Sep-96): 	(sort files 'string<))))
1.126        (rms      19-Sep-94): 
1.126        (rms      19-Sep-94): (defun rmail-list-to-menu (menu-name l action &optional full-name)
1.126        (rms      19-Sep-94):   (let ((menu (make-sparse-keymap menu-name)))
1.440        (gm       12-Oct-07):     (mapc
1.126        (rms      19-Sep-94):      (function (lambda (item)
1.148        (rms      12-Mar-95): 		 (let (command)
1.148        (rms      12-Mar-95): 		   (if (consp item)
1.148        (rms      12-Mar-95): 		       (progn
1.148        (rms      12-Mar-95): 			 (setq command
1.358        (pot      06-May-02): 			       (rmail-list-to-menu (car item) (cdr item)
1.358        (pot      06-May-02): 						   action
1.148        (rms      12-Mar-95): 						   (if full-name
1.148        (rms      12-Mar-95): 						       (concat full-name "/"
1.148        (rms      12-Mar-95): 							       (car item))
1.148        (rms      12-Mar-95): 						     (car item))))
1.148        (rms      12-Mar-95): 			 (setq name (car item)))
1.126        (rms      19-Sep-94): 		     (progn
1.148        (rms      12-Mar-95): 		       (setq name item)
1.358        (pot      06-May-02): 		       (setq command
1.148        (rms      12-Mar-95): 			     (list 'lambda () '(interactive)
1.148        (rms      12-Mar-95): 				   (list action
1.358        (pot      06-May-02): 					 (expand-file-name
1.148        (rms      12-Mar-95): 					  (if full-name
1.148        (rms      12-Mar-95): 					      (concat full-name "/" item)
1.148        (rms      12-Mar-95): 					    item)
1.148        (rms      12-Mar-95): 					  rmail-secondary-file-directory))))))
1.148        (rms      12-Mar-95): 		   (define-key menu (vector (intern name))
1.148        (rms      12-Mar-95): 		     (cons name command)))))
1.135        (rms      11-Oct-94):      (reverse l))
1.126        (rms      19-Sep-94):     menu))
1.358        (pot      06-May-02): 
1.135        (rms      11-Oct-94): ;; This command is always "disabled" when it appears in a menu.
1.135        (rms      11-Oct-94): (put 'rmail-disable-menu 'menu-enable ''nil)
1.135        (rms      11-Oct-94): 
1.126        (rms      19-Sep-94): (defun rmail-construct-io-menu ()
1.126        (rms      19-Sep-94):   (let ((files (rmail-find-all-files rmail-secondary-file-directory)))
1.135        (rms      11-Oct-94):     (if files
1.126        (rms      19-Sep-94): 	(progn
1.126        (rms      19-Sep-94): 	  (define-key rmail-mode-map [menu-bar classify input-menu]
1.358        (pot      06-May-02): 	    (cons "Input Rmail File"
1.358        (pot      06-May-02): 		  (rmail-list-to-menu "Input Rmail File"
1.135        (rms      11-Oct-94): 				      files
1.126        (rms      19-Sep-94): 				      'rmail-input)))
1.126        (rms      19-Sep-94): 	  (define-key rmail-mode-map [menu-bar classify output-menu]
1.358        (pot      06-May-02): 	    (cons "Output Rmail File"
1.358        (pot      06-May-02): 		  (rmail-list-to-menu "Output Rmail File"
1.135        (rms      11-Oct-94): 				      files
1.135        (rms      11-Oct-94): 				      'rmail-output-to-rmail-file))))
1.135        (rms      11-Oct-94): 
1.135        (rms      11-Oct-94):       (define-key rmail-mode-map [menu-bar classify input-menu]
1.135        (rms      11-Oct-94): 	'("Input Rmail File" . rmail-disable-menu))
1.135        (rms      11-Oct-94):       (define-key rmail-mode-map [menu-bar classify output-menu]
1.135        (rms      11-Oct-94): 	'("Output Rmail File" . rmail-disable-menu)))))
1.102        (rms      04-May-94): 
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;; *** Rmail input ***
1.1          (roland   13-May-91): 
1.443        (dann     27-Nov-07): (declare-function rmail-spam-filter "rmail-spam-filter" (msg))
1.443        (dann     27-Nov-07): (declare-function rmail-summary-goto-msg "rmailsum" (&optional n nowarn skip-rmail))
1.443        (dann     27-Nov-07): (declare-function rmail-summary-mark-undeleted "rmailsum" (n))
1.443        (dann     27-Nov-07): (declare-function rmail-summary-mark-deleted "rmailsum" (&optional n undel))
1.443        (dann     27-Nov-07): (declare-function rfc822-addresses "rfc822" (header-text))
1.443        (dann     27-Nov-07): (declare-function mail-abbrev-make-syntax-table "mailabbrev.el" ())
1.443        (dann     27-Nov-07): (declare-function mail-sendmail-delimit-header "sendmail" ())
1.443        (dann     27-Nov-07): (declare-function mail-header-end "sendmail" ())
1.443        (dann     27-Nov-07): 
1.1          (roland   13-May-91): ;; RLK feature not added in this version:
1.1          (roland   13-May-91): ;; argument specifies inbox file or files in various ways.
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-get-new-mail (&optional file-name)
1.1          (roland   13-May-91):   "Move any new mail from this RMAIL file's inbox files.
1.1          (roland   13-May-91): The inbox files can be specified with the file's Mail: option.  The
1.1          (roland   13-May-91): variable `rmail-primary-inbox-list' specifies the inboxes for your
1.40         (rms      29-Mar-93): primary RMAIL file if it has no Mail: option.  By default, this is
1.40         (rms      29-Mar-93): your /usr/spool/mail/$USER.
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): You can also specify the file to get new mail from.  In this case, the
1.1          (roland   13-May-91): file of new mail is not changed or deleted.  Noninteractively, you can
1.1          (roland   13-May-91): pass the inbox file name as an argument.  Interactively, a prefix
1.124        (rms      05-Sep-94): argument causes us to read a file name and use that file as the inbox.
1.124        (rms      05-Sep-94): 
1.205        (rms      21-Jan-97): If the variable `rmail-preserve-inbox' is non-nil, new mail will
1.205        (rms      21-Jan-97): always be left in inbox files rather than deleted.
1.205        (rms      21-Jan-97): 
1.138        (rms      03-Dec-94): This function runs `rmail-get-new-mail-hook' before saving the updated file.
1.138        (rms      03-Dec-94): It returns t if it got any new messages."
1.1          (roland   13-May-91):   (interactive
1.1          (roland   13-May-91):    (list (if current-prefix-arg
1.1          (roland   13-May-91): 	     (read-file-name "Get new mail from file: "))))
1.190        (rms      28-Jun-96):   (run-hooks 'rmail-before-get-new-mail-hook)
1.152        (rms      24-Apr-95):   ;; If the disk file has been changed from under us,
1.152        (rms      24-Apr-95):   ;; revert to it before we get new mail.
1.1          (roland   13-May-91):   (or (verify-visited-file-modtime (current-buffer))
1.152        (rms      24-Apr-95):       (find-file (buffer-file-name)))
1.339        (gerd     08-May-01):   (set-buffer rmail-buffer)
1.1          (roland   13-May-91):   (rmail-maybe-set-message-counters)
1.1          (roland   13-May-91):   (widen)
1.1          (roland   13-May-91):   ;; Get rid of all undo records for this buffer.
1.1          (roland   13-May-91):   (or (eq buffer-undo-list t)
1.1          (roland   13-May-91):       (setq buffer-undo-list nil))
1.198        (rms      19-Sep-96):   (let ((all-files (if file-name (list file-name)
1.237        (kwzh     15-Oct-97): 		     rmail-inbox-list))
1.247        (handa    20-Feb-98): 	(rmail-enable-multibyte (default-value 'enable-multibyte-characters))
1.237        (kwzh     15-Oct-97): 	found)
1.198        (rms      19-Sep-96):     (unwind-protect
1.237        (kwzh     15-Oct-97): 	(progn
1.206        (kwzh     25-Jan-97): 	  (while all-files
1.206        (kwzh     25-Jan-97): 	    (let ((opoint (point))
1.206        (kwzh     25-Jan-97): 		  (new-messages 0)
1.380        (uid65566 16-Jan-04): 		  (rsf-number-of-spam 0)
1.206        (kwzh     25-Jan-97): 		  (delete-files ())
1.206        (kwzh     25-Jan-97): 		  ;; If buffer has not changed yet, and has not been saved yet,
1.206        (kwzh     25-Jan-97): 		  ;; don't replace the old backup file now.
1.206        (kwzh     25-Jan-97): 		  (make-backup-files (and make-backup-files (buffer-modified-p)))
1.206        (kwzh     25-Jan-97): 		  (buffer-read-only nil)
1.206        (kwzh     25-Jan-97): 		  ;; Don't make undo records for what we do in getting mail.
1.206        (kwzh     25-Jan-97): 		  (buffer-undo-list t)
1.206        (kwzh     25-Jan-97): 		  success
1.206        (kwzh     25-Jan-97): 		  ;; Files to insert this time around.
1.206        (kwzh     25-Jan-97): 		  files
1.206        (kwzh     25-Jan-97): 		  ;; Last names of those files.
1.206        (kwzh     25-Jan-97): 		  file-last-names)
1.206        (kwzh     25-Jan-97): 	      ;; Pull files off all-files onto files
1.206        (kwzh     25-Jan-97): 	      ;; as long as there is no name conflict.
1.206        (kwzh     25-Jan-97): 	      ;; A conflict happens when two inbox file names
1.206        (kwzh     25-Jan-97): 	      ;; have the same last component.
1.206        (kwzh     25-Jan-97): 	      (while (and all-files
1.206        (kwzh     25-Jan-97): 			  (not (member (file-name-nondirectory (car all-files))
1.206        (kwzh     25-Jan-97): 				       file-last-names)))
1.206        (kwzh     25-Jan-97): 		(setq files (cons (car all-files) files)
1.206        (kwzh     25-Jan-97): 		      file-last-names
1.206        (kwzh     25-Jan-97): 		      (cons (file-name-nondirectory (car all-files)) files))
1.206        (kwzh     25-Jan-97): 		(setq all-files (cdr all-files)))
1.206        (kwzh     25-Jan-97): 	      ;; Put them back in their original order.
1.206        (kwzh     25-Jan-97): 	      (setq files (nreverse files))
1.198        (rms      19-Sep-96): 
1.206        (kwzh     25-Jan-97): 	      (goto-char (point-max))
1.206        (kwzh     25-Jan-97): 	      (skip-chars-backward " \t\n") ; just in case of brain damage
1.206        (kwzh     25-Jan-97): 	      (delete-region (point) (point-max)) ; caused by require-final-newline
1.206        (kwzh     25-Jan-97): 	      (save-excursion
1.206        (kwzh     25-Jan-97): 		(save-restriction
1.206        (kwzh     25-Jan-97): 		  (narrow-to-region (point) (point))
1.206        (kwzh     25-Jan-97): 		  ;; Read in the contents of the inbox files,
1.206        (kwzh     25-Jan-97): 		  ;; renaming them as necessary,
1.206        (kwzh     25-Jan-97): 		  ;; and adding to the list of files to delete eventually.
1.206        (kwzh     25-Jan-97): 		  (if file-name
1.206        (kwzh     25-Jan-97): 		      (rmail-insert-inbox-text files nil)
1.206        (kwzh     25-Jan-97): 		    (setq delete-files (rmail-insert-inbox-text files t)))
1.206        (kwzh     25-Jan-97): 		  ;; Scan the new text and convert each message to babyl format.
1.206        (kwzh     25-Jan-97): 		  (goto-char (point-min))
1.206        (kwzh     25-Jan-97): 		  (unwind-protect
1.206        (kwzh     25-Jan-97): 		      (save-excursion
1.206        (kwzh     25-Jan-97): 			(setq new-messages (rmail-convert-to-babyl-format)
1.206        (kwzh     25-Jan-97): 			      success t))
1.290        (rms      21-Oct-98): 		    ;; Try to delete the garbage just inserted.
1.290        (rms      21-Oct-98): 		    (or success (delete-region (point-min) (point-max)))
1.206        (kwzh     25-Jan-97): 		    ;; If we could not convert the file's inboxes,
1.206        (kwzh     25-Jan-97): 		    ;; rename the files we tried to read
1.206        (kwzh     25-Jan-97): 		    ;; so we won't over and over again.
1.206        (kwzh     25-Jan-97): 		    (if (and (not file-name) (not success))
1.206        (kwzh     25-Jan-97): 			(let ((delfiles delete-files)
1.206        (kwzh     25-Jan-97): 			      (count 0))
1.206        (kwzh     25-Jan-97): 			  (while delfiles
1.206        (kwzh     25-Jan-97): 			    (while (file-exists-p (format "RMAILOSE.%d" count))
1.206        (kwzh     25-Jan-97): 			      (setq count (1+ count)))
1.206        (kwzh     25-Jan-97): 			    (rename-file (car delfiles)
1.206        (kwzh     25-Jan-97): 					 (format "RMAILOSE.%d" count))
1.206        (kwzh     25-Jan-97): 			    (setq delfiles (cdr delfiles))))))
1.206        (kwzh     25-Jan-97): 		  (or (zerop new-messages)
1.206        (kwzh     25-Jan-97): 		      (let (success)
1.206        (kwzh     25-Jan-97): 			(widen)
1.206        (kwzh     25-Jan-97): 			(search-backward "\n\^_" nil t)
1.206        (kwzh     25-Jan-97): 			(narrow-to-region (point) (point-max))
1.206        (kwzh     25-Jan-97): 			(goto-char (1+ (point-min)))
1.206        (kwzh     25-Jan-97): 			(rmail-count-new-messages)
1.206        (kwzh     25-Jan-97): 			(run-hooks 'rmail-get-new-mail-hook)
1.206        (kwzh     25-Jan-97): 			(save-buffer)))
1.206        (kwzh     25-Jan-97): 		  ;; Delete the old files, now that babyl file is saved.
1.206        (kwzh     25-Jan-97): 		  (while delete-files
1.206        (kwzh     25-Jan-97): 		    (condition-case ()
1.206        (kwzh     25-Jan-97): 			;; First, try deleting.
1.206        (kwzh     25-Jan-97): 			(condition-case ()
1.206        (kwzh     25-Jan-97): 			    (delete-file (car delete-files))
1.206        (kwzh     25-Jan-97): 			  (file-error
1.206        (kwzh     25-Jan-97): 			   ;; If we can't delete it, truncate it.
1.206        (kwzh     25-Jan-97): 			   (write-region (point) (point) (car delete-files))))
1.206        (kwzh     25-Jan-97): 		      (file-error nil))
1.206        (kwzh     25-Jan-97): 		    (setq delete-files (cdr delete-files)))))
1.206        (kwzh     25-Jan-97): 	      (if (= new-messages 0)
1.206        (kwzh     25-Jan-97): 		  (progn (goto-char opoint)
1.206        (kwzh     25-Jan-97): 			 (if (or file-name rmail-inbox-list)
1.206        (kwzh     25-Jan-97): 			     (message "(No new mail has arrived)")))
1.380        (uid65566 16-Jan-04): 		;; check new messages to see if any of them is spam:
1.385        (uid65627 17-Feb-04): 		(if (and (featurep 'rmail-spam-filter)
1.385        (uid65627 17-Feb-04): 			 rmail-use-spam-filter)
1.380        (uid65566 16-Jan-04): 		    (let*
1.380        (uid65566 16-Jan-04): 			((old-messages (- rmail-total-messages new-messages))
1.380        (uid65566 16-Jan-04):                          (rsf-scanned-message-number (1+ old-messages))
1.380        (uid65566 16-Jan-04):                          ;; save deletion flags of old messages: vector starts
1.380        (uid65566 16-Jan-04):                          ;; at zero (is one longer that no of messages),
1.380        (uid65566 16-Jan-04):                          ;; therefore take 1+ old-messages
1.380        (uid65566 16-Jan-04):                          (save-deleted
1.380        (uid65566 16-Jan-04):                           (substring rmail-deleted-vector 0 (1+
1.380        (uid65566 16-Jan-04):                           old-messages))))
1.380        (uid65566 16-Jan-04):                       ;; set all messages to undeleted
1.380        (uid65566 16-Jan-04):                       (setq rmail-deleted-vector
1.380        (uid65566 16-Jan-04):                             (make-string (1+ rmail-total-messages) ?\ ))
1.380        (uid65566 16-Jan-04): 		      (while (<= rsf-scanned-message-number
1.380        (uid65566 16-Jan-04): 		      rmail-total-messages)
1.380        (uid65566 16-Jan-04): 			(progn
1.380        (uid65566 16-Jan-04): 			  (if (not (rmail-spam-filter rsf-scanned-message-number))
1.380        (uid65566 16-Jan-04): 			      (progn (setq rsf-number-of-spam (1+ rsf-number-of-spam)))
1.380        (uid65566 16-Jan-04): 			    )
1.380        (uid65566 16-Jan-04): 			  (setq rsf-scanned-message-number (1+ rsf-scanned-message-number))
1.380        (uid65566 16-Jan-04): 			  ))
1.380        (uid65566 16-Jan-04): 		      (if (> rsf-number-of-spam 0)
1.380        (uid65566 16-Jan-04): 			  (progn
1.380        (uid65566 16-Jan-04): 			    (when (rmail-expunge-confirmed)
1.380        (uid65566 16-Jan-04):                               (rmail-only-expunge t))
1.380        (uid65566 16-Jan-04):                             ))
1.380        (uid65566 16-Jan-04):                       (setq rmail-deleted-vector
1.380        (uid65566 16-Jan-04):                             (concat
1.380        (uid65566 16-Jan-04):                              save-deleted
1.380        (uid65566 16-Jan-04):                              (make-string (- rmail-total-messages old-messages)
1.380        (uid65566 16-Jan-04):                                           ?\ )))
1.380        (uid65566 16-Jan-04): 		      ))
1.380        (uid65566 16-Jan-04):  		(if (rmail-summary-exists)
1.206        (kwzh     25-Jan-97): 		    (rmail-select-summary
1.206        (kwzh     25-Jan-97): 		     (rmail-update-summary)))
1.380        (uid65566 16-Jan-04): 		(message "%d new message%s read%s"
1.380        (uid65566 16-Jan-04): 			 new-messages (if (= 1 new-messages) "" "s")
1.380        (uid65566 16-Jan-04): 			 ;; print out a message on number of spam messages found:
1.385        (uid65627 17-Feb-04): 			 (if (and (featurep 'rmail-spam-filter)
1.385        (uid65627 17-Feb-04): 				  rmail-use-spam-filter
1.385        (uid65627 17-Feb-04): 				  (> rsf-number-of-spam 0))
1.427        (rms      08-Sep-06): 			     (cond ((= 1 new-messages)
1.427        (rms      08-Sep-06): 				    ", and appears to be spam")
1.427        (rms      08-Sep-06): 				   ((= rsf-number-of-spam new-messages)
1.427        (rms      08-Sep-06): 				    ", and all appear to be spam")
1.427        (rms      08-Sep-06): 				   ((> rsf-number-of-spam 1)
1.427        (rms      08-Sep-06): 				    (format ", and %d appear to be spam"
1.427        (rms      08-Sep-06): 					    rsf-number-of-spam))
1.427        (rms      08-Sep-06): 				   (t
1.427        (rms      08-Sep-06): 				    ", and 1 appears to be spam"))
1.380        (uid65566 16-Jan-04): 			   ""))
1.385        (uid65627 17-Feb-04): 		(if (and (featurep 'rmail-spam-filter)
1.385        (uid65627 17-Feb-04): 			 rmail-use-spam-filter
1.385        (uid65627 17-Feb-04): 			 (> rsf-number-of-spam 0))
1.393        (eliz     12-Nov-04): 		    (progn (if rsf-beep (beep t))
1.393        (eliz     12-Nov-04): 			   (sleep-for rsf-sleep-after-message)))
1.380        (uid65566 16-Jan-04): 
1.206        (kwzh     25-Jan-97): 		;; Move to the first new message
1.206        (kwzh     25-Jan-97): 		;; unless we have other unseen messages before it.
1.206        (kwzh     25-Jan-97): 		(rmail-show-message (rmail-first-unseen-message))
1.206        (kwzh     25-Jan-97): 		(run-hooks 'rmail-after-get-new-mail-hook)
1.206        (kwzh     25-Jan-97): 		(setq found t))))
1.206        (kwzh     25-Jan-97): 	  found)
1.198        (rms      19-Sep-96):       ;; Don't leave the buffer screwed up if we get a disk-full error.
1.237        (kwzh     15-Oct-97):       (or found (rmail-show-message)))))
1.1          (roland   13-May-91): 
1.395        (eliz     15-Jan-05): (defun rmail-parse-url (file)
1.395        (eliz     15-Jan-05):   "Parse the supplied URL. Return (list MAILBOX-NAME REMOTE PASSWORD GOT-PASSWORD)
1.395        (eliz     15-Jan-05): WHERE MAILBOX-NAME is the name of the mailbox suitable as argument to the
1.395        (eliz     15-Jan-05): actual version of `movemail', REMOTE is non-nil if MAILBOX-NAME refers to
1.395        (eliz     15-Jan-05): a remote mailbox, PASSWORD is the password if it should be
1.395        (eliz     15-Jan-05): supplied as a separate argument to `movemail' or nil otherwise, GOT-PASSWORD
1.395        (eliz     15-Jan-05): is non-nil if the user has supplied the password interactively.
1.395        (eliz     15-Jan-05): "
1.398        (eliz     02-Apr-05):   (cond
1.398        (eliz     02-Apr-05):    ((string-match "^\\([^:]+\\)://\\(\\([^:@]+\\)\\(:\\([^@]+\\)\\)?@\\)?.*" file)
1.396        (kfstorm  09-Feb-05):       (let (got-password supplied-password
1.395        (eliz     15-Jan-05): 	    (proto (match-string 1 file))
1.395        (eliz     15-Jan-05): 	    (user  (match-string 3 file))
1.395        (eliz     15-Jan-05): 	    (pass  (match-string 5 file))
1.395        (eliz     15-Jan-05): 	    (host  (substring file (or (match-end 2)
1.395        (eliz     15-Jan-05): 				       (+ 3 (match-end 1))))))
1.407        (ttn      06-Aug-05): 
1.395        (eliz     15-Jan-05): 	(if (not pass)
1.395        (eliz     15-Jan-05): 	    (when rmail-remote-password-required
1.395        (eliz     15-Jan-05): 	      (setq got-password (not (rmail-have-password)))
1.395        (eliz     15-Jan-05): 	      (setq supplied-password (rmail-get-remote-password
1.395        (eliz     15-Jan-05): 				       (string-equal proto "imap")))))
1.396        (kfstorm  09-Feb-05): 
1.395        (eliz     15-Jan-05): 	(if (rmail-movemail-variant-p 'emacs)
1.395        (eliz     15-Jan-05): 	    (if (string-equal proto "pop")
1.395        (eliz     15-Jan-05): 		(list (concat "po:" user ":" host)
1.395        (eliz     15-Jan-05): 		      t
1.395        (eliz     15-Jan-05): 		      (or pass supplied-password)
1.395        (eliz     15-Jan-05): 		      got-password)
1.395        (eliz     15-Jan-05): 	      (error "Emacs movemail does not support %s protocol" proto))
1.395        (eliz     15-Jan-05): 	  (list file
1.395        (eliz     15-Jan-05): 		(or (string-equal proto "pop") (string-equal proto "imap"))
1.395        (eliz     15-Jan-05): 		supplied-password
1.398        (eliz     02-Apr-05): 		got-password))))
1.407        (ttn      06-Aug-05): 
1.398        (eliz     02-Apr-05):    ((string-match "^po:\\([^:]+\\)\\(:\\(.*\\)\\)?" file)
1.398        (eliz     02-Apr-05):     (let (got-password supplied-password
1.398        (eliz     02-Apr-05):           (proto "pop")
1.398        (eliz     02-Apr-05): 	  (user  (match-string 1 file))
1.398        (eliz     02-Apr-05): 	  (host  (match-string 3 file)))
1.407        (ttn      06-Aug-05): 
1.398        (eliz     02-Apr-05):       (when rmail-remote-password-required
1.398        (eliz     02-Apr-05): 	(setq got-password (not (rmail-have-password)))
1.398        (eliz     02-Apr-05): 	(setq supplied-password (rmail-get-remote-password nil)))
1.398        (eliz     02-Apr-05): 
1.398        (eliz     02-Apr-05):       (list file "pop" supplied-password got-password)))
1.407        (ttn      06-Aug-05): 
1.398        (eliz     02-Apr-05):    (t
1.398        (eliz     02-Apr-05):     (list file nil nil nil))))
1.395        (eliz     15-Jan-05): 
1.1          (roland   13-May-91): (defun rmail-insert-inbox-text (files renamep)
1.198        (rms      19-Sep-96):   ;; Detect a locked file now, so that we avoid moving mail
1.198        (rms      19-Sep-96):   ;; out of the real inbox file.  (That could scare people.)
1.198        (rms      19-Sep-96):   (or (memq (file-locked-p buffer-file-name) '(nil t))
1.198        (rms      19-Sep-96):       (error "RMAIL file %s is locked"
1.198        (rms      19-Sep-96): 	     (file-name-nondirectory buffer-file-name)))
1.282        (rms      27-Jul-98):   (let (file tofile delete-files movemail popmail got-password password)
1.1          (roland   13-May-91):     (while files
1.395        (eliz     15-Jan-05):       ;; Handle remote mailbox names specially; don't expand as filenames
1.296        (andrewi  29-Jan-99):       ;; in case the userid contains a directory separator.
1.296        (andrewi  29-Jan-99):       (setq file (car files))
1.395        (eliz     15-Jan-05):       (let ((url-data (rmail-parse-url file)))
1.395        (eliz     15-Jan-05): 	(setq file (nth 0 url-data))
1.395        (eliz     15-Jan-05): 	(setq popmail (nth 1 url-data))
1.395        (eliz     15-Jan-05): 	(setq password (nth 2 url-data))
1.395        (eliz     15-Jan-05): 	(setq got-password (nth 3 url-data)))
1.395        (eliz     15-Jan-05): 
1.296        (andrewi  29-Jan-99):       (if popmail
1.296        (andrewi  29-Jan-99): 	  (setq renamep t)
1.296        (andrewi  29-Jan-99): 	(setq file (file-truename
1.333        (handa    16-Mar-01): 		    (substitute-in-file-name (expand-file-name file)))))
1.296        (andrewi  29-Jan-99):       (setq tofile (expand-file-name
1.157        (rms      25-Jul-95): 		    ;; Generate name to move to from inbox name,
1.157        (rms      25-Jul-95): 		    ;; in case of multiple inboxes that need moving.
1.395        (eliz     15-Jan-05): 		    (concat ".newmail-"
1.396        (kfstorm  09-Feb-05): 			    (file-name-nondirectory
1.395        (eliz     15-Jan-05): 			     (if (memq system-type '(windows-nt cygwin))
1.395        (eliz     15-Jan-05): 				 ;; cannot have "po:" in file name
1.395        (eliz     15-Jan-05): 				 (substring file 3)
1.395        (eliz     15-Jan-05): 			       file)))
1.157        (rms      25-Jul-95): 		    ;; Use the directory of this rmail file
1.157        (rms      25-Jul-95): 		    ;; because it's a nuisance to use the homedir
1.157        (rms      25-Jul-95): 		    ;; if that is on a full disk and this rmail
1.157        (rms      25-Jul-95): 		    ;; file isn't.
1.157        (rms      25-Jul-95): 		    (file-name-directory
1.157        (rms      25-Jul-95): 		     (expand-file-name buffer-file-name))))
1.157        (rms      25-Jul-95):       ;; Always use movemail to rename the file,
1.157        (rms      25-Jul-95):       ;; since there can be mailboxes in various directories.
1.398        (eliz     02-Apr-05):       (if (not popmail)
1.1          (roland   13-May-91): 	  (progn
1.1          (roland   13-May-91): 	    ;; On some systems, /usr/spool/mail/foo is a directory
1.1          (roland   13-May-91): 	    ;; and the actual inbox is /usr/spool/mail/foo/foo.
1.1          (roland   13-May-91): 	    (if (file-directory-p file)
1.86         (kwzh     11-Feb-94): 		(setq file (expand-file-name (user-login-name)
1.1          (roland   13-May-91): 					     file)))))
1.150        (rms      14-Apr-95):       (cond (popmail
1.395        (eliz     15-Jan-05): 	     (message "Getting mail from the remote server ..."))
1.150        (rms      14-Apr-95): 	    ((and (file-exists-p tofile)
1.150        (rms      14-Apr-95): 		  (/= 0 (nth 7 (file-attributes tofile))))
1.150        (rms      14-Apr-95): 	     (message "Getting mail from %s..." tofile))
1.150        (rms      14-Apr-95): 	    ((and (file-exists-p file)
1.150        (rms      14-Apr-95): 		  (/= 0 (nth 7 (file-attributes file))))
1.150        (rms      14-Apr-95): 	     (message "Getting mail from %s..." file)))
1.1          (roland   13-May-91):       ;; Set TOFILE if have not already done so, and
1.1          (roland   13-May-91):       ;; rename or copy the file FILE to TOFILE if and as appropriate.
1.1          (roland   13-May-91):       (cond ((not renamep)
1.1          (roland   13-May-91): 	     (setq tofile file))
1.39         (rms      09-Mar-93): 	    ((or (file-exists-p tofile) (and (not popmail)
1.39         (rms      09-Mar-93): 					     (not (file-exists-p file))))
1.1          (roland   13-May-91): 	     nil)
1.1          (roland   13-May-91): 	    (t
1.395        (eliz     15-Jan-05): 	     (with-temp-buffer
1.395        (eliz     15-Jan-05): 	       (let ((errors (current-buffer)))
1.395        (eliz     15-Jan-05): 		 (buffer-disable-undo errors)
1.395        (eliz     15-Jan-05): 		 (let ((args
1.395        (eliz     15-Jan-05): 			(append
1.439        (gm       22-Aug-07): 			 (list rmail-movemail-program nil errors nil)
1.395        (eliz     15-Jan-05): 			 (if rmail-preserve-inbox
1.395        (eliz     15-Jan-05): 			     (list "-p")
1.395        (eliz     15-Jan-05): 			   nil)
1.395        (eliz     15-Jan-05): 			 (if (rmail-movemail-variant-p 'mailutils)
1.395        (eliz     15-Jan-05): 			     (append (list "--emacs") rmail-movemail-flags)
1.395        (eliz     15-Jan-05): 			   rmail-movemail-flags)
1.395        (eliz     15-Jan-05): 			 (list file tofile)
1.395        (eliz     15-Jan-05): 			 (if password (list password) nil))))
1.395        (eliz     15-Jan-05): 		   (apply 'call-process args))
1.395        (eliz     15-Jan-05): 		 (if (not (buffer-modified-p errors))
1.395        (eliz     15-Jan-05): 		     ;; No output => movemail won
1.395        (eliz     15-Jan-05): 		     nil
1.395        (eliz     15-Jan-05): 		   (set-buffer errors)
1.395        (eliz     15-Jan-05): 		   (subst-char-in-region (point-min) (point-max)
1.395        (eliz     15-Jan-05): 					 ?\n ?\  )
1.395        (eliz     15-Jan-05): 		   (goto-char (point-max))
1.395        (eliz     15-Jan-05): 		   (skip-chars-backward " \t")
1.395        (eliz     15-Jan-05): 		   (delete-region (point) (point-max))
1.395        (eliz     15-Jan-05): 		   (goto-char (point-min))
1.395        (eliz     15-Jan-05): 		   (if (looking-at "movemail: ")
1.395        (eliz     15-Jan-05): 		       (delete-region (point-min) (match-end 0)))
1.395        (eliz     15-Jan-05): 		   (beep t)
1.395        (eliz     15-Jan-05): 		   ;; If we just read the password, most likely it is
1.395        (eliz     15-Jan-05): 		   ;; wrong.  Otherwise, see if there is a specific
1.395        (eliz     15-Jan-05): 		   ;; reason to think that the problem is a wrong passwd.
1.395        (eliz     15-Jan-05): 		   (if (or got-password
1.395        (eliz     15-Jan-05): 			   (re-search-forward rmail-remote-password-error
1.395        (eliz     15-Jan-05): 					      nil t))
1.395        (eliz     15-Jan-05): 		       (rmail-set-remote-password nil))
1.395        (eliz     15-Jan-05): 
1.395        (eliz     15-Jan-05): 		   ;; If using Mailutils, remove initial error code
1.395        (eliz     15-Jan-05): 		   ;; abbreviation
1.395        (eliz     15-Jan-05): 		   (when (rmail-movemail-variant-p 'mailutils)
1.395        (eliz     15-Jan-05): 		     (goto-char (point-min))
1.395        (eliz     15-Jan-05): 		     (when (looking-at "[A-Z][A-Z0-9_]*:")
1.395        (eliz     15-Jan-05): 		       (delete-region (point-min) (match-end 0))))
1.396        (kfstorm  09-Feb-05): 
1.395        (eliz     15-Jan-05): 		   (message "movemail: %s"
1.395        (eliz     15-Jan-05): 			    (buffer-substring (point-min)
1.395        (eliz     15-Jan-05): 					      (point-max)))
1.396        (kfstorm  09-Feb-05): 
1.395        (eliz     15-Jan-05): 		   (sit-for 3)
1.395        (eliz     15-Jan-05): 		   nil)))))
1.396        (kfstorm  09-Feb-05): 
1.1          (roland   13-May-91):       ;; At this point, TOFILE contains the name to read:
1.1          (roland   13-May-91):       ;; Either the alternate name (if we renamed)
1.1          (roland   13-May-91):       ;; or the actual inbox (if not renaming).
1.1          (roland   13-May-91):       (if (file-exists-p tofile)
1.212        (handa    26-Feb-97): 	  (let ((coding-system-for-read 'no-conversion)
1.212        (handa    26-Feb-97): 		size)
1.1          (roland   13-May-91): 	    (goto-char (point-max))
1.212        (handa    26-Feb-97): 	    (setq size (nth 1 (insert-file-contents tofile)))
1.1          (roland   13-May-91): 	    (goto-char (point-max))
1.1          (roland   13-May-91): 	    (or (= (preceding-char) ?\n)
1.1          (roland   13-May-91): 		(zerop size)
1.1          (roland   13-May-91): 		(insert ?\n))
1.205        (rms      21-Jan-97): 	    (if (not (and rmail-preserve-inbox (string= file tofile)))
1.205        (rms      21-Jan-97): 		(setq delete-files (cons tofile delete-files)))))
1.1          (roland   13-May-91):       (message "")
1.1          (roland   13-May-91):       (setq files (cdr files)))
1.1          (roland   13-May-91):     delete-files))
1.183        (rms      26-Apr-96): 
1.295        (rms      28-Jan-99): ;; Decode the region specified by FROM and TO by CODING.
1.295        (rms      28-Jan-99): ;; If CODING is nil or an invalid coding system, decode by `undecided'.
1.295        (rms      28-Jan-99): (defun rmail-decode-region (from to coding)
1.295        (rms      28-Jan-99):   (if (or (not coding) (not (coding-system-p coding)))
1.295        (rms      28-Jan-99):       (setq coding 'undecided))
1.390        (eliz     24-Apr-04):   ;; Use -dos decoding, to remove ^M characters left from base64 or
1.390        (eliz     24-Apr-04):   ;; rogue qp-encoded text.
1.390        (eliz     24-Apr-04):   (decode-coding-region from to
1.390        (eliz     24-Apr-04): 			(coding-system-change-eol-conversion coding 1))
1.390        (eliz     24-Apr-04):   ;; Don't reveal the fact we used -dos decoding, as users generally
1.390        (eliz     24-Apr-04):   ;; will not expect the RMAIL buffer to use DOS EOL format.
1.390        (eliz     24-Apr-04):   (setq buffer-file-coding-system
1.390        (eliz     24-Apr-04): 	(setq last-coding-system-used
1.390        (eliz     24-Apr-04): 	      (coding-system-change-eol-conversion coding 0))))
1.295        (rms      28-Jan-99): 
1.1          (roland   13-May-91): ;; the  rmail-break-forwarded-messages  feature is not implemented
1.1          (roland   13-May-91): (defun rmail-convert-to-babyl-format ()
1.1          (roland   13-May-91):   (let ((count 0) start
1.5          (rms      18-Aug-91): 	(case-fold-search nil)
1.427        (rms      08-Sep-06): 	(buffer-undo-list t)
1.5          (rms      18-Aug-91): 	(invalid-input-resync
1.5          (rms      18-Aug-91): 	 (function (lambda ()
1.5          (rms      18-Aug-91): 		     (message "Invalid Babyl format in inbox!")
1.198        (rms      19-Sep-96): 		     (sit-for 3)
1.5          (rms      18-Aug-91): 		     ;; Try to get back in sync with a real message.
1.5          (rms      18-Aug-91): 		     (if (re-search-forward
1.226        (rms      01-Jun-97): 			  (concat rmail-mmdf-delim1 "\\|^From") nil t)
1.5          (rms      18-Aug-91): 			 (beginning-of-line)
1.5          (rms      18-Aug-91): 		       (goto-char (point-max)))))))
1.1          (roland   13-May-91):     (goto-char (point-min))
1.1          (roland   13-May-91):     (save-restriction
1.1          (roland   13-May-91):       (while (not (eobp))
1.212        (handa    26-Feb-97): 	(setq start (point))
1.445        (m061211  13-Jan-08): 	(cond ((looking-at "BABYL OPTIONS:")	;Babyl header
1.5          (rms      18-Aug-91): 	       (if (search-forward "\n\^_" nil t)
1.5          (rms      18-Aug-91): 		   ;; If we find the proper terminator, delete through there.
1.5          (rms      18-Aug-91): 		   (delete-region (point-min) (point))
1.5          (rms      18-Aug-91): 		 (funcall invalid-input-resync)
1.7          (mib      20-Aug-91): 		 (delete-region (point-min) (point))))
1.1          (roland   13-May-91): 	      ;; Babyl format message
1.1          (roland   13-May-91): 	      ((looking-at "\^L")
1.1          (roland   13-May-91): 	       (or (search-forward "\n\^_" nil t)
1.5          (rms      18-Aug-91): 		   (funcall invalid-input-resync))
1.1          (roland   13-May-91): 	       (setq count (1+ count))
1.1          (roland   13-May-91): 	       ;; Make sure there is no extra white space after the ^_
1.1          (roland   13-May-91): 	       ;; at the end of the message.
1.1          (roland   13-May-91): 	       ;; Narrowing will make sure that whatever follows the junk
1.1          (roland   13-May-91): 	       ;; will be treated properly.
1.1          (roland   13-May-91): 	       (delete-region (point)
1.1          (roland   13-May-91): 			      (save-excursion
1.1          (roland   13-May-91): 				(skip-chars-forward " \t\n")
1.1          (roland   13-May-91): 				(point)))
1.445        (m061211  13-Jan-08): 	       ;; The following let* form was wrapped in a `save-excursion'
1.445        (m061211  13-Jan-08): 	       ;; which in one case caused infinite looping, see:
1.445        (m061211  13-Jan-08): 	       ;; http://lists.gnu.org/archive/html/emacs-devel/2008-01/msg00968.html
1.445        (m061211  13-Jan-08): 	       ;; Removing that form leaves `point' at the end of the
1.445        (m061211  13-Jan-08): 	       ;; region decoded by `rmail-decode-region' which should
1.445        (m061211  13-Jan-08): 	       ;; be correct.
1.445        (m061211  13-Jan-08): 	       (let* ((header-end
1.445        (m061211  13-Jan-08): 		       (progn
1.372        (eliz     28-Aug-03): 			 (save-excursion
1.372        (eliz     28-Aug-03): 			   (goto-char start)
1.445        (m061211  13-Jan-08): 			   (forward-line 1)
1.445        (m061211  13-Jan-08): 			   (if (looking-at "0")
1.445        (m061211  13-Jan-08): 			       (forward-line 1)
1.445        (m061211  13-Jan-08): 			     (forward-line 2))
1.445        (m061211  13-Jan-08): 			   (save-restriction
1.445        (m061211  13-Jan-08): 			     (narrow-to-region (point) (point-max))
1.445        (m061211  13-Jan-08): 			     (rfc822-goto-eoh)
1.445        (m061211  13-Jan-08): 			     (point)))))
1.445        (m061211  13-Jan-08): 		      (case-fold-search t)
1.445        (m061211  13-Jan-08): 		      (quoted-printable-header-field-end
1.445        (m061211  13-Jan-08): 		       (save-excursion
1.445        (m061211  13-Jan-08): 			 (goto-char start)
1.445        (m061211  13-Jan-08): 			 (re-search-forward
1.445        (m061211  13-Jan-08): 			  "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
1.445        (m061211  13-Jan-08): 			  header-end t)))
1.445        (m061211  13-Jan-08): 		      (base64-header-field-end
1.372        (eliz     28-Aug-03): 		       (save-excursion
1.445        (m061211  13-Jan-08): 			 (goto-char start)
1.445        (m061211  13-Jan-08): 			 ;; Don't try to decode non-text data.
1.445        (m061211  13-Jan-08): 			 (and (re-search-forward
1.445        (m061211  13-Jan-08): 			       "^content-type:\\(\n?[\t ]\\)\\(text\\|message\\)/"
1.445        (m061211  13-Jan-08): 			       header-end t)
1.445        (m061211  13-Jan-08): 			      (goto-char start)
1.445        (m061211  13-Jan-08): 			      (re-search-forward
1.445        (m061211  13-Jan-08): 			       "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*"
1.445        (m061211  13-Jan-08): 			       header-end t)))))
1.445        (m061211  13-Jan-08): 		 (if quoted-printable-header-field-end
1.445        (m061211  13-Jan-08): 		     (save-excursion
1.445        (m061211  13-Jan-08): 		       (unless
1.445        (m061211  13-Jan-08): 			   (mail-unquote-printable-region header-end (point) nil t t)
1.445        (m061211  13-Jan-08): 			 (message "Malformed MIME quoted-printable message"))
1.445        (m061211  13-Jan-08): 		       ;; Change "quoted-printable" to "8bit",
1.445        (m061211  13-Jan-08): 		       ;; to reflect the decoding we just did.
1.445        (m061211  13-Jan-08): 		       (goto-char quoted-printable-header-field-end)
1.445        (m061211  13-Jan-08): 		       (delete-region (point) (search-backward ":"))
1.445        (m061211  13-Jan-08): 		       (insert ": 8bit")))
1.445        (m061211  13-Jan-08): 		 (if base64-header-field-end
1.445        (m061211  13-Jan-08): 		     (save-excursion
1.445        (m061211  13-Jan-08): 		       (when
1.445        (m061211  13-Jan-08): 			   (condition-case nil
1.445        (m061211  13-Jan-08): 			       (progn
1.445        (m061211  13-Jan-08): 				 (base64-decode-region (1+ header-end)
1.445        (m061211  13-Jan-08): 						       (- (point) 2))
1.445        (m061211  13-Jan-08): 				 t)
1.445        (m061211  13-Jan-08): 			     (error nil))
1.445        (m061211  13-Jan-08): 			 ;; Change "base64" to "8bit", to reflect the
1.445        (m061211  13-Jan-08): 			 ;; decoding we just did.
1.445        (m061211  13-Jan-08): 			 (goto-char base64-header-field-end)
1.372        (eliz     28-Aug-03): 			 (delete-region (point) (search-backward ":"))
1.445        (m061211  13-Jan-08): 			 (insert ": 8bit"))))
1.445        (m061211  13-Jan-08): 		 (setq last-coding-system-used nil)
1.445        (m061211  13-Jan-08): 		 (or rmail-enable-mime
1.445        (m061211  13-Jan-08): 		     (not rmail-enable-multibyte)
1.445        (m061211  13-Jan-08): 		     (let ((mime-charset
1.445        (m061211  13-Jan-08): 			    (if (and rmail-decode-mime-charset
1.445        (m061211  13-Jan-08): 				     (save-excursion
1.445        (m061211  13-Jan-08): 				       (goto-char start)
1.445        (m061211  13-Jan-08): 				       (search-forward "\n\n" nil t)
1.445        (m061211  13-Jan-08): 				       (let ((case-fold-search t))
1.445        (m061211  13-Jan-08): 					 (re-search-backward
1.445        (m061211  13-Jan-08): 					  rmail-mime-charset-pattern
1.445        (m061211  13-Jan-08): 					  start t))))
1.445        (m061211  13-Jan-08): 				(intern (downcase (match-string 1))))))
1.445        (m061211  13-Jan-08): 		       (rmail-decode-region start (point) mime-charset))))
1.265        (rms      12-May-98): 	       ;; Add an X-Coding-System: header if we don't have one.
1.265        (rms      12-May-98): 	       (save-excursion
1.265        (rms      12-May-98): 		 (goto-char start)
1.265        (rms      12-May-98): 		 (forward-line 1)
1.265        (rms      12-May-98): 		 (if (looking-at "0")
1.265        (rms      12-May-98): 		     (forward-line 1)
1.265        (rms      12-May-98): 		   (forward-line 2))
1.265        (rms      12-May-98): 		 (or (save-restriction
1.265        (rms      12-May-98): 		       (narrow-to-region (point) (point-max))
1.265        (rms      12-May-98): 		       (rfc822-goto-eoh)
1.265        (rms      12-May-98): 		       (goto-char (point-min))
1.265        (rms      12-May-98): 		       (re-search-forward "^X-Coding-System:" nil t))
1.265        (rms      12-May-98): 		     (insert "X-Coding-System: "
1.265        (rms      12-May-98): 			     (symbol-name last-coding-system-used)
1.265        (rms      12-May-98): 			     "\n")))
1.374        (eliz     16-Oct-03): 	       (narrow-to-region (point) (point-max))
1.374        (eliz     16-Oct-03): 	       (and (= 0 (% count 10))
1.375        (eliz     16-Oct-03): 		    (message "Converting to Babyl format...%d" count)))
1.1          (roland   13-May-91): 	      ;;*** MMDF format
1.1          (roland   13-May-91): 	      ((let ((case-fold-search t))
1.226        (rms      01-Jun-97): 		 (looking-at rmail-mmdf-delim1))
1.1          (roland   13-May-91): 	       (let ((case-fold-search t))
1.1          (roland   13-May-91): 		 (replace-match "\^L\n0, unseen,,\n*** EOOH ***\n")
1.226        (rms      01-Jun-97): 		 (re-search-forward rmail-mmdf-delim2 nil t)
1.1          (roland   13-May-91): 		 (replace-match "\^_"))
1.1          (roland   13-May-91): 	       (save-excursion
1.1          (roland   13-May-91): 		 (save-restriction
1.1          (roland   13-May-91): 		   (narrow-to-region start (1- (point)))
1.1          (roland   13-May-91): 		   (goto-char (point-min))
1.445        (m061211  13-Jan-08): 		   (while (search-forward "\n\^_" nil t) ; single char "\^_"
1.445        (m061211  13-Jan-08): 		     (replace-match "\n^_"))))	; 2 chars: "^" and "_"
1.265        (rms      12-May-98): 	       (setq last-coding-system-used nil)
1.212        (handa    26-Feb-97): 	       (or rmail-enable-mime
1.247        (handa    20-Feb-98): 		   (not rmail-enable-multibyte)
1.225        (handa    16-May-97): 		   (decode-coding-region start (point) 'undecided))
1.265        (rms      12-May-98): 	       (save-excursion
1.265        (rms      12-May-98): 		 (goto-char start)
1.265        (rms      12-May-98): 		 (forward-line 3)
1.265        (rms      12-May-98): 		 (insert "X-Coding-System: "
1.265        (rms      12-May-98): 			 (symbol-name last-coding-system-used)
1.265        (rms      12-May-98): 			 "\n"))
1.1          (roland   13-May-91): 	       (narrow-to-region (point) (point-max))
1.374        (eliz     16-Oct-03): 	       (setq count (1+ count))
1.374        (eliz     16-Oct-03): 	       (and (= 0 (% count 10))
1.375        (eliz     16-Oct-03): 		    (message "Converting to Babyl format...%d" count)))
1.1          (roland   13-May-91): 	      ;;*** Mail format
1.1          (roland   13-May-91): 	      ((looking-at "^From ")
1.1          (roland   13-May-91): 	       (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
1.1          (roland   13-May-91): 	       (rmail-nuke-pinhead-header)
1.39         (rms      09-Mar-93): 	       ;; If this message has a Content-Length field,
1.39         (rms      09-Mar-93): 	       ;; skip to the end of the contents.
1.39         (rms      09-Mar-93): 	       (let* ((header-end (save-excursion
1.39         (rms      09-Mar-93): 				    (and (re-search-forward "\n\n" nil t)
1.77         (rms      06-Jan-94): 					 (1- (point)))))
1.39         (rms      09-Mar-93): 		      (case-fold-search t)
1.239        (kwzh     18-Nov-97): 		      (quoted-printable-header-field-end
1.239        (kwzh     18-Nov-97): 		       (save-excursion
1.239        (kwzh     18-Nov-97): 			 (re-search-forward
1.240        (kwzh     18-Nov-97): 			  "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
1.239        (kwzh     18-Nov-97): 			  header-end t)))
1.372        (eliz     28-Aug-03): 		      (base64-header-field-end
1.433        (eliz     03-Apr-07): 		       (and
1.434        (eliz     14-May-07): 			;; Don't decode non-text data.
1.433        (eliz     03-Apr-07): 			(save-excursion
1.433        (eliz     03-Apr-07): 			  (re-search-forward
1.434        (eliz     14-May-07): 			   "^content-type:\\(\n?[\t ]\\)\\(text\\|message\\)/"
1.433        (eliz     03-Apr-07): 			   header-end t))
1.433        (eliz     03-Apr-07): 			(save-excursion
1.433        (eliz     03-Apr-07): 			  (re-search-forward
1.434        (eliz     14-May-07): 			   "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*"
1.433        (eliz     03-Apr-07): 			   header-end t))))
1.39         (rms      09-Mar-93): 		      (size
1.39         (rms      09-Mar-93): 		       ;; Get the numeric value from the Content-Length field.
1.39         (rms      09-Mar-93): 		       (save-excursion
1.39         (rms      09-Mar-93): 			 ;; Back up to end of prev line,
1.39         (rms      09-Mar-93): 			 ;; in case the Content-Length field comes first.
1.39         (rms      09-Mar-93): 			 (forward-char -1)
1.39         (rms      09-Mar-93): 			 (and (search-forward "\ncontent-length: "
1.39         (rms      09-Mar-93): 					      header-end t)
1.39         (rms      09-Mar-93): 			      (let ((beg (point))
1.39         (rms      09-Mar-93): 				    (eol (progn (end-of-line) (point))))
1.402        (lektu    16-May-05): 				(string-to-number (buffer-substring beg eol)))))))
1.90         (kwzh     17-Mar-94): 		 (and size
1.90         (kwzh     17-Mar-94): 		      (if (and (natnump size)
1.90         (kwzh     17-Mar-94): 			       (<= (+ header-end size) (point-max))
1.90         (kwzh     17-Mar-94): 			       ;; Make sure this would put us at a position
1.90         (kwzh     17-Mar-94): 			       ;; that we could continue from.
1.90         (kwzh     17-Mar-94): 			       (save-excursion
1.90         (kwzh     17-Mar-94): 				 (goto-char (+ header-end size))
1.90         (kwzh     17-Mar-94): 				 (skip-chars-forward "\n")
1.90         (kwzh     17-Mar-94): 				 (or (eobp)
1.90         (kwzh     17-Mar-94): 				     (and (looking-at "BABYL OPTIONS:")
1.90         (kwzh     17-Mar-94): 					  (search-forward "\n\^_" nil t))
1.90         (kwzh     17-Mar-94): 				     (and (looking-at "\^L")
1.90         (kwzh     17-Mar-94): 					  (search-forward "\n\^_" nil t))
1.90         (kwzh     17-Mar-94): 				     (let ((case-fold-search t))
1.226        (rms      01-Jun-97): 				       (looking-at rmail-mmdf-delim1))
1.90         (kwzh     17-Mar-94): 				     (looking-at "From "))))
1.90         (kwzh     17-Mar-94): 			  (goto-char (+ header-end size))
1.90         (kwzh     17-Mar-94): 			(message "Ignoring invalid Content-Length field")
1.239        (kwzh     18-Nov-97): 			(sit-for 1 0 t)))
1.365        (rms      29-Nov-02): 		 (if (let ((case-fold-search nil))
1.365        (rms      29-Nov-02): 		       (re-search-forward
1.365        (rms      29-Nov-02): 			(concat "^[\^_]?\\("
1.365        (rms      29-Nov-02): 				rmail-unix-mail-delimiter
1.365        (rms      29-Nov-02): 				"\\|"
1.365        (rms      29-Nov-02): 				rmail-mmdf-delim1 "\\|"
1.365        (rms      29-Nov-02): 				"^BABYL OPTIONS:\\|"
1.365        (rms      29-Nov-02): 				"\^L\n[01],\\)") nil t))
1.239        (kwzh     18-Nov-97): 		     (goto-char (match-beginning 1))
1.239        (kwzh     18-Nov-97): 		   (goto-char (point-max)))
1.239        (kwzh     18-Nov-97): 		 (setq count (1+ count))
1.239        (kwzh     18-Nov-97): 		 (if quoted-printable-header-field-end
1.239        (kwzh     18-Nov-97): 		     (save-excursion
1.379        (uid65566 12-Jan-04): 		       (unless
1.386        (rms      04-Mar-04): 			   (mail-unquote-printable-region header-end (point) nil t t)
1.379        (uid65566 12-Jan-04): 			 (message "Malformed MIME quoted-printable message"))
1.239        (kwzh     18-Nov-97): 		       ;; Change "quoted-printable" to "8bit",
1.239        (kwzh     18-Nov-97): 		       ;; to reflect the decoding we just did.
1.239        (kwzh     18-Nov-97): 		       (goto-char quoted-printable-header-field-end)
1.372        (eliz     28-Aug-03): 		       (delete-region (point) (search-backward ":"))
1.372        (eliz     28-Aug-03): 		       (insert ": 8bit")))
1.372        (eliz     28-Aug-03): 		 (if base64-header-field-end
1.377        (uid65627 30-Dec-03): 		     (save-excursion
1.377        (uid65627 30-Dec-03): 		       (when
1.377        (uid65627 30-Dec-03): 			   (condition-case nil
1.377        (uid65627 30-Dec-03): 			       (progn
1.381        (uid66361 21-Jan-04): 				 (base64-decode-region
1.381        (uid66361 21-Jan-04): 				  (1+ header-end)
1.381        (uid66361 21-Jan-04): 				  (save-excursion
1.381        (uid66361 21-Jan-04): 				    ;; Prevent base64-decode-region
1.381        (uid66361 21-Jan-04): 				    ;; from removing newline characters.
1.381        (uid66361 21-Jan-04): 				    (skip-chars-backward "\n\t ")
1.381        (uid66361 21-Jan-04): 				    (point)))
1.377        (uid65627 30-Dec-03): 				 t)
1.377        (uid65627 30-Dec-03): 			     (error nil))
1.377        (uid65627 30-Dec-03): 			 ;; Change "base64" to "8bit", to reflect the
1.377        (uid65627 30-Dec-03): 			 ;; decoding we just did.
1.377        (uid65627 30-Dec-03): 			 (goto-char base64-header-field-end)
1.377        (uid65627 30-Dec-03): 			 (delete-region (point) (search-backward ":"))
1.377        (uid65627 30-Dec-03): 			 (insert ": 8bit")))))
1.39         (rms      09-Mar-93): 
1.1          (roland   13-May-91): 	       (save-excursion
1.1          (roland   13-May-91): 		 (save-restriction
1.1          (roland   13-May-91): 		   (narrow-to-region start (point))
1.1          (roland   13-May-91): 		   (goto-char (point-min))
1.445        (m061211  13-Jan-08): 		   (while (search-forward "\n\^_" nil t) ; single char
1.445        (m061211  13-Jan-08): 		     (replace-match "\n^_"))))	; 2 chars: "^" and "_"
1.386        (rms      04-Mar-04): 	       ;; This is for malformed messages that don't end in newline.
1.386        (rms      04-Mar-04): 	       ;; There shouldn't be any, but some users say occasionally
1.386        (rms      04-Mar-04): 	       ;; there are some.
1.386        (rms      04-Mar-04):  	       (or (bolp) (newline))
1.1          (roland   13-May-91): 	       (insert ?\^_)
1.265        (rms      12-May-98): 	       (setq last-coding-system-used nil)
1.212        (handa    26-Feb-97): 	       (or rmail-enable-mime
1.247        (handa    20-Feb-98): 		   (not rmail-enable-multibyte)
1.295        (rms      28-Jan-99): 		   (let ((mime-charset
1.295        (rms      28-Jan-99): 			  (if (and rmail-decode-mime-charset
1.295        (rms      28-Jan-99): 				   (save-excursion
1.295        (rms      28-Jan-99): 				     (goto-char start)
1.295        (rms      28-Jan-99): 				     (search-forward "\n\n" nil t)
1.295        (rms      28-Jan-99): 				     (let ((case-fold-search t))
1.295        (rms      28-Jan-99): 				       (re-search-backward
1.295        (rms      28-Jan-99): 					rmail-mime-charset-pattern
1.295        (rms      28-Jan-99): 					start t))))
1.426        (eliz     20-May-06): 			      (intern (downcase (match-string 1))))))
1.295        (rms      28-Jan-99): 		     (rmail-decode-region start (point) mime-charset)))
1.265        (rms      12-May-98): 	       (save-excursion
1.265        (rms      12-May-98): 		 (goto-char start)
1.265        (rms      12-May-98): 		 (forward-line 3)
1.265        (rms      12-May-98): 		 (insert "X-Coding-System: "
1.265        (rms      12-May-98): 			 (symbol-name last-coding-system-used)
1.265        (rms      12-May-98): 			 "\n"))
1.374        (eliz     16-Oct-03): 	       (narrow-to-region (point) (point-max))
1.374        (eliz     16-Oct-03): 	       (and (= 0 (% count 10))
1.375        (eliz     16-Oct-03): 		    (message "Converting to Babyl format...%d" count)))
1.1          (roland   13-May-91): 	      ;;
1.43         (rms      09-May-93): 	      ;; This kludge is because some versions of sendmail.el
1.43         (rms      09-May-93): 	      ;; insert an extra newline at the beginning that shouldn't
1.43         (rms      09-May-93): 	      ;; be there.  sendmail.el has been fixed, but old versions
1.43         (rms      09-May-93): 	      ;; may still be in use.  -- rms, 7 May 1993.
1.43         (rms      09-May-93): 	      ((eolp) (delete-char 1))
1.7          (mib      20-Aug-91): 	      (t (error "Cannot convert to babyl format")))))
1.427        (rms      08-Sep-06):     (setq buffer-undo-list nil)
1.1          (roland   13-May-91):     count))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; Delete the "From ..." line, creating various other headers with
1.1          (roland   13-May-91): ;; information from it if they don't already exist.  Now puts the
1.68         (rms      09-Oct-93): ;; original line into a mail-from: header line for debugging and for
1.68         (rms      09-Oct-93): ;; use by the rmail-output function.
1.1          (roland   13-May-91): (defun rmail-nuke-pinhead-header ()
1.1          (roland   13-May-91):   (save-excursion
1.1          (roland   13-May-91):     (save-restriction
1.1          (roland   13-May-91):       (let ((start (point))
1.1          (roland   13-May-91):   	    (end (progn
1.1          (roland   13-May-91): 		   (condition-case ()
1.1          (roland   13-May-91): 		       (search-forward "\n\n")
1.1          (roland   13-May-91): 		     (error
1.1          (roland   13-May-91): 		      (goto-char (point-max))
1.1          (roland   13-May-91): 		      (insert "\n\n")))
1.1          (roland   13-May-91): 		   (point)))
1.1          (roland   13-May-91): 	    has-from has-date)
1.1          (roland   13-May-91): 	(narrow-to-region start end)
1.1          (roland   13-May-91): 	(let ((case-fold-search t))
1.1          (roland   13-May-91): 	  (goto-char start)
1.1          (roland   13-May-91): 	  (setq has-from (search-forward "\nFrom:" nil t))
1.1          (roland   13-May-91): 	  (goto-char start)
1.1          (roland   13-May-91): 	  (setq has-date (and (search-forward "\nDate:" nil t) (point)))
1.1          (roland   13-May-91): 	  (goto-char start))
1.1          (roland   13-May-91): 	(let ((case-fold-search nil))
1.10         (jimb     19-Apr-92): 	  (if (re-search-forward (concat "^" rmail-unix-mail-delimiter) nil t)
1.1          (roland   13-May-91): 	      (replace-match
1.1          (roland   13-May-91): 		(concat
1.1          (roland   13-May-91): 		  "Mail-from: \\&"
1.1          (roland   13-May-91): 		  ;; Keep and reformat the date if we don't
1.1          (roland   13-May-91): 		  ;;  have a Date: field.
1.1          (roland   13-May-91): 		  (if has-date
1.1          (roland   13-May-91): 		      ""
1.24         (jimb     13-Sep-92): 		    (concat
1.188        (rms      28-Jun-96): 		     "Date: \\2, \\4 \\3 \\9 \\5 "
1.358        (pot      06-May-02): 
1.24         (jimb     13-Sep-92): 		     ;; The timezone could be matched by group 7 or group 10.
1.24         (jimb     13-Sep-92): 		     ;; If neither of them matched, assume EST, since only
1.24         (jimb     13-Sep-92): 		     ;; Easterners would be so sloppy.
1.24         (jimb     13-Sep-92): 		     ;; It's a shame the substitution can't use "\\10".
1.24         (jimb     13-Sep-92): 		     (cond
1.24         (jimb     13-Sep-92): 		      ((/= (match-beginning 7) (match-end 7)) "\\7")
1.24         (jimb     13-Sep-92): 		      ((/= (match-beginning 10) (match-end 10))
1.24         (jimb     13-Sep-92): 		       (buffer-substring (match-beginning 10)
1.24         (jimb     13-Sep-92): 					 (match-end 10)))
1.24         (jimb     13-Sep-92): 		      (t "EST"))
1.24         (jimb     13-Sep-92): 		     "\n"))
1.1          (roland   13-May-91): 		  ;; Keep and reformat the sender if we don't
1.1          (roland   13-May-91): 		  ;; have a From: field.
1.1          (roland   13-May-91): 		  (if has-from
1.1          (roland   13-May-91): 		      ""
1.60         (rms      29-Jul-93): 		    "From: \\1\n"))
1.60         (rms      29-Jul-93): 		t)))))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;; *** Rmail Message Formatting and Header Manipulation ***
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-reformat-message (beg end)
1.1          (roland   13-May-91):   (goto-char beg)
1.1          (roland   13-May-91):   (forward-line 1)
1.1          (roland   13-May-91):   (if (/= (following-char) ?0)
1.348        (pj       15-Jul-01):       (error "Bad format in RMAIL file"))
1.344        (rms      29-Jun-01):   (let ((inhibit-read-only t)
1.1          (roland   13-May-91): 	(delta (- (buffer-size) end)))
1.1          (roland   13-May-91):     (delete-char 1)
1.1          (roland   13-May-91):     (insert ?1)
1.1          (roland   13-May-91):     (forward-line 1)
1.60         (rms      29-Jul-93):     (let ((case-fold-search t))
1.68         (rms      09-Oct-93):       (while (looking-at "Summary-line:\\|Mail-From:")
1.68         (rms      09-Oct-93):  	(forward-line 1)))
1.1          (roland   13-May-91):     (if (looking-at "\\*\\*\\* EOOH \\*\\*\\*\n")
1.1          (roland   13-May-91): 	(delete-region (point)
1.1          (roland   13-May-91): 		       (progn (forward-line 1) (point))))
1.1          (roland   13-May-91):     (let ((str (buffer-substring (point)
1.1          (roland   13-May-91): 				 (save-excursion (search-forward "\n\n" end 'move)
1.1          (roland   13-May-91): 						 (point)))))
1.1          (roland   13-May-91):       (insert str "*** EOOH ***\n")
1.1          (roland   13-May-91):       (narrow-to-region (point) (- (buffer-size) delta)))
1.1          (roland   13-May-91):     (goto-char (point-min))
1.129        (rms      24-Sep-94):     (if rmail-message-filter (funcall rmail-message-filter))
1.150        (rms      14-Apr-95):     (if (or rmail-displayed-headers rmail-ignored-headers)
1.150        (rms      14-Apr-95): 	(rmail-clear-headers))))
1.1          (roland   13-May-91): 
1.128        (rms      23-Sep-94): (defun rmail-clear-headers (&optional ignored-headers)
1.150        (rms      14-Apr-95):   "Delete all header fields that Rmail should not show.
1.150        (rms      14-Apr-95): If the optional argument IGNORED-HEADERS is non-nil,
1.150        (rms      14-Apr-95): delete all header fields whose names match that regexp.
1.150        (rms      14-Apr-95): Otherwise, if `rmail-displayed-headers' is non-nil,
1.150        (rms      14-Apr-95): delete all header fields *except* those whose names match that regexp.
1.413        (rms      15-Aug-05): Otherwise, delete all header fields whose names match `rmail-ignored-headers'
1.413        (rms      15-Aug-05): unless they also match `rmail-nonignored-headers'."
1.253        (rms      16-Mar-98):   (when (search-forward "\n\n" nil t)
1.253        (rms      16-Mar-98):     (forward-char -1)
1.253        (rms      16-Mar-98):     (let ((case-fold-search t)
1.253        (rms      16-Mar-98): 	  (buffer-read-only nil))
1.253        (rms      16-Mar-98):       (if (and rmail-displayed-headers (null ignored-headers))
1.254        (rms      26-Mar-98): 	  (save-restriction
1.254        (rms      26-Mar-98): 	    (narrow-to-region (point-min) (point))
1.254        (rms      26-Mar-98): 	    (let (lim next)
1.254        (rms      26-Mar-98): 	      (goto-char (point-min))
1.254        (rms      26-Mar-98): 	      (while (and (not (eobp))
1.254        (rms      26-Mar-98): 			  (save-excursion
1.254        (rms      26-Mar-98): 			    (if (re-search-forward "\n[^ \t]" nil t)
1.254        (rms      26-Mar-98): 				(setq lim (match-beginning 0)
1.254        (rms      26-Mar-98): 				      next (1+ lim))
1.254        (rms      26-Mar-98): 			      (setq lim nil next (point-max)))))
1.254        (rms      26-Mar-98): 		(if (save-excursion
1.254        (rms      26-Mar-98): 		      (re-search-forward rmail-displayed-headers lim t))
1.254        (rms      26-Mar-98): 		  (goto-char next)
1.254        (rms      26-Mar-98): 		  (delete-region (point) next))))
1.254        (rms      26-Mar-98): 	    (goto-char (point-min)))
1.253        (rms      16-Mar-98): 	(or ignored-headers (setq ignored-headers rmail-ignored-headers))
1.253        (rms      16-Mar-98): 	(save-restriction
1.253        (rms      16-Mar-98): 	  (narrow-to-region (point-min) (point))
1.413        (rms      15-Aug-05): 	  (goto-char (point-min))
1.320        (gerd     07-Jul-00): 	  (while (and ignored-headers
1.413        (rms      15-Aug-05): 		      (re-search-forward ignored-headers nil t))
1.253        (rms      16-Mar-98): 	    (beginning-of-line)
1.448        (bastien1 10-Feb-08): 	    (if (and rmail-nonignored-headers
1.448        (bastien1 10-Feb-08): 		     (looking-at rmail-nonignored-headers))
1.413        (rms      15-Aug-05): 		(forward-line 1)
1.413        (rms      15-Aug-05): 	      (delete-region (point)
1.413        (rms      15-Aug-05): 			     (save-excursion
1.413        (rms      15-Aug-05): 			       (if (re-search-forward "\n[^ \t]" nil t)
1.413        (rms      15-Aug-05): 				   (1- (point))
1.413        (rms      15-Aug-05): 				 (point-max)))))))))))
1.1          (roland   13-May-91): 
1.204        (rms      28-Dec-96): (defun rmail-msg-is-pruned ()
1.1          (roland   13-May-91):   (rmail-maybe-set-message-counters)
1.204        (rms      28-Dec-96):   (save-restriction
1.271        (rms      27-May-98):     (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
1.204        (rms      28-Dec-96):     (save-excursion
1.271        (rms      27-May-98):       (goto-char (point-min))
1.271        (rms      27-May-98):       (forward-line 1)
1.204        (rms      28-Dec-96):       (= (following-char) ?1))))
1.204        (rms      28-Dec-96): 
1.343        (gerd     26-Jun-01): (defun rmail-msg-restore-non-pruned-header ()
1.344        (rms      29-Jun-01):   (let ((old-point (point))
1.344        (rms      29-Jun-01): 	new-point
1.344        (rms      29-Jun-01): 	new-start
1.344        (rms      29-Jun-01): 	(inhibit-read-only t))
1.344        (rms      29-Jun-01):     (save-excursion
1.344        (rms      29-Jun-01):       (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
1.343        (gerd     26-Jun-01):       (goto-char (point-min))
1.343        (gerd     26-Jun-01):       (forward-line 1)
1.343        (gerd     26-Jun-01):       ;; Change 1 to 0.
1.343        (gerd     26-Jun-01):       (delete-char 1)
1.343        (gerd     26-Jun-01):       (insert ?0)
1.343        (gerd     26-Jun-01):       ;; Insert new EOOH line at the proper place.
1.343        (gerd     26-Jun-01):       (forward-line 1)
1.343        (gerd     26-Jun-01):       (let ((case-fold-search t))
1.343        (gerd     26-Jun-01): 	(while (looking-at "Summary-Line:\\|Mail-From:")
1.343        (gerd     26-Jun-01): 	  (forward-line 1)))
1.343        (gerd     26-Jun-01):       (insert "*** EOOH ***\n")
1.343        (gerd     26-Jun-01):       (setq new-start (point))
1.343        (gerd     26-Jun-01):       ;; Delete the old reformatted header.
1.343        (gerd     26-Jun-01):       (forward-char -1)
1.343        (gerd     26-Jun-01):       (search-forward "\n*** EOOH ***\n")
1.343        (gerd     26-Jun-01):       (forward-line -1)
1.343        (gerd     26-Jun-01):       (let ((start (point)))
1.343        (gerd     26-Jun-01): 	(search-forward "\n\n")
1.344        (rms      29-Jun-01): 	(if (and (<= start old-point)
1.344        (rms      29-Jun-01): 		 (<= old-point (point)))
1.344        (rms      29-Jun-01): 	    (setq new-point new-start))
1.343        (gerd     26-Jun-01): 	(delete-region start (point)))
1.343        (gerd     26-Jun-01):       ;; Narrow to after the new EOOH line.
1.344        (rms      29-Jun-01):       (narrow-to-region new-start (point-max)))
1.344        (rms      29-Jun-01):     (if new-point
1.344        (rms      29-Jun-01): 	(goto-char new-point))))
1.343        (gerd     26-Jun-01): 
1.343        (gerd     26-Jun-01): (defun rmail-msg-prune-header ()
1.344        (rms      29-Jun-01):   (let ((new-point
1.344        (rms      29-Jun-01): 	 (= (point) (point-min))))
1.344        (rms      29-Jun-01):     (save-excursion
1.344        (rms      29-Jun-01):       (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
1.344        (rms      29-Jun-01):       (rmail-reformat-message (point-min) (point-max)))
1.344        (rms      29-Jun-01):     (if new-point
1.344        (rms      29-Jun-01): 	(goto-char (point-min)))))
1.343        (gerd     26-Jun-01): 
1.204        (rms      28-Dec-96): (defun rmail-toggle-header (&optional arg)
1.204        (rms      28-Dec-96):   "Show original message header if pruned header currently shown, or vice versa.
1.204        (rms      28-Dec-96): With argument ARG, show the message header pruned if ARG is greater than zero;
1.204        (rms      28-Dec-96): otherwise, show it in full."
1.204        (rms      28-Dec-96):   (interactive "P")
1.343        (gerd     26-Jun-01):   (let* ((pruned (with-current-buffer rmail-buffer
1.343        (gerd     26-Jun-01): 		   (rmail-msg-is-pruned)))
1.273        (kwzh     04-Jun-98): 	 (prune (if arg
1.273        (kwzh     04-Jun-98): 		    (> (prefix-numeric-value arg) 0)
1.273        (kwzh     04-Jun-98): 		  (not pruned))))
1.273        (kwzh     04-Jun-98):     (if (eq pruned prune)
1.273        (kwzh     04-Jun-98): 	t
1.343        (gerd     26-Jun-01):       (set-buffer rmail-buffer)
1.273        (kwzh     04-Jun-98):       (rmail-maybe-set-message-counters)
1.343        (gerd     26-Jun-01):       (if rmail-enable-mime
1.343        (gerd     26-Jun-01): 	  (let ((buffer-read-only nil))
1.343        (gerd     26-Jun-01): 	    (if pruned
1.343        (gerd     26-Jun-01): 		(rmail-msg-restore-non-pruned-header)
1.343        (gerd     26-Jun-01): 	      (rmail-msg-prune-header))
1.343        (gerd     26-Jun-01): 	    (funcall rmail-show-mime-function))
1.343        (gerd     26-Jun-01): 	(let* ((buffer-read-only nil)
1.343        (gerd     26-Jun-01): 	       (window (get-buffer-window (current-buffer)))
1.343        (gerd     26-Jun-01): 	       (at-point-min (= (point) (point-min)))
1.343        (gerd     26-Jun-01): 	       (all-headers-visible (= (window-start window) (point-min)))
1.343        (gerd     26-Jun-01): 	       (on-header
1.343        (gerd     26-Jun-01): 		(save-excursion
1.343        (gerd     26-Jun-01): 		  (and (not (search-backward "\n\n" nil t))
1.343        (gerd     26-Jun-01): 		       (progn
1.343        (gerd     26-Jun-01): 			 (end-of-line)
1.343        (gerd     26-Jun-01): 			 (re-search-backward "^[-A-Za-z0-9]+:" nil t))
1.343        (gerd     26-Jun-01): 		       (match-string 0))))
1.343        (gerd     26-Jun-01): 	       (old-screen-line
1.343        (gerd     26-Jun-01): 		(rmail-count-screen-lines (window-start window) (point))))
1.275        (rms      11-Jun-98): 	  (if pruned
1.343        (gerd     26-Jun-01): 	      (rmail-msg-restore-non-pruned-header)
1.343        (gerd     26-Jun-01): 	    (rmail-msg-prune-header))
1.343        (gerd     26-Jun-01): 	  (cond (at-point-min
1.343        (gerd     26-Jun-01): 		 (goto-char (point-min)))
1.343        (gerd     26-Jun-01): 		(on-header
1.343        (gerd     26-Jun-01): 		 (goto-char (point-min))
1.343        (gerd     26-Jun-01): 		 (search-forward "\n\n")
1.343        (gerd     26-Jun-01): 		 (or (re-search-backward
1.343        (gerd     26-Jun-01): 		      (concat "^" (regexp-quote on-header)) nil t)
1.343        (gerd     26-Jun-01): 		     (goto-char (point-min))))
1.343        (gerd     26-Jun-01): 		(t
1.343        (gerd     26-Jun-01): 		 (save-selected-window
1.343        (gerd     26-Jun-01): 		   (select-window window)
1.343        (gerd     26-Jun-01): 		   (recenter old-screen-line)
1.343        (gerd     26-Jun-01): 		   (if (and all-headers-visible
1.343        (gerd     26-Jun-01): 			    (not (= (window-start) (point-min))))
1.355        (rms      06-Feb-02): 		       (recenter (- (window-height) 2))))))))
1.273        (kwzh     04-Jun-98):       (rmail-highlight-headers))))
1.273        (kwzh     04-Jun-98): 
1.344        (rms      29-Jun-01): (defun rmail-narrow-to-non-pruned-header ()
1.344        (rms      29-Jun-01):   "Narrow to the whole (original) header of the current message."
1.344        (rms      29-Jun-01):   (let (start end)
1.344        (rms      29-Jun-01):     (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
1.344        (rms      29-Jun-01):     (goto-char (point-min))
1.344        (rms      29-Jun-01):     (forward-line 1)
1.344        (rms      29-Jun-01):     (if (= (following-char) ?1)
1.344        (rms      29-Jun-01): 	(progn
1.344        (rms      29-Jun-01): 	  (forward-line 1)
1.344        (rms      29-Jun-01): 	  (setq start (point))
1.344        (rms      29-Jun-01): 	  (search-forward "*** EOOH ***\n")
1.344        (rms      29-Jun-01): 	  (setq end (match-beginning 0)))
1.344        (rms      29-Jun-01):       (forward-line 2)
1.344        (rms      29-Jun-01):       (setq start (point))
1.344        (rms      29-Jun-01):       (search-forward "\n\n")
1.344        (rms      29-Jun-01):       (setq end (1- (point))))
1.344        (rms      29-Jun-01):     (narrow-to-region start end)
1.344        (rms      29-Jun-01):     (goto-char start)))
1.344        (rms      29-Jun-01): 
1.273        (kwzh     04-Jun-98): ;; Lifted from repos-count-screen-lines.
1.273        (kwzh     04-Jun-98): ;; Return number of screen lines between START and END.
1.273        (kwzh     04-Jun-98): (defun rmail-count-screen-lines (start end)
1.272        (kwzh     02-Jun-98):   (save-excursion
1.273        (kwzh     04-Jun-98):     (save-restriction
1.273        (kwzh     04-Jun-98):       (narrow-to-region start end)
1.273        (kwzh     04-Jun-98):       (goto-char (point-min))
1.273        (kwzh     04-Jun-98):       (vertical-motion (- (point-max) (point-min))))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;; *** Rmail Attributes and Keywords ***
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; Make a string describing current message's attributes and keywords
1.1          (roland   13-May-91): ;; and set it up as the name of a minor mode
1.1          (roland   13-May-91): ;; so it will appear in the mode line.
1.1          (roland   13-May-91): (defun rmail-display-labels ()
1.1          (roland   13-May-91):   (let ((blurb "") (beg (point-min-marker)) (end (point-max-marker)))
1.1          (roland   13-May-91):     (save-excursion
1.1          (roland   13-May-91):       (unwind-protect
1.1          (roland   13-May-91): 	  (progn
1.1          (roland   13-May-91): 	    (widen)
1.1          (roland   13-May-91): 	    (goto-char (rmail-msgbeg rmail-current-message))
1.1          (roland   13-May-91): 	    (forward-line 1)
1.1          (roland   13-May-91): 	    (if (looking-at "[01],")
1.1          (roland   13-May-91): 		(progn
1.1          (roland   13-May-91): 		  (narrow-to-region (point) (progn (end-of-line) (point)))
1.1          (roland   13-May-91): 		  ;; Truly valid BABYL format requires a space before each
1.1          (roland   13-May-91): 		  ;; attribute or keyword name.  Put them in if missing.
1.1          (roland   13-May-91): 		  (let (buffer-read-only)
1.1          (roland   13-May-91): 		    (goto-char (point-min))
1.1          (roland   13-May-91): 		    (while (search-forward "," nil t)
1.1          (roland   13-May-91): 		      (or (looking-at "[ ,]") (eobp)
1.1          (roland   13-May-91): 			  (insert " "))))
1.1          (roland   13-May-91): 		  (goto-char (point-max))
1.1          (roland   13-May-91): 		  (if (search-backward ",," nil 'move)
1.1          (roland   13-May-91): 		      (progn
1.1          (roland   13-May-91): 			(if (> (point) (1+ (point-min)))
1.1          (roland   13-May-91): 			    (setq blurb (buffer-substring (+ 1 (point-min)) (point))))
1.1          (roland   13-May-91): 			(if (> (- (point-max) (point)) 2)
1.1          (roland   13-May-91): 			    (setq blurb
1.1          (roland   13-May-91): 				  (concat blurb
1.1          (roland   13-May-91): 					  ";"
1.1          (roland   13-May-91): 					  (buffer-substring (+ (point) 3)
1.1          (roland   13-May-91): 							    (1- (point-max)))))))))))
1.1          (roland   13-May-91): 	;; Note: we don't use save-restriction because that does not work right
1.1          (roland   13-May-91): 	;; if changes are made outside the saved restriction
1.1          (roland   13-May-91): 	;; before that restriction is restored.
1.1          (roland   13-May-91): 	(narrow-to-region beg end)
1.1          (roland   13-May-91): 	(set-marker beg nil)
1.1          (roland   13-May-91): 	(set-marker end nil)))
1.1          (roland   13-May-91):     (while (string-match " +," blurb)
1.1          (roland   13-May-91):       (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
1.1          (roland   13-May-91): 			  (substring blurb (match-end 0)))))
1.1          (roland   13-May-91):     (while (string-match ", +" blurb)
1.1          (roland   13-May-91):       (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
1.1          (roland   13-May-91): 			  (substring blurb (match-end 0)))))
1.1          (roland   13-May-91):     (setq mode-line-process
1.150        (rms      14-Apr-95): 	  (format " %d/%d%s"
1.339        (gerd     08-May-01): 		  rmail-current-message rmail-total-messages blurb))
1.339        (gerd     08-May-01):     ;; If rmail-enable-mime is non-nil, we may have to update
1.339        (gerd     08-May-01):     ;; `mode-line-process' of rmail-view-buffer too.
1.339        (gerd     08-May-01):     (if (and rmail-enable-mime
1.339        (gerd     08-May-01): 	     (not (eq (current-buffer) rmail-view-buffer))
1.339        (gerd     08-May-01): 	     (buffer-live-p rmail-view-buffer))
1.339        (gerd     08-May-01): 	(let ((mlp mode-line-process))
1.339        (gerd     08-May-01): 	  (with-current-buffer rmail-view-buffer
1.339        (gerd     08-May-01): 	    (setq mode-line-process mlp))))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; Turn an attribute of a message on or off according to STATE.
1.1          (roland   13-May-91): ;; ATTR is the name of the attribute, as a string.
1.1          (roland   13-May-91): ;; MSGNUM is message number to change; nil means current message.
1.1          (roland   13-May-91): (defun rmail-set-attribute (attr state &optional msgnum)
1.339        (gerd     08-May-01):   (set-buffer rmail-buffer)
1.1          (roland   13-May-91):   (let ((omax (point-max-marker))
1.1          (roland   13-May-91): 	(omin (point-min-marker))
1.1          (roland   13-May-91): 	(buffer-read-only nil))
1.1          (roland   13-May-91):     (or msgnum (setq msgnum rmail-current-message))
1.71         (rms      16-Nov-93):     (if (> msgnum 0)
1.71         (rms      16-Nov-93): 	(unwind-protect
1.71         (rms      16-Nov-93): 	    (save-excursion
1.71         (rms      16-Nov-93): 	      (widen)
1.71         (rms      16-Nov-93): 	      (goto-char (+ 3 (rmail-msgbeg msgnum)))
1.71         (rms      16-Nov-93): 	      (let ((curstate
1.71         (rms      16-Nov-93): 		     (not
1.71         (rms      16-Nov-93): 		      (null (search-backward (concat ", " attr ",")
1.71         (rms      16-Nov-93): 					     (prog1 (point) (end-of-line)) t)))))
1.71         (rms      16-Nov-93): 		(or (eq curstate (not (not state)))
1.71         (rms      16-Nov-93): 		    (if curstate
1.71         (rms      16-Nov-93): 			(delete-region (point) (1- (match-end 0)))
1.71         (rms      16-Nov-93): 		      (beginning-of-line)
1.71         (rms      16-Nov-93): 		      (forward-char 2)
1.71         (rms      16-Nov-93): 		      (insert " " attr ","))))
1.71         (rms      16-Nov-93): 	      (if (string= attr "deleted")
1.71         (rms      16-Nov-93): 		  (rmail-set-message-deleted-p msgnum state)))
1.71         (rms      16-Nov-93): 	  ;; Note: we don't use save-restriction because that does not work right
1.71         (rms      16-Nov-93): 	  ;; if changes are made outside the saved restriction
1.71         (rms      16-Nov-93): 	  ;; before that restriction is restored.
1.71         (rms      16-Nov-93): 	  (narrow-to-region omin omax)
1.71         (rms      16-Nov-93): 	  (set-marker omin nil)
1.71         (rms      16-Nov-93): 	  (set-marker omax nil)
1.71         (rms      16-Nov-93): 	  (if (= msgnum rmail-current-message)
1.71         (rms      16-Nov-93): 	      (rmail-display-labels))))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; Return t if the attributes/keywords line of msg number MSG
1.1          (roland   13-May-91): ;; contains a match for the regexp LABELS.
1.1          (roland   13-May-91): (defun rmail-message-labels-p (msg labels)
1.1          (roland   13-May-91):   (save-excursion
1.1          (roland   13-May-91):     (save-restriction
1.1          (roland   13-May-91):       (widen)
1.1          (roland   13-May-91):       (goto-char (rmail-msgbeg msg))
1.1          (roland   13-May-91):       (forward-char 3)
1.1          (roland   13-May-91):       (re-search-backward labels (prog1 (point) (end-of-line)) t))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;; *** Rmail Message Selection And Support ***
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-msgend (n)
1.1          (roland   13-May-91):   (marker-position (aref rmail-message-vector (1+ n))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-msgbeg (n)
1.1          (roland   13-May-91):   (marker-position (aref rmail-message-vector n)))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-widen-to-current-msgbeg (function)
1.1          (roland   13-May-91):   "Call FUNCTION with point at start of internal data of current message.
1.1          (roland   13-May-91): Assumes that bounds were previously narrowed to display the message in Rmail.
1.1          (roland   13-May-91): The bounds are widened enough to move point where desired, then narrowed
1.1          (roland   13-May-91): again afterward.
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): FUNCTION may not change the visible text of the message, but it may
1.1          (roland   13-May-91): change the invisible header text."
1.1          (roland   13-May-91):   (save-excursion
1.318        (gerd     30-May-00):     (unwind-protect
1.318        (gerd     30-May-00): 	(progn
1.318        (gerd     30-May-00): 	  (narrow-to-region (rmail-msgbeg rmail-current-message)
1.318        (gerd     30-May-00): 			    (point-max))
1.318        (gerd     30-May-00): 	  (goto-char (point-min))
1.318        (gerd     30-May-00): 	  (funcall function))
1.1          (roland   13-May-91): 	;; Note: we don't use save-restriction because that does not work right
1.1          (roland   13-May-91): 	;; if changes are made outside the saved restriction
1.1          (roland   13-May-91): 	;; before that restriction is restored.
1.318        (gerd     30-May-00):       (narrow-to-region (rmail-msgbeg rmail-current-message)
1.318        (gerd     30-May-00): 			(rmail-msgend rmail-current-message)))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-forget-messages ()
1.1          (roland   13-May-91):   (unwind-protect
1.1          (roland   13-May-91):       (if (vectorp rmail-message-vector)
1.1          (roland   13-May-91): 	  (let* ((i 0)
1.1          (roland   13-May-91): 		 (v rmail-message-vector)
1.1          (roland   13-May-91): 		 (n (length v)))
1.1          (roland   13-May-91): 	    (while (< i n)
1.1          (roland   13-May-91): 	      (move-marker (aref v i)  nil)
1.1          (roland   13-May-91): 	      (setq i (1+ i)))))
1.1          (roland   13-May-91):     (setq rmail-message-vector nil)
1.218        (rms      02-May-97):     (setq rmail-msgref-vector nil)
1.1          (roland   13-May-91):     (setq rmail-deleted-vector nil)))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-maybe-set-message-counters ()
1.1          (roland   13-May-91):   (if (not (and rmail-deleted-vector
1.1          (roland   13-May-91): 		rmail-message-vector
1.1          (roland   13-May-91): 		rmail-current-message
1.1          (roland   13-May-91): 		rmail-total-messages))
1.1          (roland   13-May-91):       (rmail-set-message-counters)))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-count-new-messages (&optional nomsg)
1.1          (roland   13-May-91):   (let* ((case-fold-search nil)
1.1          (roland   13-May-91): 	 (total-messages 0)
1.1          (roland   13-May-91): 	 (messages-head nil)
1.1          (roland   13-May-91): 	 (deleted-head nil))
1.1          (roland   13-May-91):     (or nomsg (message "Counting new messages..."))
1.1          (roland   13-May-91):     (goto-char (point-max))
1.1          (roland   13-May-91):     ;; Put at the end of messages-head
1.1          (roland   13-May-91):     ;; the entry for message N+1, which marks
1.1          (roland   13-May-91):     ;; the end of message N.  (N = number of messages).
1.1          (roland   13-May-91):     (search-backward "\n\^_")
1.1          (roland   13-May-91):     (forward-char 1)
1.1          (roland   13-May-91):     (setq messages-head (list (point-marker)))
1.1          (roland   13-May-91):     (rmail-set-message-counters-counter (point-min))
1.1          (roland   13-May-91):     (setq rmail-current-message (1+ rmail-total-messages))
1.1          (roland   13-May-91):     (setq rmail-total-messages
1.1          (roland   13-May-91): 	  (+ rmail-total-messages total-messages))
1.1          (roland   13-May-91):     (setq rmail-message-vector
1.1          (roland   13-May-91): 	  (vconcat rmail-message-vector (cdr messages-head)))
1.1          (roland   13-May-91):     (aset rmail-message-vector
1.1          (roland   13-May-91): 	  rmail-current-message (car messages-head))
1.1          (roland   13-May-91):     (setq rmail-deleted-vector
1.1          (roland   13-May-91): 	  (concat rmail-deleted-vector deleted-head))
1.1          (roland   13-May-91):     (setq rmail-summary-vector
1.1          (roland   13-May-91): 	  (vconcat rmail-summary-vector (make-vector total-messages nil)))
1.218        (rms      02-May-97):     (setq rmail-msgref-vector
1.218        (rms      02-May-97): 	  (vconcat rmail-msgref-vector (make-vector total-messages nil)))
1.218        (rms      02-May-97):     ;; Fill in the new elements of rmail-msgref-vector.
1.220        (rms      04-May-97):     (let ((i (1+ (- rmail-total-messages total-messages))))
1.218        (rms      02-May-97):       (while (<= i rmail-total-messages)
1.218        (rms      02-May-97): 	(aset rmail-msgref-vector i (list i))
1.218        (rms      02-May-97): 	(setq i (1+ i))))
1.1          (roland   13-May-91):     (goto-char (point-min))
1.1          (roland   13-May-91):     (or nomsg (message "Counting new messages...done (%d)" total-messages))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-set-message-counters ()
1.1          (roland   13-May-91):   (rmail-forget-messages)
1.1          (roland   13-May-91):   (save-excursion
1.1          (roland   13-May-91):     (save-restriction
1.1          (roland   13-May-91):       (widen)
1.1          (roland   13-May-91):       (let* ((point-save (point))
1.1          (roland   13-May-91): 	     (total-messages 0)
1.1          (roland   13-May-91): 	     (messages-after-point)
1.1          (roland   13-May-91): 	     (case-fold-search nil)
1.1          (roland   13-May-91): 	     (messages-head nil)
1.1          (roland   13-May-91): 	     (deleted-head nil))
1.1          (roland   13-May-91): 	(message "Counting messages...")
1.1          (roland   13-May-91): 	(goto-char (point-max))
1.1          (roland   13-May-91): 	;; Put at the end of messages-head
1.1          (roland   13-May-91): 	;; the entry for message N+1, which marks
1.1          (roland   13-May-91): 	;; the end of message N.  (N = number of messages).
1.79         (rms      14-Jan-94): 	(search-backward "\n\^_" nil t)
1.79         (rms      14-Jan-94): 	(if (/= (point) (point-max)) (forward-char 1))
1.1          (roland   13-May-91): 	(setq messages-head (list (point-marker)))
1.1          (roland   13-May-91): 	(rmail-set-message-counters-counter (min (point) point-save))
1.1          (roland   13-May-91): 	(setq messages-after-point total-messages)
1.1          (roland   13-May-91): 	(rmail-set-message-counters-counter)
1.1          (roland   13-May-91): 	(setq rmail-total-messages total-messages)
1.1          (roland   13-May-91): 	(setq rmail-current-message
1.1          (roland   13-May-91): 	      (min total-messages
1.1          (roland   13-May-91): 		   (max 1 (- total-messages messages-after-point))))
1.1          (roland   13-May-91): 	(setq rmail-message-vector
1.1          (roland   13-May-91): 	      (apply 'vector (cons (point-min-marker) messages-head))
1.324        (gerd     30-Nov-00): 	      rmail-deleted-vector (concat "0" deleted-head)
1.218        (rms      02-May-97): 	      rmail-summary-vector (make-vector rmail-total-messages nil)
1.218        (rms      02-May-97): 	      rmail-msgref-vector (make-vector (1+ rmail-total-messages) nil))
1.218        (rms      02-May-97): 	(let ((i 0))
1.218        (rms      02-May-97): 	  (while (<= i rmail-total-messages)
1.218        (rms      02-May-97): 	    (aset rmail-msgref-vector i (list i))
1.218        (rms      02-May-97): 	    (setq i (1+ i))))
1.1          (roland   13-May-91): 	(message "Counting messages...done")))))
1.358        (pot      06-May-02): 
1.1          (roland   13-May-91): (defun rmail-set-message-counters-counter (&optional stop)
1.292        (andrewi  22-Nov-98):   (let ((start (point))
1.292        (andrewi  22-Nov-98): 	next)
1.292        (andrewi  22-Nov-98):     (while (search-backward "\n\^_\^L" stop t)
1.292        (andrewi  22-Nov-98):       ;; Detect messages that have been added with DOS line endings and
1.292        (andrewi  22-Nov-98):       ;; convert the line endings for such messages.
1.292        (andrewi  22-Nov-98):       (setq next (point))
1.292        (andrewi  22-Nov-98):       (if (looking-at "\n\^_\^L\r\n")
1.292        (andrewi  22-Nov-98): 	  (let ((buffer-read-only nil)
1.292        (andrewi  22-Nov-98): 		(buffer-undo t))
1.292        (andrewi  22-Nov-98): 	    (message "Counting messages...(converting line endings)")
1.292        (andrewi  22-Nov-98): 	    (save-excursion
1.292        (andrewi  22-Nov-98): 	      (goto-char start)
1.292        (andrewi  22-Nov-98): 	      (while (search-backward "\r\n" next t)
1.292        (andrewi  22-Nov-98): 		(delete-char 1)))))
1.292        (andrewi  22-Nov-98):       (setq start next)
1.292        (andrewi  22-Nov-98):       (forward-char 1)
1.292        (andrewi  22-Nov-98):       (setq messages-head (cons (point-marker) messages-head))
1.292        (andrewi  22-Nov-98):       (save-excursion
1.292        (andrewi  22-Nov-98): 	(setq deleted-head
1.292        (andrewi  22-Nov-98): 	      (cons (if (search-backward ", deleted,"
1.292        (andrewi  22-Nov-98): 					 (prog1 (point)
1.292        (andrewi  22-Nov-98): 					   (forward-line 2))
1.292        (andrewi  22-Nov-98): 					 t)
1.292        (andrewi  22-Nov-98): 			?D ?\ )
1.292        (andrewi  22-Nov-98): 		    deleted-head)))
1.292        (andrewi  22-Nov-98):       (if (zerop (% (setq total-messages (1+ total-messages)) 20))
1.292        (andrewi  22-Nov-98): 	  (message "Counting messages...%d" total-messages)))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-beginning-of-message ()
1.1          (roland   13-May-91):   "Show current message starting from the beginning."
1.1          (roland   13-May-91):   (interactive)
1.410        (eliz     12-Aug-05):   (let ((rmail-show-message-hook
1.410        (eliz     12-Aug-05): 	 (list (function (lambda ()
1.410        (eliz     12-Aug-05): 			   (goto-char (point-min)))))))
1.410        (eliz     12-Aug-05):     (rmail-show-message rmail-current-message)))
1.410        (eliz     12-Aug-05): 
1.410        (eliz     12-Aug-05): (defun rmail-end-of-message ()
1.410        (eliz     12-Aug-05):   "Show bottom of current message."
1.410        (eliz     12-Aug-05):   (interactive)
1.410        (eliz     12-Aug-05):   (let ((rmail-show-message-hook
1.410        (eliz     12-Aug-05): 	 (list (function (lambda ()
1.410        (eliz     12-Aug-05): 			   (goto-char (point-max))
1.410        (eliz     12-Aug-05): 			   (recenter (1- (window-height))))))))
1.410        (eliz     12-Aug-05):     (rmail-show-message rmail-current-message)))
1.1          (roland   13-May-91): 
1.397        (rms      18-Mar-05): (defun rmail-unknown-mail-followup-to ()
1.397        (rms      18-Mar-05):   "Handle a \"Mail-Followup-To\" header field with an unknown mailing list.
1.397        (rms      18-Mar-05): Ask the user whether to add that list name to `mail-mailing-lists'."
1.397        (rms      18-Mar-05):    (save-restriction
1.397        (rms      18-Mar-05):      (rmail-narrow-to-non-pruned-header)
1.397        (rms      18-Mar-05):      (let ((mail-followup-to (mail-fetch-field "mail-followup-to" nil t)))
1.397        (rms      18-Mar-05):        (when mail-followup-to
1.397        (rms      18-Mar-05): 	 (let ((addresses
1.407        (ttn      06-Aug-05): 		(split-string
1.397        (rms      18-Mar-05): 		 (mail-strip-quoted-names mail-followup-to)
1.397        (rms      18-Mar-05): 		 ",[[:space:]]+" t)))
1.397        (rms      18-Mar-05): 	   (dolist (addr addresses)
1.397        (rms      18-Mar-05): 	     (when (and (not (member addr mail-mailing-lists))
1.397        (rms      18-Mar-05): 			(not
1.397        (rms      18-Mar-05): 			 ;; taken from rmailsum.el
1.397        (rms      18-Mar-05): 			 (string-match
1.397        (rms      18-Mar-05): 			  (or rmail-user-mail-address-regexp
1.397        (rms      18-Mar-05): 			      (concat "^\\("
1.397        (rms      18-Mar-05): 				      (regexp-quote (user-login-name))
1.397        (rms      18-Mar-05): 				      "\\($\\|@\\)\\|"
1.397        (rms      18-Mar-05): 				      (regexp-quote
1.397        (rms      18-Mar-05): 				       (or user-mail-address
1.397        (rms      18-Mar-05): 					   (concat (user-login-name) "@"
1.397        (rms      18-Mar-05): 						   (or mail-host-address
1.397        (rms      18-Mar-05): 						       (system-name)))))
1.397        (rms      18-Mar-05): 				      "\\>\\)"))
1.397        (rms      18-Mar-05): 			  addr))
1.397        (rms      18-Mar-05): 			(y-or-n-p
1.397        (rms      18-Mar-05): 			 (format "Add `%s' to `mail-mailing-lists'? "
1.397        (rms      18-Mar-05): 				 addr)))
1.397        (rms      18-Mar-05): 	       (customize-save-variable 'mail-mailing-lists
1.397        (rms      18-Mar-05): 					(cons addr mail-mailing-lists)))))))))
1.397        (rms      18-Mar-05): 
1.134        (rms      11-Oct-94): (defun rmail-show-message (&optional n no-summary)
1.39         (rms      09-Mar-93):   "Show message number N (prefix argument), counting from start of file.
1.39         (rms      09-Mar-93): If summary buffer is currently displayed, update current message there also."
1.1          (roland   13-May-91):   (interactive "p")
1.212        (handa    26-Feb-97):   (or (eq major-mode 'rmail-mode)
1.212        (handa    26-Feb-97):       (switch-to-buffer rmail-buffer))
1.1          (roland   13-May-91):   (rmail-maybe-set-message-counters)
1.1          (roland   13-May-91):   (widen)
1.1          (roland   13-May-91):   (if (zerop rmail-total-messages)
1.1          (roland   13-May-91):       (progn (narrow-to-region (point-min) (1- (point-max)))
1.1          (roland   13-May-91): 	     (goto-char (point-min))
1.1          (roland   13-May-91): 	     (setq mode-line-process nil))
1.265        (rms      12-May-98):     (let (blurb coding-system)
1.1          (roland   13-May-91):       (if (not n)
1.1          (roland   13-May-91): 	  (setq n rmail-current-message)
1.1          (roland   13-May-91): 	(cond ((<= n 0)
1.1          (roland   13-May-91): 	       (setq n 1
1.1          (roland   13-May-91): 		     rmail-current-message 1
1.1          (roland   13-May-91): 		     blurb "No previous message"))
1.1          (roland   13-May-91): 	      ((> n rmail-total-messages)
1.1          (roland   13-May-91): 	       (setq n rmail-total-messages
1.1          (roland   13-May-91): 		     rmail-current-message rmail-total-messages
1.1          (roland   13-May-91): 		     blurb "No following message"))
1.1          (roland   13-May-91): 	      (t
1.1          (roland   13-May-91): 	       (setq rmail-current-message n))))
1.198        (rms      19-Sep-96):       (let ((beg (rmail-msgbeg n)))
1.1          (roland   13-May-91): 	(goto-char beg)
1.1          (roland   13-May-91): 	(forward-line 1)
1.265        (rms      12-May-98): 	(save-excursion
1.265        (rms      12-May-98): 	  (let ((end (rmail-msgend n)))
1.265        (rms      12-May-98): 	    (save-restriction
1.265        (rms      12-May-98): 	      (if (prog1 (= (following-char) ?0)
1.265        (rms      12-May-98): 		    (forward-line 2)
1.300        (rms      16-Feb-99): 		    ;; If there's a Summary-line in the (otherwise empty)
1.300        (rms      16-Feb-99): 		    ;; header, we didn't yet get past the EOOH line.
1.300        (rms      16-Feb-99): 		    (if (looking-at "^\\*\\*\\* EOOH \\*\\*\\*\n")
1.300        (rms      16-Feb-99): 			(forward-line 1))
1.265        (rms      12-May-98): 		    (narrow-to-region (point) end))
1.265        (rms      12-May-98): 		  (rfc822-goto-eoh)
1.265        (rms      12-May-98): 		(search-forward "\n*** EOOH ***\n" end t))
1.265        (rms      12-May-98): 	      (narrow-to-region beg (point))
1.265        (rms      12-May-98): 	      (goto-char (point-min))
1.265        (rms      12-May-98): 	      (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
1.265        (rms      12-May-98): 		  (let ((coding-system (intern (match-string 1))))
1.359        (rms      10-May-02): 		    (condition-case nil
1.359        (rms      10-May-02): 			(progn
1.359        (rms      10-May-02): 			  (check-coding-system coding-system)
1.359        (rms      10-May-02): 			  (setq buffer-file-coding-system coding-system))
1.368        (jpw      06-Jan-03): 		      (error
1.359        (rms      10-May-02): 		       (setq buffer-file-coding-system nil))))
1.265        (rms      12-May-98): 		(setq buffer-file-coding-system nil)))))
1.198        (rms      19-Sep-96): 	;; Clear the "unseen" attribute when we show a message.
1.198        (rms      19-Sep-96): 	(rmail-set-attribute "unseen" nil)
1.198        (rms      19-Sep-96): 	(let ((end (rmail-msgend n)))
1.265        (rms      12-May-98): 	  ;; Reformat the header, or else find the reformatted header.
1.198        (rms      19-Sep-96): 	  (if (= (following-char) ?0)
1.1          (roland   13-May-91): 	      (rmail-reformat-message beg end)
1.198        (rms      19-Sep-96): 	    (search-forward "\n*** EOOH ***\n" end t)
1.198        (rms      19-Sep-96): 	    (narrow-to-region (point) end)))
1.1          (roland   13-May-91): 	(goto-char (point-min))
1.347        (gerd     10-Jul-01): 	(walk-windows
1.347        (gerd     10-Jul-01): 	 (function (lambda (window)
1.347        (gerd     10-Jul-01): 		     (if (eq (window-buffer window) (current-buffer))
1.347        (gerd     10-Jul-01): 			 (set-window-point window (point)))))
1.347        (gerd     10-Jul-01): 	 nil t)
1.1          (roland   13-May-91): 	(rmail-display-labels)
1.212        (handa    26-Feb-97): 	(if (eq rmail-enable-mime t)
1.212        (handa    26-Feb-97): 	    (funcall rmail-show-mime-function)
1.397        (rms      18-Mar-05): 	  (setq rmail-view-buffer rmail-buffer))
1.397        (rms      18-Mar-05): 	(when mail-mailing-lists
1.397        (rms      18-Mar-05): 	  (rmail-unknown-mail-followup-to))
1.100        (kwzh     24-Apr-94): 	(rmail-highlight-headers)
1.105        (rms      26-May-94): 	(if transient-mark-mode (deactivate-mark))
1.1          (roland   13-May-91): 	(run-hooks 'rmail-show-message-hook)
1.39         (rms      09-Mar-93): 	;; If there is a summary buffer, try to move to this message
1.39         (rms      09-Mar-93): 	;; in that buffer.  But don't complain if this message
1.39         (rms      09-Mar-93): 	;; is not mentioned in the summary.
1.134        (rms      11-Oct-94): 	;; Don't do this at all if we were called on behalf
1.134        (rms      11-Oct-94): 	;; of cursor motion in the summary buffer.
1.134        (rms      11-Oct-94): 	(and (rmail-summary-exists) (not no-summary)
1.134        (rms      11-Oct-94): 	     (let ((curr-msg rmail-current-message))
1.134        (rms      11-Oct-94): 	       (rmail-select-summary
1.134        (rms      11-Oct-94): 		(rmail-summary-goto-msg curr-msg t t))))
1.339        (gerd     08-May-01): 	(with-current-buffer rmail-buffer
1.339        (gerd     08-May-01): 	  (rmail-auto-file))
1.1          (roland   13-May-91): 	(if blurb
1.1          (roland   13-May-91): 	    (message blurb))))))
1.1          (roland   13-May-91): 
1.430        (eliz     04-Nov-06): (defun rmail-redecode-body (coding &optional raw)
1.326        (eliz     22-Jan-01):   "Decode the body of the current message using coding system CODING.
1.326        (eliz     22-Jan-01): This is useful with mail messages that have malformed or missing
1.326        (eliz     22-Jan-01): charset= headers.
1.326        (eliz     22-Jan-01): 
1.326        (eliz     22-Jan-01): This function assumes that the current message is already decoded
1.326        (eliz     22-Jan-01): and displayed in the RMAIL buffer, but the coding system used to
1.326        (eliz     22-Jan-01): decode it was incorrect.  It then encodes the message back to its
1.327        (eliz     25-Jan-01): original form, and decodes it again, using the coding system CODING.
1.326        (eliz     22-Jan-01): 
1.430        (eliz     04-Nov-06): Optional argument RAW, if non-nil, means don't encode the message
1.430        (eliz     04-Nov-06): before decoding it with the new CODING.  This is useful if the current
1.430        (eliz     04-Nov-06): message text was produced by some function which invokes `insert',
1.430        (eliz     04-Nov-06): since `insert' leaves unibyte character codes 128 through 255 unconverted
1.430        (eliz     04-Nov-06): to multibyte.  One example of such a situation is when the text was
1.430        (eliz     04-Nov-06): produced by `base64-decode-region'.
1.430        (eliz     04-Nov-06): 
1.430        (eliz     04-Nov-06): Interactively, invoke the function with a prefix argument to set RAW
1.430        (eliz     04-Nov-06): non-nil.
1.430        (eliz     04-Nov-06): 
1.326        (eliz     22-Jan-01): Note that if Emacs erroneously auto-detected one of the iso-2022
1.326        (eliz     22-Jan-01): encodings in the message, this function might fail because the escape
1.326        (eliz     22-Jan-01): sequences that switch between character sets and also single-shift and
1.326        (eliz     22-Jan-01): locking-shift codes are impossible to recover.  This function is meant
1.326        (eliz     22-Jan-01): to be used to fix messages encoded with 8-bit encodings, such as
1.326        (eliz     22-Jan-01): iso-8859, koi8-r, etc."
1.326        (eliz     22-Jan-01):   (interactive "zCoding system for re-decoding this message: ")
1.326        (eliz     22-Jan-01):   (when (not rmail-enable-mime)
1.326        (eliz     22-Jan-01):     (or (eq major-mode 'rmail-mode)
1.326        (eliz     22-Jan-01): 	(switch-to-buffer rmail-buffer))
1.326        (eliz     22-Jan-01):     (save-excursion
1.430        (eliz     04-Nov-06):       (let ((pruned (rmail-msg-is-pruned))
1.430        (eliz     04-Nov-06): 	    (raw (or raw current-prefix-arg)))
1.353        (eliz     02-Feb-02): 	(unwind-protect
1.353        (eliz     02-Feb-02): 	    (let ((msgbeg (rmail-msgbeg rmail-current-message))
1.353        (eliz     02-Feb-02): 		  (msgend (rmail-msgend rmail-current-message))
1.353        (eliz     02-Feb-02): 		  x-coding-header)
1.353        (eliz     02-Feb-02): 	      ;; We need the message headers pruned (we later restore
1.353        (eliz     02-Feb-02): 	      ;; the pruned stat to what it was, see the end of
1.353        (eliz     02-Feb-02): 	      ;; unwind-protect form).
1.353        (eliz     02-Feb-02): 	      (or pruned
1.353        (eliz     02-Feb-02): 		  (rmail-toggle-header 1))
1.353        (eliz     02-Feb-02): 	      (narrow-to-region msgbeg msgend)
1.353        (eliz     02-Feb-02): 	      (goto-char (point-min))
1.353        (eliz     02-Feb-02): 	      (when (search-forward "\n*** EOOH ***\n" (point-max) t)
1.353        (eliz     02-Feb-02): 		(narrow-to-region msgbeg (point)))
1.353        (eliz     02-Feb-02): 	      (goto-char (point-min))
1.353        (eliz     02-Feb-02): 	      (if (re-search-forward "^X-Coding-System: *\\(.*\\)$" nil t)
1.353        (eliz     02-Feb-02): 		  (let ((old-coding (intern (match-string 1)))
1.353        (eliz     02-Feb-02): 			(buffer-read-only nil))
1.353        (eliz     02-Feb-02): 		    (check-coding-system old-coding)
1.353        (eliz     02-Feb-02): 		    ;; Make sure the new coding system uses the same EOL
1.353        (eliz     02-Feb-02): 		    ;; conversion, to prevent ^M characters from popping
1.353        (eliz     02-Feb-02): 		    ;; up all over the place.
1.353        (eliz     02-Feb-02): 		    (setq coding
1.353        (eliz     02-Feb-02): 			  (coding-system-change-eol-conversion
1.353        (eliz     02-Feb-02): 			   coding
1.353        (eliz     02-Feb-02): 			   (coding-system-eol-type old-coding)))
1.428        (eliz     07-Oct-06): 		    ;; If old-coding is `undecided', encode-coding-region
1.428        (eliz     07-Oct-06): 		    ;; will not encode the text at all.  Find a proper
1.428        (eliz     07-Oct-06): 		    ;; non-trivial encoding to use.
1.428        (eliz     07-Oct-06): 		    (if (memq (coding-system-base old-coding) '(nil undecided))
1.428        (eliz     07-Oct-06): 			(setq old-coding
1.428        (eliz     07-Oct-06): 			      (car (find-coding-systems-region msgbeg msgend))))
1.353        (eliz     02-Feb-02): 		    (setq x-coding-header (point-marker))
1.353        (eliz     02-Feb-02): 		    (narrow-to-region msgbeg msgend)
1.430        (eliz     04-Nov-06): 		    (and (null raw)
1.430        (eliz     04-Nov-06): 			 ;; If old and new encoding are the same, it
1.430        (eliz     04-Nov-06): 			 ;; clearly doesn't make sense to encode.
1.430        (eliz     04-Nov-06): 			 (not (coding-system-equal
1.430        (eliz     04-Nov-06): 			       (coding-system-base old-coding)
1.430        (eliz     04-Nov-06): 			       (coding-system-base coding)))
1.430        (eliz     04-Nov-06): 			 ;; If the body includes only eight-bit-*
1.430        (eliz     04-Nov-06): 			 ;; characters, encoding might fail, e.g. with
1.430        (eliz     04-Nov-06): 			 ;; UTF-8, and isn't needed anyway.
1.430        (eliz     04-Nov-06): 			 (> (length (delq 'ascii
1.430        (eliz     04-Nov-06): 					  (delq 'eight-bit-graphic
1.430        (eliz     04-Nov-06): 						(delq 'eight-bit-control
1.430        (eliz     04-Nov-06): 						      (find-charset-region
1.430        (eliz     04-Nov-06): 						       msgbeg msgend)))))
1.430        (eliz     04-Nov-06): 			    0)
1.430        (eliz     04-Nov-06): 			 (encode-coding-region (point) msgend old-coding))
1.353        (eliz     02-Feb-02): 		    (decode-coding-region (point) msgend coding)
1.353        (eliz     02-Feb-02): 		    (setq last-coding-system-used coding)
1.353        (eliz     02-Feb-02): 		    ;; Rewrite the coding-system header according
1.353        (eliz     02-Feb-02): 		    ;; to what we did.
1.353        (eliz     02-Feb-02): 		    (goto-char x-coding-header)
1.353        (eliz     02-Feb-02): 		    (delete-region (point)
1.353        (eliz     02-Feb-02): 				   (save-excursion
1.353        (eliz     02-Feb-02): 				     (beginning-of-line)
1.353        (eliz     02-Feb-02): 				     (point)))
1.353        (eliz     02-Feb-02): 		    (insert "X-Coding-System: "
1.353        (eliz     02-Feb-02): 			    (symbol-name last-coding-system-used))
1.353        (eliz     02-Feb-02): 		    (set-marker x-coding-header nil)
1.353        (eliz     02-Feb-02): 		    (rmail-show-message))
1.353        (eliz     02-Feb-02): 		(error "No X-Coding-System header found")))
1.353        (eliz     02-Feb-02): 	  (or pruned
1.353        (eliz     02-Feb-02): 	      (rmail-toggle-header 0)))))))
1.326        (eliz     22-Jan-01): 
1.100        (kwzh     24-Apr-94): ;; Find all occurrences of certain fields, and highlight them.
1.100        (kwzh     24-Apr-94): (defun rmail-highlight-headers ()
1.100        (kwzh     24-Apr-94):   ;; Do this only if the system supports faces.
1.107        (rms      30-Jun-94):   (if (and (fboundp 'internal-find-face)
1.107        (rms      30-Jun-94): 	   rmail-highlighted-headers)
1.100        (kwzh     24-Apr-94):       (save-excursion
1.100        (kwzh     24-Apr-94): 	(search-forward "\n\n" nil 'move)
1.100        (kwzh     24-Apr-94): 	(save-restriction
1.100        (kwzh     24-Apr-94): 	  (narrow-to-region (point-min) (point))
1.100        (kwzh     24-Apr-94): 	  (let ((case-fold-search t)
1.100        (kwzh     24-Apr-94): 		(inhibit-read-only t)
1.100        (kwzh     24-Apr-94): 		;; Highlight with boldface if that is available.
1.100        (kwzh     24-Apr-94): 		;; Otherwise use the `highlight' face.
1.451        (bastien1 13-Feb-08): 		(face (or 'rmail-highlight
1.112        (rms      30-Jul-94): 			  (if (face-differs-from-default-p 'bold)
1.112        (rms      30-Jul-94): 			      'bold 'highlight)))
1.100        (kwzh     24-Apr-94): 		;; List of overlays to reuse.
1.100        (kwzh     24-Apr-94): 		(overlays rmail-overlay-list))
1.100        (kwzh     24-Apr-94): 	    (goto-char (point-min))
1.100        (kwzh     24-Apr-94): 	    (while (re-search-forward rmail-highlighted-headers nil t)
1.106        (rms      18-Jun-94): 	      (skip-chars-forward " \t")
1.100        (kwzh     24-Apr-94): 	      (let ((beg (point))
1.100        (kwzh     24-Apr-94): 		    overlay)
1.100        (kwzh     24-Apr-94): 		(while (progn (forward-line 1)
1.100        (kwzh     24-Apr-94): 			      (looking-at "[ \t]")))
1.100        (kwzh     24-Apr-94): 		;; Back up over newline, then trailing spaces or tabs
1.100        (kwzh     24-Apr-94): 		(forward-char -1)
1.100        (kwzh     24-Apr-94): 		(while (member (preceding-char) '(?  ?\t))
1.100        (kwzh     24-Apr-94): 		  (forward-char -1))
1.100        (kwzh     24-Apr-94): 		(if overlays
1.100        (kwzh     24-Apr-94): 		    ;; Reuse an overlay we already have.
1.100        (kwzh     24-Apr-94): 		    (progn
1.100        (kwzh     24-Apr-94): 		      (setq overlay (car overlays)
1.100        (kwzh     24-Apr-94): 			    overlays (cdr overlays))
1.100        (kwzh     24-Apr-94): 		      (overlay-put overlay 'face face)
1.100        (kwzh     24-Apr-94): 		      (move-overlay overlay beg (point)))
1.100        (kwzh     24-Apr-94): 		  ;; Make a new overlay and add it to
1.100        (kwzh     24-Apr-94): 		  ;; rmail-overlay-list.
1.100        (kwzh     24-Apr-94): 		  (setq overlay (make-overlay beg (point)))
1.100        (kwzh     24-Apr-94): 		  (overlay-put overlay 'face face)
1.100        (kwzh     24-Apr-94): 		  (setq rmail-overlay-list
1.100        (kwzh     24-Apr-94): 			(cons overlay rmail-overlay-list))))))))))
1.317        (fx       24-May-00): 
1.317        (fx       24-May-00): (defun rmail-auto-file ()
1.317        (fx       24-May-00):   "Automatically move a message into a sub-folder based on criteria.
1.317        (fx       24-May-00): Called when a new message is displayed."
1.317        (fx       24-May-00):   (if (or (rmail-message-labels-p rmail-current-message "filed")
1.317        (fx       24-May-00): 	  (not (string= (buffer-file-name)
1.317        (fx       24-May-00): 			(expand-file-name rmail-file-name))))
1.317        (fx       24-May-00):       ;; Do nothing if it's already been filed.
1.317        (fx       24-May-00):       nil
1.317        (fx       24-May-00):     ;; Find out some basics (common fields)
1.317        (fx       24-May-00):     (let ((from (mail-fetch-field "from"))
1.317        (fx       24-May-00): 	  (subj (mail-fetch-field "subject"))
1.317        (fx       24-May-00): 	  (to   (concat (mail-fetch-field "to") "," (mail-fetch-field "cc")))
1.317        (fx       24-May-00): 	  (d rmail-automatic-folder-directives)
1.317        (fx       24-May-00): 	  (directive-loop nil)
1.317        (fx       24-May-00): 	  (folder nil))
1.317        (fx       24-May-00):       (while d
1.317        (fx       24-May-00): 	(setq folder (car (car d))
1.317        (fx       24-May-00): 	      directive-loop (cdr (car d)))
1.317        (fx       24-May-00): 	(while (and (car directive-loop)
1.317        (fx       24-May-00): 		    (let ((f (cond
1.317        (fx       24-May-00): 			      ((string= (car directive-loop) "from") from)
1.317        (fx       24-May-00): 			      ((string= (car directive-loop) "to") to)
1.317        (fx       24-May-00): 			      ((string= (car directive-loop) "subject") subj)
1.317        (fx       24-May-00): 			      (t (mail-fetch-field (car directive-loop))))))
1.317        (fx       24-May-00): 		      (and f (string-match (car (cdr directive-loop)) f))))
1.317        (fx       24-May-00): 	  (setq directive-loop (cdr (cdr directive-loop))))
1.317        (fx       24-May-00): 	;; If there are no directives left, then it was a complete match.
1.317        (fx       24-May-00): 	(if (null directive-loop)
1.317        (fx       24-May-00): 	    (if (null folder)
1.317        (fx       24-May-00): 		(rmail-delete-forward)
1.317        (fx       24-May-00): 	      (if (string= "/dev/null" folder)
1.317        (fx       24-May-00): 		  (rmail-delete-message)
1.317        (fx       24-May-00): 		(rmail-output-to-rmail-file folder 1 t)
1.317        (fx       24-May-00): 		(setq d nil))))
1.317        (fx       24-May-00): 	(setq d (cdr d))))))
1.100        (kwzh     24-Apr-94): 
1.1          (roland   13-May-91): (defun rmail-next-message (n)
1.1          (roland   13-May-91):   "Show following message whether deleted or not.
1.1          (roland   13-May-91): With prefix arg N, moves forward N messages, or backward if N is negative."
1.1          (roland   13-May-91):   (interactive "p")
1.339        (gerd     08-May-01):   (set-buffer rmail-buffer)
1.1          (roland   13-May-91):   (rmail-maybe-set-message-counters)
1.1          (roland   13-May-91):   (rmail-show-message (+ rmail-current-message n)))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-previous-message (n)
1.1          (roland   13-May-91):   "Show previous message whether deleted or not.
1.1          (roland   13-May-91): With prefix arg N, moves backward N messages, or forward if N is negative."
1.1          (roland   13-May-91):   (interactive "p")
1.358        (pot      06-May-02):   (rmail-next-message (- n)))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-next-undeleted-message (n)
1.1          (roland   13-May-91):   "Show following non-deleted message.
1.1          (roland   13-May-91): With prefix arg N, moves forward N non-deleted messages,
1.68         (rms      09-Oct-93): or backward if N is negative.
1.68         (rms      09-Oct-93): 
1.68         (rms      09-Oct-93): Returns t if a new message is being shown, nil otherwise."
1.1          (roland   13-May-91):   (interactive "p")
1.339        (gerd     08-May-01):   (set-buffer rmail-buffer)
1.1          (roland   13-May-91):   (rmail-maybe-set-message-counters)
1.1          (roland   13-May-91):   (let ((lastwin rmail-current-message)
1.1          (roland   13-May-91): 	(current rmail-current-message))
1.1          (roland   13-May-91):     (while (and (> n 0) (< current rmail-total-messages))
1.1          (roland   13-May-91):       (setq current (1+ current))
1.1          (roland   13-May-91):       (if (not (rmail-message-deleted-p current))
1.1          (roland   13-May-91): 	  (setq lastwin current n (1- n))))
1.1          (roland   13-May-91):     (while (and (< n 0) (> current 1))
1.1          (roland   13-May-91):       (setq current (1- current))
1.1          (roland   13-May-91):       (if (not (rmail-message-deleted-p current))
1.1          (roland   13-May-91): 	  (setq lastwin current n (1+ n))))
1.1          (roland   13-May-91):     (if (/= lastwin rmail-current-message)
1.68         (rms      09-Oct-93):  	(progn (rmail-show-message lastwin)
1.68         (rms      09-Oct-93):  	       t)
1.68         (rms      09-Oct-93):       (if (< n 0)
1.68         (rms      09-Oct-93): 	  (message "No previous nondeleted message"))
1.68         (rms      09-Oct-93):       (if (> n 0)
1.68         (rms      09-Oct-93): 	  (message "No following nondeleted message"))
1.68         (rms      09-Oct-93):       nil)))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-previous-undeleted-message (n)
1.1          (roland   13-May-91):   "Show previous non-deleted message.
1.1          (roland   13-May-91): With prefix argument N, moves backward N non-deleted messages,
1.1          (roland   13-May-91): or forward if N is negative."
1.1          (roland   13-May-91):   (interactive "p")
1.1          (roland   13-May-91):   (rmail-next-undeleted-message (- n)))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-first-message ()
1.1          (roland   13-May-91):   "Show first message in file."
1.1          (roland   13-May-91):   (interactive)
1.1          (roland   13-May-91):   (rmail-maybe-set-message-counters)
1.1          (roland   13-May-91):   (rmail-show-message 1))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-last-message ()
1.1          (roland   13-May-91):   "Show last message in file."
1.1          (roland   13-May-91):   (interactive)
1.1          (roland   13-May-91):   (rmail-maybe-set-message-counters)
1.1          (roland   13-May-91):   (rmail-show-message rmail-total-messages))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-what-message ()
1.1          (roland   13-May-91):   (let ((where (point))
1.1          (roland   13-May-91): 	(low 1)
1.1          (roland   13-May-91): 	(high rmail-total-messages)
1.1          (roland   13-May-91): 	(mid (/ rmail-total-messages 2)))
1.1          (roland   13-May-91):     (while (> (- high low) 1)
1.1          (roland   13-May-91):       (if (>= where (rmail-msgbeg mid))
1.1          (roland   13-May-91): 	  (setq low mid)
1.1          (roland   13-May-91): 	(setq high mid))
1.1          (roland   13-May-91):       (setq mid (+ low (/ (- high low) 2))))
1.1          (roland   13-May-91):     (if (>= where (rmail-msgbeg high)) high low)))
1.1          (roland   13-May-91): 
1.39         (rms      09-Mar-93): (defun rmail-message-recipients-p (msg recipients &optional primary-only)
1.39         (rms      09-Mar-93):   (save-restriction
1.39         (rms      09-Mar-93):     (goto-char (rmail-msgbeg msg))
1.261        (rms      18-Apr-98):     (search-forward "\n*** EOOH ***\n")
1.39         (rms      09-Mar-93):     (narrow-to-region (point) (progn (search-forward "\n\n") (point)))
1.39         (rms      09-Mar-93):     (or (string-match recipients (or (mail-fetch-field "To") ""))
1.39         (rms      09-Mar-93): 	(string-match recipients (or (mail-fetch-field "From") ""))
1.39         (rms      09-Mar-93): 	(if (not primary-only)
1.39         (rms      09-Mar-93): 	    (string-match recipients (or (mail-fetch-field "Cc") ""))))))
1.39         (rms      09-Mar-93): 
1.334        (gerd     26-Apr-01): (defun rmail-message-regexp-p (n regexp)
1.334        (gerd     26-Apr-01):   "Return t, if for message number N, regexp REGEXP matches in the header."
1.334        (gerd     26-Apr-01):   (let ((beg (rmail-msgbeg n))
1.334        (gerd     26-Apr-01): 	(end (rmail-msgend n)))
1.334        (gerd     26-Apr-01):     (goto-char beg)
1.334        (gerd     26-Apr-01):     (forward-line 1)
1.334        (gerd     26-Apr-01):     (save-excursion
1.334        (gerd     26-Apr-01):       (save-restriction
1.334        (gerd     26-Apr-01): 	(if (prog1 (= (following-char) ?0)
1.334        (gerd     26-Apr-01): 	      (forward-line 2)
1.334        (gerd     26-Apr-01): 	      ;; If there's a Summary-line in the (otherwise empty)
1.334        (gerd     26-Apr-01): 	      ;; header, we didn't yet get past the EOOH line.
1.336        (gerd     30-Apr-01): 	      (when (looking-at "^\\*\\*\\* EOOH \\*\\*\\*\n")
1.336        (gerd     30-Apr-01): 		(forward-line 1))
1.335        (gerd     27-Apr-01): 	      (setq beg (point))
1.334        (gerd     26-Apr-01): 	      (narrow-to-region (point) end))
1.358        (pot      06-May-02): 	    (progn
1.336        (gerd     30-Apr-01): 	      (rfc822-goto-eoh)
1.336        (gerd     30-Apr-01): 	      (setq end (point)))
1.335        (gerd     27-Apr-01): 	  (setq beg (point))
1.336        (gerd     30-Apr-01): 	  (search-forward "\n*** EOOH ***\n" end t)
1.336        (gerd     30-Apr-01): 	  (setq end (1+ (match-beginning 0)))))
1.335        (gerd     27-Apr-01): 	(goto-char beg)
1.339        (gerd     08-May-01): 	(if rmail-enable-mime
1.339        (gerd     08-May-01): 	    (funcall rmail-search-mime-header-function n regexp end)
1.339        (gerd     08-May-01): 	  (re-search-forward regexp end t)))))
1.339        (gerd     08-May-01): 
1.339        (gerd     08-May-01): (defun rmail-search-message (msg regexp)
1.339        (gerd     08-May-01):   "Return non-nil, if for message number MSG, regexp REGEXP matches."
1.339        (gerd     08-May-01):   (goto-char (rmail-msgbeg msg))
1.339        (gerd     08-May-01):   (if rmail-enable-mime
1.339        (gerd     08-May-01):       (funcall rmail-search-mime-message-function msg regexp)
1.339        (gerd     08-May-01):     (re-search-forward regexp (rmail-msgend msg) t)))
1.39         (rms      09-Mar-93): 
1.1          (roland   13-May-91): (defvar rmail-search-last-regexp nil)
1.19         (rms      26-Jul-92): (defun rmail-search (regexp &optional n)
1.164        (kwzh     21-Dec-95):   "Show message containing next match for REGEXP (but not the current msg).
1.19         (rms      26-Jul-92): Prefix argument gives repeat count; negative argument means search
1.19         (rms      26-Jul-92): backwards (through earlier messages).
1.19         (rms      26-Jul-92): Interactively, empty argument means use same regexp used last time."
1.1          (roland   13-May-91):   (interactive
1.1          (roland   13-May-91):     (let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0))
1.1          (roland   13-May-91): 	   (prompt
1.415        (rfrancoi 24-Sep-05): 	    (concat (if reversep "Reverse " "") "Rmail search (regexp"))
1.1          (roland   13-May-91): 	   regexp)
1.415        (rfrancoi 24-Sep-05):       (setq prompt
1.415        (rfrancoi 24-Sep-05): 	    (concat prompt
1.415        (rfrancoi 24-Sep-05): 		    (if rmail-search-last-regexp
1.415        (rfrancoi 24-Sep-05): 			(concat ", default "
1.415        (rfrancoi 24-Sep-05): 				rmail-search-last-regexp "): ")
1.415        (rfrancoi 24-Sep-05): 		      "): ")))
1.1          (roland   13-May-91):       (setq regexp (read-string prompt))
1.1          (roland   13-May-91):       (cond ((not (equal regexp ""))
1.1          (roland   13-May-91): 	     (setq rmail-search-last-regexp regexp))
1.1          (roland   13-May-91): 	    ((not rmail-search-last-regexp)
1.1          (roland   13-May-91): 	     (error "No previous Rmail search string")))
1.19         (rms      26-Jul-92):       (list rmail-search-last-regexp
1.19         (rms      26-Jul-92): 	    (prefix-numeric-value current-prefix-arg))))
1.19         (rms      26-Jul-92):   (or n (setq n 1))
1.1          (roland   13-May-91):   (message "%sRmail search for %s..."
1.20         (rms      05-Aug-92): 	   (if (< n 0) "Reverse " "")
1.1          (roland   13-May-91): 	   regexp)
1.339        (gerd     08-May-01):   (set-buffer rmail-buffer)
1.1          (roland   13-May-91):   (rmail-maybe-set-message-counters)
1.1          (roland   13-May-91):   (let ((omin (point-min))
1.1          (roland   13-May-91): 	(omax (point-max))
1.1          (roland   13-May-91): 	(opoint (point))
1.1          (roland   13-May-91): 	win
1.19         (rms      26-Jul-92): 	(reversep (< n 0))
1.1          (roland   13-May-91): 	(msg rmail-current-message))
1.1          (roland   13-May-91):     (unwind-protect
1.1          (roland   13-May-91): 	(progn
1.1          (roland   13-May-91): 	  (widen)
1.19         (rms      26-Jul-92): 	  (while (/= n 0)
1.19         (rms      26-Jul-92): 	    ;; Check messages one by one, advancing message number up or down
1.19         (rms      26-Jul-92): 	    ;; but searching forward through each message.
1.19         (rms      26-Jul-92): 	    (if reversep
1.19         (rms      26-Jul-92): 		(while (and (null win) (> msg 1))
1.339        (gerd     08-May-01): 		  (setq msg (1- msg)
1.339        (gerd     08-May-01): 			win (rmail-search-message msg regexp)))
1.19         (rms      26-Jul-92): 	      (while (and (null win) (< msg rmail-total-messages))
1.339        (gerd     08-May-01): 		(setq msg (1+ msg)
1.339        (gerd     08-May-01): 		      win (rmail-search-message msg regexp))))
1.20         (rms      05-Aug-92): 	    (setq n (+ n (if reversep 1 -1)))))
1.1          (roland   13-May-91):       (if win
1.1          (roland   13-May-91): 	  (progn
1.339        (gerd     08-May-01): 	    (rmail-show-message msg)
1.339        (gerd     08-May-01): 	    ;; Search forward (if this is a normal search) or backward
1.339        (gerd     08-May-01): 	    ;; (if this is a reverse search) through this message to
1.339        (gerd     08-May-01): 	    ;; position point.  This search may fail because REGEXP
1.339        (gerd     08-May-01): 	    ;; was found in the hidden portion of this message.  In
1.339        (gerd     08-May-01): 	    ;; that case, move point to the beginning of visible
1.339        (gerd     08-May-01): 	    ;; portion.
1.1          (roland   13-May-91): 	    (if reversep
1.1          (roland   13-May-91): 		(progn
1.339        (gerd     08-May-01): 		  (goto-char (point-max))
1.339        (gerd     08-May-01): 		  (re-search-backward regexp nil 'move))
1.339        (gerd     08-May-01): 	      (goto-char (point-min))
1.339        (gerd     08-May-01): 	      (re-search-forward regexp nil t))
1.1          (roland   13-May-91): 	    (message "%sRmail search for %s...done"
1.1          (roland   13-May-91): 		     (if reversep "Reverse " "")
1.339        (gerd     08-May-01): 		     regexp))
1.1          (roland   13-May-91): 	(goto-char opoint)
1.1          (roland   13-May-91): 	(narrow-to-region omin omax)
1.1          (roland   13-May-91): 	(ding)
1.1          (roland   13-May-91): 	(message "Search failed: %s" regexp)))))
1.19         (rms      26-Jul-92): 
1.19         (rms      26-Jul-92): (defun rmail-search-backwards (regexp &optional n)
1.19         (rms      26-Jul-92):   "Show message containing previous match for REGEXP.
1.19         (rms      26-Jul-92): Prefix argument gives repeat count; negative argument means search
1.19         (rms      26-Jul-92): forward (through later messages).
1.19         (rms      26-Jul-92): Interactively, empty argument means use same regexp used last time."
1.19         (rms      26-Jul-92):   (interactive
1.20         (rms      05-Aug-92):     (let* ((reversep (>= (prefix-numeric-value current-prefix-arg) 0))
1.19         (rms      26-Jul-92): 	   (prompt
1.415        (rfrancoi 24-Sep-05): 	    (concat (if reversep "Reverse " "") "Rmail search (regexp"))
1.19         (rms      26-Jul-92): 	   regexp)
1.415        (rfrancoi 24-Sep-05):       (setq prompt
1.415        (rfrancoi 24-Sep-05): 	    (concat prompt
1.415        (rfrancoi 24-Sep-05): 		    (if rmail-search-last-regexp
1.415        (rfrancoi 24-Sep-05): 			(concat ", default "
1.415        (rfrancoi 24-Sep-05): 				rmail-search-last-regexp "): ")
1.415        (rfrancoi 24-Sep-05): 		      "): ")))
1.19         (rms      26-Jul-92):       (setq regexp (read-string prompt))
1.19         (rms      26-Jul-92):       (cond ((not (equal regexp ""))
1.19         (rms      26-Jul-92): 	     (setq rmail-search-last-regexp regexp))
1.19         (rms      26-Jul-92): 	    ((not rmail-search-last-regexp)
1.19         (rms      26-Jul-92): 	     (error "No previous Rmail search string")))
1.19         (rms      26-Jul-92):       (list rmail-search-last-regexp
1.19         (rms      26-Jul-92): 	    (prefix-numeric-value current-prefix-arg))))
1.154        (kwzh     13-Jun-95):   (rmail-search regexp (- (or n 1))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;; Show the first message which has the `unseen' attribute.
1.1          (roland   13-May-91): (defun rmail-first-unseen-message ()
1.31         (jla      07-Oct-92):   (rmail-maybe-set-message-counters)
1.1          (roland   13-May-91):   (let ((current 1)
1.1          (roland   13-May-91): 	found)
1.1          (roland   13-May-91):     (save-restriction
1.1          (roland   13-May-91):       (widen)
1.141        (rms      20-Dec-94):       (while (and (not found) (<= current rmail-total-messages))
1.1          (roland   13-May-91): 	(if (rmail-message-labels-p current ", ?\\(unseen\\),")
1.4          (roland   23-Jul-91): 	    (setq found current))
1.4          (roland   23-Jul-91): 	(setq current (1+ current))))
1.30         (jla      05-Oct-92): ;; Let the caller show the message.
1.30         (jla      05-Oct-92): ;;    (if found
1.30         (jla      05-Oct-92): ;;	(rmail-show-message found))
1.30         (jla      05-Oct-92):     found))
1.144        (rms      05-Feb-95): 
1.417        (as       08-Jan-06): (defun rmail-current-subject ()
1.417        (as       08-Jan-06):   "Return the current subject.
1.417        (as       08-Jan-06): The subject is stripped of leading and trailing whitespace, and
1.417        (as       08-Jan-06): of typical reply prefixes such as Re:."
1.417        (as       08-Jan-06):   (let ((subject (or (mail-fetch-field "Subject") "")))
1.251        (rms      08-Mar-98):     (if (string-match "\\`[ \t]+" subject)
1.251        (rms      08-Mar-98): 	(setq subject (substring subject (match-end 0))))
1.417        (as       08-Jan-06):     (if (string-match rmail-reply-regexp subject)
1.191        (kwzh     21-Jul-96): 	(setq subject (substring subject (match-end 0))))
1.251        (rms      08-Mar-98):     (if (string-match "[ \t]+\\'" subject)
1.251        (rms      08-Mar-98): 	(setq subject (substring subject 0 (match-beginning 0))))
1.417        (as       08-Jan-06):     subject))
1.417        (as       08-Jan-06): 
1.417        (as       08-Jan-06): (defun rmail-current-subject-regexp ()
1.417        (as       08-Jan-06):   "Return a regular expression matching the current subject.
1.417        (as       08-Jan-06): The regular expression matches the subject header line of
1.417        (as       08-Jan-06): messages about the same subject.  The subject itself is stripped
1.417        (as       08-Jan-06): of leading and trailing whitespace, of typical reply prefixes
1.417        (as       08-Jan-06): such as Re: and whitespace within the subject is replaced by a
1.417        (as       08-Jan-06): regular expression matching whitespace in general in order to
1.417        (as       08-Jan-06): take into account that subject header lines may include newlines
1.417        (as       08-Jan-06): and more whitespace.  The returned regular expressions contains
1.417        (as       08-Jan-06): `rmail-reply-regexp' and ends with a newline."
1.417        (as       08-Jan-06):   (let ((subject (rmail-current-subject)))
1.416        (eliz     10-Dec-05):     ;; If Subject is long, mailers will break it into several lines at
1.416        (eliz     10-Dec-05):     ;; arbitrary places, so replace whitespace with a regexp that will
1.416        (eliz     10-Dec-05):     ;; match any sequence of spaces, TABs, and newlines.
1.416        (eliz     10-Dec-05):     (setq subject (regexp-quote subject))
1.416        (eliz     10-Dec-05):     (setq subject
1.416        (eliz     10-Dec-05): 	  (replace-regexp-in-string "[ \t\n]+" "[ \t\n]+" subject t t))
1.441        (miles    21-Nov-07):     ;; Some mailers insert extra spaces after "Subject:", so allow any
1.441        (miles    21-Nov-07):     ;; amount of them.
1.441        (miles    21-Nov-07):     (concat "^Subject:[ \t]+"
1.417        (as       08-Jan-06): 	    (if (string= "\\`" (substring rmail-reply-regexp 0 2))
1.417        (as       08-Jan-06): 		(substring rmail-reply-regexp 2)
1.417        (as       08-Jan-06): 	      rmail-reply-regexp)
1.417        (as       08-Jan-06): 	    subject "[ \t]*\n")))
1.417        (as       08-Jan-06): 
1.417        (as       08-Jan-06): (defun rmail-next-same-subject (n)
1.417        (as       08-Jan-06):   "Go to the next mail message having the same subject header.
1.417        (as       08-Jan-06): With prefix argument N, do this N times.
1.417        (as       08-Jan-06): If N is negative, go backwards instead."
1.417        (as       08-Jan-06):   (interactive "p")
1.417        (as       08-Jan-06):   (let ((search-regexp (rmail-current-subject-regexp))
1.417        (as       08-Jan-06): 	(forward (> n 0))
1.417        (as       08-Jan-06): 	(i rmail-current-message)
1.417        (as       08-Jan-06): 	(case-fold-search t)
1.417        (as       08-Jan-06): 	found)
1.144        (rms      05-Feb-95):     (save-excursion
1.144        (rms      05-Feb-95):       (save-restriction
1.144        (rms      05-Feb-95): 	(widen)
1.144        (rms      05-Feb-95): 	(while (and (/= n 0)
1.144        (rms      05-Feb-95): 		    (if forward
1.144        (rms      05-Feb-95): 			(< i rmail-total-messages)
1.144        (rms      05-Feb-95): 		      (> i 1)))
1.144        (rms      05-Feb-95): 	  (let (done)
1.144        (rms      05-Feb-95): 	    (while (and (not done)
1.144        (rms      05-Feb-95): 			(if forward
1.144        (rms      05-Feb-95): 			    (< i rmail-total-messages)
1.144        (rms      05-Feb-95): 			  (> i 1)))
1.144        (rms      05-Feb-95): 	      (setq i (if forward (1+ i) (1- i)))
1.144        (rms      05-Feb-95): 	      (goto-char (rmail-msgbeg i))
1.144        (rms      05-Feb-95): 	      (search-forward "\n*** EOOH ***\n")
1.144        (rms      05-Feb-95): 	      (let ((beg (point)) end)
1.144        (rms      05-Feb-95): 		(search-forward "\n\n")
1.144        (rms      05-Feb-95): 		(setq end (point))
1.144        (rms      05-Feb-95): 		(goto-char beg)
1.144        (rms      05-Feb-95): 		(setq done (re-search-forward search-regexp end t))))
1.144        (rms      05-Feb-95): 	    (if done (setq found i)))
1.144        (rms      05-Feb-95): 	  (setq n (if forward (1- n) (1+ n))))))
1.144        (rms      05-Feb-95):     (if found
1.144        (rms      05-Feb-95): 	(rmail-show-message found)
1.144        (rms      05-Feb-95):       (error "No %s message with same subject"
1.144        (rms      05-Feb-95): 	     (if forward "following" "previous")))))
1.144        (rms      05-Feb-95): 
1.144        (rms      05-Feb-95): (defun rmail-previous-same-subject (n)
1.144        (rms      05-Feb-95):   "Go to the previous mail message having the same subject header.
1.144        (rms      05-Feb-95): With prefix argument N, do this N times.
1.144        (rms      05-Feb-95): If N is negative, go forwards instead."
1.144        (rms      05-Feb-95):   (interactive "p")
1.144        (rms      05-Feb-95):   (rmail-next-same-subject (- n)))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;; *** Rmail Message Deletion Commands ***
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-message-deleted-p (n)
1.1          (roland   13-May-91):   (= (aref rmail-deleted-vector n) ?D))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-set-message-deleted-p (n state)
1.1          (roland   13-May-91):   (aset rmail-deleted-vector n (if state ?D ?\ )))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-delete-message ()
1.1          (roland   13-May-91):   "Delete this message and stay on it."
1.1          (roland   13-May-91):   (interactive)
1.161        (rms      10-Nov-95):   (rmail-set-attribute "deleted" t)
1.161        (rms      10-Nov-95):   (run-hooks 'rmail-delete-message-hook))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-undelete-previous-message ()
1.1          (roland   13-May-91):   "Back up to deleted message, select it, and undelete it."
1.1          (roland   13-May-91):   (interactive)
1.339        (gerd     08-May-01):   (set-buffer rmail-buffer)
1.1          (roland   13-May-91):   (let ((msg rmail-current-message))
1.1          (roland   13-May-91):     (while (and (> msg 0)
1.1          (roland   13-May-91): 		(not (rmail-message-deleted-p msg)))
1.1          (roland   13-May-91):       (setq msg (1- msg)))
1.1          (roland   13-May-91):     (if (= msg 0)
1.1          (roland   13-May-91): 	(error "No previous deleted message")
1.1          (roland   13-May-91):       (if (/= msg rmail-current-message)
1.1          (roland   13-May-91): 	  (rmail-show-message msg))
1.39         (rms      09-Mar-93):       (rmail-set-attribute "deleted" nil)
1.39         (rms      09-Mar-93):       (if (rmail-summary-exists)
1.39         (rms      09-Mar-93): 	  (save-excursion
1.39         (rms      09-Mar-93): 	    (set-buffer rmail-summary-buffer)
1.39         (rms      09-Mar-93): 	    (rmail-summary-mark-undeleted msg)))
1.39         (rms      09-Mar-93):       (rmail-maybe-display-summary))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-delete-forward (&optional backward)
1.1          (roland   13-May-91):   "Delete this message and move to next nondeleted one.
1.1          (roland   13-May-91): Deleted messages stay in the file until the \\[rmail-expunge] command is given.
1.68         (rms      09-Oct-93): With prefix argument, delete and move backward.
1.68         (rms      09-Oct-93): 
1.68         (rms      09-Oct-93): Returns t if a new message is displayed after the delete, or nil otherwise."
1.1          (roland   13-May-91):   (interactive "P")
1.1          (roland   13-May-91):   (rmail-set-attribute "deleted" t)
1.161        (rms      10-Nov-95):   (run-hooks 'rmail-delete-message-hook)
1.39         (rms      09-Mar-93):   (let ((del-msg rmail-current-message))
1.39         (rms      09-Mar-93):     (if (rmail-summary-exists)
1.133        (rms      08-Oct-94): 	(rmail-select-summary
1.133        (rms      08-Oct-94): 	 (rmail-summary-mark-deleted del-msg)))
1.68         (rms      09-Oct-93):     (prog1 (rmail-next-undeleted-message (if backward -1 1))
1.68         (rms      09-Oct-93):       (rmail-maybe-display-summary))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-delete-backward ()
1.1          (roland   13-May-91):   "Delete this message and move to previous nondeleted one.
1.1          (roland   13-May-91): Deleted messages stay in the file until the \\[rmail-expunge] command is given."
1.1          (roland   13-May-91):   (interactive)
1.1          (roland   13-May-91):   (rmail-delete-forward t))
1.1          (roland   13-May-91): 
1.131        (rms      27-Sep-94): ;; Compute the message number a given message would have after expunging.
1.131        (rms      27-Sep-94): ;; The present number of the message is OLDNUM.
1.131        (rms      27-Sep-94): ;; DELETEDVEC should be rmail-deleted-vector.
1.131        (rms      27-Sep-94): ;; The value is nil for a message that would be deleted.
1.131        (rms      27-Sep-94): (defun rmail-msg-number-after-expunge (deletedvec oldnum)
1.131        (rms      27-Sep-94):   (if (or (null oldnum) (= (aref deletedvec oldnum) ?D))
1.131        (rms      27-Sep-94):       nil
1.131        (rms      27-Sep-94):     (let ((i 0)
1.131        (rms      27-Sep-94): 	  (newnum 0))
1.131        (rms      27-Sep-94):       (while (< i oldnum)
1.131        (rms      27-Sep-94): 	(if (/= (aref deletedvec i) ?D)
1.131        (rms      27-Sep-94): 	    (setq newnum (1+ newnum)))
1.131        (rms      27-Sep-94): 	(setq i (1+ i)))
1.131        (rms      27-Sep-94):       newnum)))
1.131        (rms      27-Sep-94): 
1.325        (gerd     04-Dec-00): (defun rmail-expunge-confirmed ()
1.325        (gerd     04-Dec-00):   "Return t if deleted message should be expunged. If necessary, ask the user.
1.325        (gerd     04-Dec-00): See also user-option `rmail-confirm-expunge'."
1.339        (gerd     08-May-01):   (set-buffer rmail-buffer)
1.325        (gerd     04-Dec-00):   (or (not (stringp rmail-deleted-vector))
1.325        (gerd     04-Dec-00):       (not (string-match "D" rmail-deleted-vector))
1.325        (gerd     04-Dec-00):       (null rmail-confirm-expunge)
1.325        (gerd     04-Dec-00):       (funcall rmail-confirm-expunge
1.325        (gerd     04-Dec-00): 	       "Erase deleted messages from Rmail file? ")))
1.325        (gerd     04-Dec-00): 
1.380        (uid65566 16-Jan-04): (defun rmail-only-expunge (&optional dont-show)
1.1          (roland   13-May-91):   "Actually erase all deleted messages in the file."
1.1          (roland   13-May-91):   (interactive)
1.339        (gerd     08-May-01):   (set-buffer rmail-buffer)
1.1          (roland   13-May-91):   (message "Expunging deleted messages...")
1.1          (roland   13-May-91):   ;; Discard all undo records for this buffer.
1.1          (roland   13-May-91):   (or (eq buffer-undo-list t)
1.1          (roland   13-May-91):       (setq buffer-undo-list nil))
1.1          (roland   13-May-91):   (rmail-maybe-set-message-counters)
1.1          (roland   13-May-91):   (let* ((omax (- (buffer-size) (point-max)))
1.1          (roland   13-May-91): 	 (omin (- (buffer-size) (point-min)))
1.1          (roland   13-May-91): 	 (opoint (if (and (> rmail-current-message 0)
1.96         (kwzh     23-Apr-94): 			  (rmail-message-deleted-p rmail-current-message))
1.96         (kwzh     23-Apr-94): 		     0
1.339        (gerd     08-May-01): 		   (if rmail-enable-mime
1.339        (gerd     08-May-01): 		       (with-current-buffer rmail-view-buffer
1.339        (gerd     08-May-01): 			 (- (point)(point-min)))
1.339        (gerd     08-May-01): 		     (- (point) (point-min)))))
1.1          (roland   13-May-91): 	 (messages-head (cons (aref rmail-message-vector 0) nil))
1.1          (roland   13-May-91): 	 (messages-tail messages-head)
1.1          (roland   13-May-91): 	 ;; Don't make any undo records for the expunging.
1.1          (roland   13-May-91): 	 (buffer-undo-list t)
1.1          (roland   13-May-91): 	 (win))
1.1          (roland   13-May-91):     (unwind-protect
1.1          (roland   13-May-91): 	(save-excursion
1.1          (roland   13-May-91): 	  (widen)
1.1          (roland   13-May-91): 	  (goto-char (point-min))
1.1          (roland   13-May-91): 	  (let ((counter 0)
1.1          (roland   13-May-91): 		(number 1)
1.1          (roland   13-May-91): 		(total rmail-total-messages)
1.1          (roland   13-May-91): 		(new-message-number rmail-current-message)
1.1          (roland   13-May-91): 		(new-summary nil)
1.218        (rms      02-May-97): 		(new-msgref (list (list 0)))
1.131        (rms      27-Sep-94): 		(rmailbuf (current-buffer))
1.1          (roland   13-May-91): 		(buffer-read-only nil)
1.1          (roland   13-May-91): 		(messages rmail-message-vector)
1.1          (roland   13-May-91): 		(deleted rmail-deleted-vector)
1.1          (roland   13-May-91): 		(summary rmail-summary-vector))
1.1          (roland   13-May-91): 	    (setq rmail-total-messages nil
1.1          (roland   13-May-91): 		  rmail-current-message nil
1.1          (roland   13-May-91): 		  rmail-message-vector nil
1.1          (roland   13-May-91): 		  rmail-deleted-vector nil
1.1          (roland   13-May-91): 		  rmail-summary-vector nil)
1.131        (rms      27-Sep-94): 
1.1          (roland   13-May-91): 	    (while (<= number total)
1.1          (roland   13-May-91): 	      (if (= (aref deleted number) ?D)
1.1          (roland   13-May-91): 		  (progn
1.1          (roland   13-May-91): 		    (delete-region
1.1          (roland   13-May-91): 		      (marker-position (aref messages number))
1.1          (roland   13-May-91): 		      (marker-position (aref messages (1+ number))))
1.1          (roland   13-May-91): 		    (move-marker (aref messages number) nil)
1.1          (roland   13-May-91): 		    (if (> new-message-number counter)
1.1          (roland   13-May-91): 			(setq new-message-number (1- new-message-number))))
1.1          (roland   13-May-91): 		(setq counter (1+ counter))
1.1          (roland   13-May-91): 		(setq messages-tail
1.1          (roland   13-May-91): 		      (setcdr messages-tail
1.1          (roland   13-May-91): 			      (cons (aref messages number) nil)))
1.1          (roland   13-May-91): 		(setq new-summary
1.1          (roland   13-May-91): 		      (cons (if (= counter number) (aref summary (1- number)))
1.218        (rms      02-May-97): 			    new-summary))
1.218        (rms      02-May-97): 		(setq new-msgref
1.218        (rms      02-May-97): 		      (cons (aref rmail-msgref-vector number)
1.218        (rms      02-May-97): 			    new-msgref))
1.218        (rms      02-May-97): 		(setcar (car new-msgref) counter))
1.1          (roland   13-May-91): 	      (if (zerop (% (setq number (1+ number)) 20))
1.1          (roland   13-May-91): 		  (message "Expunging deleted messages...%d" number)))
1.1          (roland   13-May-91): 	    (setq messages-tail
1.1          (roland   13-May-91): 		  (setcdr messages-tail
1.1          (roland   13-May-91): 			  (cons (aref messages number) nil)))
1.1          (roland   13-May-91): 	    (setq rmail-current-message new-message-number
1.1          (roland   13-May-91): 		  rmail-total-messages counter
1.1          (roland   13-May-91): 		  rmail-message-vector (apply 'vector messages-head)
1.1          (roland   13-May-91): 		  rmail-deleted-vector (make-string (1+ counter) ?\ )
1.1          (roland   13-May-91): 		  rmail-summary-vector (vconcat (nreverse new-summary))
1.218        (rms      02-May-97): 		  rmail-msgref-vector (apply 'vector (nreverse new-msgref))
1.1          (roland   13-May-91): 		  win t)))
1.1          (roland   13-May-91):       (message "Expunging deleted messages...done")
1.1          (roland   13-May-91):       (if (not win)
1.1          (roland   13-May-91): 	  (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax)))
1.380        (uid65566 16-Jan-04):       (if (not dont-show)
1.380        (uid65566 16-Jan-04): 	  (rmail-show-message
1.406        (rms      08-Jul-05): 	   (if (zerop rmail-current-message) 1 nil)))
1.406        (rms      08-Jul-05):       (if rmail-enable-mime
1.406        (rms      08-Jul-05): 	  (goto-char (+ (point-min) opoint))
1.406        (rms      08-Jul-05): 	(goto-char (+ (point) opoint))))))
1.39         (rms      09-Mar-93): 
1.39         (rms      09-Mar-93): (defun rmail-expunge ()
1.39         (rms      09-Mar-93):   "Erase deleted messages from Rmail file and summary buffer."
1.39         (rms      09-Mar-93):   (interactive)
1.325        (gerd     04-Dec-00):   (when (rmail-expunge-confirmed)
1.313        (gerd     24-Mar-00):     (rmail-only-expunge)
1.313        (gerd     24-Mar-00):     (if (rmail-summary-exists)
1.325        (gerd     04-Dec-00): 	(rmail-select-summary (rmail-update-summary)))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): ;;;; *** Rmail Mailing Commands ***
1.1          (roland   13-May-91): 
1.203        (rms      07-Dec-96): (defun rmail-start-mail (&optional noerase to subject in-reply-to cc
1.203        (rms      07-Dec-96): 				   replybuffer sendactions same-window others)
1.203        (rms      07-Dec-96):   (let (yank-action)
1.203        (rms      07-Dec-96):     (if replybuffer
1.203        (rms      07-Dec-96): 	(setq yank-action (list 'insert-buffer replybuffer)))
1.203        (rms      07-Dec-96):     (setq others (cons (cons "cc" cc) others))
1.203        (rms      07-Dec-96):     (setq others (cons (cons "in-reply-to" in-reply-to) others))
1.203        (rms      07-Dec-96):     (if same-window
1.203        (rms      07-Dec-96): 	(compose-mail to subject others
1.203        (rms      07-Dec-96): 		      noerase nil
1.203        (rms      07-Dec-96): 		      yank-action sendactions)
1.390        (eliz     24-Apr-04):       (if rmail-mail-new-frame
1.203        (rms      07-Dec-96): 	  (prog1
1.203        (rms      07-Dec-96): 	      (compose-mail to subject others
1.203        (rms      07-Dec-96): 			    noerase 'switch-to-buffer-other-frame
1.203        (rms      07-Dec-96): 			    yank-action sendactions)
1.203        (rms      07-Dec-96): 	    ;; This is not a standard frame parameter;
1.203        (rms      07-Dec-96): 	    ;; nothing except sendmail.el looks at it.
1.203        (rms      07-Dec-96): 	    (modify-frame-parameters (selected-frame)
1.203        (rms      07-Dec-96): 				     '((mail-dedicated-frame . t))))
1.203        (rms      07-Dec-96): 	(compose-mail to subject others
1.203        (rms      07-Dec-96): 		      noerase 'switch-to-buffer-other-window
1.203        (rms      07-Dec-96): 		      yank-action sendactions)))))
1.57         (rms      16-Jul-93): 
1.1          (roland   13-May-91): (defun rmail-mail ()
1.39         (rms      09-Mar-93):   "Send mail in another window.
1.39         (rms      09-Mar-93): While composing the message, use \\[mail-yank-original] to yank the
1.39         (rms      09-Mar-93): original message into it."
1.1          (roland   13-May-91):   (interactive)
1.212        (handa    26-Feb-97):   (rmail-start-mail nil nil nil nil nil rmail-view-buffer))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-continue ()
1.1          (roland   13-May-91):   "Continue composing outgoing message previously being composed."
1.1          (roland   13-May-91):   (interactive)
1.57         (rms      16-Jul-93):   (rmail-start-mail t))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-reply (just-sender)
1.1          (roland   13-May-91):   "Reply to the current message.
1.1          (roland   13-May-91): Normally include CC: to all other recipients of original message;
1.1          (roland   13-May-91): prefix argument means ignore them.  While composing the reply,
1.1          (roland   13-May-91): use \\[mail-yank-original] to yank the original message into it."
1.1          (roland   13-May-91):   (interactive "P")
1.207        (rms      31-Jan-97):   (let (from reply-to cc subject date to message-id references
1.202        (rms      26-Oct-96): 	     resent-to resent-cc resent-reply-to
1.212        (handa    26-Feb-97): 	     (msgnum rmail-current-message))
1.1          (roland   13-May-91):     (save-excursion
1.1          (roland   13-May-91):       (save-restriction
1.345        (gerd     06-Jul-01): 	(if rmail-enable-mime
1.345        (gerd     06-Jul-01): 	    (narrow-to-region
1.345        (gerd     06-Jul-01): 	     (goto-char (point-min))
1.345        (gerd     06-Jul-01): 	     (if (search-forward "\n\n" nil 'move)
1.345        (gerd     06-Jul-01): 		 (1+ (match-beginning 0))
1.345        (gerd     06-Jul-01): 	       (point)))
1.339        (gerd     08-May-01): 	  (widen)
1.339        (gerd     08-May-01): 	  (goto-char (rmail-msgbeg rmail-current-message))
1.339        (gerd     08-May-01): 	  (forward-line 1)
1.339        (gerd     08-May-01): 	  (if (= (following-char) ?0)
1.339        (gerd     08-May-01): 	      (narrow-to-region
1.339        (gerd     08-May-01): 	       (progn (forward-line 2)
1.339        (gerd     08-May-01): 		      (point))
1.339        (gerd     08-May-01): 	       (progn (search-forward "\n\n" (rmail-msgend rmail-current-message)
1.339        (gerd     08-May-01): 				      'move)
1.339        (gerd     08-May-01): 		      (point)))
1.339        (gerd     08-May-01): 	    (narrow-to-region (point)
1.339        (gerd     08-May-01): 			      (progn (search-forward "\n*** EOOH ***\n")
1.339        (gerd     08-May-01): 				     (beginning-of-line) (point)))))
1.202        (rms      26-Oct-96): 	(setq from (mail-fetch-field "from")
1.413        (rms      15-Aug-05): 	      reply-to (or (mail-fetch-field "mail-reply-to" nil t)
1.397        (rms      18-Mar-05): 			   (mail-fetch-field "reply-to" nil t)
1.1          (roland   13-May-91): 			   from)
1.202        (rms      26-Oct-96): 	      subject (mail-fetch-field "subject")
1.202        (rms      26-Oct-96): 	      date (mail-fetch-field "date")
1.202        (rms      26-Oct-96): 	      message-id (mail-fetch-field "message-id")
1.207        (rms      31-Jan-97): 	      references (mail-fetch-field "references" nil nil t)
1.207        (rms      31-Jan-97): 	      resent-reply-to (mail-fetch-field "resent-reply-to" nil t)
1.202        (rms      26-Oct-96): 	      resent-cc (and (not just-sender)
1.202        (rms      26-Oct-96): 			     (mail-fetch-field "resent-cc" nil t))
1.202        (rms      26-Oct-96): 	      resent-to (or (mail-fetch-field "resent-to" nil t) "")
1.202        (rms      26-Oct-96): ;;;	      resent-subject (mail-fetch-field "resent-subject")
1.202        (rms      26-Oct-96): ;;;	      resent-date (mail-fetch-field "resent-date")
1.202        (rms      26-Oct-96): ;;;	      resent-message-id (mail-fetch-field "resent-message-id")
1.413        (rms      15-Aug-05): 	      )
1.413        (rms      15-Aug-05): 	(unless just-sender
1.413        (rms      15-Aug-05): 	  (if (mail-fetch-field "mail-followup-to" nil t)
1.413        (rms      15-Aug-05): 	      ;; If this header field is present, use it instead of the To and CC fields.
1.413        (rms      15-Aug-05): 	      (setq to (mail-fetch-field "mail-followup-to" nil t))
1.413        (rms      15-Aug-05): 	    (setq cc (or (mail-fetch-field "cc" nil t) "")
1.413        (rms      15-Aug-05): 		  to (or (mail-fetch-field "to" nil t) ""))))
1.413        (rms      15-Aug-05): 
1.413        (rms      15-Aug-05): 	))
1.413        (rms      15-Aug-05): 
1.202        (rms      26-Oct-96):     ;; Merge the resent-to and resent-cc into the to and cc.
1.202        (rms      26-Oct-96):     (if (and resent-to (not (equal resent-to "")))
1.202        (rms      26-Oct-96): 	(if (not (equal to ""))
1.202        (rms      26-Oct-96): 	    (setq to (concat to ", " resent-to))
1.202        (rms      26-Oct-96): 	  (setq to resent-to)))
1.202        (rms      26-Oct-96):     (if (and resent-cc (not (equal resent-cc "")))
1.202        (rms      26-Oct-96): 	(if (not (equal cc ""))
1.202        (rms      26-Oct-96): 	    (setq cc (concat cc ", " resent-cc))
1.202        (rms      26-Oct-96): 	  (setq cc resent-cc)))
1.202        (rms      26-Oct-96):     ;; Add `Re: ' to subject if not there already.
1.39         (rms      09-Mar-93):     (and (stringp subject)
1.143        (kwzh     03-Feb-95): 	 (setq subject
1.143        (kwzh     03-Feb-95): 	       (concat rmail-reply-prefix
1.211        (kwzh     23-Feb-97): 		       (if (let ((case-fold-search t))
1.211        (kwzh     23-Feb-97): 			     (string-match rmail-reply-regexp subject))
1.143        (kwzh     03-Feb-95): 			   (substring subject (match-end 0))
1.143        (kwzh     03-Feb-95): 			 subject))))
1.226        (rms      01-Jun-97):     (rmail-start-mail
1.226        (rms      01-Jun-97):      nil
1.226        (rms      01-Jun-97):      ;; Using mail-strip-quoted-names is undesirable with newer mailers
1.226        (rms      01-Jun-97):      ;; since they can handle the names unstripped.
1.226        (rms      01-Jun-97):      ;; I don't know whether there are other mailers that still
1.226        (rms      01-Jun-97):      ;; need the names to be stripped.
1.366        (rms      01-Jan-03): ;;;     (mail-strip-quoted-names reply-to)
1.403        (eliz     21-May-05):      ;; Remove unwanted names from reply-to, since Mail-Followup-To
1.403        (eliz     21-May-05):      ;; header causes all the names in it to wind up in reply-to, not
1.403        (eliz     21-May-05):      ;; in cc.  But if what's left is an empty list, use the original.
1.403        (eliz     21-May-05):      (let* ((reply-to-list (rmail-dont-reply-to reply-to)))
1.403        (eliz     21-May-05):        (if (string= reply-to-list "") reply-to reply-to-list))
1.226        (rms      01-Jun-97):      subject
1.226        (rms      01-Jun-97):      (rmail-make-in-reply-to-field from date message-id)
1.226        (rms      01-Jun-97):      (if just-sender
1.226        (rms      01-Jun-97): 	 nil
1.226        (rms      01-Jun-97):        ;; mail-strip-quoted-names is NOT necessary for rmail-dont-reply-to
1.226        (rms      01-Jun-97):        ;; to do its job.
1.226        (rms      01-Jun-97):        (let* ((cc-list (rmail-dont-reply-to
1.226        (rms      01-Jun-97): 			(mail-strip-quoted-names
1.226        (rms      01-Jun-97): 			 (if (null cc) to (concat to ", " cc))))))
1.226        (rms      01-Jun-97): 	 (if (string= cc-list "") nil cc-list)))
1.226        (rms      01-Jun-97):      rmail-view-buffer
1.226        (rms      01-Jun-97):      (list (list 'rmail-mark-message
1.339        (gerd     08-May-01): 		 rmail-buffer
1.339        (gerd     08-May-01): 		 (with-current-buffer rmail-buffer
1.339        (gerd     08-May-01): 		   (aref rmail-msgref-vector msgnum))
1.226        (rms      01-Jun-97): 		 "answered"))
1.226        (rms      01-Jun-97):      nil
1.226        (rms      01-Jun-97):      (list (cons "References" (concat (mapconcat 'identity references " ")
1.226        (rms      01-Jun-97): 				      " " message-id))))))
1.217        (rms      26-Apr-97): 
1.218        (rms      02-May-97): (defun rmail-mark-message (buffer msgnum-list attribute)
1.218        (rms      02-May-97):   "Give BUFFER's message number in MSGNUM-LIST the attribute ATTRIBUTE.
1.218        (rms      02-May-97): This is use in the send-actions for message buffers.
1.218        (rms      02-May-97): MSGNUM-LIST is a list of the form (MSGNUM)
1.218        (rms      02-May-97): which is an element of rmail-msgref-vector."
1.217        (rms      26-Apr-97):   (save-excursion
1.217        (rms      26-Apr-97):     (set-buffer buffer)
1.218        (rms      02-May-97):     (if (car msgnum-list)
1.218        (rms      02-May-97): 	(rmail-set-attribute attribute t (car msgnum-list)))))
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): (defun rmail-make-in-reply-to-field (from date message-id)
1.1          (roland   13-May-91):   (cond ((not from)
1.1          (roland   13-May-91):          (if message-id
1.1          (roland   13-May-91):              message-id
1.1          (roland   13-May-91):              nil))
1.1          (roland   13-May-91):         (mail-use-rfc822
1.1          (roland   13-May-91):          (require 'rfc822)
1.1          (roland   13-May-91):          (let ((tem (car (rfc822-addresses from))))
1.1          (roland   13-May-91):            (if message-id
1.233        (rms      12-Aug-97):                (if (or (not tem)
1.233        (rms      12-Aug-97): 		       (string-match
1.233        (rms      12-Aug-97): 			(regexp-quote (if (string-match "@[^@]*\\'" tem)
1.233        (rms      12-Aug-97): 					  (substring tem 0
1.233        (rms      12-Aug-97): 						     (match-beginning 0))
1.233        (rms      12-Aug-97): 					tem))
1.233        (rms      12-Aug-97): 			message-id))
1.233        (rms      12-Aug-97):                    ;; missing From, or Message-ID is sufficiently informative
1.1          (roland   13-May-91):                    message-id
1.1          (roland   13-May-91):                    (concat message-id " (" tem ")"))
1.82         (rms      29-Jan-94): 	     ;; Copy TEM, discarding text properties.
1.82         (rms      29-Jan-94): 	     (setq tem (copy-sequence tem))
1.82         (rms      29-Jan-94): 	     (set-text-properties 0 (length tem) nil tem)
1.82         (rms      29-Jan-94): 	     (setq tem (copy-sequence tem))
1.82         (rms      29-Jan-94): 	     ;; Use prin1 to fake RFC822 quoting
1.82         (rms      29-Jan-94): 	     (let ((field (prin1-to-string tem)))
1.82         (rms      29-Jan-94): 	       (if date
1.82         (rms      29-Jan-94): 		   (concat field "'s message of " date)
1.82         (rms      29-Jan-94): 		   field)))))
1.243        (rms      19-Jan-98):         ((let* ((foo "[^][\000-\037()<>@,;:\\\" ]+")
1.243        (rms      19-Jan-98):                 (bar "[^][\000-\037()<>@,;:\\\"]+"))
1.243        (rms      19-Jan-98): 	   ;; These strings both match all non-ASCII characters.
1.1          (roland   13-May-91):            (or (string-match (concat "\\`[ \t]*\\(" bar
1.1          (roland   13-May-91):                                      "\\)\\(<" foo "@" foo ">\\)?[ \t]*\\'")
1.1          (roland   13-May-91):                              ;; "Unix Loser <Foo@bar.edu>" => "Unix Loser"
1.1          (roland   13-May-91):                              from)
1.1          (roland   13-May-91):                (string-match (concat "\\`[ \t]*<" foo "@" foo ">[ \t]*(\\("
1.1          (roland   13-May-91):                                      bar "\\))[ \t]*\\'")
1.1          (roland   13-May-91):                              ;; "<Bugs@bar.edu>" (Losing Unix) => "Losing Unix"
1.1          (roland   13-May-91):                              from)))
1.1          (roland   13-May-91):          (let ((start (match-beginning 1))
1.1          (roland   13-May-91):                (end (match-end 1)))
1.1          (roland   13-May-91):            ;; Trim whitespace which above regexp match allows
1.1          (roland   13-May-91):            (while (and (< start end)
1.1          (roland   13-May-91):                        (memq (aref from start) '(?\t ?\ )))
1.1          (roland   13-May-91):              (setq start (1+ start)))
1.1          (roland   13-May-91):            (while (and (< start end)
1.1          (roland   13-May-91):                        (memq (aref from (1- end)) '(?\t ?\ )))
1.1          (roland   13-May-91):              (setq end (1- end)))
1.1          (roland   13-May-91):            (let ((field (substring from start end)))
1.1          (roland   13-May-91):              (if date (setq field (concat "message from " field " on " date)))
1.1          (roland   13-May-91):              (if message-id
1.1          (roland   13-May-91):                  ;; "<AA259@bar.edu> (message from Unix Loser on 1-Apr-89)"
1.1          (roland   13-May-91):                  (concat message-id " (" field ")")
1.1          (roland   13-May-91):                  field))))
1.1          (roland   13-May-91):         (t
1.1          (roland   13-May-91):          ;; If we can't kludge it simply, do it correctly
1.1          (roland   13-May-91):          (let ((mail-use-rfc822 t))
1.1          (roland   13-May-91):            (rmail-make-in-reply-to-field from date message-id)))))
1.147        (rms      12-Mar-95): 
1.42         (rms      07-May-93): (defun rmail-forward (resend)
1.42         (rms      07-May-93):   "Forward the current message to another user.
1.42         (rms      07-May-93): With prefix argument, \"resend\" the message instead of forwarding it;
1.42         (rms      07-May-93): see the documentation of `rmail-resend'."
1.42         (rms      07-May-93):   (interactive "P")
1.42         (rms      07-May-93):   (if resend
1.42         (rms      07-May-93):       (call-interactively 'rmail-resend)
1.339        (gerd     08-May-01):     (let ((forward-buffer rmail-buffer)
1.131        (rms      27-Sep-94): 	  (msgnum rmail-current-message)
1.42         (rms      07-May-93): 	  (subject (concat "["
1.42         (rms      07-May-93): 			   (let ((from (or (mail-fetch-field "From")
1.42         (rms      07-May-93): 					   (mail-fetch-field ">From"))))
1.42         (rms      07-May-93): 			     (if from
1.42         (rms      07-May-93): 				 (concat (mail-strip-quoted-names from) ": ")
1.42         (rms      07-May-93): 			       ""))
1.42         (rms      07-May-93): 			   (or (mail-fetch-field "Subject") "")
1.42         (rms      07-May-93): 			   "]")))
1.203        (rms      07-Dec-96):       (if (rmail-start-mail
1.203        (rms      07-Dec-96): 	   nil nil subject nil nil nil
1.217        (rms      26-Apr-97): 	   (list (list 'rmail-mark-message
1.218        (rms      02-May-97): 		       forward-buffer
1.339        (gerd     08-May-01): 		       (with-current-buffer rmail-buffer
1.339        (gerd     08-May-01): 			 (aref rmail-msgref-vector msgnum))
1.217        (rms      26-Apr-97): 		       "forwarded"))
1.203        (rms      07-Dec-96): 	   ;; If only one window, use it for the mail buffer.
1.203        (rms      07-Dec-96): 	   ;; Otherwise, use another window for the mail buffer
1.203        (rms      07-Dec-96): 	   ;; so that the Rmail buffer remains visible
1.203        (rms      07-Dec-96): 	   ;; and sending the mail will get back to it.
1.203        (rms      07-Dec-96): 	   (and (not rmail-mail-new-frame) (one-window-p t)))
1.131        (rms      27-Sep-94): 	  ;; The mail buffer is now current.
1.58         (rms      24-Jul-93): 	  (save-excursion
1.65         (rms      15-Sep-93): 	    ;; Insert after header separator--before signature if any.
1.264        (rms      30-Apr-98): 	    (goto-char (mail-text-start))
1.350        (zsh      25-Nov-01): 	    (if (or rmail-enable-mime rmail-enable-mime-composing)
1.339        (gerd     08-May-01): 		(funcall rmail-insert-mime-forwarded-message-function
1.339        (gerd     08-May-01): 			 forward-buffer)
1.339        (gerd     08-May-01): 	      (insert "------- Start of forwarded message -------\n")
1.339        (gerd     08-May-01): 	      ;; Quote lines with `- ' if they start with `-'.
1.339        (gerd     08-May-01): 	      (let ((beg (point)) end)
1.339        (gerd     08-May-01): 		(setq end (point-marker))
1.339        (gerd     08-May-01): 		(set-marker-insertion-type end t)
1.339        (gerd     08-May-01): 		(insert-buffer-substring forward-buffer)
1.339        (gerd     08-May-01): 		(goto-char beg)
1.339        (gerd     08-May-01): 		(while (re-search-forward "^-" end t)
1.339        (gerd     08-May-01): 		  (beginning-of-line)
1.339        (gerd     08-May-01): 		  (insert "- ")
1.339        (gerd     08-May-01): 		  (forward-line 1))
1.339        (gerd     08-May-01): 		(goto-char end)
1.339        (gerd     08-May-01): 		(skip-chars-backward "\n")
1.339        (gerd     08-May-01): 		(if (< (point) end)
1.339        (gerd     08-May-01): 		    (forward-char 1))
1.339        (gerd     08-May-01): 		(delete-region (point) end)
1.339        (gerd     08-May-01): 		(set-marker end nil))
1.339        (gerd     08-May-01): 	      (insert "------- End of forwarded message -------\n"))
1.131        (rms      27-Sep-94): 	    (push-mark))))))
1.147        (rms      12-Mar-95): 
1.1          (roland   13-May-91): (defun rmail-resend (address &optional from comment mail-alias-file)
1.1          (roland   13-May-91):   "Resend current message to ADDRESSES.
1.73         (rms      23-Dec-93): ADDRESSES should be a single address, a string consisting of several
1.1          (roland   13-May-91): addresses separated by commas, or a list of addresses.
1.1          (roland   13-May-91): 
1.1          (roland   13-May-91): Optional FROM is the address to resend the message from, and
1.232        (rms      29-Jul-97): defaults from the value of `user-mail-address'.
1.232        (rms      29-Jul-97): Optional COMMENT is a string to insert as a comment in the resent message.
1.1          (roland   13-May-91): Optional ALIAS-FILE is alternate aliases file to be used by sendmail,
1.1          (roland   13-May-91): typically for purposes of moderating a list."
1.1          (roland   13-May-91):   (interactive "sResend to: ")
1.46         (rms      04-Jun-93):   (require 'sendmail)
1.46         (rms      04-Jun-93):   (require 'mailalias)
1.342        (gerd     31-May-01):   (unless (or (eq rmail-view-buffer (current-buffer))
1.342        (gerd     31-May-01): 	      (eq rmail-buffer (current-buffer)))
1.311        (gerd     25-Feb-00):     (error "Not an Rmail buffer"))
1.232        (rms      29-Jul-97):   (if (not from) (setq from user-mail-address))
1.1          (roland   13-May-91):   (let ((tembuf (generate-new-buffer " sendmail temp"))
1.1          (roland   13-May-91): 	(case-fold-search nil)
1.394        (rms      27-Dec-04): 	(mail-personal-alias-file
1.394        (rms      27-Dec-04): 	 (or mail-alias-file mail-personal-alias-file))
1.288        (kwzh     21-Sep-98): 	(mailbuf rmail-buffer))
1.1          (roland   13-May-91):     (unwind-protect
1.288        (kwzh     21-Sep-98): 	(with-current-buffer tembuf
1.1          (roland   13-May-91): 	  ;;>> Copy message into temp buffer
1.342        (gerd     31-May-01): 	  (if rmail-enable-mime
1.342        (gerd     31-May-01): 	      (funcall rmail-insert-mime-resent-message-function mailbuf)
1.342        (gerd     31-May-01): 	    (insert-buffer-substring mailbuf))
1.1          (roland   13-May-91): 	  (goto-char (point-min))
1.167        (rms      05-Jan-96): 	  ;; Delete any Sender field, since that's not specifiable.
1.73         (rms      23-Dec-93): 	  ; Only delete Sender fields in the actual header.
1.73         (rms      23-Dec-93): 	  (re-search-forward "^$" nil 'move)
1.73         (rms      23-Dec-93): 	  ; Using "while" here rather than "if" because some buggy mail
1.73         (rms      23-Dec-93): 	  ; software may have inserted multiple Sender fields.
1.73         (rms      23-Dec-93): 	  (while (re-search-backward "^Sender:" nil t)
1.73         (rms      23-Dec-93): 	    (let (beg)
1.73         (rms      23-Dec-93): 	      (setq beg (point))
1.73         (rms      23-Dec-93): 	      (forward-line 1)
1.73         (rms      23-Dec-93): 	      (while (looking-at "[ \t]")
1.73         (rms      23-Dec-93): 		(forward-line 1))
1.73         (rms      23-Dec-93): 	      (delete-region beg (point))))
1.73         (rms      23-Dec-93): 	  ; Go back to the beginning of the buffer so the Resent- fields
1.73         (rms      23-Dec-93): 	  ; are inserted there.
1.73         (rms      23-Dec-93): 	  (goto-char (point-min))
1.1          (roland   13-May-91): 	  ;;>> Insert resent-from:
1.1          (roland   13-May-91): 	  (insert "Resent-From: " from "\n")
1.55         (rms      07-Jul-93): 	  (insert "Resent-Date: " (mail-rfc822-date) "\n")
1.1          (roland   13-May-91): 	  ;;>> Insert resent-to: and bcc if need be.
1.1          (roland   13-May-91): 	  (let ((before (point)))
1.68         (rms      09-Oct-93): 	    (if mail-self-blind
1.68         (rms      09-Oct-93): 		(insert "Resent-Bcc: " (user-login-name) "\n"))
1.1          (roland   13-May-91): 	    (insert "Resent-To: " (if (stringp address)
1.1          (roland   13-May-91): 			       address
1.1          (roland   13-May-91): 			     (mapconcat 'identity address ",\n\t"))
1.1          (roland   13-May-91): 		    "\n")
1.150        (rms      14-Apr-95): 	    ;; Expand abbrevs in the recipients.
1.121        (rms      14-Aug-94): 	    (save-excursion
1.150        (rms      14-Apr-95): 	      (if (featurep 'mailabbrev)
1.152        (rms      24-Apr-95): 		  (let ((end (point-marker))
1.152        (rms      24-Apr-95): 			(local-abbrev-table mail-abbrevs)
1.152        (rms      24-Apr-95): 			(old-syntax-table (syntax-table)))
1.152        (rms      24-Apr-95): 		    (if (and (not (vectorp mail-abbrevs))
1.152        (rms      24-Apr-95): 			     (file-exists-p mail-personal-alias-file))
1.152        (rms      24-Apr-95): 			(build-mail-abbrevs))
1.357        (rms      25-Mar-02): 		    (unless mail-abbrev-syntax-table
1.357        (rms      25-Mar-02): 		      (mail-abbrev-make-syntax-table))
1.152        (rms      24-Apr-95): 		    (set-syntax-table mail-abbrev-syntax-table)
1.152        (rms      24-Apr-95): 		    (goto-char before)
1.152        (rms      24-Apr-95): 		    (while (and (< (point) end)
1.152        (rms      24-Apr-95): 				(progn (forward-word 1)
1.152        (rms      24-Apr-95): 				       (<= (point) end)))
1.152        (rms      24-Apr-95): 		      (expand-abbrev))
1.152        (rms      24-Apr-95): 		    (set-syntax-table old-syntax-table))
1.150        (rms      14-Apr-95): 		(expand-mail-aliases before (point)))))
1.1          (roland   13-May-91): 	  ;;>> Set up comment, if any.
1.1          (roland   13-May-91): 	  (if (and (sequencep comment) (not (zerop (length comment))))
1.1          (roland   13-May-91): 	      (let ((before (point))
1.1          (roland   13-May-91): 		    after)
1.1          (roland   13-May-91): 		(insert comment)
1.1          (roland   13-May-91): 		(or (eolp) (insert "\n"))
1.1          (roland   13-May-91): 		(setq after (point))
1.1          (roland   13-May-91): 		(goto-char before)
1.1          (roland   13-May-91): 		(while (< (point) after)
1.1          (roland   13-May-91): 		  (insert "Resent-Comment: ")
1.1          (roland   13-May-91): 		  (forward-line 1))))
1.1          (roland   13-May-91): 	  ;; Don't expand aliases in the destination fields
1.1          (roland   13-May-91): 	  ;; of the original message.
1.1          (roland   13-May-91): 	  (let (mail-aliases)
1.78         (rms      06-Jan-94): 	    (funcall send-mail-function)))
1.42         (rms      07-May-93):       (kill-buffer tembuf))
1.288        (kwzh     21-Sep-98):     (with-current-buffer rmail-buffer
1.288        (kwzh     21-Sep-98):       (rmail-set-attribute "resent" t rmail-current-message))))
1.147        (rms      12-Mar-95): 
1.29         (rms      29-Sep-92): (defvar mail-unsent-separator
1.32         (rms      09-Oct-92):   (concat "^ *---+ +Unsent message follows +---+ *$\\|"
1.32         (rms      09-Oct-92): 	  "^ *---+ +Returned message +---+ *$\\|"
1.269        (rms      20-May-98): 	  "^ *---+ *Returned mail follows *---+ *$\\|"
1.146        (rms      24-Feb-95): 	  "^Start of returned message$\\|"
1.279        (rms      25-Jun-98): 	  "^---+ Below this line is a copy of the message.$\\|"
1.33         (rms      09-Oct-92): 	  "^ *---+ +Original message +---+ *$\\|"
1.37         (rms      09-Jan-93): 	  "^ *--+ +begin message +--+ *$\\|"
1.68         (rms      09-Oct-93): 	  "^ *---+ +Original message follows +---+ *$\\|"
1.250        (kwzh     25-Feb-98): 	  "^ *---+ +Your message follows +---+ *$\\|"
1.305        (rms      07-Jul-99): 	  "^|? *---+ +Message text follows: +---+ *|?$\\|"
1.319        (gerd     06-Jul-00): 	  "^ *---+ +This is a copy of \\w+ message, including all the headers.*---+ *$")
1.122        (rms      19-Aug-94):   "A regexp that matches the separator before the text of a failed message.")
1.1          (roland   13-May-91): 
1.214        (rms      20-Mar-97): (defvar mail-mime-unsent-header "^Content-Type: message/rfc822 *$"
1.214        (rms      20-Mar-97):  "A regexp that matches the header of a MIME body part with a failed message.")
1.214        (rms      20-Mar-97): 
1.1          (roland   13-May-91): (defun rmail-retry-failure ()
1.1          (roland   13-May-91):   "Edit a mail message which is based on the contents of the current message.
1.1          (roland   13-May-91): For a message rejected by the mail system, extract the interesting headers and
1.122        (rms      19-Aug-94): the body of the original message.
1.214        (rms      20-Mar-97): If the failed message is a MIME multipart message, it is searched for a
1.214        (rms      20-Mar-97): body part with a header which matches the variable `mail-mime-unsent-header'.
1.214        (rms      20-Mar-97): Otherwise, the variable `mail-unsent-separator' should match the string that
1.128        (rms      23-Sep-94): delimits the returned original message.
1.128        (rms      23-Sep-94): The variable `rmail-retry-ignored-headers' is a regular expression
1.128        (rms      23-Sep-94): specifying headers which should not be copied into the new message."
1.1          (roland   13-May-91):   (interactive)
1.1          (roland   13-May-91):   (require 'mail-utils)
1.223        (rms      15-May-97):   (let ((rmail-this-buffer (current-buffer))
1.164        (kwzh     21-Dec-95): 	(msgnum rmail-current-message)
1.344        (rms      29-Jun-01): 	bounce-start bounce-end bounce-indent resending
1.344        (rms      29-Jun-01): 	;; Fetch any content-type header in current message
1.344        (rms      29-Jun-01): 	;; Must search thru the whole unpruned header.
1.344        (rms      29-Jun-01): 	(content-type
1.344        (rms      29-Jun-01): 	 (save-excursion
1.344        (rms      29-Jun-01): 	   (save-restriction
1.344        (rms      29-Jun-01): 	     (rmail-narrow-to-non-pruned-header)
1.344        (rms      29-Jun-01): 	     (mail-fetch-field "Content-Type") ))))
1.344        (rms      29-Jun-01):     (save-excursion
1.344        (rms      29-Jun-01):       (goto-char (point-min))
1.344        (rms      29-Jun-01):       (let ((case-fold-search t))
1.358        (pot      06-May-02): 	(if (and content-type
1.358        (pot      06-May-02): 		 (string-match
1.358        (pot      06-May-02): 		  ";[\n\t ]*boundary=\"?\\([-0-9a-z'()+_,./:=? ]+\\)\"?"
1.344        (rms      29-Jun-01): 		  content-type))
1.344        (rms      29-Jun-01): 	    ;; Handle a MIME multipart bounce message.
1.344        (rms      29-Jun-01): 	    (let ((codestring
1.344        (rms      29-Jun-01): 		   (concat "\n--"
1.358        (pot      06-May-02): 			   (substring content-type (match-beginning 1)
1.344        (rms      29-Jun-01): 				      (match-end 1)))))
1.344        (rms      29-Jun-01): 	      (unless (re-search-forward mail-mime-unsent-header nil t)
1.344        (rms      29-Jun-01): 		(error "Cannot find beginning of header in failed message"))
1.344        (rms      29-Jun-01): 	      (unless (search-forward "\n\n" nil t)
1.344        (rms      29-Jun-01): 		(error "Cannot find start of Mime data in failed message"))
1.344        (rms      29-Jun-01): 	      (setq bounce-start (point))
1.344        (rms      29-Jun-01): 	      (if (search-forward codestring nil t)
1.344        (rms      29-Jun-01): 		  (setq bounce-end (match-beginning 0))
1.344        (rms      29-Jun-01): 		(setq bounce-end (point-max))))
1.344        (rms      29-Jun-01): 	  ;; Non-MIME bounce.
1.344        (rms      29-Jun-01): 	  (or (re-search-forward mail-unsent-separator nil t)
1.344        (rms      29-Jun-01): 	      (error "Cannot parse this as a failure message"))
1.344        (rms      29-Jun-01): 	  (skip-chars-forward "\n")
1.344        (rms      29-Jun-01): 	  ;; Support a style of failure message in which the original
1.344        (rms      29-Jun-01): 	  ;; message is indented, and included within lines saying
1.344        (rms      29-Jun-01): 	  ;; `Start of returned message' and `End of returned message'.
1.344        (rms      29-Jun-01): 	  (if (looking-at " +Received:")
1.344        (rms      29-Jun-01): 	      (progn
1.344        (rms      29-Jun-01): 		(setq bounce-start (point))
1.344        (rms      29-Jun-01): 		(skip-chars-forward " ")
1.344        (rms      29-Jun-01): 		(setq bounce-indent (- (current-column)))
1.344        (rms      29-Jun-01): 		(goto-char (point-max))
1.344        (rms      29-Jun-01): 		(re-search-backward "^End of returned message$" nil t)
1.344        (rms      29-Jun-01): 		(setq bounce-end (point)))
1.344        (rms      29-Jun-01): 	    ;; One message contained a few random lines before
1.344        (rms      29-Jun-01): 	    ;; the old message header.  The first line of the
1.344        (rms      29-Jun-01): 	    ;; message started with two hyphens.  A blank line
1.344        (rms      29-Jun-01): 	    ;; followed these random lines.  The same line
1.344        (rms      29-Jun-01): 	    ;; beginning with two hyphens was possibly marking
1.344        (rms      29-Jun-01): 	    ;; the end of the message.
1.344        (rms      29-Jun-01): 	    (if (looking-at "^--")
1.344        (rms      29-Jun-01): 		(let ((boundary (buffer-substring-no-properties
1.344        (rms      29-Jun-01): 				 (point)
1.344        (rms      29-Jun-01): 				 (progn (end-of-line) (point)))))
1.344        (rms      29-Jun-01): 		  (search-forward "\n\n")
1.344        (rms      29-Jun-01): 		  (skip-chars-forward "\n")
1.344        (rms      29-Jun-01): 		  (setq bounce-start (point))
1.344        (rms      29-Jun-01): 		  (goto-char (point-max))
1.344        (rms      29-Jun-01): 		  (search-backward (concat "\n\n" boundary) bounce-start t)
1.344        (rms      29-Jun-01): 		  (setq bounce-end (point)))
1.344        (rms      29-Jun-01): 	      (setq bounce-start (point)
1.344        (rms      29-Jun-01): 		    bounce-end (point-max)))
1.344        (rms      29-Jun-01): 	    (unless (search-forward "\n\n" nil t)
1.344        (rms      29-Jun-01): 	      (error "Cannot find end of header in failed message"))))))
1.344        (rms      29-Jun-01):     ;; We have found the message that bounced, within the current message.
1.344        (rms      29-Jun-01):     ;; Now start sending new message; default header fields from original.
1.344        (rms      29-Jun-01):     ;; Turn off the usual actions for initializing the message body
1.344        (rms      29-Jun-01):     ;; because we want to get only the text from the failure message.
1.344        (rms      29-Jun-01):     (let (mail-signature mail-setup-hook)
1.344        (rms      29-Jun-01):       (if (rmail-start-mail nil nil nil nil nil rmail-this-buffer
1.344        (rms      29-Jun-01): 			    (list (list 'rmail-mark-message
1.344        (rms      29-Jun-01): 					rmail-this-buffer
1.344        (rms      29-Jun-01): 					(aref rmail-msgref-vector msgnum)
1.344        (rms      29-Jun-01): 					"retried")))
1.344        (rms      29-Jun-01): 	  ;; Insert original text as initial text of new draft message.
1.344        (rms      29-Jun-01): 	  ;; Bind inhibit-read-only since the header delimiter
1.344        (rms      29-Jun-01): 	  ;; of the previous message was probably read-only.
1.344        (rms      29-Jun-01): 	  (let ((inhibit-read-only t)
1.344        (rms      29-Jun-01): 		rmail-displayed-headers
1.344        (rms      29-Jun-01): 		rmail-ignored-headers)
1.344        (rms      29-Jun-01): 	    (erase-buffer)
1.344        (rms      29-Jun-01): 	    (insert-buffer-substring rmail-this-buffer
1.344        (rms      29-Jun-01): 				     bounce-start bounce-end)
1.344        (rms      29-Jun-01): 	    (goto-char (point-min))
1.344        (rms      29-Jun-01): 	    (if bounce-indent
1.344        (rms      29-Jun-01): 		(indent-rigidly (point-min) (point-max) bounce-indent))
1.344        (rms      29-Jun-01): 	    (rmail-clear-headers rmail-retry-ignored-headers)
1.344        (rms      29-Jun-01): 	    (rmail-clear-headers "^sender:\\|^return-path:\\|^received:")
1.344        (rms      29-Jun-01): 	    (mail-sendmail-delimit-header)
1.344        (rms      29-Jun-01): 	    (save-restriction
1.344        (rms      29-Jun-01): 	      (narrow-to-region (point-min) (mail-header-end))
1.344        (rms      29-Jun-01): 	      (setq resending (mail-fetch-field "resent-to"))
1.344        (rms      29-Jun-01): 	      (if mail-self-blind
1.344        (rms      29-Jun-01): 		  (if resending
1.344        (rms      29-Jun-01): 		      (insert "Resent-Bcc: " (user-login-name) "\n")
1.344        (rms      29-Jun-01): 		    (insert "BCC: " (user-login-name) "\n"))))
1.344        (rms      29-Jun-01): 	    (goto-char (point-min))
1.344        (rms      29-Jun-01): 	    (mail-position-on-field (if resending "Resent-To" "To") t))))))
1.147        (rms      12-Mar-95): 
1.39         (rms      09-Mar-93): (defun rmail-summary-exists ()
1.437        (miles    13-Aug-07):   "Non-nil if in an RMAIL buffer and an associated summary buffer exists.
1.91         (rms      18-Mar-94): In fact, the non-nil value returned is the summary buffer itself."
1.39         (rms      09-Mar-93):   (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
1.39         (rms      09-Mar-93):        rmail-summary-buffer))
1.39         (rms      09-Mar-93): 
1.39         (rms      09-Mar-93): (defun rmail-summary-displayed ()
1.437        (miles    13-Aug-07):   "t if in RMAIL buffer and an associated summary buffer is displayed."
1.39         (rms      09-Mar-93):   (and rmail-summary-buffer (get-buffer-window rmail-summary-buffer)))
1.39         (rms      09-Mar-93): 
1.219        (rms      03-May-97): (defcustom rmail-redisplay-summary nil
1.39         (rms      09-Mar-93):   "*Non-nil means Rmail should show the summary when it changes.
1.219        (rms      03-May-97): This has an effect only if a summary buffer exists."
1.219        (rms      03-May-97):   :type 'boolean
1.219        (rms      03-May-97):   :group 'rmail-summary)
1.219        (rms      03-May-97): 
1.219        (rms      03-May-97): (defcustom rmail-summary-window-size nil
1.219        (rms      03-May-97):   "*Non-nil means specify the height for an Rmail summary window."
1.238        (kwzh     15-Nov-97):   :type '(choice (const :tag "Disabled" nil) integer)
1.219        (rms      03-May-97):   :group 'rmail-summary)
1.91         (rms      18-Mar-94): 
1.39         (rms      09-Mar-93): ;; Put the summary buffer back on the screen, if user wants that.
1.39         (rms      09-Mar-93): (defun rmail-maybe-display-summary ()
1.91         (rms      18-Mar-94):   (let ((selected (selected-window))
1.91         (rms      18-Mar-94): 	window)
1.91         (rms      18-Mar-94):     ;; If requested, make sure the summary is displayed.
1.91         (rms      18-Mar-94):     (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
1.91         (rms      18-Mar-94): 	 rmail-redisplay-summary
1.120        (rms      13-Aug-94): 	 (if (get-buffer-window rmail-summary-buffer 0)
1.120        (rms      13-Aug-94): 	     ;; It's already in some frame; show that one.
1.120        (rms      13-Aug-94): 	     (let ((frame (window-frame
1.120        (rms      13-Aug-94): 			   (get-buffer-window rmail-summary-buffer 0))))
1.120        (rms      13-Aug-94): 	       (make-frame-visible frame)
1.120        (rms      13-Aug-94): 	       (raise-frame frame))
1.120        (rms      13-Aug-94): 	   (display-buffer rmail-summary-buffer)))
1.91         (rms      18-Mar-94):     ;; If requested, set the height of the summary window.
1.91         (rms      18-Mar-94):     (and rmail-summary-buffer (buffer-name rmail-summary-buffer)
1.91         (rms      18-Mar-94): 	 rmail-summary-window-size
1.91         (rms      18-Mar-94): 	 (setq window (get-buffer-window rmail-summary-buffer))
1.120        (rms      13-Aug-94): 	 ;; Don't try to change the size if just one window in frame.
1.120        (rms      13-Aug-94): 	 (not (eq window (frame-root-window (window-frame window))))
1.358        (pot      06-May-02): 	 (unwind-protect
1.91         (rms      18-Mar-94): 	     (progn
1.91         (rms      18-Mar-94): 	       (select-window window)
1.180        (simon    07-Mar-96): 	       (enlarge-window (- rmail-summary-window-size (window-height))))
1.91         (rms      18-Mar-94): 	   (select-window selected)))))
1.171        (simon    26-Jan-96): 
1.171        (simon    26-Jan-96): ;;;; *** Rmail Local Fontification ***
1.171        (simon    26-Jan-96): 
1.171        (simon    26-Jan-96): (defun rmail-fontify-buffer-function ()
1.171        (simon    26-Jan-96):   ;; This function's symbol is bound to font-lock-fontify-buffer-function.
1.172        (simon    02-Feb-96):   (add-hook 'rmail-show-message-hook 'rmail-fontify-message nil t)
1.180        (simon    07-Mar-96):   ;; If we're already showing a message, fontify it now.
1.180        (simon    07-Mar-96):   (if rmail-current-message (rmail-fontify-message))
1.180        (simon    07-Mar-96):   ;; Prevent Font Lock mode from kicking in.
1.172        (simon    02-Feb-96):   (setq font-lock-fontified t))
1.171        (simon    26-Jan-96): 
1.171        (simon    26-Jan-96): (defun rmail-unfontify-buffer-function ()
1.171        (simon    26-Jan-96):   ;; This function's symbol is bound to font-lock-fontify-unbuffer-function.
1.172        (simon    02-Feb-96):   (let ((modified (buffer-modified-p))
1.172        (simon    02-Feb-96): 	(buffer-undo-list t) (inhibit-read-only t)
1.172        (simon    02-Feb-96): 	before-change-functions after-change-functions
1.172        (simon    02-Feb-96): 	buffer-file-name buffer-file-truename)
1.172        (simon    02-Feb-96):     (save-restriction
1.172        (simon    02-Feb-96):       (widen)
1.172        (simon    02-Feb-96):       (remove-hook 'rmail-show-message-hook 'rmail-fontify-message t)
1.172        (simon    02-Feb-96):       (remove-text-properties (point-min) (point-max) '(rmail-fontified nil))
1.181        (rms      27-Mar-96):       (font-lock-default-unfontify-buffer)
1.181        (rms      27-Mar-96):       (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil)))))
1.171        (simon    26-Jan-96): 
1.171        (simon    26-Jan-96): (defun rmail-fontify-message ()
1.171        (simon    26-Jan-96):   ;; Fontify the current message if it is not already fontified.
1.171        (simon    26-Jan-96):   (if (text-property-any (point-min) (point-max) 'rmail-fontified nil)
1.171        (simon    26-Jan-96):       (let ((modified (buffer-modified-p))
1.171        (simon    26-Jan-96): 	    (buffer-undo-list t) (inhibit-read-only t)
1.171        (simon    26-Jan-96): 	    before-change-functions after-change-functions
1.171        (simon    26-Jan-96): 	    buffer-file-name buffer-file-truename)
1.171        (simon    26-Jan-96): 	(save-excursion
1.171        (simon    26-Jan-96): 	  (save-match-data
1.171        (simon    26-Jan-96): 	    (add-text-properties (point-min) (point-max) '(rmail-fontified t))
1.181        (rms      27-Mar-96): 	    (font-lock-fontify-region (point-min) (point-max))
1.181        (rms      27-Mar-96): 	    (and (not modified) (buffer-modified-p) (set-buffer-modified-p nil)))))))
1.281        (kwzh     10-Jul-98): 
1.281        (kwzh     10-Jul-98): ;;; Speedbar support for RMAIL files.
1.281        (kwzh     10-Jul-98): (eval-when-compile (require 'speedbar))
1.179        (rms      04-Mar-96): 
1.281        (kwzh     10-Jul-98): (defvar rmail-speedbar-match-folder-regexp "^[A-Z0-9]+\\(\\.[A-Z0-9]+\\)?$"
1.363        (jpw      24-Aug-02):   "*This regex is used to match folder names to be displayed in speedbar.
1.281        (kwzh     10-Jul-98): Enabling this will permit speedbar to display your folders for easy
1.281        (kwzh     10-Jul-98): browsing, and moving of messages.")
1.244        (zappo    23-Jan-98): 
1.244        (zappo    23-Jan-98): (defvar rmail-speedbar-last-user nil
1.244        (zappo    23-Jan-98):   "The last user to be displayed in the speedbar.")
1.244        (zappo    23-Jan-98): 
1.281        (kwzh     10-Jul-98): (defvar rmail-speedbar-key-map nil
1.281        (kwzh     10-Jul-98):   "Keymap used when in rmail display mode.")
1.281        (kwzh     10-Jul-98): 
1.281        (kwzh     10-Jul-98): (defun rmail-install-speedbar-variables ()
1.281        (kwzh     10-Jul-98):   "Install those variables used by speedbar to enhance rmail."
1.281        (kwzh     10-Jul-98):   (if rmail-speedbar-key-map
1.281        (kwzh     10-Jul-98):       nil
1.281        (kwzh     10-Jul-98):     (setq rmail-speedbar-key-map (speedbar-make-specialized-keymap))
1.281        (kwzh     10-Jul-98): 
1.281        (kwzh     10-Jul-98):     (define-key rmail-speedbar-key-map "e" 'speedbar-edit-line)
1.281        (kwzh     10-Jul-98):     (define-key rmail-speedbar-key-map "r" 'speedbar-edit-line)
1.281        (kwzh     10-Jul-98):     (define-key rmail-speedbar-key-map "\C-m" 'speedbar-edit-line)
1.281        (kwzh     10-Jul-98):     (define-key rmail-speedbar-key-map "M"
1.281        (kwzh     10-Jul-98):       'rmail-speedbar-move-message-to-folder-on-line)))
1.281        (kwzh     10-Jul-98): 
1.244        (zappo    23-Jan-98): (defvar rmail-speedbar-menu-items
1.281        (kwzh     10-Jul-98):   '(["Read Folder" speedbar-edit-line t]
1.281        (kwzh     10-Jul-98):     ["Move message to folder" rmail-speedbar-move-message-to-folder-on-line
1.244        (zappo    23-Jan-98):      (save-excursion (beginning-of-line)
1.244        (zappo    23-Jan-98): 		     (looking-at "<M> "))])
1.244        (zappo    23-Jan-98):   "Additional menu-items to add to speedbar frame.")
1.244        (zappo    23-Jan-98): 
1.281        (kwzh     10-Jul-98): ;; Make sure our special speedbar major mode is loaded
1.281        (kwzh     10-Jul-98): (if (featurep 'speedbar)
1.281        (kwzh     10-Jul-98):     (rmail-install-speedbar-variables)
1.281        (kwzh     10-Jul-98):   (add-hook 'speedbar-load-hook 'rmail-install-speedbar-variables))
1.281        (kwzh     10-Jul-98): 
1.244        (zappo    23-Jan-98): (defun rmail-speedbar-buttons (buffer)
1.244        (zappo    23-Jan-98):   "Create buttons for BUFFER containing rmail messages.
1.244        (zappo    23-Jan-98): Click on the address under Reply to: to reply to this person.
1.244        (zappo    23-Jan-98): Under Folders: Click a name to read it, or on the <M> to move the
1.244        (zappo    23-Jan-98): current message into that RMAIL folder."
1.244        (zappo    23-Jan-98):   (let ((from nil))
1.244        (zappo    23-Jan-98):     (save-excursion
1.244        (zappo    23-Jan-98):       (set-buffer buffer)
1.244        (zappo    23-Jan-98):       (goto-char (point-min))
1.244        (zappo    23-Jan-98):       (if (not (re-search-forward "^Reply-To: " nil t))
1.244        (zappo    23-Jan-98): 	  (if (not (re-search-forward "^From:? " nil t))
1.244        (zappo    23-Jan-98): 	      (setq from t)))
1.244        (zappo    23-Jan-98):       (if from
1.244        (zappo    23-Jan-98): 	  nil
1.244        (zappo    23-Jan-98): 	(setq from (buffer-substring (point) (save-excursion
1.244        (zappo    23-Jan-98): 					       (end-of-line)
1.244        (zappo    23-Jan-98): 					       (point))))))
1.244        (zappo    23-Jan-98):     (goto-char (point-min))
1.244        (zappo    23-Jan-98):     (if (and (looking-at "Reply to:")
1.244        (zappo    23-Jan-98): 	     (equal from rmail-speedbar-last-user))
1.244        (zappo    23-Jan-98): 	nil
1.244        (zappo    23-Jan-98):       (setq rmail-speedbar-last-user from)
1.244        (zappo    23-Jan-98):       (erase-buffer)
1.244        (zappo    23-Jan-98):       (insert "Reply To:\n")
1.244        (zappo    23-Jan-98):       (if (stringp from)
1.244        (zappo    23-Jan-98): 	  (speedbar-insert-button from 'speedbar-directory-face 'highlight
1.244        (zappo    23-Jan-98): 				  'rmail-speedbar-button 'rmail-reply))
1.244        (zappo    23-Jan-98):       (insert "Folders:\n")
1.244        (zappo    23-Jan-98):       (let* ((case-fold-search nil)
1.244        (zappo    23-Jan-98): 	     (df (directory-files (save-excursion (set-buffer buffer)
1.244        (zappo    23-Jan-98): 						  default-directory)
1.281        (kwzh     10-Jul-98): 				  nil rmail-speedbar-match-folder-regexp)))
1.244        (zappo    23-Jan-98): 	(while df
1.244        (zappo    23-Jan-98): 	  (speedbar-insert-button "<M>" 'speedbar-button-face 'highlight
1.244        (zappo    23-Jan-98): 				  'rmail-speedbar-move-message (car df))
1.244        (zappo    23-Jan-98): 	  (speedbar-insert-button (car df) 'speedbar-file-face 'highlight
1.244        (zappo    23-Jan-98): 				  'rmail-speedbar-find-file nil t)
1.244        (zappo    23-Jan-98): 	  (setq df (cdr df)))))))
1.244        (zappo    23-Jan-98): 
1.244        (zappo    23-Jan-98): (defun rmail-speedbar-button (text token indent)
1.244        (zappo    23-Jan-98):   "Execute an rmail command specified by TEXT.
1.244        (zappo    23-Jan-98): The command used is TOKEN.  INDENT is not used."
1.244        (zappo    23-Jan-98):   (speedbar-with-attached-buffer
1.244        (zappo    23-Jan-98):    (funcall token t)))
1.244        (zappo    23-Jan-98): 
1.244        (zappo    23-Jan-98): (defun rmail-speedbar-find-file (text token indent)
1.244        (zappo    23-Jan-98):   "Load in the rmail file TEXT.
1.244        (zappo    23-Jan-98): TOKEN and INDENT are not used."
1.244        (zappo    23-Jan-98):   (speedbar-with-attached-buffer
1.244        (zappo    23-Jan-98):    (message "Loading in RMAIL file %s..." text)
1.244        (zappo    23-Jan-98):    (find-file text)))
1.244        (zappo    23-Jan-98): 
1.281        (kwzh     10-Jul-98): (defun rmail-speedbar-move-message-to-folder-on-line ()
1.244        (zappo    23-Jan-98):   "If the current line is a folder, move current message to it."
1.244        (zappo    23-Jan-98):   (interactive)
1.244        (zappo    23-Jan-98):   (save-excursion
1.244        (zappo    23-Jan-98):     (beginning-of-line)
1.244        (zappo    23-Jan-98):     (if (re-search-forward "<M> " (save-excursion (end-of-line) (point)) t)
1.244        (zappo    23-Jan-98): 	(progn
1.244        (zappo    23-Jan-98): 	  (forward-char -2)
1.244        (zappo    23-Jan-98): 	  (speedbar-do-function-pointer)))))
1.244        (zappo    23-Jan-98): 
1.244        (zappo    23-Jan-98): (defun rmail-speedbar-move-message (text token indent)
1.244        (zappo    23-Jan-98):   "From button TEXT, copy current message to the rmail file specified by TOKEN.
1.244        (zappo    23-Jan-98): TEXT and INDENT are not used."
1.244        (zappo    23-Jan-98):   (speedbar-with-attached-buffer
1.244        (zappo    23-Jan-98):    (message "Moving message to %s" token)
1.244        (zappo    23-Jan-98):    (rmail-output-to-rmail-file token)))
1.244        (zappo    23-Jan-98): 
1.282        (rms      27-Jul-98): ; Functions for setting, getting and encoding the POP password.
1.282        (rms      27-Jul-98): ; The password is encoded to prevent it from being easily accessible
1.282        (rms      27-Jul-98): ; to "prying eyes."  Obviously, this encoding isn't "real security,"
1.282        (rms      27-Jul-98): ; nor is it meant to be.
1.282        (rms      27-Jul-98): 
1.282        (rms      27-Jul-98): ;;;###autoload
1.395        (eliz     15-Jan-05): (defun rmail-set-remote-password (password)
1.395        (eliz     15-Jan-05):   "Set PASSWORD to be used for retrieving mail from a POP or IMAP server."
1.282        (rms      27-Jul-98):   (interactive "sPassword: ")
1.282        (rms      27-Jul-98):   (if password
1.395        (eliz     15-Jan-05):       (setq rmail-encoded-remote-password
1.282        (rms      27-Jul-98): 	    (rmail-encode-string password (emacs-pid)))
1.395        (eliz     15-Jan-05):     (setq rmail-remote-password nil)
1.395        (eliz     15-Jan-05):     (setq rmail-encoded-remote-password nil)))
1.282        (rms      27-Jul-98): 
1.395        (eliz     15-Jan-05): (defun rmail-get-remote-password (imap)
1.395        (eliz     15-Jan-05):   "Get the password for retrieving mail from a POP or IMAP server.  If none
1.282        (rms      27-Jul-98): has been set, then prompt the user for one."
1.395        (eliz     15-Jan-05):   (when (not rmail-encoded-remote-password)
1.395        (eliz     15-Jan-05):     (if (not rmail-remote-password)
1.395        (eliz     15-Jan-05): 	(setq rmail-remote-password
1.395        (eliz     15-Jan-05): 	      (read-passwd (if imap
1.395        (eliz     15-Jan-05): 			       "IMAP password: "
1.395        (eliz     15-Jan-05): 			     "POP password: "))))
1.395        (eliz     15-Jan-05):     (rmail-set-remote-password rmail-remote-password)
1.395        (eliz     15-Jan-05):     (setq rmail-remote-password nil))
1.395        (eliz     15-Jan-05):   (rmail-encode-string rmail-encoded-remote-password (emacs-pid)))
1.282        (rms      27-Jul-98): 
1.282        (rms      27-Jul-98): (defun rmail-have-password ()
1.395        (eliz     15-Jan-05):   (or rmail-remote-password rmail-encoded-remote-password))
1.282        (rms      27-Jul-98): 
1.282        (rms      27-Jul-98): (defun rmail-encode-string (string mask)
1.282        (rms      27-Jul-98):  "Encode STRING with integer MASK, by taking the exclusive OR of the
1.282        (rms      27-Jul-98): lowest byte in the mask with the first character of string, the
1.282        (rms      27-Jul-98): second-lowest-byte with the second character of the string, etc.,
1.282        (rms      27-Jul-98): restarting at the lowest byte of the mask whenever it runs out.
1.282        (rms      27-Jul-98): Returns the encoded string.  Calling the function again with an
1.282        (rms      27-Jul-98): encoded string (and the same mask) will decode the string."
1.293        (rms      31-Dec-98):  (setq mask (abs mask))			; doesn't work if negative
1.358        (pot      06-May-02):  (let* ((string-vector (string-to-vector string)) (i 0)
1.282        (rms      27-Jul-98): 	(len (length string-vector)) (curmask mask) charmask)
1.282        (rms      27-Jul-98):    (while (< i len)
1.282        (rms      27-Jul-98):      (if (= curmask 0)
1.282        (rms      27-Jul-98): 	 (setq curmask mask))
1.282        (rms      27-Jul-98):      (setq charmask (% curmask 256))
1.282        (rms      27-Jul-98):      (setq curmask (lsh curmask -8))
1.282        (rms      27-Jul-98):      (aset string-vector i (logxor charmask (aref string-vector i)))
1.282        (rms      27-Jul-98):      (setq i (1+ i)))
1.282        (rms      27-Jul-98):    (concat string-vector)))
1.389        (lh       21-Apr-04): 
1.389        (lh       21-Apr-04): ;;;;  Desktop support
1.389        (lh       21-Apr-04): 
1.389        (lh       21-Apr-04): (defun rmail-restore-desktop-buffer (desktop-buffer-file-name
1.389        (lh       21-Apr-04):                                      desktop-buffer-name
1.389        (lh       21-Apr-04):                                      desktop-buffer-misc)
1.389        (lh       21-Apr-04):   "Restore an rmail buffer specified in a desktop file."
1.389        (lh       21-Apr-04):   (condition-case error
1.389        (lh       21-Apr-04):       (progn
1.389        (lh       21-Apr-04):         (rmail-input desktop-buffer-file-name)
1.389        (lh       21-Apr-04):         (if (eq major-mode 'rmail-mode)
1.389        (lh       21-Apr-04):             (current-buffer)
1.389        (lh       21-Apr-04):           rmail-buffer))
1.389        (lh       21-Apr-04):     (file-locked
1.389        (lh       21-Apr-04):       (kill-buffer (current-buffer))
1.389        (lh       21-Apr-04):       nil)))
1.409        (lh       10-Aug-05): 
1.412        (schwab   14-Aug-05): (add-to-list 'desktop-buffer-mode-handlers
1.412        (schwab   14-Aug-05): 	     '(rmail-mode . rmail-restore-desktop-buffer))
1.244        (zappo    23-Jan-98): 
1.9          (jimb     16-Mar-92): (provide 'rmail)
1.9          (jimb     16-Mar-92): 
1.453        (monnier  10-Apr-08): ;; arch-tag: cff0a950-57fe-4f73-a86e-91ff75afd06c
1.12         (eric     30-May-92): ;;; rmail.el ends here