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