annotate lisp/mail/rmailout.el @ 91837:3ef9dcc38460

*** empty log message ***
author Kenichi Handa <handa@m17n.org>
date Thu, 14 Feb 2008 12:21:58 +0000
parents 107ccd98fa12
children 606f2d163a64 1e3a407766b9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 38304
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
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 1985, 1987, 1993, 1994, 2001, 2002, 2003, 2004,
79712
de499b20517a Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
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
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
10
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
78232
8e27d63c45eb Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75347
diff changeset
13 ;; the Free Software Foundation; either version 3, or (at your option)
63
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
14 ;; any later version.
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
15
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
19 ;; GNU General Public License for more details.
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
20
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13054
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 52401
diff changeset
24 ;; Boston, MA 02110-1301, USA.
63
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
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
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
29
5859
84ad3a2c5373 Add (require 'rmail) so the macro will be byte-compiled properly.
Karl Heuer <kwzh@gnu.org>
parents: 5802
diff changeset
30 (require 'rmail)
23986
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
31 (provide 'rmailout)
5859
84ad3a2c5373 Add (require 'rmail) so the macro will be byte-compiled properly.
Karl Heuer <kwzh@gnu.org>
parents: 5802
diff changeset
32
16188
5bc27ae3cd14 (rmail-output-file-alist): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
33 ;;;###autoload
17631
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
34 (defcustom rmail-output-file-alist nil
145
1a0f15a66c06 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 63
diff changeset
35 "*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
36 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
37 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
38 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
39 or more generally it may be any kind of expression that returns
17631
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
40 a file name as a string."
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
41 :type '(repeat (cons regexp
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
42 (choice :value ""
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
43 (string :tag "File Name")
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
44 sexp)))
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
45 :group 'rmail-output)
145
1a0f15a66c06 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 63
diff changeset
46
23986
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
47 (defun rmail-output-read-rmail-file-name ()
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
48 "Read the file name to use for `rmail-output-to-rmail-file'.
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
49 Set `rmail-default-rmail-file' to this name as well as returning it."
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
50 (let ((default-file
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
51 (let (answer tail)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
52 (setq tail rmail-output-file-alist)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
53 ;; Suggest a file based on a pattern match.
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
54 (while (and tail (not answer))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
55 (save-excursion
37613
d5dbe7f1300c (rmail-output-read-rmail-file-name): Be sure to
Gerd Moellmann <gerd@gnu.org>
parents: 36717
diff changeset
56 (set-buffer rmail-buffer)
23986
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
57 (goto-char (point-min))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
58 (if (re-search-forward (car (car tail)) nil t)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
59 (setq answer (eval (cdr (car tail)))))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
60 (setq tail (cdr tail))))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
61 ;; If no suggestions, use same file as last time.
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
62 (expand-file-name (or answer rmail-default-rmail-file)))))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
63 (let ((read-file
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
64 (expand-file-name
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
65 (read-file-name
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64754
diff changeset
66 (concat "Output message to Rmail file (default "
23986
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
67 (file-name-nondirectory default-file)
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64754
diff changeset
68 "): ")
23986
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
69 (file-name-directory default-file)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
70 (abbreviate-file-name default-file))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
71 (file-name-directory default-file))))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
72 ;; If the user enters just a directory,
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
73 ;; use the name within that directory chosen by the default.
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
74 (setq rmail-default-rmail-file
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
75 (if (file-directory-p read-file)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
76 (expand-file-name (file-name-nondirectory default-file)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
77 read-file)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
78 read-file)))))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
79
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
80 (defun rmail-output-read-file-name ()
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
81 "Read the file name to use for `rmail-output'.
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
82 Set `rmail-default-file' to this name as well as returning it."
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
83 (let ((default-file
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
84 (let (answer tail)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
85 (setq tail rmail-output-file-alist)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
86 ;; Suggest a file based on a pattern match.
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
87 (while (and tail (not answer))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
88 (save-excursion
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
89 (goto-char (point-min))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
90 (if (re-search-forward (car (car tail)) nil t)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
91 (setq answer (eval (cdr (car tail)))))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
92 (setq tail (cdr tail))))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
93 ;; If no suggestion, use same file as last time.
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
94 (or answer rmail-default-file))))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
95 (let ((read-file
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
96 (expand-file-name
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
97 (read-file-name
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64754
diff changeset
98 (concat "Output message to Unix mail file (default "
23986
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
99 (file-name-nondirectory default-file)
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 64754
diff changeset
100 "): ")
23986
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
101 (file-name-directory default-file)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
102 (abbreviate-file-name default-file))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
103 (file-name-directory default-file))))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
104 (setq rmail-default-file
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
105 (if (file-directory-p read-file)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
106 (expand-file-name (file-name-nondirectory default-file)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
107 read-file)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
108 (expand-file-name
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
109 (or read-file (file-name-nondirectory default-file))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
110 (file-name-directory default-file)))))))
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
111
86440
4aedd218aad1 * mail/mspools.el (rmail-get-new-mail):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78232
diff changeset
112 (declare-function rmail-update-summary "rmailsum" (&rest ignore))
4aedd218aad1 * mail/mspools.el (rmail-get-new-mail):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78232
diff changeset
113
23042
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
114 ;;; 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
115 ;;; 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
116 ;;;###autoload
29160
998506bd35f3 1999-01-23 Eric M. Ludlam <zappo@ultranet.com>
Dave Love <fx@gnu.org>
parents: 24838
diff changeset
117 (defun rmail-output-to-rmail-file (file-name &optional count stay)
63
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
118 "Append the current message to an Rmail file named FILE-NAME.
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
119 If the file does not exist, ask if it should be created.
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
120 If file is being visited, the message is appended to the Emacs
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
121 buffer visiting that file.
19961
be32396bfb04 (rmail-output-to-rmail-file): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17631
diff changeset
122 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
123 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
124
7332
e30a34bfc536 (rmail-output-menu): Set rmail-default-rmail-file.
Richard M. Stallman <rms@gnu.org>
parents: 7320
diff changeset
125 The default file name comes from `rmail-default-rmail-file',
5592
ee1ed3d9e517 Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5590
diff changeset
126 which is updated to the name you use in this command.
ee1ed3d9e517 Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5590
diff changeset
127
66701
ceaaebf15d29 (rmail-output-to-rmail-file, rmail-output): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 65680
diff changeset
128 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
129 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
130
66701
ceaaebf15d29 (rmail-output-to-rmail-file, rmail-output): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 65680
diff changeset
131 If the optional argument STAY is non-nil, then leave the last filed
ceaaebf15d29 (rmail-output-to-rmail-file, rmail-output): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 65680
diff changeset
132 message up instead of moving forward to the next non-deleted message."
3657
7503a402c721 (rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents: 2717
diff changeset
133 (interactive
23986
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
134 (list (rmail-output-read-rmail-file-name)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
135 (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
136 (or count (setq count 1))
202
ae5ace097df2 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 145
diff changeset
137 (setq file-name
ae5ace097df2 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 145
diff changeset
138 (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
139 (file-name-directory rmail-default-rmail-file)))
13054
b2df0396fae2 (rmail-file-p): Function moved to mail-utils.el
Richard M. Stallman <rms@gnu.org>
parents: 10101
diff changeset
140 (if (and (file-readable-p file-name) (not (mail-file-babyl-p file-name)))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
141 (rmail-output file-name count)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
142 (rmail-maybe-set-message-counters)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
143 (setq file-name (abbreviate-file-name file-name))
17268
c945c9845f01 (rmail-output-to-rmail-file):
Richard M. Stallman <rms@gnu.org>
parents: 17267
diff changeset
144 (or (find-buffer-visiting file-name)
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
145 (file-exists-p file-name)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
146 (if (yes-or-no-p
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
147 (concat "\"" file-name "\" does not exist, create it? "))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
148 (let ((file-buffer (create-file-buffer file-name)))
63
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
149 (save-excursion
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
150 (set-buffer file-buffer)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
151 (rmail-insert-rmail-file-header)
36717
919d4bc1079b (rmail-output-to-rmail-file): When writing the
Eli Zaretskii <eliz@gnu.org>
parents: 29160
diff changeset
152 (let ((require-final-newline nil)
919d4bc1079b (rmail-output-to-rmail-file): When writing the
Eli Zaretskii <eliz@gnu.org>
parents: 29160
diff changeset
153 (coding-system-for-write
919d4bc1079b (rmail-output-to-rmail-file): When writing the
Eli Zaretskii <eliz@gnu.org>
parents: 29160
diff changeset
154 (or rmail-file-coding-system
919d4bc1079b (rmail-output-to-rmail-file): When writing the
Eli Zaretskii <eliz@gnu.org>
parents: 29160
diff changeset
155 'emacs-mule-unix)))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
156 (write-region (point-min) (point-max) file-name t 1)))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
157 (kill-buffer file-buffer))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
158 (error "Output file does not exist")))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
159 (while (> count 0)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
160 (let (redelete)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
161 (unwind-protect
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
162 (progn
37613
d5dbe7f1300c (rmail-output-read-rmail-file-name): Be sure to
Gerd Moellmann <gerd@gnu.org>
parents: 36717
diff changeset
163 (set-buffer rmail-buffer)
5278
92268e08c166 (rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents: 5051
diff changeset
164 ;; Temporarily turn off Deleted attribute.
92268e08c166 (rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents: 5051
diff changeset
165 ;; Do this outside the save-restriction, since it would
92268e08c166 (rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents: 5051
diff changeset
166 ;; shift the place in the buffer where the visible text starts.
92268e08c166 (rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents: 5051
diff changeset
167 (if (rmail-message-deleted-p rmail-current-message)
92268e08c166 (rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents: 5051
diff changeset
168 (progn (setq redelete t)
92268e08c166 (rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents: 5051
diff changeset
169 (rmail-set-attribute "deleted" nil)))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
170 (save-restriction
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
171 (widen)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
172 ;; Decide whether to append to a file or to an Emacs buffer.
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
173 (save-excursion
17268
c945c9845f01 (rmail-output-to-rmail-file):
Richard M. Stallman <rms@gnu.org>
parents: 17267
diff changeset
174 (let ((buf (find-buffer-visiting file-name))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
175 (cur (current-buffer))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
176 (beg (1+ (rmail-msgbeg rmail-current-message)))
22259
e7a998137db5 (rmail-output-to-rmail-file): Specify the coding system for writing.
Richard M. Stallman <rms@gnu.org>
parents: 22202
diff changeset
177 (end (1+ (rmail-msgend rmail-current-message)))
e7a998137db5 (rmail-output-to-rmail-file): Specify the coding system for writing.
Richard M. Stallman <rms@gnu.org>
parents: 22202
diff changeset
178 (coding-system-for-write
e7a998137db5 (rmail-output-to-rmail-file): Specify the coding system for writing.
Richard M. Stallman <rms@gnu.org>
parents: 22202
diff changeset
179 (or rmail-file-coding-system
e7a998137db5 (rmail-output-to-rmail-file): Specify the coding system for writing.
Richard M. Stallman <rms@gnu.org>
parents: 22202
diff changeset
180 'emacs-mule-unix)))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
181 (if (not buf)
9993
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
182 ;; Output to a file.
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
183 (if rmail-fields-not-to-output
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
184 ;; Delete some fields while we output.
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
185 (let ((obuf (current-buffer)))
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
186 (set-buffer (get-buffer-create " rmail-out-temp"))
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
187 (insert-buffer-substring obuf beg end)
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
188 (rmail-delete-unwanted-fields)
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
189 (append-to-file (point-min) (point-max) file-name)
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
190 (set-buffer obuf)
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
191 (kill-buffer (get-buffer " rmail-out-temp")))
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
192 (append-to-file beg end file-name))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
193 (if (eq buf (current-buffer))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
194 (error "Can't output message to same file it's already in"))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
195 ;; File has been visited, in buffer BUF.
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
196 (set-buffer buf)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
197 (let ((buffer-read-only nil)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
198 (msg (and (boundp 'rmail-current-message)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
199 rmail-current-message)))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
200 ;; If MSG is non-nil, buffer is in RMAIL mode.
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
201 (if msg
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
202 (progn
5331
a74ffe260236 (rmail-output-to-rmail-file): When copying to a buffer,
Richard M. Stallman <rms@gnu.org>
parents: 5278
diff changeset
203 ;; Turn on auto save mode, if it's off in this
a74ffe260236 (rmail-output-to-rmail-file): When copying to a buffer,
Richard M. Stallman <rms@gnu.org>
parents: 5278
diff changeset
204 ;; buffer but enabled by default.
a74ffe260236 (rmail-output-to-rmail-file): When copying to a buffer,
Richard M. Stallman <rms@gnu.org>
parents: 5278
diff changeset
205 (and (not buffer-auto-save-file-name)
a74ffe260236 (rmail-output-to-rmail-file): When copying to a buffer,
Richard M. Stallman <rms@gnu.org>
parents: 5278
diff changeset
206 auto-save-default
a74ffe260236 (rmail-output-to-rmail-file): When copying to a buffer,
Richard M. Stallman <rms@gnu.org>
parents: 5278
diff changeset
207 (auto-save-mode t))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
208 (rmail-maybe-set-message-counters)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
209 (widen)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
210 (narrow-to-region (point-max) (point-max))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
211 (insert-buffer-substring cur beg end)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
212 (goto-char (point-min))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
213 (widen)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
214 (search-backward "\n\^_")
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
215 (narrow-to-region (point) (point-max))
9993
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
216 (rmail-delete-unwanted-fields)
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
217 (rmail-count-new-messages t)
5278
92268e08c166 (rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents: 5051
diff changeset
218 (if (rmail-summary-exists)
92268e08c166 (rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents: 5051
diff changeset
219 (rmail-select-summary
92268e08c166 (rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents: 5051
diff changeset
220 (rmail-update-summary)))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
221 (rmail-show-message msg))
22259
e7a998137db5 (rmail-output-to-rmail-file): Specify the coding system for writing.
Richard M. Stallman <rms@gnu.org>
parents: 22202
diff changeset
222 ;; Output file not in rmail mode => just insert at the end.
e7a998137db5 (rmail-output-to-rmail-file): Specify the coding system for writing.
Richard M. Stallman <rms@gnu.org>
parents: 22202
diff changeset
223 (narrow-to-region (point-min) (1+ (buffer-size)))
e7a998137db5 (rmail-output-to-rmail-file): Specify the coding system for writing.
Richard M. Stallman <rms@gnu.org>
parents: 22202
diff changeset
224 (goto-char (point-max))
e7a998137db5 (rmail-output-to-rmail-file): Specify the coding system for writing.
Richard M. Stallman <rms@gnu.org>
parents: 22202
diff changeset
225 (insert-buffer-substring cur beg end)
e7a998137db5 (rmail-output-to-rmail-file): Specify the coding system for writing.
Richard M. Stallman <rms@gnu.org>
parents: 22202
diff changeset
226 (rmail-delete-unwanted-fields)))))))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
227 (rmail-set-attribute "filed" t))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
228 (if redelete (rmail-set-attribute "deleted" t))))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
229 (setq count (1- count))
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
230 (if rmail-delete-after-output
49587
e82b3fe06d4c (rmail-output): If preserving MIME-version, preserve Content-type too.
Francesco Potortì <pot@gnu.org>
parents: 38412
diff changeset
231 (unless
29160
998506bd35f3 1999-01-23 Eric M. Ludlam <zappo@ultranet.com>
Dave Love <fx@gnu.org>
parents: 24838
diff changeset
232 (if (and (= count 0) stay)
998506bd35f3 1999-01-23 Eric M. Ludlam <zappo@ultranet.com>
Dave Love <fx@gnu.org>
parents: 24838
diff changeset
233 (rmail-delete-message)
998506bd35f3 1999-01-23 Eric M. Ludlam <zappo@ultranet.com>
Dave Love <fx@gnu.org>
parents: 24838
diff changeset
234 (rmail-delete-forward))
998506bd35f3 1999-01-23 Eric M. Ludlam <zappo@ultranet.com>
Dave Love <fx@gnu.org>
parents: 24838
diff changeset
235 (setq count 0))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
236 (if (> count 0)
49587
e82b3fe06d4c (rmail-output): If preserving MIME-version, preserve Content-type too.
Francesco Potortì <pot@gnu.org>
parents: 38412
diff changeset
237 (unless
29160
998506bd35f3 1999-01-23 Eric M. Ludlam <zappo@ultranet.com>
Dave Love <fx@gnu.org>
parents: 24838
diff changeset
238 (if (not stay) (rmail-next-undeleted-message 1))
998506bd35f3 1999-01-23 Eric M. Ludlam <zappo@ultranet.com>
Dave Love <fx@gnu.org>
parents: 24838
diff changeset
239 (setq count 0)))))))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
240
16343
e2b0e3d63822 (rmail-fields-not-to-output): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents: 16188
diff changeset
241 ;;;###autoload
17631
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
242 (defcustom rmail-fields-not-to-output nil
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
243 "*Regexp describing fields to exclude when outputting a message to a file."
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
244 :type '(choice (const :tag "None" nil)
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
245 regexp)
35d8e74c6edb Use defcustom.
Richard M. Stallman <rms@gnu.org>
parents: 17305
diff changeset
246 :group 'rmail-output)
9993
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
247
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
248 ;; 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
249 ;; 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
250 ;; 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
251 (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
252 (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
253 (save-excursion
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
254 (goto-char (point-min))
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
255 ;; Find the end of the header.
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
256 (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
257 (search-forward "\n\n" nil t))
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
258 (let ((end (point-marker)))
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
259 (goto-char (point-min))
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
260 (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
261 (beginning-of-line)
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
262 (delete-region (point)
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
263 (progn (forward-line 1) (point)))))))))
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
264
23042
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
265 ;;; 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
266 ;;; 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
267 ;;;###autoload
5011
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
268 (defun rmail-output (file-name &optional count noattribute from-gnus)
6651
714341c56a9a Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 6407
diff changeset
269 "Append this message to system-inbox-format mail file named FILE-NAME.
66701
ceaaebf15d29 (rmail-output-to-rmail-file, rmail-output): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 65680
diff changeset
270 A prefix argument COUNT says to output that many consecutive messages,
1866
a712cff3b6e7 * rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents: 1460
diff changeset
271 starting with the current one. Deleted messages are skipped and don't count.
66701
ceaaebf15d29 (rmail-output-to-rmail-file, rmail-output): Doc fix.
Eli Zaretskii <eliz@gnu.org>
parents: 65680
diff changeset
272 When called from lisp code, COUNT may be omitted and defaults to 1.
4265
2812d8619305 (rmail-output): New arg NOATTRIBUTE.
Richard M. Stallman <rms@gnu.org>
parents: 4264
diff changeset
273
4836
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
274 If the pruned message header is shown on the current message, then
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
275 messages will be appended with pruned headers; otherwise, messages
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
276 will be appended with their original headers.
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
277
7561
22a4985ddad3 (rmail-output): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 7332
diff changeset
278 The default file name comes from `rmail-default-file',
5592
ee1ed3d9e517 Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5590
diff changeset
279 which is updated to the name you use in this command.
ee1ed3d9e517 Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 5590
diff changeset
280
4265
2812d8619305 (rmail-output): New arg NOATTRIBUTE.
Richard M. Stallman <rms@gnu.org>
parents: 4264
diff changeset
281 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
282 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
283
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
284 The optional fourth argument FROM-GNUS is set when called from GNUS."
63
714e88ef93c8 Initial revision
root <root>
parents:
diff changeset
285 (interactive
23986
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
286 (list (rmail-output-read-file-name)
2c996615e2e9 Provide `rmailout'.
Richard M. Stallman <rms@gnu.org>
parents: 23941
diff changeset
287 (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
288 (or count (setq count 1))
202
ae5ace097df2 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 145
diff changeset
289 (setq file-name
ae5ace097df2 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 145
diff changeset
290 (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
291 (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
292 (file-name-directory rmail-default-file))))
13054
b2df0396fae2 (rmail-file-p): Function moved to mail-utils.el
Richard M. Stallman <rms@gnu.org>
parents: 10101
diff changeset
293 (if (and (file-readable-p file-name) (mail-file-babyl-p file-name))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
294 (rmail-output-to-rmail-file file-name count)
37613
d5dbe7f1300c (rmail-output-read-rmail-file-name): Be sure to
Gerd Moellmann <gerd@gnu.org>
parents: 36717
diff changeset
295 (set-buffer rmail-buffer)
4836
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
296 (let ((orig-count count)
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
297 (rmailbuf (current-buffer))
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
298 (case-fold-search t)
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
299 (tembuf (get-buffer-create " rmail-output"))
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
300 (original-headers-p
5011
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
301 (and (not from-gnus)
49587
e82b3fe06d4c (rmail-output): If preserving MIME-version, preserve Content-type too.
Francesco Potortì <pot@gnu.org>
parents: 38412
diff changeset
302 (save-excursion
5011
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
303 (save-restriction
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
304 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
305 (goto-char (point-min))
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
306 (forward-line 1)
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
307 (= (following-char) ?0)))))
4836
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
308 header-beginning
49587
e82b3fe06d4c (rmail-output): If preserving MIME-version, preserve Content-type too.
Francesco Potortì <pot@gnu.org>
parents: 38412
diff changeset
309 mail-from mime-version content-type)
4836
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
310 (while (> count 0)
23042
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
311 ;; Preserve the Mail-From and MIME-Version fields
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
312 ;; even if they have been pruned.
5011
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
313 (or from-gnus
23042
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
314 (save-excursion
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
315 (save-restriction
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
316 (widen)
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
317 (goto-char (rmail-msgbeg rmail-current-message))
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
318 (setq header-beginning (point))
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
319 (search-forward "\n*** EOOH ***\n")
4404e3d66e80 (rmail-output): Always preserve MIME-Version field,
Richard M. Stallman <rms@gnu.org>
parents: 22740
diff changeset
320 (narrow-to-region header-beginning (point))
49587
e82b3fe06d4c (rmail-output): If preserving MIME-version, preserve Content-type too.
Francesco Potortì <pot@gnu.org>
parents: 38412
diff changeset
321 (setq mail-from (mail-fetch-field "Mail-From"))
e82b3fe06d4c (rmail-output): If preserving MIME-version, preserve Content-type too.
Francesco Potortì <pot@gnu.org>
parents: 38412
diff changeset
322 (unless rmail-enable-mime
e82b3fe06d4c (rmail-output): If preserving MIME-version, preserve Content-type too.
Francesco Potortì <pot@gnu.org>
parents: 38412
diff changeset
323 (setq mime-version (mail-fetch-field "MIME-Version")
e82b3fe06d4c (rmail-output): If preserving MIME-version, preserve Content-type too.
Francesco Potortì <pot@gnu.org>
parents: 38412
diff changeset
324 content-type (mail-fetch-field "Content-type"))))))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
325 (save-excursion
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
326 (set-buffer tembuf)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
327 (erase-buffer)
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
328 (insert-buffer-substring rmailbuf)
38304
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
329 (when rmail-enable-mime
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
330 (if original-headers-p
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
331 (delete-region (goto-char (point-min))
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
332 (if (search-forward "\n*** EOOH ***\n")
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
333 (match-end 0)))
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
334 (goto-char (point-min))
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
335 (forward-line 2)
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
336 (delete-region (point-min)(point))
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
337 (search-forward "\n*** EOOH ***\n")
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
338 (delete-region (match-beginning 0)
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
339 (if (search-forward "\n\n")
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
340 (1- (match-end 0)))))
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
341 (setq buffer-file-coding-system (or rmail-file-coding-system
f818b591ff17 (rmail-output): Fix duplicate MIME-Version:
Gerd Moellmann <gerd@gnu.org>
parents: 37613
diff changeset
342 'raw-text)))
9993
26f63d276d89 (rmail-fields-not-to-output): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 8910
diff changeset
343 (rmail-delete-unwanted-fields t)
23528
3bb7a66a51a8 (rmail-output): Insert newline only if necessary.
Richard M. Stallman <rms@gnu.org>
parents: 23042
diff changeset
344 (or (bolp) (insert "\n"))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
345 (goto-char (point-min))
4836
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
346 (if mail-from
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
347 (insert mail-from "\n")
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
348 (insert "From "
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
349 (mail-strip-quoted-names (or (mail-fetch-field "from")
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
350 (mail-fetch-field "really-from")
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
351 (mail-fetch-field "sender")
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
352 "unknown"))
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
353 " " (current-time-string) "\n"))
68316
232a4bf5f26f (rmail-output): Don't use content-type if it is nil.
Eli Zaretskii <eliz@gnu.org>
parents: 66701
diff changeset
354 (when mime-version
232a4bf5f26f (rmail-output): Don't use content-type if it is nil.
Eli Zaretskii <eliz@gnu.org>
parents: 66701
diff changeset
355 (insert "MIME-Version: " mime-version)
232a4bf5f26f (rmail-output): Don't use content-type if it is nil.
Eli Zaretskii <eliz@gnu.org>
parents: 66701
diff changeset
356 ;; Some malformed MIME messages set content-type to nil.
232a4bf5f26f (rmail-output): Don't use content-type if it is nil.
Eli Zaretskii <eliz@gnu.org>
parents: 66701
diff changeset
357 (when content-type
232a4bf5f26f (rmail-output): Don't use content-type if it is nil.
Eli Zaretskii <eliz@gnu.org>
parents: 66701
diff changeset
358 (insert "\nContent-type: " content-type "\n")))
4056
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
359 ;; ``Quote'' "\nFrom " as "\n>From "
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
360 ;; (note that this isn't really quoting, as there is no requirement
419e92a78e6f (rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents: 3832
diff changeset
361 ;; that "\n[>]+From " be quoted in the same transparent way.)
10101
c0afdaf34c6f (rmail-output): Don't quote "From " lines unless the capitalization is exact.
Karl Heuer <kwzh@gnu.org>
parents: 9993
diff changeset
362 (let ((case-fold-search nil))
c0afdaf34c6f (rmail-output): Don't quote "From " lines unless the capitalization is exact.
Karl Heuer <kwzh@gnu.org>
parents: 9993
diff changeset
363 (while (search-forward "\nFrom " nil t)
c0afdaf34c6f (rmail-output): Don't quote "From " lines unless the capitalization is exact.
Karl Heuer <kwzh@gnu.org>
parents: 9993
diff changeset
364 (forward-char -5)
c0afdaf34c6f (rmail-output): Don't quote "From " lines unless the capitalization is exact.
Karl Heuer <kwzh@gnu.org>
parents: 9993
diff changeset
365 (insert ?>)))
4265
2812d8619305 (rmail-output): New arg NOATTRIBUTE.
Richard M. Stallman <rms@gnu.org>
parents: 4264
diff changeset
366 (write-region (point-min) (point-max) file-name t
2812d8619305 (rmail-output): New arg NOATTRIBUTE.
Richard M. Stallman <rms@gnu.org>
parents: 4264
diff changeset
367 (if noattribute 'nomsg)))
4836
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
368 (or noattribute
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
369 (if (equal major-mode 'rmail-mode)
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
370 (rmail-set-attribute "filed" t)))
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
371 (setq count (1- count))
5011
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
372 (or from-gnus
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
373 (let ((next-message-p
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
374 (if rmail-delete-after-output
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
375 (rmail-delete-forward)
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
376 (if (> count 0)
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
377 (rmail-next-undeleted-message 1))))
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
378 (num-appended (- orig-count count)))
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
379 (if (and next-message-p original-headers-p)
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
380 (rmail-toggle-header))
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
381 (if (and (> count 0) (not next-message-p))
49587
e82b3fe06d4c (rmail-output): If preserving MIME-version, preserve Content-type too.
Francesco Potortì <pot@gnu.org>
parents: 38412
diff changeset
382 (progn
87141
1a8ec74a74f3 Fix buggy calls to `error'.
Deepak Goel <deego@gnufans.org>
parents: 86440
diff changeset
383 (error "%s"
5011
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
384 (save-excursion
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
385 (set-buffer rmailbuf)
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
386 (format "Only %d message%s appended" num-appended
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
387 (if (= num-appended 1) "" "s"))))
22c7b341d536 (rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents: 4851
diff changeset
388 (setq count 0))))))
4836
38a0f0209707 (rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents: 4265
diff changeset
389 (kill-buffer tembuf))))
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 202
diff changeset
390
17267
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
391 ;;;###autoload
17305
7a3eb2b72749 (rmail-output-body-to-file): Query if file exists.
Richard M. Stallman <rms@gnu.org>
parents: 17268
diff changeset
392 (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
393 "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
394 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
395 (interactive
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
396 (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
397 (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
398 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
399 (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
400 (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
401 "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
402 (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
403 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
404 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
405 (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
406 (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
407 (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
408 (file-name-directory rmail-default-body-file))))
17267
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
409 (save-excursion
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
410 (goto-char (point-min))
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
411 (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
412 (and (file-exists-p file-name)
73972
98d8e09fad2d (rmail-output-body-to-file): Use `format', not `message', in `y-or-n-p' call.
Juanma Barranquero <lekktu@gmail.com>
parents: 68648
diff changeset
413 (not (y-or-n-p (format "File %s exists; overwrite? " file-name)))
17305
7a3eb2b72749 (rmail-output-body-to-file): Query if file exists.
Richard M. Stallman <rms@gnu.org>
parents: 17268
diff changeset
414 (error "Operation aborted"))
17267
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
415 (write-region (point) (point-max) file-name)
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
416 (if (equal major-mode 'rmail-mode)
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
417 (rmail-set-attribute "stored" t)))
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
418 (if rmail-delete-after-output
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
419 (rmail-delete-forward)))
958340c8db5e (rmail-output-body): New command.
Richard M. Stallman <rms@gnu.org>
parents: 16343
diff changeset
420
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49587
diff changeset
421 ;;; arch-tag: 447117c6-1a9a-4b88-aa43-3101b043e3a4
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 202
diff changeset
422 ;;; rmailout.el ends here