annotate lisp/mail/rmailout.el @ 110141:e6f89f34c02d

gnus-agent.el (gnus-agent-short-article, gnus-agent-long-article): Increase values for these two variables.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Thu, 02 Sep 2010 03:39:33 +0000
parents 280c8ae2476d
children 417b1e4d63cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
1 ;;; rmailout.el --- "RMAIL" mail reader for Emacs: output message to a file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
2
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
3 ;; Copyright (C) 1985, 1987, 1993, 1994, 2001, 2002, 2003, 2004, 2005,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 104612
diff changeset
4 ;; 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
5
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
6 ;; Maintainer: FSF
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
7 ;; Keywords: mail
110015
280c8ae2476d Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
8 ;; Package: rmail
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
9
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
11
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
12 ;; GNU Emacs is free software: you can redistribute it and/or modify
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
14 ;; the Free Software Foundation, either version 3 of the License, or
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
15 ;; (at your option) any later version.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
16
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
21
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
24
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
25 ;;; Commentary:
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
26
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
27 ;;; Code:
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
28
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
29 (require 'rmail)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
30 (provide 'rmailout)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
31
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
32 (defcustom rmail-output-decode-coding nil
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
33 "If non-nil, do coding system decoding when outputting message as Babyl."
102048
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
34 :type 'boolean
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
35 :group 'rmail-output)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
36
102404
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
37 ;; FIXME risky?
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
38 (defcustom rmail-output-file-alist nil
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
39 "Alist matching regexps to suggested output Rmail files.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
40 This is a list of elements of the form (REGEXP . NAME-EXP).
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
41 The suggestion is taken if REGEXP matches anywhere in the message buffer.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
42 NAME-EXP may be a string constant giving the file name to use,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
43 or more generally it may be any kind of expression that returns
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
44 a file name as a string."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
45 :type '(repeat (cons regexp
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
46 (choice :value ""
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
47 (string :tag "File Name")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
48 sexp)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
49 :group 'rmail-output)
104612
c220a29e75fd Define risky-local-variable property here rather than in files.el.
Glenn Morris <rgm@gnu.org>
parents: 102913
diff changeset
50 ;;;###autoload(put 'rmail-output-file-alist 'risky-local-variable t)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
51
102048
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
52 (defcustom rmail-fields-not-to-output nil
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
53 "Regexp describing fields to exclude when outputting a message to a file.
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
54 The function `rmail-delete-unwanted-fields' uses this, ignoring case."
102048
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
55 :type '(choice (const :tag "None" nil)
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
56 regexp)
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
57 :group 'rmail-output)
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
58
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
59 (defun rmail-output-read-file-name ()
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
60 "Read the file name to use for `rmail-output'.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
61 Set `rmail-default-file' to this name as well as returning it."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
62 (let ((default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
63 (let (answer tail)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
64 (setq tail rmail-output-file-alist)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
65 ;; Suggest a file based on a pattern match.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
66 (while (and tail (not answer))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
67 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
68 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
69 (if (re-search-forward (car (car tail)) nil t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
70 (setq answer (eval (cdr (car tail)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
71 (setq tail (cdr tail))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
72 ;; If no suggestion, use same file as last time.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
73 (or answer rmail-default-file))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
74 (let ((read-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
75 (expand-file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
76 (read-file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
77 (concat "Output message to mail file (default "
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
78 (file-name-nondirectory default-file)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
79 "): ")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
80 (file-name-directory default-file)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
81 (abbreviate-file-name default-file))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
82 (file-name-directory default-file))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
83 (setq rmail-default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
84 (if (file-directory-p read-file)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
85 (expand-file-name (file-name-nondirectory default-file)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
86 read-file)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
87 (expand-file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
88 (or read-file (file-name-nondirectory default-file))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
89 (file-name-directory default-file)))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
90
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
91 (defun rmail-delete-unwanted-fields (preserve)
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
92 "Delete all headers matching `rmail-fields-not-to-output'.
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
93 Retains headers matching the regexp PRESERVE. Ignores case.
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
94 The buffer should be narrowed to just the header."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
95 (if rmail-fields-not-to-output
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
96 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
97 (goto-char (point-min))
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
98 (let ((case-fold-search t))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
99 (while (re-search-forward rmail-fields-not-to-output nil t)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
100 (beginning-of-line)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
101 (unless (looking-at preserve)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
102 (delete-region (point) (line-beginning-position 2))))))))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
103
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
104 (defun rmail-output-as-babyl (file-name nomsg)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
105 "Convert the current buffer's text to Babyl and output to FILE-NAME.
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
106 Alters the current buffer's text, so it should be a temporary buffer.
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
107 If a buffer is visiting FILE-NAME, adds the text to that buffer
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
108 rather than saving the file directly. If the buffer is an Rmail buffer,
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
109 updates it accordingly. If no buffer is visiting FILE-NAME, appends
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
110 the text directly to FILE-NAME, and displays a \"Wrote file\" message
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
111 unless NOMSG is a symbol (neither nil nor t)."
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
112 (let ((coding-system-for-write 'emacs-mule-unix))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
113 (save-restriction
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
114 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
115 (search-forward "\n\n" nil 'move)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
116 (narrow-to-region (point-min) (point))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
117 (if rmail-fields-not-to-output
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
118 (rmail-delete-unwanted-fields nil)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
119
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
120 ;; Convert to Babyl format.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
121 (rmail-convert-to-babyl-format)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
122 ;; Write it into the file, or its buffer.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
123 (let ((buf (find-buffer-visiting file-name))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
124 (tembuf (current-buffer)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
125 (if (null buf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
126 (write-region (point-min) (point-max) file-name t nomsg)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
127 (if (eq buf (current-buffer))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
128 (error "Can't output message to same file it's already in"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
129 ;; File has been visited, in buffer BUF.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
130 (set-buffer buf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
131 (let ((inhibit-read-only t)
102048
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
132 (msg (bound-and-true-p rmail-current-message)))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
133 ;; If MSG is non-nil, buffer is in RMAIL mode.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
134 (if msg
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
135 (rmail-output-to-babyl-buffer tembuf msg)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
136 ;; Output file not in rmail mode => just insert at the end.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
137 (narrow-to-region (point-min) (1+ (buffer-size)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
138 (goto-char (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
139 (insert-buffer-substring tembuf)))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
140
102051
cb3542dc1e2f (rmail-update-summary): Move declaration earlier in file.
Glenn Morris <rgm@gnu.org>
parents: 102050
diff changeset
141 ;; Called only if rmail-summary-exists, which means rmailsum is loaded.
cb3542dc1e2f (rmail-update-summary): Move declaration earlier in file.
Glenn Morris <rgm@gnu.org>
parents: 102050
diff changeset
142 (declare-function rmail-update-summary "rmailsum" (&rest ignore))
cb3542dc1e2f (rmail-update-summary): Move declaration earlier in file.
Glenn Morris <rgm@gnu.org>
parents: 102050
diff changeset
143
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
144 (defun rmail-output-to-babyl-buffer (tembuf msg)
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
145 "Copy message in TEMBUF into the current Babyl Rmail buffer.
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
146 Do what is necessary to make Rmail know about the new message, then
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
147 display message number MSG."
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
148 ;; Turn on Auto Save mode, if it's off in this buffer but enabled by default.
102048
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
149 (and (not buffer-auto-save-file-name)
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
150 auto-save-default
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
151 (auto-save-mode t))
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
152 (rmail-maybe-set-message-counters)
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
153 (widen)
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
154 (narrow-to-region (point-max) (point-max))
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
155 (insert-buffer-substring tembuf)
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
156 (goto-char (point-min))
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
157 (widen)
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
158 (search-backward "\n\^_")
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
159 (narrow-to-region (point) (point-max))
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
160 (rmail-count-new-messages t)
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
161 (if (rmail-summary-exists)
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
162 (rmail-select-summary (rmail-update-summary)))
102048
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
163 (rmail-show-message-1 msg))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
164
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
165 (defun rmail-convert-to-babyl-format ()
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
166 "Convert the mbox message in the current buffer to Babyl format."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
167 (let ((count 0) (start (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
168 (case-fold-search nil)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
169 (buffer-undo-list t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
170 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
171 (save-restriction
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
172 (unless (looking-at "^From ")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
173 (error "Invalid mbox message"))
102912
45cc1409f5e2 * mail/rmailout.el (rmail-convert-to-babyl-format): Don't set "unseen".
Richard M. Stallman <rms@gnu.org>
parents: 102910
diff changeset
174 (insert "\^L\n0,,\n*** EOOH ***\n")
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
175 (rmail-nuke-pinhead-header)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
176 ;; Decode base64 or quoted printable contents, Rmail style.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
177 (let* ((header-end (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
178 (and (re-search-forward "\n\n" nil t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
179 (1- (point)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
180 (case-fold-search t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
181 (quoted-printable-header-field-end
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
182 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
183 (re-search-forward
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
184 "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
185 header-end t)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
186 (base64-header-field-end
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
187 (and
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
188 ;; Don't decode non-text data.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
189 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
190 (re-search-forward
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
191 "^content-type:\\(\n?[\t ]\\)\\(text\\|message\\)/"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
192 header-end t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
193 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
194 (re-search-forward
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
195 "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
196 header-end t)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
197
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
198 (goto-char (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
199 (if quoted-printable-header-field-end
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
200 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
201 (unless (mail-unquote-printable-region
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
202 header-end (point) nil t t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
203 (message "Malformed MIME quoted-printable message"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
204 ;; Change "quoted-printable" to "8bit",
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
205 ;; to reflect the decoding we just did.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
206 (goto-char quoted-printable-header-field-end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
207 (delete-region (point) (search-backward ":"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
208 (insert ": 8bit")))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
209 (if base64-header-field-end
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
210 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
211 (when (condition-case nil
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
212 (progn
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
213 (base64-decode-region
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
214 (1+ header-end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
215 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
216 ;; Prevent base64-decode-region
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
217 ;; from removing newline characters.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
218 (skip-chars-backward "\n\t ")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
219 (point)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
220 t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
221 (error nil))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
222 ;; Change "base64" to "8bit", to reflect the
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
223 ;; decoding we just did.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
224 (goto-char base64-header-field-end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
225 (delete-region (point) (search-backward ":"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
226 (insert ": 8bit")))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
227 ;; Transform anything within the message text
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
228 ;; that might appear to be the end of a Babyl-format message.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
229 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
230 (save-restriction
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
231 (narrow-to-region start (point))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
232 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
233 (while (search-forward "\n\^_" nil t) ; single char
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
234 (replace-match "\n^_")))) ; 2 chars: "^" and "_"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
235 ;; This is for malformed messages that don't end in newline.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
236 ;; There shouldn't be any, but some users say occasionally
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
237 ;; there are some.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
238 (or (bolp) (newline))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
239 (insert ?\^_)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
240 (setq last-coding-system-used nil)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
241 ;; Decode coding system, following specs in the message header,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
242 ;; and record what coding system was decoded.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
243 (if rmail-output-decode-coding
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
244 (let ((mime-charset
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
245 (if (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
246 (goto-char start)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
247 (search-forward "\n\n" nil t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
248 (let ((case-fold-search t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
249 (re-search-backward
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
250 rmail-mime-charset-pattern
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
251 start t)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
252 (intern (downcase (match-string 1))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
253 (rmail-decode-region start (point) mime-charset)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
254 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
255 (goto-char start)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
256 (forward-line 3)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
257 (insert "X-Coding-System: "
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
258 (symbol-name last-coding-system-used)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
259 "\n")))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
260
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
261 (defun rmail-nuke-pinhead-header ()
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
262 "Delete the \"From \" line in the current mbox message.
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
263 The variable `rmail-unix-mail-delimiter' specifies the From line format.
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
264 Replaces the From line with a \"Mail-from\" header. Adds \"Date\" and
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
265 \"From\" headers if they are not already present."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
266 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
267 (save-restriction
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
268 (let ((start (point))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
269 (end (progn
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
270 (condition-case ()
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
271 (search-forward "\n\n")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
272 (error
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
273 (goto-char (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
274 (insert "\n\n")))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
275 (point)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
276 has-from has-date)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
277 (narrow-to-region start end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
278 (let ((case-fold-search t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
279 (goto-char start)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
280 (setq has-from (search-forward "\nFrom:" nil t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
281 (goto-char start)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
282 (setq has-date (and (search-forward "\nDate:" nil t) (point)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
283 (goto-char start))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
284 (let ((case-fold-search nil))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
285 (if (re-search-forward (concat "^" rmail-unix-mail-delimiter) nil t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
286 (replace-match
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
287 (concat
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
288 "Mail-from: \\&"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
289 ;; Keep and reformat the date if we don't
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
290 ;; have a Date: field.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
291 (if has-date
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
292 ""
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
293 (concat
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
294 "Date: \\2, \\4 \\3 \\9 \\5 "
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
295
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
296 ;; The timezone could be matched by group 7 or group 10.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
297 ;; If neither of them matched, assume EST, since only
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
298 ;; Easterners would be so sloppy.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
299 ;; It's a shame the substitution can't use "\\10".
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
300 (cond
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
301 ((/= (match-beginning 7) (match-end 7)) "\\7")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
302 ((/= (match-beginning 10) (match-end 10))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
303 (buffer-substring (match-beginning 10)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
304 (match-end 10)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
305 (t "EST"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
306 "\n"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
307 ;; Keep and reformat the sender if we don't
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
308 ;; have a From: field.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
309 (if has-from
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
310 ""
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
311 "From: \\1\n"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
312 t)))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
313
102089
edc57b1b19f0 (rmail-mbox-from): Move to mail-utils.
Glenn Morris <rgm@gnu.org>
parents: 102065
diff changeset
314 (autoload 'mail-mbox-from "mail-utils")
102065
8dfd81b55840 (rmail-mbox-from): New function.
Glenn Morris <rgm@gnu.org>
parents: 102062
diff changeset
315
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
316 (defun rmail-output-as-mbox (file-name nomsg &optional as-seen)
102048
24b13226c128 (rmail-output-decode-coding): Fix custom type, group.
Glenn Morris <rgm@gnu.org>
parents: 102014
diff changeset
317 "Convert the current buffer's text to mbox and output to FILE-NAME.
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
318 Alters the current buffer's text, so it should be a temporary buffer.
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
319 If a buffer is visiting FILE-NAME, adds the text to that buffer
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
320 rather than saving the file directly. If the buffer is an Rmail buffer,
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
321 updates it accordingly. If no buffer is visiting FILE-NAME, appends
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
322 the text directly to FILE-NAME, and displays a \"Wrote file\" message
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
323 unless NOMSG is a symbol (neither nil nor t).
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
324 AS-SEEN is non-nil if we are copying the message \"as seen\"."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
325 (let ((case-fold-search t)
102050
ec7d88c6aa9d (rmail-output-as-mbox): Start search from point-min. If constructing a
Glenn Morris <rgm@gnu.org>
parents: 102048
diff changeset
326 from date)
ec7d88c6aa9d (rmail-output-as-mbox): Start search from point-min. If constructing a
Glenn Morris <rgm@gnu.org>
parents: 102048
diff changeset
327 (goto-char (point-min))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
328 ;; Preserve the Mail-From and MIME-Version fields
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
329 ;; even if they have been pruned.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
330 (search-forward "\n\n" nil 'move)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
331 (narrow-to-region (point-min) (point))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
332 (rmail-delete-unwanted-fields
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
333 (if rmail-enable-mime "Mail-From"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
334 "Mail-From\\|MIME-Version\\|Content-type"))
102050
ec7d88c6aa9d (rmail-output-as-mbox): Start search from point-min. If constructing a
Glenn Morris <rgm@gnu.org>
parents: 102048
diff changeset
335 (goto-char (point-min))
102065
8dfd81b55840 (rmail-mbox-from): New function.
Glenn Morris <rgm@gnu.org>
parents: 102062
diff changeset
336 (or (looking-at "From ")
102089
edc57b1b19f0 (rmail-mbox-from): Move to mail-utils.
Glenn Morris <rgm@gnu.org>
parents: 102065
diff changeset
337 (insert (mail-mbox-from)))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
338 (widen)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
339 ;; Make sure message ends with blank line.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
340 (goto-char (point-max))
102404
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
341 (rmail-ensure-blank-line)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
342 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
343 (let ((buf (find-buffer-visiting file-name))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
344 (tembuf (current-buffer)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
345 (if (null buf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
346 (let ((coding-system-for-write 'raw-text-unix))
102404
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
347 ;; FIXME should ensure existing file ends with a blank line.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
348 (write-region (point-min) (point-max) file-name t nomsg))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
349 (if (eq buf (current-buffer))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
350 (error "Can't output message to same file it's already in"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
351 ;; File has been visited, in buffer BUF.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
352 (set-buffer buf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
353 (let ((inhibit-read-only t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
354 (msg (and (boundp 'rmail-current-message)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
355 rmail-current-message)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
356 (and msg as-seen
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
357 (error "Can't output \"as seen\" to a visited Rmail file"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
358 (if msg
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
359 (rmail-output-to-rmail-buffer tembuf msg)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
360 ;; Output file not in Rmail mode => just insert at the end.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
361 (narrow-to-region (point-min) (1+ (buffer-size)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
362 (goto-char (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
363 (insert-buffer-substring tembuf)))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
364
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
365 (defun rmail-output-to-rmail-buffer (tembuf msg)
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
366 "Copy message in TEMBUF into the current Rmail buffer.
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
367 Do what is necessary to make Rmail know about the new message. then
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
368 display message number MSG."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
369 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
370 (rmail-swap-buffers-maybe)
102910
3d4fe9d9e9e6 Don't query before visiting a Babyl file.
Richard M. Stallman <rms@gnu.org>
parents: 102404
diff changeset
371 (rmail-modify-format)
102404
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
372 ;; Turn on Auto Save mode, if it's off in this buffer but enabled
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
373 ;; by default.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
374 (and (not buffer-auto-save-file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
375 auto-save-default
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
376 (auto-save-mode t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
377 (rmail-maybe-set-message-counters)
102404
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
378 ;; Insert the new message after the last old message.
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
379 (widen)
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
380 ;; Make sure the last old message ends with a blank line.
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
381 (goto-char (point-max))
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
382 (rmail-ensure-blank-line)
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
383 ;; Insert the new message at the end.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
384 (narrow-to-region (point-max) (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
385 (insert-buffer-substring tembuf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
386 (rmail-count-new-messages t)
102404
b2bd32bf5b5e (rmail-output-as-mbox): Use rmail-ensure-blank-line.
Glenn Morris <rgm@gnu.org>
parents: 102318
diff changeset
387 ;; FIXME should re-use existing windows.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
388 (if (rmail-summary-exists)
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
389 (rmail-select-summary (rmail-update-summary)))
101993
1bb96ade4801 Update for rmail-show-message -> rmail-show-message-1 name change.
Glenn Morris <rgm@gnu.org>
parents: 101538
diff changeset
390 (rmail-show-message-1 msg)))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
391
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
392 ;;; There are functions elsewhere in Emacs that use this function;
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
393 ;;; look at them before you change the calling method.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
394 ;;;###autoload
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
395 (defun rmail-output (file-name &optional count noattribute not-rmail)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
396 "Append this message to mail file FILE-NAME.
102053
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
397 Writes mbox format, unless FILE-NAME exists and is Babyl format, in which
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
398 case it writes Babyl.
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
399
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
400 Interactively, the default file name comes from `rmail-default-file',
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
401 which is updated to the name you use in this command. In all uses, if
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
402 FILE-NAME is not absolute, it is expanded with the directory part of
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
403 `rmail-default-file'.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
404
102053
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
405 If a buffer is visiting FILE-NAME, adds the text to that buffer
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
406 rather than saving the file directly. If the buffer is an Rmail
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
407 buffer, updates it accordingly.
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
408
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
409 This command always outputs the complete message header, even if
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
410 the header display is currently pruned.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
411
102053
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
412 Optional prefix argument COUNT (default 1) says to output that
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
413 many consecutive messages, starting with the current one (ignoring
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
414 deleted messages). If `rmail-delete-after-output' is non-nil, deletes
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
415 messages after output.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
416
102053
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
417 The optional third argument NOATTRIBUTE, if non-nil, says not to
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
418 set the `filed' attribute, and not to display a \"Wrote file\"
20687882f9e1 (rmail-output, rmail-output-as-seen): Further doc fixes.
Glenn Morris <rgm@gnu.org>
parents: 102052
diff changeset
419 message (if writing a file directly).
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
420
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
421 Set the optional fourth argument NOT-RMAIL non-nil if you call this
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
422 from a non-Rmail buffer. In this case, COUNT is ignored."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
423 (interactive
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
424 (list (rmail-output-read-file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
425 (prefix-numeric-value current-prefix-arg)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
426 (or count (setq count 1))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
427 (setq file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
428 (expand-file-name file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
429 (and rmail-default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
430 (file-name-directory rmail-default-file))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
431 ;; Warn about creating new file.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
432 (or (find-buffer-visiting file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
433 (file-exists-p file-name)
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
434 (yes-or-no-p (concat "\"" file-name "\" does not exist, create it? "))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
435 (error "Output file does not exist"))
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
436 (if noattribute (setq noattribute 'nomsg))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
437 (let ((babyl-format (and (file-readable-p file-name)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
438 (mail-file-babyl-p file-name)))
102913
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
439 (cur (current-buffer))
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
440 (buf (find-buffer-visiting file-name)))
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
441
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
442 ;; If a babyl file is visited in a buffer, is it visited as babyl
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
443 ;; or as mbox?
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
444 (and babyl-format buf
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
445 (with-current-buffer buf
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
446 (save-restriction
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
447 (widen)
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
448 (save-excursion
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
449 (goto-char (point-min))
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
450 (setq babyl-format
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
451 (looking-at "BABYL OPTIONS:"))))))
497d7a904c67 * mail/rmailout.el (rmail-output): If file is visited,
Richard M. Stallman <rms@gnu.org>
parents: 102912
diff changeset
452
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
453 (if not-rmail ; eg via message-fcc-handler-function
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
454 (with-temp-buffer
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
455 (insert-buffer-substring cur)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
456 ;; Output in the appropriate format.
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
457 (if babyl-format
102065
8dfd81b55840 (rmail-mbox-from): New function.
Glenn Morris <rgm@gnu.org>
parents: 102062
diff changeset
458 (progn
8dfd81b55840 (rmail-mbox-from): New function.
Glenn Morris <rgm@gnu.org>
parents: 102062
diff changeset
459 (goto-char (point-min))
8dfd81b55840 (rmail-mbox-from): New function.
Glenn Morris <rgm@gnu.org>
parents: 102062
diff changeset
460 ;; rmail-convert-to-babyl-format errors if no From line,
8dfd81b55840 (rmail-mbox-from): New function.
Glenn Morris <rgm@gnu.org>
parents: 102062
diff changeset
461 ;; whereas rmail-output-as-mbox inserts one.
8dfd81b55840 (rmail-mbox-from): New function.
Glenn Morris <rgm@gnu.org>
parents: 102062
diff changeset
462 (or (looking-at "From ")
102089
edc57b1b19f0 (rmail-mbox-from): Move to mail-utils.
Glenn Morris <rgm@gnu.org>
parents: 102065
diff changeset
463 (insert (mail-mbox-from)))
102065
8dfd81b55840 (rmail-mbox-from): New function.
Glenn Morris <rgm@gnu.org>
parents: 102062
diff changeset
464 (rmail-output-as-babyl file-name noattribute))
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
465 (rmail-output-as-mbox file-name noattribute)))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
466 ;; Called from an Rmail buffer.
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
467 (if rmail-buffer
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
468 (set-buffer rmail-buffer)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
469 (error "There is no Rmail buffer"))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
470 (let ((orig-count count)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
471 beg end)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
472 (while (> count 0)
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
473 (setq beg (rmail-msgbeg rmail-current-message)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
474 end (rmail-msgend rmail-current-message))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
475 ;; All access to the buffer's local variables is now finished...
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
476 (save-excursion
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
477 ;; ... so it is ok to go to a different buffer.
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
478 (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
479 (setq cur (current-buffer))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
480 (save-restriction
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
481 (widen)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
482 (with-temp-buffer
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
483 (insert-buffer-substring cur beg end)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
484 (if babyl-format
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
485 (rmail-output-as-babyl file-name noattribute)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
486 (rmail-output-as-mbox file-name noattribute)))))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
487 (or noattribute ; mark message as "filed"
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
488 (rmail-set-attribute rmail-filed-attr-index t))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
489 (setq count (1- count))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
490 (let ((next-message-p
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
491 (if rmail-delete-after-output
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
492 (rmail-delete-forward)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
493 (if (> count 0)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
494 (rmail-next-undeleted-message 1))))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
495 (num-appended (- orig-count count)))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
496 (if (and (> count 0) (not next-message-p))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
497 (error "Only %d message%s appended" num-appended
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
498 (if (= num-appended 1) "" "s")))))))))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
499
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
500 ;; FIXME nothing outside uses this, so NOT-RMAIL could be dropped.
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
501 ;; FIXME this duplicates code from rmail-output.
102318
c9c0d0cbf010 (rmail-output-as-seen): Add autoload cookie.
Glenn Morris <rgm@gnu.org>
parents: 102089
diff changeset
502 ;;;###autoload
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
503 (defun rmail-output-as-seen (file-name &optional count noattribute not-rmail)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
504 "Append this message to mbox file named FILE-NAME.
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
505 The details are as for `rmail-output', except that:
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
506 i) the header is output as currently seen
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
507 ii) this function cannot write to Babyl files
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
508 iii) an Rmail buffer cannot be visiting FILE-NAME
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
509
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
510 Note that if NOT-RMAIL is non-nil, there is no difference between this
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
511 function and `rmail-output'. This argument may be removed in future,
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
512 so you should call `rmail-output' directly in that case."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
513 (interactive
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
514 (list (rmail-output-read-file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
515 (prefix-numeric-value current-prefix-arg)))
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
516 (if not-rmail
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
517 (rmail-output file-name count noattribute not-rmail)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
518 (or count (setq count 1))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
519 (setq file-name
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
520 (expand-file-name file-name
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
521 (and rmail-default-file
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
522 (file-name-directory rmail-default-file))))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
523 ;; Warn about creating new file.
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
524 (or (find-buffer-visiting file-name)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
525 (file-exists-p file-name)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
526 (yes-or-no-p (concat "\"" file-name "\" does not exist, create it? "))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
527 (error "Output file does not exist"))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
528 ;; FIXME why not?
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
529 (if (and (file-readable-p file-name) (mail-file-babyl-p file-name))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
530 (error "Cannot output `as seen' to a Babyl file"))
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
531 (if noattribute (setq noattribute 'nomsg))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
532 (if rmail-buffer
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
533 (set-buffer rmail-buffer)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
534 (error "There is no Rmail buffer"))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
535 (let ((orig-count count)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
536 (cur (current-buffer)))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
537 (while (> count 0)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
538 (let (beg end)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
539 ;; If operating from whole-mbox buffer, get message bounds.
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
540 (or (rmail-buffers-swapped-p)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
541 (setq beg (rmail-msgbeg rmail-current-message)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
542 end (rmail-msgend rmail-current-message)))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
543 (save-restriction
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
544 (widen)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
545 ;; If operating from the view buffer, get the bounds.
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
546 (or beg
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
547 (setq beg (point-min)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
548 end (point-max)))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
549 (with-temp-buffer
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
550 (insert-buffer-substring cur beg end)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
551 (rmail-output-as-mbox file-name noattribute t))))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
552 (or noattribute ; mark message as "filed"
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
553 (rmail-set-attribute rmail-filed-attr-index t))
102062
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
554 (setq count (1- count))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
555 (let ((next-message-p
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
556 (if rmail-delete-after-output
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
557 (rmail-delete-forward)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
558 (if (> count 0)
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
559 (rmail-next-undeleted-message 1))))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
560 (num-appended (- orig-count count)))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
561 (if (and (> count 0) (not next-message-p))
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
562 (error "Only %d message%s appended" num-appended
8ddbc5972ea9 (rmail-fields-not-to-output): Doc fix.
Glenn Morris <rgm@gnu.org>
parents: 102053
diff changeset
563 (if (= num-appended 1) "" "s"))))))))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
564
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
565
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
566 ;;;###autoload
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
567 (defun rmail-output-body-to-file (file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
568 "Write this message body to the file FILE-NAME.
102052
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
569 Interactively, the default file name comes from either the message
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
570 \"Subject\" header, or from `rmail-default-body-file'. Updates the value
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
571 of `rmail-default-body-file' accordingly. In all uses, if FILE-NAME
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
572 is not absolute, it is expanded with the directory part of
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
573 `rmail-default-body-file'.
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
574
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
575 Note that this overwrites FILE-NAME (after confirmation), rather
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
576 than appending to it. Deletes the message after writing if
734a66852e68 (rmail-delete-unwanted-fields)
Glenn Morris <rgm@gnu.org>
parents: 102051
diff changeset
577 `rmail-delete-after-output' is non-nil."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
578 (interactive
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
579 (let ((default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
580 (or (mail-fetch-field "Subject")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
581 rmail-default-body-file)))
102014
3c79c5603836 (rmail-output-body-to-file): Avoid space and colon in default file name.
Richard M. Stallman <rms@gnu.org>
parents: 101993
diff changeset
582 (setq default-file
3c79c5603836 (rmail-output-body-to-file): Avoid space and colon in default file name.
Richard M. Stallman <rms@gnu.org>
parents: 101993
diff changeset
583 (replace-regexp-in-string ":" "-" default-file))
3c79c5603836 (rmail-output-body-to-file): Avoid space and colon in default file name.
Richard M. Stallman <rms@gnu.org>
parents: 101993
diff changeset
584 (setq default-file
3c79c5603836 (rmail-output-body-to-file): Avoid space and colon in default file name.
Richard M. Stallman <rms@gnu.org>
parents: 101993
diff changeset
585 (replace-regexp-in-string " " "-" default-file))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
586 (list (setq rmail-default-body-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
587 (read-file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
588 "Output message body to file: "
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
589 (and default-file (file-name-directory default-file))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
590 default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
591 nil default-file)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
592 (setq file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
593 (expand-file-name file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
594 (and rmail-default-body-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
595 (file-name-directory rmail-default-body-file))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
596 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
597 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
598 (search-forward "\n\n")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
599 (and (file-exists-p file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
600 (not (y-or-n-p (format "File %s exists; overwrite? " file-name)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
601 (error "Operation aborted"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
602 (write-region (point) (point-max) file-name))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
603 (if rmail-delete-after-output
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
604 (rmail-delete-forward)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
605
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
606 ;; arch-tag: 4059abf0-f249-4be4-8e0d-602d370d01d1
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
607 ;;; rmailout.el ends here