annotate lisp/mail/rmail.el @ 1372:e839dc00fc2e

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