annotate lisp/mail/rmail.el @ 1998:656f4297962e

(describe_syntax_1): Delete excess arg to describe_vector. (check_syntax_table): Delete excess arg to wrong_type_argument. (Fforward_comment): New function.
author Richard M. Stallman <rms@gnu.org>
date Tue, 02 Mar 1993 17:21:05 +0000
parents 7e85913523ef
children 3f64e7ba7fdd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 621
diff changeset
1 ;;; rmail.el --- main code of "RMAIL" mail reader for Emacs.
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 621
diff changeset
2
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 830
diff changeset
3 ;; Copyright (C) 1985, 1986, 1987, 1988, 1991, 1992 Free Software Foundation, Inc.
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 830
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
5 ;; Maintainer: FSF
814
38b2499cb3e9 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 813
diff changeset
6 ;; Keywords: mail
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
7
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
9
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
13 ;; any later version.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
14
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
19
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
23
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 658
diff changeset
24 ;;; Code:
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
25
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
26 ;; Souped up by shane@mit-ajax based on ideas of rlk@athena.mit.edu
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
27 ;; New features include attribute and keyword support, message
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
28 ;; selection by dispatch table, summary by attributes and keywords,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
29 ;; expunging by dispatch table, sticky options for file commands.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
30
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
31 (require 'mail-utils)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
32 ; These variables now declared paths.el
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
33 ;(defvar rmail-spool-directory "/usr/spool/mail/"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
34 ; "This is the name of the directory used by the system mailer for\n\
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
35 ;delivering new mail. It's name should end with a slash.")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
36 ;(defvar rmail-file-name
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
37 ; (expand-file-name "~/RMAIL")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
38 ; "")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
39
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
40 ;;;###autoload
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
41 (defvar rmail-dont-reply-to-names nil "\
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
42 *A regexp specifying names to prune of reply to messages.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
43 nil means dont reply to yourself.")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
44
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
45 ;;;###autoload
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
46 (defvar rmail-default-dont-reply-to-names "info-" "\
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
47 A regular expression specifying part of the value of the default value of
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
48 the variable `rmail-dont-reply-to-names', for when the user does not set
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
49 `rmail-dont-reply-to-names' explicitly. (The other part of the default
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
50 value is the user's name.)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
51 It is useful to set this variable in the site customisation file.")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
52
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
53 ;;;###autoload
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
54 (defvar rmail-ignored-headers "^via:\\|^mail-from:\\|^origin:\\|^status:\\|^received:\\|^message-id:\\|^summary-line:" "\
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
55 *Gubbish headers one would rather not see.")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
56
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
57 ;;;###autoload
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
58 (defvar rmail-delete-after-output nil "\
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
59 *Non-nil means automatically delete a message that is copied to a file.")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
60
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
61 ;;;###autoload
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
62 (defconst rmail-primary-inbox-list nil "\
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
63 *List of files which are inboxes for user's primary mail file ~/RMAIL.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
64 `nil' means the default, which is (\"/usr/spool/mail/$USER\" \"~/mbox\")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
65 \(the first name varies depending on the operating system,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
66 and the value of the environment variable MAIL overrides it).")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
67
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
68 ;; these may be altered by site-init.el to match the format of mmdf files
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
69 ;; delimitation used on a given host (delim1 and delim2 from the config
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
70 ;; files)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
71
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
72 (defvar mmdf-delim1 "^\001\001\001\001\n"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
73 "Regexp marking the start of an mmdf message")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
74 (defvar mmdf-delim2 "^\001\001\001\001\n"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
75 "Regexp marking the end of an mmdf message")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
76
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
77 (defvar rmail-message-filter nil
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
78 "If non nil, is a filter function for new headers in RMAIL.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
79 Called with region narrowed to unformatted header.")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
80
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
81 (defvar rmail-mode-map nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
82
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
83 (defvar rmail-inbox-list nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
84 (defvar rmail-keywords nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
85
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
86 ;; Message counters and markers. Deleted flags.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
87
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
88 (defvar rmail-current-message nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
89 (defvar rmail-total-messages nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
90 (defvar rmail-message-vector nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
91 (defvar rmail-deleted-vector nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
92
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
93 ;; These are used by autoloaded rmail-summary.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
94
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
95 (defvar rmail-summary-buffer nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
96 (defvar rmail-summary-vector nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
97
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
98 ;; `Sticky' default variables.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
99
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
100 ;; Last individual label specified to a or k.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
101 (defvar rmail-last-label nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
102 ;; Last set of labels specified to C-M-n or C-M-p or C-M-l.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
103 (defvar rmail-last-multi-labels nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
104 (defvar rmail-last-file nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
105 (defvar rmail-last-rmail-file nil)
617
cde1f15848c6 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
106
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 617
diff changeset
107 ;;; Regexp matching the delimiter of messages in UNIX mail format
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 617
diff changeset
108 ;;; (UNIX From lines), minus the initial ^. Note that if you change
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 617
diff changeset
109 ;;; this expression, you must change the code in rmail-nuke-pinhead-header
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 617
diff changeset
110 ;;; that knows the exact ordering of the \\( \\) subexpressions.
617
cde1f15848c6 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
111 (defvar rmail-unix-mail-delimiter
1112
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
112 (let ((time-zone-regexp
1704
7e1897c2951b * rmail.el (rmail-unix-mail-delimiter): Not all time zone names
Jim Blandy <jimb@redhat.com>
parents: 1464
diff changeset
113 (concat "\\([A-Z]?[A-Z][A-Z][A-Z]\\( DST\\)?"
1112
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
114 "\\|[-+]?[0-9][0-9][0-9][0-9]"
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
115 "\\|"
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
116 "\\) *")))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
117 (concat
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
118 "From "
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
119
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
120 ;; Username, perhaps with a quoted section that can contain spaces.
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
121 "\\("
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
122 "[^ \n]*"
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
123 "\\(\\|\".*\"[^ \n]*\\)"
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
124 "\\) ?"
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
125
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
126 ;; The time the message was sent.
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
127 "\\([^ \n]*\\) *" ; day of the week
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
128 "\\([^ ]*\\) *" ; month
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
129 "\\([0-9]*\\) *" ; day of month
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
130 "\\([0-9:]*\\) *" ; time of day
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
131
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
132 ;; Perhaps a time zone, specified by an abbreviation, or by a
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
133 ;; numeric offset.
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
134 time-zone-regexp
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
135
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
136 ;; The year.
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
137 " [0-9][0-9]\\([0-9]*\\) *"
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
138
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
139 ;; On some systems the time zone can appear after the year, too.
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
140 time-zone-regexp
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
141
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
142 ;; I'm not sure what this is.
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
143 "\\(remote from [^\n]*\\)?"
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
144
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
145 "\n"))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
146 nil)
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
147
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
148
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
149
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
150 ;;;; *** Rmail Mode ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
151
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
152 ;;;###autoload
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
153 (defun rmail (&optional file-name-arg)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
154 "Read and edit incoming mail.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
155 Moves messages into file named by rmail-file-name (a babyl format file)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
156 and edits that file in RMAIL Mode.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
157 Type \\[describe-mode] once editing that file, for a list of RMAIL commands.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
158
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
159 May be called with filename as argument; then performs rmail editing on
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
160 that file, but does not copy any new mail into the file."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
161 (interactive (if current-prefix-arg
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
162 (list (read-file-name "Run rmail on RMAIL file: "
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
163 nil nil t))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
164 (or rmail-last-file
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
165 (setq rmail-last-file (expand-file-name "~/xmail")))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
166 (or rmail-last-rmail-file
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
167 (setq rmail-last-rmail-file (expand-file-name "~/XMAIL")))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
168 (let* ((file-name (expand-file-name (or file-name-arg rmail-file-name)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
169 (existed (get-file-buffer file-name)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
170 ;; Like find-file, but in the case where a buffer existed
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
171 ;; and the file was reverted, recompute the message-data.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
172 (if (and existed (not (verify-visited-file-modtime existed)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
173 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
174 ;; Don't be confused by apparent local-variables spec
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
175 ;; in the last message in the RMAIL file.
1024
ceb4469d3cd7 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 997
diff changeset
176 (let ((enable-local-variables nil))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
177 (find-file file-name))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
178 (if (verify-visited-file-modtime existed)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
179 (progn (rmail-forget-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
180 (rmail-set-message-counters))))
1024
ceb4469d3cd7 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 997
diff changeset
181 (let ((enable-local-variables nil))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
182 (find-file file-name)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
183 (if (and existed (> (buffer-size) 0))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
184 ;; Buffer not new and not empty; ensure in proper mode, but that's all.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
185 (or (eq major-mode 'rmail-mode)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
186 (rmail-mode-2))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
187 (rmail-mode-2)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
188 ;; Provide default set of inboxes for primary mail file ~/RMAIL.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
189 (and (null rmail-inbox-list)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
190 (null file-name-arg)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
191 (setq rmail-inbox-list
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
192 (or rmail-primary-inbox-list
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
193 (list "~/mbox"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
194 (or (getenv "MAIL")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
195 (concat rmail-spool-directory
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
196 (user-original-login-name)))))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
197 ;; Convert all or part to Babyl file if possible.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
198 (rmail-convert-file)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
199 (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
200 (if (null rmail-inbox-list)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
201 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
202 (rmail-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
203 (rmail-show-message))))
1342
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
204 (let ((existing-unseen (rmail-first-unseen-message)))
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
205 (rmail-get-new-mail)
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
206 ;; Show the first unseen message, which might be from a previous session
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
207 ;; or might have been just read in by rmail-get-new-mail. Must
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
208 ;; determine already unseen messages first, as rmail-get-new-mail
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
209 ;; positions on the first new messsage, thus marking it as seen.
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
210 (rmail-show-message existing-unseen))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
211
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
212 ;; Given the value of MAILPATH, return a list of inbox file names.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
213 ;; This is turned off because it is not clear that the user wants
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
214 ;; all these inboxes to feed into the primary rmail file.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
215 ; (defun rmail-convert-mailpath (string)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
216 ; (let (idx list)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
217 ; (while (setq idx (string-match "[%:]" string))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
218 ; (let ((this (substring string 0 idx)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
219 ; (setq string (substring string (1+ idx)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
220 ; (setq list (cons (if (string-match "%" this)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
221 ; (substring this 0 (string-match "%" this))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
222 ; this)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
223 ; list))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
224 ; list))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
225
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
226 ; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
227 ; will not cause emacs 18.55 problems.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
228
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
229 (defun rmail-convert-file ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
230 (let (convert)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
231 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
232 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
233 ;; If file doesn't start like a Babyl file,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
234 ;; convert it to one, by adding a header and converting each message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
235 (cond ((looking-at "BABYL OPTIONS:"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
236 ((looking-at "Version: 5\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
237 ;; Losing babyl file made by old version of Rmail.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
238 ;; Just fix the babyl file header; don't make a new one,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
239 ;; so we don't lose the Labels: file attribute, etc.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
240 (let ((buffer-read-only nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
241 (insert "BABYL OPTIONS: -*- rmail -*-\n")))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
242 (t
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
243 (setq convert t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
244 (rmail-insert-rmail-file-header)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
245 ;; If file was not a Babyl file or if there are
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
246 ;; Unix format messages added at the end,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
247 ;; convert file as necessary.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
248 (if (or convert
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
249 (progn (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
250 (search-backward "\^_")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
251 (forward-char 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
252 (looking-at "\n*From ")))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
253 (let ((buffer-read-only nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
254 (message "Converting to Babyl format...")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
255 (narrow-to-region (point) (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
256 (rmail-convert-to-babyl-format)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
257 (message "Converting to Babyl format...done")))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
258
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
259 ; I have checked that adding "-*- rmail -*-" to the BABYL OPTIONS line
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
260 ; will not cause emacs 18.55 problems.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
261
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
262 (defun rmail-insert-rmail-file-header ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
263 (let ((buffer-read-only nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
264 (insert "BABYL OPTIONS: -*- rmail -*-
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
265 Version: 5
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
266 Labels:
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
267 Note: This is the header of an rmail file.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
268 Note: If you are seeing it in rmail,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
269 Note: it means the file has no messages in it.\n\^_")))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
271 (if rmail-mode-map
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
272 nil
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
273 (setq rmail-mode-map (make-keymap))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
274 (suppress-keymap rmail-mode-map)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
275 (define-key rmail-mode-map "." 'rmail-beginning-of-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
276 (define-key rmail-mode-map " " 'scroll-up)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
277 (define-key rmail-mode-map "\177" 'scroll-down)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
278 (define-key rmail-mode-map "n" 'rmail-next-undeleted-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
279 (define-key rmail-mode-map "p" 'rmail-previous-undeleted-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
280 (define-key rmail-mode-map "\en" 'rmail-next-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
281 (define-key rmail-mode-map "\ep" 'rmail-previous-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
282 (define-key rmail-mode-map "\e\C-n" 'rmail-next-labeled-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
283 (define-key rmail-mode-map "\e\C-p" 'rmail-previous-labeled-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
284 (define-key rmail-mode-map "a" 'rmail-add-label)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
285 (define-key rmail-mode-map "k" 'rmail-kill-label)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
286 (define-key rmail-mode-map "d" 'rmail-delete-forward)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
287 (define-key rmail-mode-map "u" 'rmail-undelete-previous-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
288 (define-key rmail-mode-map "x" 'rmail-expunge)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
289 (define-key rmail-mode-map "s" 'rmail-expunge-and-save)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
290 (define-key rmail-mode-map "g" 'rmail-get-new-mail)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
291 (define-key rmail-mode-map "h" 'rmail-summary)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
292 (define-key rmail-mode-map "\e\C-h" 'rmail-summary)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
293 (define-key rmail-mode-map "l" 'rmail-summary-by-labels)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
294 (define-key rmail-mode-map "\e\C-l" 'rmail-summary-by-labels)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
295 (define-key rmail-mode-map "\e\C-r" 'rmail-summary-by-recipients)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
296 (define-key rmail-mode-map "\e\C-s" 'rmail-summary-by-regexp)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
297 (define-key rmail-mode-map "t" 'rmail-toggle-header)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
298 (define-key rmail-mode-map "m" 'rmail-mail)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
299 (define-key rmail-mode-map "r" 'rmail-reply)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
300 (define-key rmail-mode-map "\e\C-m" 'rmail-retry-failure)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
301 (define-key rmail-mode-map "c" 'rmail-continue)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
302 (define-key rmail-mode-map "f" 'rmail-forward)
1464
7f25b15a6809 (rmail-mode-map): Delete binding of M-r (use global one).
Richard M. Stallman <rms@gnu.org>
parents: 1382
diff changeset
303 ;; I find I can't live without the default M-r command -- rms.
7f25b15a6809 (rmail-mode-map): Delete binding of M-r (use global one).
Richard M. Stallman <rms@gnu.org>
parents: 1382
diff changeset
304 ;; (define-key rmail-mode-map "\er" 'rmail-search-backwards)
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
305 (define-key rmail-mode-map "\es" 'rmail-search)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
306 (define-key rmail-mode-map "<" 'rmail-first-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
307 (define-key rmail-mode-map ">" 'rmail-last-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
308 (define-key rmail-mode-map "j" 'rmail-show-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
309 (define-key rmail-mode-map "o" 'rmail-output-to-rmail-file)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
310 (define-key rmail-mode-map "\C-o" 'rmail-output)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
311 (define-key rmail-mode-map "i" 'rmail-input)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
312 (define-key rmail-mode-map "q" 'rmail-quit)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
313 (define-key rmail-mode-map "?" 'describe-mode)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
314 (define-key rmail-mode-map "w" 'rmail-edit-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
315 (define-key rmail-mode-map "e" 'rmail-edit-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
316 (define-key rmail-mode-map "\C-d" 'rmail-delete-backward))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
317
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
318 ;; Rmail mode is suitable only for specially formatted data.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
319 (put 'rmail-mode 'mode-class 'special)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
320
1382
9b210c7d6c23 * rmail.el (rmail-mode): Make this autoload; we might find a file
Jim Blandy <jimb@redhat.com>
parents: 1372
diff changeset
321 ;;;###autoload
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
322 (defun rmail-mode ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
323 "Rmail Mode is used by \\<rmail-mode-map>\\[rmail] for editing Rmail files.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
324 All normal editing commands are turned off.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
325 Instead, these commands are available:
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
326
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
327 \\[rmail-beginning-of-message] Move point to front of this message (same as \\[beginning-of-buffer]).
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
328 \\[scroll-up] Scroll to next screen of this message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
329 \\[scroll-down] Scroll to previous screen of this message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
330 \\[rmail-next-undeleted-message] Move to Next non-deleted message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
331 \\[rmail-previous-undeleted-message] Move to Previous non-deleted message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
332 \\[rmail-next-message] Move to Next message whether deleted or not.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
333 \\[rmail-previous-message] Move to Previous message whether deleted or not.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
334 \\[rmail-first-message] Move to the first message in Rmail file.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
335 \\[rmail-last-message] Move to the last message in Rmail file.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
336 \\[rmail-show-message] Jump to message specified by numeric position in file.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
337 \\[rmail-search] Search for string and show message it is found in.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
338 \\[rmail-delete-forward] Delete this message, move to next nondeleted.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
339 \\[rmail-delete-backward] Delete this message, move to previous nondeleted.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
340 \\[rmail-undelete-previous-message] Undelete message. Tries current message, then earlier messages
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
341 till a deleted message is found.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
342 \\[rmail-expunge] Expunge deleted messages.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
343 \\[rmail-expunge-and-save] Expunge and save the file.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
344 \\[rmail-quit] Quit Rmail: expunge, save, then switch to another buffer.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
345 \\[save-buffer] Save without expunging.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
346 \\[rmail-get-new-mail] Move new mail from system spool directory or mbox into this file.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
347 \\[rmail-mail] Mail a message (same as \\[mail-other-window]).
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
348 \\[rmail-continue] Continue composing outgoing message started before.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
349 \\[rmail-reply] Reply to this message. Like m but initializes some fields.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
350 \\[rmail-retry-failure] Send this message again. Used on a mailer failure message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
351 \\[rmail-forward] Forward this message to another user.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
352 \\[rmail-output-to-rmail-file] Output this message to an Rmail file (append it).
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
353 \\[rmail-output] Output this message to a Unix-format mail file (append it).
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
354 \\[rmail-input] Input Rmail file. Run Rmail on that file.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
355 \\[rmail-add-label] Add label to message. It will be displayed in the mode line.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
356 \\[rmail-kill-label] Kill label. Remove a label from current message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
357 \\[rmail-next-labeled-message] Move to Next message with specified label
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
358 (label defaults to last one specified).
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
359 Standard labels: filed, unseen, answered, forwarded, deleted.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
360 Any other label is present only if you add it with `a'.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
361 \\[rmail-previous-labeled-message] Move to Previous message with specified label
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
362 \\[rmail-summary] Show headers buffer, with a one line summary of each message.
1078
15b4ed20e524 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1024
diff changeset
363 \\[rmail-summary-by-labels] Like \\[rmail-summary] only just messages with particular label(s) are summarized.
15b4ed20e524 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1024
diff changeset
364 \\[rmail-summary-by-recipients] Like \\[rmail-summary] only just messages with particular recipient(s) are summarized.
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
365 \\[rmail-toggle-header] Toggle header, show Rmail header if unformatted or vice versa.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
366 \\[rmail-edit-current-message] Edit the current message. \\[rmail-cease-edit] to return to Rmail."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
367 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
368 (rmail-mode-2)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
369 (rmail-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
370 (rmail-show-message))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
371
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
372 (defun rmail-mode-2 ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
373 (kill-all-local-variables)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
374 (rmail-mode-1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
375 (rmail-variables)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
376 (run-hooks 'rmail-mode-hook))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
377
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
378 (defun rmail-mode-1 ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
379 (setq major-mode 'rmail-mode)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
380 (setq mode-name "RMAIL")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
381 (setq buffer-read-only t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
382 ;; No need to auto save RMAIL files.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
383 (setq buffer-auto-save-file-name nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
384 (if (boundp 'mode-line-modified)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
385 (setq mode-line-modified "--- ")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
386 (setq mode-line-format
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
387 (cons "--- " (cdr (default-value 'mode-line-format)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
388 (use-local-map rmail-mode-map)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
389 (set-syntax-table text-mode-syntax-table)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
390 (setq local-abbrev-table text-mode-abbrev-table))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
391
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
392 (defun rmail-variables ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
393 (make-local-variable 'revert-buffer-function)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
394 (setq revert-buffer-function 'rmail-revert)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
395 (make-local-variable 'rmail-last-label)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
396 (make-local-variable 'rmail-deleted-vector)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
397 (make-local-variable 'rmail-summary-buffer)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
398 (make-local-variable 'rmail-summary-vector)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
399 (make-local-variable 'rmail-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
400 (make-local-variable 'rmail-total-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
401 (make-local-variable 'require-final-newline)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
402 (setq require-final-newline nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
403 (make-local-variable 'version-control)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
404 (setq version-control 'never)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
405 (make-local-variable 'file-precious-flag)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
406 (setq file-precious-flag t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
407 (make-local-variable 'rmail-message-vector)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
408 (make-local-variable 'rmail-last-file)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
409 (make-local-variable 'rmail-inbox-list)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
410 (setq rmail-inbox-list (rmail-parse-file-inboxes))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
411 (make-local-variable 'rmail-keywords)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
412 ;; this gets generated as needed
280
e6f9ccb230ad *** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents: 270
diff changeset
413 (setq rmail-keywords nil))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
414
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
415 ;; Handle M-x revert-buffer done in an rmail-mode buffer.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
416 (defun rmail-revert (arg noconfirm)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
417 (let (revert-buffer-function)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
418 ;; Call our caller again, but this time it does the default thing.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
419 (if (revert-buffer arg noconfirm)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
420 ;; If the user said "yes", and we changed something,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
421 ;; reparse the messages.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
422 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
423 (rmail-convert-file)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
424 (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
425 (rmail-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
426 (rmail-show-message)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
427
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
428 ;; Return a list of files from this buffer's Mail: option.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
429 ;; Does not assume that messages have been parsed.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
430 ;; Just returns nil if buffer does not look like Babyl format.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
431 (defun rmail-parse-file-inboxes ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
432 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
433 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
434 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
435 (goto-char 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
436 (cond ((looking-at "BABYL OPTIONS:")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
437 (search-forward "\n\^_" nil 'move)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
438 (narrow-to-region 1 (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
439 (goto-char 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
440 (if (search-forward "\nMail:" nil t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
441 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
442 (narrow-to-region (point) (progn (end-of-line) (point)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
443 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
444 (mail-parse-comma-list))))))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
445
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
446 (defun rmail-expunge-and-save ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
447 "Expunge and save RMAIL file."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
448 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
449 (rmail-expunge)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
450 (save-buffer))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
451
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
452 (defun rmail-quit ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
453 "Quit out of RMAIL."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
454 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
455 (rmail-expunge-and-save)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
456 ;; Don't switch to the summary buffer even if it was recently visible.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
457 (if rmail-summary-buffer
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
458 (bury-buffer rmail-summary-buffer))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
459 (let ((obuf (current-buffer)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
460 (switch-to-buffer (other-buffer))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
461 (bury-buffer obuf)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
462
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
463 ;;;###autoload
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
464 (defun rmail-input (filename)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
465 "Run RMAIL on file FILENAME."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
466 (interactive "FRun rmail on RMAIL file: ")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
467 (rmail filename))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
468
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
469
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
470 ;;;; *** Rmail input ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
471
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
472 ;; RLK feature not added in this version:
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
473 ;; argument specifies inbox file or files in various ways.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
474
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
475 (defun rmail-get-new-mail (&optional file-name)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
476 "Move any new mail from this RMAIL file's inbox files.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
477 The inbox files can be specified with the file's Mail: option. The
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
478 variable `rmail-primary-inbox-list' specifies the inboxes for your
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
479 primary RMAIL file if it has no Mail: option. These are normally your
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
480 ~/mbox and your /usr/spool/mail/$USER.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
481
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
482 You can also specify the file to get new mail from. In this case, the
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
483 file of new mail is not changed or deleted. Noninteractively, you can
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
484 pass the inbox file name as an argument. Interactively, a prefix
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
485 argument causes us to read a file name and use that file as the inbox."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
486 (interactive
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
487 (list (if current-prefix-arg
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
488 (read-file-name "Get new mail from file: "))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
489 (or (verify-visited-file-modtime (current-buffer))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
490 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
491 (find-file (buffer-file-name))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
492 (if (verify-visited-file-modtime (current-buffer))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
493 (rmail-forget-messages))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
494 (rmail-maybe-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
495 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
496 ;; Get rid of all undo records for this buffer.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
497 (or (eq buffer-undo-list t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
498 (setq buffer-undo-list nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
499 (unwind-protect
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
500 (let ((opoint (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
501 (new-messages 0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
502 (delete-files ())
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
503 ;; If buffer has not changed yet, and has not been saved yet,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
504 ;; don't replace the old backup file now.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
505 (make-backup-files (and make-backup-files (buffer-modified-p)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
506 (buffer-read-only nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
507 ;; Don't make undo records for what we do in getting mail.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
508 (buffer-undo-list t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
509 (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
510 (skip-chars-backward " \t\n") ; just in case of brain damage
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
511 (delete-region (point) (point-max)) ; caused by require-final-newline
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
512 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
513 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
514 (narrow-to-region (point) (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
515 ;; Read in the contents of the inbox files,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
516 ;; renaming them as necessary,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
517 ;; and adding to the list of files to delete eventually.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
518 (if file-name
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
519 (rmail-insert-inbox-text (list file-name) nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
520 (setq delete-files (rmail-insert-inbox-text rmail-inbox-list t)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
521 ;; Scan the new text and convert each message to babyl format.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
522 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
523 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
524 (setq new-messages (rmail-convert-to-babyl-format)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
525 (or (zerop new-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
526 (let (success)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
527 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
528 (search-backward "\n\^_")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
529 (narrow-to-region (point) (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
530 (goto-char (1+ (point-min)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
531 (rmail-count-new-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
532 (save-buffer)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
533 ;; Delete the old files, now that babyl file is saved.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
534 (while delete-files
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
535 (condition-case ()
1165
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
536 ;; First, try deleting.
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
537 (condition-case ()
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
538 (delete-file (car delete-files))
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
539 (file-error
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
540 ;; If we can't delete it, truncate it.
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
541 (write-region (point) (point) (car delete-files))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
542 (file-error nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
543 (setq delete-files (cdr delete-files)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
544 (if (= new-messages 0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
545 (progn (goto-char opoint)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
546 (if (or file-name rmail-inbox-list)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
547 (message "(No new mail has arrived)")))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
548 (message "%d new message%s read"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
549 new-messages (if (= 1 new-messages) "" "s"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
550 (and (boundp 'display-time-string)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
551 (string-match " Mail" display-time-string)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
552 (setq display-time-string
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
553 (concat
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
554 (substring display-time-string 0 (match-beginning 0))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
555 (substring display-time-string (match-end 0))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
556 (force-mode-line-update 'all))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
557 ;; Don't leave the buffer screwed up if we get a disk-full error.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
558 (rmail-show-message)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
559
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
560 (defun rmail-insert-inbox-text (files renamep)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
561 (let (file tofile delete-files movemail)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
562 (while files
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
563 (setq file (expand-file-name (substitute-in-file-name (car files)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
564 ;;>> un*x specific <<
813
f3706268745a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 807
diff changeset
565 ;; The "+" used to be "~", which is an extremely poor choice;
f3706268745a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 807
diff changeset
566 ;; it might accidentally be deleted when space is low
f3706268745a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 807
diff changeset
567 ;; (as happened to me!).
f3706268745a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 807
diff changeset
568 tofile (concat file "+"))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
569 ;; If getting from mail spool directory,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
570 ;; use movemail to move rather than just renaming,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
571 ;; so as to interlock with the mailer.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
572 (setq movemail (equal (file-name-directory file) rmail-spool-directory))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
573 (if movemail
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
574 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
575 (setq tofile (expand-file-name
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
576 ;; Generate name to move to from inbox name,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
577 ;; in case of multiple inboxes that need moving.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
578 (concat ".newmail-" (file-name-nondirectory file))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
579 (file-name-directory
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
580 (expand-file-name rmail-file-name))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
581 ;; On some systems, /usr/spool/mail/foo is a directory
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
582 ;; and the actual inbox is /usr/spool/mail/foo/foo.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
583 (if (file-directory-p file)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
584 (setq file (expand-file-name (user-original-login-name)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
585 file)))))
1161
5bfabf7de8e9 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1137
diff changeset
586 (if (or (and (file-exists-p tofile)
5bfabf7de8e9 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1137
diff changeset
587 (/= 0 (nth 7 (file-attributes tofile))))
5bfabf7de8e9 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1137
diff changeset
588 (and (file-exists-p file)
5bfabf7de8e9 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 1137
diff changeset
589 (/= 0 (nth 7 (file-attributes file)))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
590 (message "Getting mail from %s..." file))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
591 ;; Set TOFILE if have not already done so, and
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
592 ;; rename or copy the file FILE to TOFILE if and as appropriate.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
593 (cond ((not renamep)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
594 (setq tofile file))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
595 ((or (file-exists-p tofile) (not (file-exists-p file)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
596 nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
597 ((not movemail)
1165
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
598 (rename-file file tofile nil)
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
599 ;; Make the real inbox file empty.
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
600 ;; Leaving it deleted could cause lossage
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
601 ;; because mailers often won't create the file.
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
602 (condition-case ()
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
603 (write-region (point) (point) file)
8aa120c74487 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 1161
diff changeset
604 (file-error nil)))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
605 (t
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
606 (let ((errors nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
607 (unwind-protect
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
608 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
609 (setq errors (generate-new-buffer " *rmail loss*"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
610 (buffer-disable-undo errors)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
611 (call-process
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
612 (expand-file-name "movemail" exec-directory)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
613 nil errors nil file tofile)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
614 (if (not (buffer-modified-p errors))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
615 ;; No output => movemail won
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
616 nil
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
617 (set-buffer errors)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
618 (subst-char-in-region (point-min) (point-max)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
619 ?\n ?\ )
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
620 (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
621 (skip-chars-backward " \t")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
622 (delete-region (point) (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
623 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
624 (if (looking-at "movemail: ")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
625 (delete-region (point-min) (match-end 0)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
626 (beep t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
627 (message (concat "movemail: "
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
628 (buffer-substring (point-min)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
629 (point-max))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
630 (sit-for 3)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
631 nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
632 (if errors (kill-buffer errors))))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
633 ;; At this point, TOFILE contains the name to read:
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
634 ;; Either the alternate name (if we renamed)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
635 ;; or the actual inbox (if not renaming).
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
636 (if (file-exists-p tofile)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
637 (let (size)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
638 (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
639 (setq size (nth 1 (insert-file-contents tofile)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
640 (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
641 (or (= (preceding-char) ?\n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
642 (zerop size)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
643 (insert ?\n))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
644 (setq delete-files (cons tofile delete-files))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
645 (message "")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
646 (setq files (cdr files)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
647 delete-files))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
648
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
649 ;; the rmail-break-forwarded-messages feature is not implemented
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
650 (defun rmail-convert-to-babyl-format ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
651 (let ((count 0) start
402
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
652 (case-fold-search nil)
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
653 (invalid-input-resync
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
654 (function (lambda ()
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
655 (message "Invalid Babyl format in inbox!")
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
656 (sit-for 1)
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
657 ;; Try to get back in sync with a real message.
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
658 (if (re-search-forward
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
659 (concat mmdf-delim1 "\\|^From") nil t)
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
660 (beginning-of-line)
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
661 (goto-char (point-max)))))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
662 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
663 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
664 (while (not (eobp))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
665 (cond ((looking-at "BABYL OPTIONS:");Babyl header
402
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
666 (if (search-forward "\n\^_" nil t)
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
667 ;; If we find the proper terminator, delete through there.
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
668 (delete-region (point-min) (point))
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
669 (funcall invalid-input-resync)
405
698d5d6e8f8b *** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents: 403
diff changeset
670 (delete-region (point-min) (point))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
671 ;; Babyl format message
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
672 ((looking-at "\^L")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
673 (or (search-forward "\n\^_" nil t)
402
14485c6a56aa *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 346
diff changeset
674 (funcall invalid-input-resync))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
675 (setq count (1+ count))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
676 ;; Make sure there is no extra white space after the ^_
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
677 ;; at the end of the message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
678 ;; Narrowing will make sure that whatever follows the junk
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
679 ;; will be treated properly.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
680 (delete-region (point)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
681 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
682 (skip-chars-forward " \t\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
683 (point)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
684 (narrow-to-region (point) (point-max)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
685 ;;*** MMDF format
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
686 ((let ((case-fold-search t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
687 (looking-at mmdf-delim1))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
688 (let ((case-fold-search t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
689 (replace-match "\^L\n0, unseen,,\n*** EOOH ***\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
690 (setq start (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
691 (re-search-forward mmdf-delim2 nil t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
692 (replace-match "\^_"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
693 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
694 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
695 (narrow-to-region start (1- (point)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
696 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
697 (while (search-forward "\n\^_" nil t); single char "\^_"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
698 (replace-match "\n^_")))); 2 chars: "^" and "_"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
699 (narrow-to-region (point) (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
700 (setq count (1+ count)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
701 ;;*** Mail format
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
702 ((looking-at "^From ")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
703 (setq start (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
704 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
705 (rmail-nuke-pinhead-header)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
706 (if (re-search-forward
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
707 (concat "^[\^_]?\\("
617
cde1f15848c6 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
708 rmail-unix-mail-delimiter
cde1f15848c6 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
709 "\\|"
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
710 mmdf-delim1 "\\|"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
711 "^BABYL OPTIONS:\\|"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
712 "\^L\n[01],\\)") nil t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
713 (goto-char (match-beginning 1))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
714 (goto-char (point-max)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
715 (setq count (1+ count))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
716 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
717 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
718 (narrow-to-region start (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
719 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
720 (while (search-forward "\n\^_" nil t); single char
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
721 (replace-match "\n^_")))); 2 chars: "^" and "_"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
722 (insert ?\^_)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
723 (narrow-to-region (point) (point-max)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
724 ;;
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
725 ;;This is a kludge, in case we're wrong about mmdf not
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
726 ;;allowing anything in between. If it loses, we'll have
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
727 ;;to look for something else
405
698d5d6e8f8b *** empty log message ***
Michael I. Bushnell <mib@gnu.org>
parents: 403
diff changeset
728 (t (error "Cannot convert to babyl format")))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
729 count))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
730
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
731 ;; Delete the "From ..." line, creating various other headers with
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
732 ;; information from it if they don't already exist. Now puts the
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
733 ;; original line into a mail-from: header line for debugging.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
734 (defun rmail-nuke-pinhead-header ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
735 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
736 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
737 (let ((start (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
738 (end (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
739 (condition-case ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
740 (search-forward "\n\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
741 (error
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
742 (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
743 (insert "\n\n")))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
744 (point)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
745 has-from has-date)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
746 (narrow-to-region start end)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
747 (let ((case-fold-search t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
748 (goto-char start)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
749 (setq has-from (search-forward "\nFrom:" nil t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
750 (goto-char start)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
751 (setq has-date (and (search-forward "\nDate:" nil t) (point)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
752 (goto-char start))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
753 (let ((case-fold-search nil))
617
cde1f15848c6 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 584
diff changeset
754 (if (re-search-forward (concat "^" rmail-unix-mail-delimiter) nil t)
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
755 (replace-match
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
756 (concat
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
757 "Mail-from: \\&"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
758 ;; Keep and reformat the date if we don't
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
759 ;; have a Date: field.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
760 (if has-date
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
761 ""
1112
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
762 (concat
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
763 "Date: \\3, \\5 \\4 \\9 \\6 "
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
764
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
765 ;; The timezone could be matched by group 7 or group 10.
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
766 ;; If neither of them matched, assume EST, since only
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
767 ;; Easterners would be so sloppy.
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
768 ;; It's a shame the substitution can't use "\\10".
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
769 (cond
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
770 ((/= (match-beginning 7) (match-end 7)) "\\7")
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
771 ((/= (match-beginning 10) (match-end 10))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
772 (buffer-substring (match-beginning 10)
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
773 (match-end 10)))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
774 (t "EST"))
1dba066c1e0a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 1078
diff changeset
775 "\n"))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
776 ;; Keep and reformat the sender if we don't
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
777 ;; have a From: field.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
778 (if has-from
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
779 ""
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
780 "From: \\1\n")))))))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
781
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
782 ;;;; *** Rmail Message Formatting and Header Manipulation ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
783
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
784 (defun rmail-reformat-message (beg end)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
785 (goto-char beg)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
786 (forward-line 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
787 (if (/= (following-char) ?0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
788 (error "Bad format in RMAIL file."))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
789 (let ((buffer-read-only nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
790 (delta (- (buffer-size) end)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
791 (delete-char 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
792 (insert ?1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
793 (forward-line 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
794 (if (looking-at "Summary-line: ")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
795 (forward-line 1))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
796 (if (looking-at "\\*\\*\\* EOOH \\*\\*\\*\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
797 (delete-region (point)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
798 (progn (forward-line 1) (point))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
799 (let ((str (buffer-substring (point)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
800 (save-excursion (search-forward "\n\n" end 'move)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
801 (point)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
802 (insert str "*** EOOH ***\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
803 (narrow-to-region (point) (- (buffer-size) delta)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
804 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
805 (if rmail-ignored-headers (rmail-clear-headers))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
806 (if rmail-message-filter (funcall rmail-message-filter))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
807
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
808 (defun rmail-clear-headers ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
809 (if (search-forward "\n\n" nil t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
810 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
811 (narrow-to-region (point-min) (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
812 (let ((buffer-read-only nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
813 (while (let ((case-fold-search t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
814 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
815 (re-search-forward rmail-ignored-headers nil t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
816 (beginning-of-line)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
817 (delete-region (point)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
818 (progn (re-search-forward "\n[^ \t]")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
819 (forward-char -1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
820 (point))))))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
821
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
822 (defun rmail-toggle-header ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
823 "Show original message header if pruned header currently shown, or vice versa."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
824 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
825 (rmail-maybe-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
826 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
827 (let ((buffer-read-only nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
828 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
829 (forward-line 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
830 (if (= (following-char) ?1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
831 (progn (delete-char 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
832 (insert ?0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
833 (forward-line 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
834 (if (looking-at "Summary-Line:")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
835 (forward-line 1))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
836 (insert "*** EOOH ***\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
837 (forward-char -1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
838 (search-forward "\n*** EOOH ***\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
839 (forward-line -1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
840 (let ((temp (point)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
841 (and (search-forward "\n\n" nil t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
842 (delete-region temp (point))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
843 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
844 (search-forward "\n*** EOOH ***\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
845 (narrow-to-region (point) (point-max)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
846 (rmail-reformat-message (point-min) (point-max)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
847
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
848 ;;;; *** Rmail Attributes and Keywords ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
849
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
850 ;; Make a string describing current message's attributes and keywords
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
851 ;; and set it up as the name of a minor mode
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
852 ;; so it will appear in the mode line.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
853 (defun rmail-display-labels ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
854 (let ((blurb "") (beg (point-min-marker)) (end (point-max-marker)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
855 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
856 (unwind-protect
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
857 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
858 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
859 (goto-char (rmail-msgbeg rmail-current-message))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
860 (forward-line 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
861 (if (looking-at "[01],")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
862 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
863 (narrow-to-region (point) (progn (end-of-line) (point)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
864 ;; Truly valid BABYL format requires a space before each
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
865 ;; attribute or keyword name. Put them in if missing.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
866 (let (buffer-read-only)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
867 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
868 (while (search-forward "," nil t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
869 (or (looking-at "[ ,]") (eobp)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
870 (insert " "))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
871 (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
872 (if (search-backward ",," nil 'move)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
873 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
874 (if (> (point) (1+ (point-min)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
875 (setq blurb (buffer-substring (+ 1 (point-min)) (point))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
876 (if (> (- (point-max) (point)) 2)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
877 (setq blurb
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
878 (concat blurb
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
879 ";"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
880 (buffer-substring (+ (point) 3)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
881 (1- (point-max)))))))))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
882 ;; Note: we don't use save-restriction because that does not work right
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
883 ;; if changes are made outside the saved restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
884 ;; before that restriction is restored.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
885 (narrow-to-region beg end)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
886 (set-marker beg nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
887 (set-marker end nil)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
888 (while (string-match " +," blurb)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
889 (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
890 (substring blurb (match-end 0)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
891 (while (string-match ", +" blurb)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
892 (setq blurb (concat (substring blurb 0 (match-beginning 0)) ","
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
893 (substring blurb (match-end 0)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
894 (setq mode-line-process
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
895 (concat " " rmail-current-message "/" rmail-total-messages
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
896 blurb))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
897
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
898 ;; Turn an attribute of a message on or off according to STATE.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
899 ;; ATTR is the name of the attribute, as a string.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
900 ;; MSGNUM is message number to change; nil means current message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
901 (defun rmail-set-attribute (attr state &optional msgnum)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
902 (let ((omax (point-max-marker))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
903 (omin (point-min-marker))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
904 (buffer-read-only nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
905 (or msgnum (setq msgnum rmail-current-message))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
906 (unwind-protect
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
907 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
908 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
909 (goto-char (+ 3 (rmail-msgbeg msgnum)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
910 (let ((curstate
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
911 (not
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
912 (null (search-backward (concat ", " attr ",")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
913 (prog1 (point) (end-of-line)) t)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
914 (or (eq curstate (not (not state)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
915 (if curstate
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
916 (delete-region (point) (1- (match-end 0)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
917 (beginning-of-line)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
918 (forward-char 2)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
919 (insert " " attr ","))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
920 (if (string= attr "deleted")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
921 (rmail-set-message-deleted-p msgnum state)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
922 ;; Note: we don't use save-restriction because that does not work right
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
923 ;; if changes are made outside the saved restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
924 ;; before that restriction is restored.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
925 (narrow-to-region omin omax)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
926 (set-marker omin nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
927 (set-marker omax nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
928 (if (= msgnum rmail-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
929 (rmail-display-labels)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
930
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
931 ;; Return t if the attributes/keywords line of msg number MSG
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
932 ;; contains a match for the regexp LABELS.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
933 (defun rmail-message-labels-p (msg labels)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
934 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
935 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
936 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
937 (goto-char (rmail-msgbeg msg))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
938 (forward-char 3)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
939 (re-search-backward labels (prog1 (point) (end-of-line)) t))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
940
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
941 ;;;; *** Rmail Message Selection And Support ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
942
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
943 (defun rmail-msgend (n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
944 (marker-position (aref rmail-message-vector (1+ n))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
945
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
946 (defun rmail-msgbeg (n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
947 (marker-position (aref rmail-message-vector n)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
948
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
949 (defun rmail-widen-to-current-msgbeg (function)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
950 "Call FUNCTION with point at start of internal data of current message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
951 Assumes that bounds were previously narrowed to display the message in Rmail.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
952 The bounds are widened enough to move point where desired, then narrowed
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
953 again afterward.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
954
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
955 FUNCTION may not change the visible text of the message, but it may
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
956 change the invisible header text."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
957 (save-excursion
344
057b6b26930e *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 280
diff changeset
958 (let ((obeg (- (point-max) (point-min))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
959 (unwind-protect
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
960 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
961 (narrow-to-region (rmail-msgbeg rmail-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
962 (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
963 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
964 (funcall function))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
965 ;; Note: we don't use save-restriction because that does not work right
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
966 ;; if changes are made outside the saved restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
967 ;; before that restriction is restored.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
968 ;; Here we assume that changes made by FUNCTION
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
969 ;; occur before the visible region of the message.
344
057b6b26930e *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 280
diff changeset
970 (narrow-to-region (- (point-max) obeg) (point-max))))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
971
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
972 (defun rmail-forget-messages ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
973 (unwind-protect
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
974 (if (vectorp rmail-message-vector)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
975 (let* ((i 0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
976 (v rmail-message-vector)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
977 (n (length v)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
978 (while (< i n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
979 (move-marker (aref v i) nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
980 (setq i (1+ i)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
981 (setq rmail-message-vector nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
982 (setq rmail-deleted-vector nil)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
983
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
984 (defun rmail-maybe-set-message-counters ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
985 (if (not (and rmail-deleted-vector
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
986 rmail-message-vector
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
987 rmail-current-message
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
988 rmail-total-messages))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
989 (rmail-set-message-counters)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
990
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
991 (defun rmail-count-new-messages (&optional nomsg)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
992 (let* ((case-fold-search nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
993 (total-messages 0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
994 (messages-head nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
995 (deleted-head nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
996 (or nomsg (message "Counting new messages..."))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
997 (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
998 ;; Put at the end of messages-head
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
999 ;; the entry for message N+1, which marks
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1000 ;; the end of message N. (N = number of messages).
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1001 (search-backward "\n\^_")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1002 (forward-char 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1003 (setq messages-head (list (point-marker)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1004 (rmail-set-message-counters-counter (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1005 (setq rmail-current-message (1+ rmail-total-messages))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1006 (setq rmail-total-messages
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1007 (+ rmail-total-messages total-messages))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1008 (setq rmail-message-vector
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1009 (vconcat rmail-message-vector (cdr messages-head)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1010 (aset rmail-message-vector
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1011 rmail-current-message (car messages-head))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1012 (setq rmail-deleted-vector
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1013 (concat rmail-deleted-vector deleted-head))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1014 (setq rmail-summary-vector
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1015 (vconcat rmail-summary-vector (make-vector total-messages nil)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1016 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1017 (or nomsg (message "Counting new messages...done (%d)" total-messages))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1018
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1019 (defun rmail-set-message-counters ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1020 (rmail-forget-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1021 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1022 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1023 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1024 (let* ((point-save (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1025 (total-messages 0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1026 (messages-after-point)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1027 (case-fold-search nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1028 (messages-head nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1029 (deleted-head nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1030 (message "Counting messages...")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1031 (goto-char (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1032 ;; Put at the end of messages-head
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1033 ;; the entry for message N+1, which marks
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1034 ;; the end of message N. (N = number of messages).
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1035 (search-backward "\n\^_")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1036 (forward-char 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1037 (setq messages-head (list (point-marker)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1038 (rmail-set-message-counters-counter (min (point) point-save))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1039 (setq messages-after-point total-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1040 (rmail-set-message-counters-counter)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1041 (setq rmail-total-messages total-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1042 (setq rmail-current-message
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1043 (min total-messages
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1044 (max 1 (- total-messages messages-after-point))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1045 (setq rmail-message-vector
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1046 (apply 'vector (cons (point-min-marker) messages-head))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1047 rmail-deleted-vector (concat "D" deleted-head)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1048 rmail-summary-vector (make-vector rmail-total-messages nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1049 (message "Counting messages...done")))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1050
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1051 (defun rmail-set-message-counters-counter (&optional stop)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1052 (while (search-backward "\n\^_\^L\n" stop t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1053 (forward-char 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1054 (setq messages-head (cons (point-marker) messages-head))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1055 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1056 (setq deleted-head
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1057 (cons (if (search-backward ", deleted,"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1058 (prog1 (point)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1059 (forward-line 2))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1060 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1061 ?D ?\ )
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1062 deleted-head)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1063 (if (zerop (% (setq total-messages (1+ total-messages)) 20))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1064 (message "Counting messages...%d" total-messages))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1065
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1066 (defun rmail-beginning-of-message ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1067 "Show current message starting from the beginning."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1068 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1069 (rmail-show-message rmail-current-message))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1070
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1071 (defun rmail-show-message (&optional n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1072 "Show message number N (prefix argument), counting from start of file."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1073 (interactive "p")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1074 (rmail-maybe-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1075 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1076 (if (zerop rmail-total-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1077 (progn (narrow-to-region (point-min) (1- (point-max)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1078 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1079 (setq mode-line-process nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1080 (let (blurb)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1081 (if (not n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1082 (setq n rmail-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1083 (cond ((<= n 0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1084 (setq n 1
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1085 rmail-current-message 1
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1086 blurb "No previous message"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1087 ((> n rmail-total-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1088 (setq n rmail-total-messages
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1089 rmail-current-message rmail-total-messages
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1090 blurb "No following message"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1091 (t
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1092 (setq rmail-current-message n))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1093 (let ((beg (rmail-msgbeg n))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1094 (end (rmail-msgend n)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1095 (goto-char beg)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1096 (forward-line 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1097 (if (= (following-char) ?0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1098 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1099 (rmail-reformat-message beg end)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1100 (rmail-set-attribute "unseen" nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1101 (search-forward "\n*** EOOH ***\n" end t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1102 (narrow-to-region (point) end))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1103 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1104 (rmail-display-labels)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1105 (run-hooks 'rmail-show-message-hook)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1106 (if blurb
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1107 (message blurb))))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1108
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1109 (defun rmail-next-message (n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1110 "Show following message whether deleted or not.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1111 With prefix arg N, moves forward N messages, or backward if N is negative."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1112 (interactive "p")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1113 (rmail-maybe-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1114 (rmail-show-message (+ rmail-current-message n)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1115
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1116 (defun rmail-previous-message (n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1117 "Show previous message whether deleted or not.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1118 With prefix arg N, moves backward N messages, or forward if N is negative."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1119 (interactive "p")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1120 (rmail-next-message (- n)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1121
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1122 (defun rmail-next-undeleted-message (n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1123 "Show following non-deleted message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1124 With prefix arg N, moves forward N non-deleted messages,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1125 or backward if N is negative."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1126 (interactive "p")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1127 (rmail-maybe-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1128 (let ((lastwin rmail-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1129 (current rmail-current-message))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1130 (while (and (> n 0) (< current rmail-total-messages))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1131 (setq current (1+ current))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1132 (if (not (rmail-message-deleted-p current))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1133 (setq lastwin current n (1- n))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1134 (while (and (< n 0) (> current 1))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1135 (setq current (1- current))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1136 (if (not (rmail-message-deleted-p current))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1137 (setq lastwin current n (1+ n))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1138 (if (/= lastwin rmail-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1139 (rmail-show-message lastwin))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1140 (if (< n 0)
997
894201c58bb8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 937
diff changeset
1141 (message "No previous nondeleted message"))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1142 (if (> n 0)
997
894201c58bb8 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 937
diff changeset
1143 (message "No following nondeleted message"))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1144
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1145 (defun rmail-previous-undeleted-message (n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1146 "Show previous non-deleted message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1147 With prefix argument N, moves backward N non-deleted messages,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1148 or forward if N is negative."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1149 (interactive "p")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1150 (rmail-next-undeleted-message (- n)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1151
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1152 (defun rmail-first-message ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1153 "Show first message in file."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1154 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1155 (rmail-maybe-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1156 (rmail-show-message 1))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1157
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1158 (defun rmail-last-message ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1159 "Show last message in file."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1160 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1161 (rmail-maybe-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1162 (rmail-show-message rmail-total-messages))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1163
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1164 (defun rmail-what-message ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1165 (let ((where (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1166 (low 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1167 (high rmail-total-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1168 (mid (/ rmail-total-messages 2)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1169 (while (> (- high low) 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1170 (if (>= where (rmail-msgbeg mid))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1171 (setq low mid)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1172 (setq high mid))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1173 (setq mid (+ low (/ (- high low) 2))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1174 (if (>= where (rmail-msgbeg high)) high low)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1175
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1176 (defvar rmail-search-last-regexp nil)
874
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1177 (defun rmail-search (regexp &optional n)
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1178 "Show message containing next match for REGEXP.
874
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1179 Prefix argument gives repeat count; negative argument means search
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1180 backwards (through earlier messages).
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1181 Interactively, empty argument means use same regexp used last time."
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1182 (interactive
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1183 (let* ((reversep (< (prefix-numeric-value current-prefix-arg) 0))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1184 (prompt
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1185 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1186 regexp)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1187 (if rmail-search-last-regexp
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1188 (setq prompt (concat prompt
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1189 "(default "
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1190 rmail-search-last-regexp
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1191 ") ")))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1192 (setq regexp (read-string prompt))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1193 (cond ((not (equal regexp ""))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1194 (setq rmail-search-last-regexp regexp))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1195 ((not rmail-search-last-regexp)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1196 (error "No previous Rmail search string")))
874
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1197 (list rmail-search-last-regexp
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1198 (prefix-numeric-value current-prefix-arg))))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1199 (or n (setq n 1))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1200 (message "%sRmail search for %s..."
937
0f082d63bfd6 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 874
diff changeset
1201 (if (< n 0) "Reverse " "")
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1202 regexp)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1203 (rmail-maybe-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1204 (let ((omin (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1205 (omax (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1206 (opoint (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1207 win
874
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1208 (reversep (< n 0))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1209 (msg rmail-current-message))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1210 (unwind-protect
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1211 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1212 (widen)
874
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1213 (while (/= n 0)
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1214 ;; Check messages one by one, advancing message number up or down
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1215 ;; but searching forward through each message.
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1216 (if reversep
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1217 (while (and (null win) (> msg 1))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1218 (goto-char (rmail-msgbeg (setq msg (1- msg))))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1219 (setq win (re-search-forward
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1220 regexp (rmail-msgend msg) t)))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1221 (while (and (null win) (< msg rmail-total-messages))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1222 (goto-char (rmail-msgbeg (setq msg (1+ msg))))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1223 (setq win (re-search-forward regexp (rmail-msgend msg) t))))
937
0f082d63bfd6 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 874
diff changeset
1224 (setq n (+ n (if reversep 1 -1)))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1225 (if win
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1226 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1227 ;; If this is a reverse search and we found a message,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1228 ;; search backward thru this message to position point.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1229 (if reversep
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1230 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1231 (goto-char (rmail-msgend msg))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1232 (re-search-backward
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1233 regexp (rmail-msgbeg msg) t)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1234 (setq win (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1235 (rmail-show-message msg)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1236 (message "%sRmail search for %s...done"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1237 (if reversep "Reverse " "")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1238 regexp)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1239 (goto-char win))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1240 (goto-char opoint)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1241 (narrow-to-region omin omax)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1242 (ding)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1243 (message "Search failed: %s" regexp)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1244
874
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1245 (defun rmail-search-backwards (regexp &optional n)
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1246 "Show message containing previous match for REGEXP.
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1247 Prefix argument gives repeat count; negative argument means search
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1248 forward (through later messages).
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1249 Interactively, empty argument means use same regexp used last time."
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1250 (interactive
937
0f082d63bfd6 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 874
diff changeset
1251 (let* ((reversep (>= (prefix-numeric-value current-prefix-arg) 0))
874
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1252 (prompt
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1253 (concat (if reversep "Reverse " "") "Rmail search (regexp): "))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1254 regexp)
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1255 (if rmail-search-last-regexp
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1256 (setq prompt (concat prompt
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1257 "(default "
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1258 rmail-search-last-regexp
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1259 ") ")))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1260 (setq regexp (read-string prompt))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1261 (cond ((not (equal regexp ""))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1262 (setq rmail-search-last-regexp regexp))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1263 ((not rmail-search-last-regexp)
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1264 (error "No previous Rmail search string")))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1265 (list rmail-search-last-regexp
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1266 (prefix-numeric-value current-prefix-arg))))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1267 (rmail-search regexp (- (or n -1))))
b945f592b94d *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 846
diff changeset
1268
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1269 ;; Show the first message which has the `unseen' attribute.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1270 (defun rmail-first-unseen-message ()
1360
9cb1a4b90b5c Cleaned up rmail-first-unseen-message.
Joseph Arceneaux <jla@gnu.org>
parents: 1342
diff changeset
1271 (rmail-maybe-set-message-counters)
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1272 (let ((current 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1273 found)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1274 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1275 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1276 (while (and (not found) (< current rmail-total-messages))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1277 (if (rmail-message-labels-p current ", ?\\(unseen\\),")
346
52cd078baf00 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 344
diff changeset
1278 (setq found current))
52cd078baf00 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 344
diff changeset
1279 (setq current (1+ current))))
1342
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
1280 ;; Let the caller show the message.
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
1281 ;; (if found
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
1282 ;; (rmail-show-message found))
776d4c59f256 * rmail.el (rmail-first-unseen-message): Don't show the message,
Joseph Arceneaux <jla@gnu.org>
parents: 1267
diff changeset
1283 found))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1284
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1285 ;;;; *** Rmail Message Deletion Commands ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1286
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1287 (defun rmail-message-deleted-p (n)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1288 (= (aref rmail-deleted-vector n) ?D))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1289
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1290 (defun rmail-set-message-deleted-p (n state)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1291 (aset rmail-deleted-vector n (if state ?D ?\ )))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1292
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1293 (defun rmail-delete-message ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1294 "Delete this message and stay on it."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1295 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1296 (rmail-set-attribute "deleted" t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1297
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1298 (defun rmail-undelete-previous-message ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1299 "Back up to deleted message, select it, and undelete it."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1300 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1301 (let ((msg rmail-current-message))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1302 (while (and (> msg 0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1303 (not (rmail-message-deleted-p msg)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1304 (setq msg (1- msg)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1305 (if (= msg 0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1306 (error "No previous deleted message")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1307 (if (/= msg rmail-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1308 (rmail-show-message msg))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1309 (rmail-set-attribute "deleted" nil))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1310
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1311 (defun rmail-delete-forward (&optional backward)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1312 "Delete this message and move to next nondeleted one.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1313 Deleted messages stay in the file until the \\[rmail-expunge] command is given.
819
5bbabfcef929 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 814
diff changeset
1314 With prefix argument, delete and move backward."
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1315 (interactive "P")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1316 (rmail-set-attribute "deleted" t)
830
d7f1e2db9faf *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 819
diff changeset
1317 (rmail-next-undeleted-message (if backward -1 1)))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1318
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1319 (defun rmail-delete-backward ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1320 "Delete this message and move to previous nondeleted one.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1321 Deleted messages stay in the file until the \\[rmail-expunge] command is given."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1322 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1323 (rmail-delete-forward t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1324
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1325 (defun rmail-expunge ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1326 "Actually erase all deleted messages in the file."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1327 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1328 (message "Expunging deleted messages...")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1329 ;; Discard all undo records for this buffer.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1330 (or (eq buffer-undo-list t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1331 (setq buffer-undo-list nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1332 (rmail-maybe-set-message-counters)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1333 (let* ((omax (- (buffer-size) (point-max)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1334 (omin (- (buffer-size) (point-min)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1335 (opoint (if (and (> rmail-current-message 0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1336 (= ?D (aref rmail-deleted-vector rmail-current-message)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1337 0 (- (point) (point-min))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1338 (messages-head (cons (aref rmail-message-vector 0) nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1339 (messages-tail messages-head)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1340 ;; Don't make any undo records for the expunging.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1341 (buffer-undo-list t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1342 (win))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1343 (unwind-protect
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1344 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1345 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1346 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1347 (let ((counter 0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1348 (number 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1349 (total rmail-total-messages)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1350 (new-message-number rmail-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1351 (new-summary nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1352 (buffer-read-only nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1353 (messages rmail-message-vector)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1354 (deleted rmail-deleted-vector)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1355 (summary rmail-summary-vector))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1356 (setq rmail-total-messages nil
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1357 rmail-current-message nil
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1358 rmail-message-vector nil
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1359 rmail-deleted-vector nil
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1360 rmail-summary-vector nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1361 (while (<= number total)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1362 (if (= (aref deleted number) ?D)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1363 (progn
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1364 (delete-region
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1365 (marker-position (aref messages number))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1366 (marker-position (aref messages (1+ number))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1367 (move-marker (aref messages number) nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1368 (if (> new-message-number counter)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1369 (setq new-message-number (1- new-message-number))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1370 (setq counter (1+ counter))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1371 (setq messages-tail
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1372 (setcdr messages-tail
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1373 (cons (aref messages number) nil)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1374 (setq new-summary
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1375 (cons (if (= counter number) (aref summary (1- number)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1376 new-summary)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1377 (if (zerop (% (setq number (1+ number)) 20))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1378 (message "Expunging deleted messages...%d" number)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1379 (setq messages-tail
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1380 (setcdr messages-tail
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1381 (cons (aref messages number) nil)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1382 (setq rmail-current-message new-message-number
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1383 rmail-total-messages counter
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1384 rmail-message-vector (apply 'vector messages-head)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1385 rmail-deleted-vector (make-string (1+ counter) ?\ )
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1386 rmail-summary-vector (vconcat (nreverse new-summary))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1387 win t)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1388 (message "Expunging deleted messages...done")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1389 (if (not win)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1390 (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1391 (rmail-show-message
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1392 (if (zerop rmail-current-message) 1 nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1393 (forward-char opoint))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1394
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1395 ;;;; *** Rmail Mailing Commands ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1396
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1397 (defun rmail-mail ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1398 "Send mail in another window. While composing the message, use
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1399 \\[mail-yank-original] to yank the original message into it."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1400 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1401 (mail-other-window nil nil nil nil nil (current-buffer)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1402
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1403 (defun rmail-continue ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1404 "Continue composing outgoing message previously being composed."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1405 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1406 (mail-other-window t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1407
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1408 (defun rmail-reply (just-sender)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1409 "Reply to the current message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1410 Normally include CC: to all other recipients of original message;
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1411 prefix argument means ignore them. While composing the reply,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1412 use \\[mail-yank-original] to yank the original message into it."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1413 (interactive "P")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1414 (let (from reply-to cc subject date to message-id resent-reply-to)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1415 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1416 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1417 (widen)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1418 (goto-char (rmail-msgbeg rmail-current-message))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1419 (forward-line 1)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1420 (if (= (following-char) ?0)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1421 (narrow-to-region
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1422 (progn (forward-line 2)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1423 (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1424 (progn (search-forward "\n\n" (rmail-msgend rmail-current-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1425 'move)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1426 (point)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1427 (narrow-to-region (point)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1428 (progn (search-forward "\n*** EOOH ***\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1429 (beginning-of-line) (point))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1430 (setq resent-reply-to (mail-fetch-field "resent-reply-to" t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1431 from (mail-fetch-field "from")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1432 reply-to (or resent-reply-to
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1433 (mail-fetch-field "reply-to" nil t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1434 from)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1435 cc (cond (just-sender nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1436 (resent-reply-to (mail-fetch-field "resent-cc" t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1437 (t (mail-fetch-field "cc" nil t)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1438 subject (or (and resent-reply-to
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1439 (mail-fetch-field "resent-subject" t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1440 (mail-fetch-field "subject"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1441 date (cond (resent-reply-to
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1442 (mail-fetch-field "resent-date" t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1443 ((mail-fetch-field "date")))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1444 to (cond (resent-reply-to
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1445 (mail-fetch-field "resent-to" t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1446 ((mail-fetch-field "to" nil t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1447 ;((mail-fetch-field "apparently-to")) ack gag barf
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1448 (t ""))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1449 message-id (cond (resent-reply-to
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1450 (mail-fetch-field "resent-message-id" t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1451 ((mail-fetch-field "message-id"))))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1452 (and subject
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1453 (string-match "\\`Re: " subject)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1454 (setq subject (substring subject 4)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1455 (mail-other-window nil
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1456 (mail-strip-quoted-names reply-to)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1457 subject
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1458 (rmail-make-in-reply-to-field from date message-id)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1459 (if just-sender
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1460 nil
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1461 (let* ((cc-list (rmail-dont-reply-to
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1462 (mail-strip-quoted-names
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1463 (if (null cc) to (concat to ", " cc))))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1464 (if (string= cc-list "") nil cc-list)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1465 (current-buffer)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1466 (list (list '(lambda (buf msgnum)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1467 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1468 (set-buffer buf)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1469 (rmail-set-attribute "answered" t msgnum)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1470 (current-buffer) rmail-current-message)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1471
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1472 (defun rmail-make-in-reply-to-field (from date message-id)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1473 (cond ((not from)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1474 (if message-id
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1475 message-id
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1476 nil))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1477 (mail-use-rfc822
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1478 (require 'rfc822)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1479 (let ((tem (car (rfc822-addresses from))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1480 (if message-id
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1481 (if (string-match
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1482 (regexp-quote (if (string-match "@[^@]*\\'" tem)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1483 (substring tem 0 (match-beginning 0))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1484 tem))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1485 message-id)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1486 ;; Message-ID is sufficiently informative
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1487 message-id
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1488 (concat message-id " (" tem ")"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1489 ;; Use prin1 to fake RFC822 quoting
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1490 (let ((field (prin1-to-string tem)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1491 (if date
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1492 (concat field "'s message of " date)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1493 field)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1494 ((let* ((foo "[^][\000-\037\177-\377()<>@,;:\\\" ]+")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1495 (bar "[^][\000-\037\177-\377()<>@,;:\\\"]+"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1496 ;; Can't use format because format loses on \000 (unix *^&%*^&%$!!)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1497 (or (string-match (concat "\\`[ \t]*\\(" bar
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1498 "\\)\\(<" foo "@" foo ">\\)?[ \t]*\\'")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1499 ;; "Unix Loser <Foo@bar.edu>" => "Unix Loser"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1500 from)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1501 (string-match (concat "\\`[ \t]*<" foo "@" foo ">[ \t]*(\\("
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1502 bar "\\))[ \t]*\\'")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1503 ;; "<Bugs@bar.edu>" (Losing Unix) => "Losing Unix"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1504 from)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1505 (let ((start (match-beginning 1))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1506 (end (match-end 1)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1507 ;; Trim whitespace which above regexp match allows
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1508 (while (and (< start end)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1509 (memq (aref from start) '(?\t ?\ )))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1510 (setq start (1+ start)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1511 (while (and (< start end)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1512 (memq (aref from (1- end)) '(?\t ?\ )))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1513 (setq end (1- end)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1514 (let ((field (substring from start end)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1515 (if date (setq field (concat "message from " field " on " date)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1516 (if message-id
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1517 ;; "<AA259@bar.edu> (message from Unix Loser on 1-Apr-89)"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1518 (concat message-id " (" field ")")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1519 field))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1520 (t
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1521 ;; If we can't kludge it simply, do it correctly
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1522 (let ((mail-use-rfc822 t))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1523 (rmail-make-in-reply-to-field from date message-id)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1524
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1525 (defun rmail-forward ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1526 "Forward the current message to another user."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1527 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1528 (let ((forward-buffer (current-buffer))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1529 (subject (concat "["
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1530 (mail-strip-quoted-names (mail-fetch-field "From"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1531 ": " (or (mail-fetch-field "Subject") "") "]")))
1137
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1532 ;; Turn off the usual actions for initializing the message body
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1533 ;; because we want to get only the text from the failure message.
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1534 (let (mail-signature mail-setup-hook)
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1535 ;; If only one window, use it for the mail buffer.
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1536 ;; Otherwise, use another window for the mail buffer
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1537 ;; so that the Rmail buffer remains visible
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1538 ;; and sending the mail will get back to it.
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1539 (if (funcall (if (one-window-p t)
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1540 (function mail)
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1541 (function mail-other-window))
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1542 nil nil subject nil nil nil
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1543 (list (list (function (lambda (buf msgnum)
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1544 (save-excursion
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1545 (set-buffer buf)
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1546 (rmail-set-attribute "forwarded" t msgnum))))
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1547 (current-buffer)
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1548 rmail-current-message)))
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1549 (save-excursion
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1550 (goto-char (point-max))
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1551 (forward-line 1)
6f2689fa1c37 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1135
diff changeset
1552 (insert-buffer forward-buffer))))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1553
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1554 (defun rmail-resend (address &optional from comment mail-alias-file)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1555 "Resend current message to ADDRESSES.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1556 ADDRESSES should be a single address, a a string consisting of several
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1557 addresses separated by commas, or a list of addresses.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1558
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1559 Optional FROM is the address to resend the message from, and
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1560 defaults to the username of the person redistributing the message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1561 Optional COMMENT is a string that will be inserted as a comment in the
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1562 resent message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1563 Optional ALIAS-FILE is alternate aliases file to be used by sendmail,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1564 typically for purposes of moderating a list."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1565 (interactive "sResend to: ")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1566 (if (not from) (setq from (user-login-name)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1567 (let ((tembuf (generate-new-buffer " sendmail temp"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1568 (mail-header-separator "")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1569 (case-fold-search nil)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1570 (mailbuf (current-buffer)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1571 (unwind-protect
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1572 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1573 ;;>> Copy message into temp buffer
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1574 (set-buffer tembuf)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1575 (insert-buffer-substring mailbuf)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1576 (goto-char (point-min))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1577 ;;>> Insert resent-from:
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1578 (insert "Resent-From: " from "\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1579 (insert "Resent-Date: " (current-time-string) "\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1580 ;;>> Insert resent-to: and bcc if need be.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1581 (let ((before (point)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1582 (insert "Resent-To: " (if (stringp address)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1583 address
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1584 (mapconcat 'identity address ",\n\t"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1585 "\n")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1586 (expand-mail-aliases before (point)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1587 ;;>> Set up comment, if any.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1588 (if (and (sequencep comment) (not (zerop (length comment))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1589 (let ((before (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1590 after)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1591 (insert comment)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1592 (or (eolp) (insert "\n"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1593 (setq after (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1594 (goto-char before)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1595 (while (< (point) after)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1596 (insert "Resent-Comment: ")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1597 (forward-line 1))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1598 ;; Don't expand aliases in the destination fields
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1599 ;; of the original message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1600 (let (mail-aliases)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1601 (sendmail-send-it)))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1602 (kill-buffer tembuf))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1603
1267
1e1a54ebb29b (mail-unsent-separator): Add another alternative.
Richard M. Stallman <rms@gnu.org>
parents: 1165
diff changeset
1604 (defvar mail-unsent-separator
1370
c017b62c8073 (mail-unsent-separator): Allow "original message" as alternative.
Richard M. Stallman <rms@gnu.org>
parents: 1360
diff changeset
1605 (concat "^ *---+ +Unsent message follows +---+ *$\\|"
c017b62c8073 (mail-unsent-separator): Allow "original message" as alternative.
Richard M. Stallman <rms@gnu.org>
parents: 1360
diff changeset
1606 "^ *---+ +Returned message +---+ *$\\|"
1372
e839dc00fc2e (mail-unsent-separator): Handle "Message text follows".
Richard M. Stallman <rms@gnu.org>
parents: 1370
diff changeset
1607 "^ *---+ +Original message +---+ *$\\|"
1757
7e85913523ef (mail-unsent-separator): Add `-- begin message --'.
Richard M. Stallman <rms@gnu.org>
parents: 1704
diff changeset
1608 "^ *--+ +begin message +--+ *$\\|"
1372
e839dc00fc2e (mail-unsent-separator): Handle "Message text follows".
Richard M. Stallman <rms@gnu.org>
parents: 1370
diff changeset
1609 "^|? *---+ +Message text follows: +---+ *|?$"))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1610
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1611 (defun rmail-retry-failure ()
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1612 "Edit a mail message which is based on the contents of the current message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1613 For a message rejected by the mail system, extract the interesting headers and
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1614 the body of the original message; otherwise copy the current message."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1615 (interactive)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1616 (require 'mail-utils)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1617 (let (to subj irp2 cc orig-message)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1618 (save-excursion
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1619 ;; Narrow down to just the quoted original message
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1620 (rmail-beginning-of-message)
1370
c017b62c8073 (mail-unsent-separator): Allow "original message" as alternative.
Richard M. Stallman <rms@gnu.org>
parents: 1360
diff changeset
1621 (let ((case-fold-search t))
c017b62c8073 (mail-unsent-separator): Allow "original message" as alternative.
Richard M. Stallman <rms@gnu.org>
parents: 1360
diff changeset
1622 (or (re-search-forward mail-unsent-separator nil t)
c017b62c8073 (mail-unsent-separator): Allow "original message" as alternative.
Richard M. Stallman <rms@gnu.org>
parents: 1360
diff changeset
1623 (error "Cannot parse this as a failure message")))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1624 (save-restriction
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1625 (narrow-to-region (point) (point-max))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1626 ;; Now mail-fetch-field will get from headers of the original message,
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1627 ;; not from the headers of the rejection.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1628 (setq to (mail-fetch-field "To")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1629 subj (mail-fetch-field "Subject")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1630 irp2 (mail-fetch-field "In-reply-to")
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1631 cc (mail-fetch-field "Cc"))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1632 ;; Get the entire text (not headers) of the original message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1633 (setq orig-message
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1634 (buffer-substring
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1635 (progn (search-forward "\n\n") (point))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1636 (point-max)))))
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1637 ;; Start sending a new message; default header fields from the original.
1135
e33f6475229a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
1638 ;; Turn off the usual actions for initializing the message body
e33f6475229a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
1639 ;; because we want to get only the text from the failure message.
e33f6475229a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
1640 (let (mail-signature mail-setup-hook)
e33f6475229a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
1641 (if (mail-other-window nil to subj irp2 cc (current-buffer))
e33f6475229a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
1642 ;; Insert original text as initial text of new draft message.
e33f6475229a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
1643 (progn
e33f6475229a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
1644 (goto-char (point-max))
e33f6475229a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
1645 (insert orig-message)
e33f6475229a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
1646 (goto-char (point-min))
e33f6475229a *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 1112
diff changeset
1647 (end-of-line))))))
270
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1648
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1649 ;;;; *** Rmail Specify Inbox Files ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1650
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1651 (autoload 'set-rmail-inbox-list "rmailmsc"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1652 "Set the inbox list of the current RMAIL file to FILE-NAME.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1653 This may be a list of file names separated by commas.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1654 If FILE-NAME is empty, remove any inbox list."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1655 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1656
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1657 ;;;; *** Rmail Commands for Labels ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1658
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1659 (autoload 'rmail-add-label "rmailkwd"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1660 "Add LABEL to labels associated with current RMAIL message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1661 Completion is performed over known labels when reading."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1662 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1663
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1664 (autoload 'rmail-kill-label "rmailkwd"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1665 "Remove LABEL from labels associated with current RMAIL message.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1666 Completion is performed over known labels when reading."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1667 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1668
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1669 (autoload 'rmail-next-labeled-message "rmailkwd"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1670 "Show next message with LABEL. Defaults to last label used.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1671 With prefix argument N moves forward N messages with this label."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1672 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1673
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1674 (autoload 'rmail-previous-labeled-message "rmailkwd"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1675 "Show previous message with LABEL. Defaults to last label used.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1676 With prefix argument N moves backward N messages with this label."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1677 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1678
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1679 ;;;; *** Rmail Edit Mode ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1680
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1681 (autoload 'rmail-edit-current-message "rmailedit"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1682 "Edit the contents of the current message"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1683 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1684
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1685 ;;;; *** Rmail Summary Mode ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1686
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1687 (autoload 'rmail-summary "rmailsum"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1688 "Display a summary of all messages, one line per message."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1689 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1690
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1691 (autoload 'rmail-summary-by-labels "rmailsum"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1692 "Display a summary of all messages with one or more LABELS.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1693 LABELS should be a string containing the desired labels, separated by commas."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1694 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1695
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1696 (autoload 'rmail-summary-by-recipients "rmailsum"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1697 "Display a summary of all messages with the given RECIPIENTS.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1698 Normally checks the To, From and Cc fields of headers; but if PRIMARY-ONLY
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1699 is non-nil (prefix arg given), only look in the To and From fields.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1700 RECIPIENTS is a string of names separated by commas."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1701 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1702
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1703 ;;;; *** Rmail output messages to files ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1704
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1705 (autoload 'rmail-output-to-rmail-file "rmailout"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1706 "Append the current message to an Rmail file named FILE-NAME.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1707 If the file does not exist, ask if it should be created.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1708 If file is being visited, the message is appended to the Emacs
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1709 buffer visiting that file."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1710 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1711
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1712 (autoload 'rmail-output "rmailout"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1713 "Append this message to Unix mail file named FILE-NAME."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1714 t)
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1715
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1716 ;;;; *** Rmail undigestification ***
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1717
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1718 (autoload 'undigestify-rmail-message "undigest"
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1719 "Break up a digest message into its constituent messages.
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1720 Leaves original message, deleted, before the undigestified messages."
f8d0e0ecd474 Initial revision
Roland McGrath <roland@gnu.org>
parents:
diff changeset
1721 t)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 474
diff changeset
1722
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 474
diff changeset
1723 (provide 'rmail)
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 474
diff changeset
1724
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 621
diff changeset
1725 ;;; rmail.el ends here