Mercurial > emacs
annotate lisp/mail/rmailout.el @ 88190:e40931b9db5d
(rmail-auto-file): Rewrote test for "filed" using
rmail-desc-get-keywords.
author | Alex Schroeder <alex@gnu.org> |
---|---|
date | Tue, 17 Jan 2006 10:04:38 +0000 |
parents | cf8100a82c36 |
children | 1044c364f41f |
rev | line source |
---|---|
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
1 ;;; rmailout.el --- "RMAIL" mail reader for Emacs: output message to a file. |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
202
diff
changeset
|
2 |
88155 | 3 ;; Copyright (C) 1985, 1987, 1993, 1994, 2001, 2002, 2003, 2004, |
4 ;; 2005 Free Software Foundation, Inc. | |
845 | 5 |
788
c8d4eb38ebfc
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
713
diff
changeset
|
6 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: mail |
788
c8d4eb38ebfc
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
713
diff
changeset
|
8 |
63 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; 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:
788
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
63 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
88155 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
63 | 25 |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
38304
diff
changeset
|
26 ;;; Commentary: |
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
38304
diff
changeset
|
27 |
788
c8d4eb38ebfc
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
713
diff
changeset
|
28 ;;; Code: |
63 | 29 |
23986 | 30 (provide 'rmailout) |
5859
84ad3a2c5373
Add (require 'rmail) so the macro will be byte-compiled properly.
Karl Heuer <kwzh@gnu.org>
parents:
5802
diff
changeset
|
31 |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
32 (eval-when-compile |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
33 (require 'rmail) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
34 (require 'rmaildesc)) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
35 |
16188
5bc27ae3cd14
(rmail-output-file-alist): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
36 ;;;###autoload |
17631 | 37 (defcustom rmail-output-file-alist nil |
145 | 38 "*Alist matching regexps to suggested output Rmail files. |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
39 This is a list of elements of the form (REGEXP . NAME-EXP). |
4851
b70799eabd57
(rmail-output-file-alist): Doc fix.
Roland McGrath <roland@gnu.org>
parents:
4836
diff
changeset
|
40 The suggestion is taken if REGEXP matches anywhere in the message buffer. |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
41 NAME-EXP may be a string constant giving the file name to use, |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
42 or more generally it may be any kind of expression that returns |
17631 | 43 a file name as a string." |
44 :type '(repeat (cons regexp | |
45 (choice :value "" | |
46 (string :tag "File Name") | |
47 sexp))) | |
48 :group 'rmail-output) | |
145 | 49 |
23986 | 50 (defun rmail-output-read-file-name () |
51 "Read the file name to use for `rmail-output'. | |
52 Set `rmail-default-file' to this name as well as returning it." | |
53 (let ((default-file | |
54 (let (answer tail) | |
55 (setq tail rmail-output-file-alist) | |
88177
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
56 (with-current-buffer rmail-buffer |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
57 ;; Suggest a file based on a pattern match. |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
58 (while (and tail (not answer)) |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
59 (save-excursion |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
60 (goto-char (point-min)) |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
61 (when (re-search-forward (caar tail) nil t) |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
62 (setq answer (eval (cdar tail)))) |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
63 (setq tail (cdr tail))))) |
23986 | 64 ;; If no suggestion, use same file as last time. |
65 (or answer rmail-default-file)))) | |
66 (let ((read-file | |
67 (expand-file-name | |
68 (read-file-name | |
88177
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
69 (concat "Output message to Rmail (mbox) file: (default " |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
70 (file-name-nondirectory default-file) "): ") |
23986 | 71 (file-name-directory default-file) |
72 (abbreviate-file-name default-file)) | |
73 (file-name-directory default-file)))) | |
74 (setq rmail-default-file | |
75 (if (file-directory-p read-file) | |
88177
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
76 (expand-file-name |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
77 (file-name-nondirectory default-file) read-file) |
23986 | 78 (expand-file-name |
79 (or read-file (file-name-nondirectory default-file)) | |
80 (file-name-directory default-file))))))) | |
81 | |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
82 ;;; mbox: ready |
23042
4404e3d66e80
(rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents:
22740
diff
changeset
|
83 ;;; There are functions elsewhere in Emacs that use this function; |
4404e3d66e80
(rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents:
22740
diff
changeset
|
84 ;;; look at them before you change the calling method. |
16343
e2b0e3d63822
(rmail-fields-not-to-output): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
16188
diff
changeset
|
85 ;;;###autoload |
29160
998506bd35f3
1999-01-23 Eric M. Ludlam <zappo@ultranet.com>
Dave Love <fx@gnu.org>
parents:
24838
diff
changeset
|
86 (defun rmail-output-to-rmail-file (file-name &optional count stay) |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
87 "Append the current message to an Rmail (mbox) file named FILE-NAME. |
63 | 88 If the file does not exist, ask if it should be created. |
89 If file is being visited, the message is appended to the Emacs | |
90 buffer visiting that file. | |
19961
be32396bfb04
(rmail-output-to-rmail-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17631
diff
changeset
|
91 If the file exists and is not an Rmail file, the message is |
be32396bfb04
(rmail-output-to-rmail-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
17631
diff
changeset
|
92 appended in inbox format, the same way `rmail-output' does it. |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
93 |
7332
e30a34bfc536
(rmail-output-menu): Set rmail-default-rmail-file.
Richard M. Stallman <rms@gnu.org>
parents:
7320
diff
changeset
|
94 The default file name comes from `rmail-default-rmail-file', |
5592 | 95 which is updated to the name you use in this command. |
96 | |
88155 | 97 A prefix argument COUNT says to output that many consecutive messages, |
29160
998506bd35f3
1999-01-23 Eric M. Ludlam <zappo@ultranet.com>
Dave Love <fx@gnu.org>
parents:
24838
diff
changeset
|
98 starting with the current one. Deleted messages are skipped and don't count. |
998506bd35f3
1999-01-23 Eric M. Ludlam <zappo@ultranet.com>
Dave Love <fx@gnu.org>
parents:
24838
diff
changeset
|
99 |
88155 | 100 If the optional argument STAY is non-nil, then leave the last filed |
101 message up instead of moving forward to the next non-deleted message." | |
88177
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
102 (interactive (list (rmail-output-read-file-name) |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
103 (prefix-numeric-value current-prefix-arg))) |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
104 ;; Use the 'rmail-output function to perform the output. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
105 (rmail-output file-name count nil nil) |
88155 | 106 ;; Deal with the next message |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
107 (if rmail-delete-after-output |
88177
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
108 (unless (if (and (= count 0) stay) |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
109 (rmail-delete-message) |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
110 (rmail-delete-forward)) |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
111 (setq count 0)) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
112 (if (> count 0) |
88177
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
113 (unless (if (not stay) (rmail-next-undeleted-message 1)) |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
114 (setq count 0))))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
115 |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
116 ;;; mbox: deprecated |
16343
e2b0e3d63822
(rmail-fields-not-to-output): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
16188
diff
changeset
|
117 ;;;###autoload |
17631 | 118 (defcustom rmail-fields-not-to-output nil |
119 "*Regexp describing fields to exclude when outputting a message to a file." | |
120 :type '(choice (const :tag "None" nil) | |
121 regexp) | |
122 :group 'rmail-output) | |
9993
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
123 |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
124 ;;; mbox: deprecated |
9993
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
125 ;; Delete from the buffer header fields we don't want output. |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
126 ;; NOT-RMAIL if t means this buffer does not have the full header |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
127 ;; and *** EOOH *** that a message in an Rmail file has. |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
128 (defun rmail-delete-unwanted-fields (&optional not-rmail) |
49587
e82b3fe06d4c
(rmail-output): If preserving MIME-version, preserve Content-type too.
Francesco Potortì <pot@gnu.org>
parents:
38412
diff
changeset
|
129 (if rmail-fields-not-to-output |
9993
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
130 (save-excursion |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
131 (goto-char (point-min)) |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
132 ;; Find the end of the header. |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
133 (if (and (or not-rmail (search-forward "\n*** EOOH ***\n" nil t)) |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
134 (search-forward "\n\n" nil t)) |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
135 (let ((end (point-marker))) |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
136 (goto-char (point-min)) |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
137 (while (re-search-forward rmail-fields-not-to-output end t) |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
138 (beginning-of-line) |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
139 (delete-region (point) |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
140 (progn (forward-line 1) (point))))))))) |
26f63d276d89
(rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
8910
diff
changeset
|
141 |
23042
4404e3d66e80
(rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents:
22740
diff
changeset
|
142 ;;; There are functions elsewhere in Emacs that use this function; |
4404e3d66e80
(rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents:
22740
diff
changeset
|
143 ;;; look at them before you change the calling method. |
16343
e2b0e3d63822
(rmail-fields-not-to-output): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
16188
diff
changeset
|
144 ;;;###autoload |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
145 (defun rmail-output (file-name &optional count noattribute ext) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
146 "Append an mbox formatted message to the mbox formatted file named |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
147 FILE-NAME. A prefix argument COUNT says to output COUNT consecutive |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
148 messages starting with the current one. Deleted messages are skipped |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
149 and don't count. When called from lisp code, COUNT may be omitted. |
4836
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
150 |
7561
22a4985ddad3
(rmail-output): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
7332
diff
changeset
|
151 The default file name comes from `rmail-default-file', |
5592 | 152 which is updated to the name you use in this command. |
153 | |
4265
2812d8619305
(rmail-output): New arg NOATTRIBUTE.
Richard M. Stallman <rms@gnu.org>
parents:
4264
diff
changeset
|
154 The optional third argument NOATTRIBUTE, if non-nil, says not |
5011
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
155 to set the `filed' attribute, and not to display a message. |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
156 |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
157 The optional fourth argument EXT is set when called from outside of an |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
158 Rmail function, for example by GNUS or Sendmail." |
88177
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
159 (interactive (list (rmail-output-read-file-name) |
cf8100a82c36
(rmail-output-read-file-name): Make sure search in executed in `rmail-buffer'.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88155
diff
changeset
|
160 (prefix-numeric-value current-prefix-arg))) |
1866
a712cff3b6e7
* rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents:
1460
diff
changeset
|
161 (or count (setq count 1)) |
202 | 162 (setq file-name |
163 (expand-file-name file-name | |
5590
1d9fabec8bec
Use new names rmail-default-file and rmail-default-rmail-file.
Richard M. Stallman <rms@gnu.org>
parents:
5399
diff
changeset
|
164 (and rmail-default-file |
1d9fabec8bec
Use new names rmail-default-file and rmail-default-rmail-file.
Richard M. Stallman <rms@gnu.org>
parents:
5399
diff
changeset
|
165 (file-name-directory rmail-default-file)))) |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
166 ;; Use the Rmail buffer, likely narrowed, as the message source |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
167 ;; unless being called from an external party, such as GNUS or |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
168 ;; Sendmail. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
169 (unless ext |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
170 (set-buffer rmail-buffer)) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
171 (let ((orig-count count) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
172 (src-buf (current-buffer)) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
173 (dst-buf (find-buffer-visiting file-name)) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
174 (current-message rmail-current-message) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
175 (tembuf (get-buffer-create " rmail-output")) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
176 (original-headers-p |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
177 (and (not ext) (not (rmail-msg-is-pruned))))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
178 ;; Output each message to the destination file. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
179 (while (> count 0) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
180 (save-excursion |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
181 ;; Copy the message, including all headers, to the temporary |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
182 ;; buffer. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
183 (set-buffer tembuf) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
184 (erase-buffer) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
185 (insert-buffer-substring src-buf) |
88155 | 186 |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
187 ;; Deal with MIME --- tbd. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
188 ;;(when rmail-enable-mime ... |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
189 |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
190 ;; Determine whether a buffer is already visiting the output |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
191 ;; file. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
192 (if dst-buf |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
193 ;; The destination file is being visited. Update it. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
194 (progn |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
195 (set-buffer dst-buf) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
196 ;; Determine if the destination file is an Rmail file. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
197 (let ((buffer-read-only nil) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
198 (dst-current-message (and (boundp 'rmail-current-message) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
199 rmail-current-message))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
200 (if dst-current-message |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
201 ;; The buffer is an Rmail buffer. Append the message. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
202 (progn |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
203 (widen) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
204 (narrow-to-region (point-max) (point-max)) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
205 (insert-buffer-substring src-buf) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
206 (insert "\n") |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
207 (rmail-process-new-messages) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
208 (rmail-show-message dst-current-message)) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
209 ;; The destination file is not an Rmail file, just |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
210 ;; insert at the end. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
211 (goto-char (point-max)) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
212 (insert-buffer-substring src-buf)))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
213 ;; The destination file is not being visited, just write out |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
214 ;; the processed message. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
215 (write-region (point-min) (point-max) file-name t |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
216 (if noattribute 'nomsg)))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
217 ;; Do housekeeping, such as setting the "Filed" attribute, if |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
218 ;; necessary and moving to the next message. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
219 (or noattribute |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
220 (if (equal major-mode 'rmail-mode) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
221 (progn |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
222 (rmail-set-attribute "filed" t current-message) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
223 (setq current-message (1+ current-message))))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
224 ;; Determine if Rmail post output operations need to be handled. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
225 (or ext |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
226 ;; They do. Move to the next non-deleted message. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
227 (let ((next-message-p |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
228 (if rmail-delete-after-output |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
229 (rmail-delete-forward) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
230 (if (> count 1) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
231 (rmail-next-undeleted-message 1)))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
232 (num-appended (- orig-count count))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
233 (if (and (> count 1) (not next-message-p)) |
88155 | 234 (progn |
88128
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
235 (error |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
236 (save-excursion |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
237 (set-buffer src-buf) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
238 (format "Only %d message%s appended" num-appended |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
239 (if (= num-appended 1) "" "s")))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
240 (setq count 0))))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
241 ;; Decrement the count for the next iteration. If an error has |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
242 ;; occurred, then count will be -1, which is every bit as good |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
243 ;; as 0. |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
244 (setq count (1- count))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
245 (kill-buffer tembuf))) |
b621daa96824
Attempt to minimize byte compilation warnings.
Paul Reilly <pmr@pajato.com>
parents:
49587
diff
changeset
|
246 |
17267
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
247 ;;;###autoload |
17305
7a3eb2b72749
(rmail-output-body-to-file): Query if file exists.
Richard M. Stallman <rms@gnu.org>
parents:
17268
diff
changeset
|
248 (defun rmail-output-body-to-file (file-name) |
17267
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
249 "Write this message body to the file FILE-NAME. |
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
250 FILE-NAME defaults, interactively, from the Subject field of the message." |
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
251 (interactive |
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
252 (let ((default-file |
22202
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
253 (or (mail-fetch-field "Subject") |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
254 rmail-default-body-file))) |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
255 (list (setq rmail-default-body-file |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
256 (read-file-name |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
257 "Output message body to file: " |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
258 (and default-file (file-name-directory default-file)) |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
259 default-file |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
260 nil default-file))))) |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
261 (setq file-name |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
262 (expand-file-name file-name |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
263 (and rmail-default-body-file |
cca4f78e5e2a
(rmail-output-body-to-file): Avoid error if message has no subject.
Richard M. Stallman <rms@gnu.org>
parents:
19961
diff
changeset
|
264 (file-name-directory rmail-default-body-file)))) |
17267
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
265 (save-excursion |
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
266 (goto-char (point-min)) |
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
267 (search-forward "\n\n") |
17305
7a3eb2b72749
(rmail-output-body-to-file): Query if file exists.
Richard M. Stallman <rms@gnu.org>
parents:
17268
diff
changeset
|
268 (and (file-exists-p file-name) |
7a3eb2b72749
(rmail-output-body-to-file): Query if file exists.
Richard M. Stallman <rms@gnu.org>
parents:
17268
diff
changeset
|
269 (not (y-or-n-p (message "File %s exists; overwrite? " file-name))) |
7a3eb2b72749
(rmail-output-body-to-file): Query if file exists.
Richard M. Stallman <rms@gnu.org>
parents:
17268
diff
changeset
|
270 (error "Operation aborted")) |
17267
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
271 (write-region (point) (point-max) file-name) |
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
272 (if (equal major-mode 'rmail-mode) |
88155 | 273 (rmail-desc-set-attribute rmail-desc-stored-index |
274 t rmail-current-message))) | |
17267
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
275 (if rmail-delete-after-output |
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
276 (rmail-delete-forward))) |
958340c8db5e
(rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents:
16343
diff
changeset
|
277 |
88155 | 278 ;;; arch-tag: 447117c6-1a9a-4b88-aa43-3101b043e3a4 |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
202
diff
changeset
|
279 ;;; rmailout.el ends here |