annotate lisp/mail/rmailout.el @ 102014:3c79c5603836

(rmail-output-body-to-file): Avoid space and colon in default file name.
author Richard M. Stallman <rms@gnu.org>
date Sat, 14 Feb 2009 02:53:37 +0000
parents 1bb96ade4801
children 24b13226c128
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,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
4 ;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
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
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
8
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
10
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
11 ;; 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
12 ;; 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
13 ;; 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
14 ;; (at your option) any later version.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
15
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
16 ;; 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
17 ;; 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
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
20
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
21 ;; 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
22 ;; 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
23
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
24 ;;; Commentary:
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
25
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
26 ;;; Code:
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
27
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
28 (require 'rmail)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
29 (provide 'rmailout)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
30
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
31 (defcustom rmail-output-decode-coding nil
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
32 "If non-nil, do coding system decoding when outputting message as Babyl."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
33 :type '(choice (const :tag "on" t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
34 (const :tag "off" nil))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
35 :group 'rmail)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
36
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
37 (defcustom rmail-output-file-alist nil
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
38 "Alist matching regexps to suggested output Rmail files.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
39 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
40 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
41 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
42 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
43 a file name as a string."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
44 :type '(repeat (cons regexp
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
45 (choice :value ""
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
46 (string :tag "File Name")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
47 sexp)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
48 :group 'rmail-output)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
49
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
50 (defun rmail-output-read-file-name ()
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
51 "Read the file name to use for `rmail-output'.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
52 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
53 (let ((default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
54 (let (answer tail)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
55 (setq tail rmail-output-file-alist)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
56 ;; Suggest a file based on a pattern match.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
57 (while (and tail (not answer))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
58 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
59 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
60 (if (re-search-forward (car (car tail)) nil t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
61 (setq answer (eval (cdr (car tail)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
62 (setq tail (cdr tail))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
63 ;; If no suggestion, use same file as last time.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
64 (or answer rmail-default-file))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
65 (let ((read-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
66 (expand-file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
67 (read-file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
68 (concat "Output message to mail file (default "
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
69 (file-name-nondirectory default-file)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
70 "): ")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
71 (file-name-directory default-file)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
72 (abbreviate-file-name default-file))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
73 (file-name-directory default-file))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
74 (setq rmail-default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
75 (if (file-directory-p read-file)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
76 (expand-file-name (file-name-nondirectory default-file)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
77 read-file)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
78 (expand-file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
79 (or read-file (file-name-nondirectory default-file))
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
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
82 (defcustom rmail-fields-not-to-output nil
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
83 "Regexp describing fields to exclude when outputting a message to a file."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
84 :type '(choice (const :tag "None" nil)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
85 regexp)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
86 :group 'rmail-output)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
87
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
88 ;; Delete from the buffer header fields we don't want output.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
89 ;; Buffer should be pre-narrowed to the header.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
90 ;; PRESERVE is a regexp for fields NEVER to delete.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
91 (defun rmail-delete-unwanted-fields (preserve)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
92 (if rmail-fields-not-to-output
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
93 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
94 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
95 (while (re-search-forward rmail-fields-not-to-output nil t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
96 (beginning-of-line)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
97 (unless (looking-at preserve)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
98 (delete-region (point)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
99 (progn (forward-line 1) (point))))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
100
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
101 (defun rmail-output-as-babyl (file-name nomsg)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
102 "Convert the current buffer's text to Babyl and output to FILE-NAME.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
103 It alters the current buffer's text, so it should be a temp buffer."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
104 (let ((coding-system-for-write
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
105 'emacs-mule-unix))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
106 (save-restriction
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
107 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
108 (search-forward "\n\n" nil 'move)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
109 (narrow-to-region (point-min) (point))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
110 (if rmail-fields-not-to-output
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
111 (rmail-delete-unwanted-fields nil)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
112
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
113 ;; Convert to Babyl format.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
114 (rmail-convert-to-babyl-format)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
115 ;; Write it into the file, or its buffer.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
116 (let ((buf (find-buffer-visiting file-name))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
117 (tembuf (current-buffer)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
118 (if (null buf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
119 (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
120 (if (eq buf (current-buffer))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
121 (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
122 ;; File has been visited, in buffer BUF.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
123 (set-buffer buf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
124 (let ((inhibit-read-only t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
125 (msg (with-no-warnings
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
126 (and (boundp 'rmail-current-message)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
127 rmail-current-message))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
128 ;; 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
129 (if msg
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
130 (rmail-output-to-babyl-buffer tembuf msg)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
131 ;; 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
132 (narrow-to-region (point-min) (1+ (buffer-size)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
133 (goto-char (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
134 (insert-buffer-substring tembuf)))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
135
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
136 (defun rmail-output-to-babyl-buffer (tembuf msg)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
137 "Copy msg in TEMBUF from BEG to END into this old R-mail BABYL buffer.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
138 Do what is necessary to make babyl R-mail know about the new message.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
139 Then display message number MSG."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
140 (with-no-warnings
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
141 ;; Turn on Auto Save mode, if it's off in this
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
142 ;; buffer but enabled by default.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
143 (and (not buffer-auto-save-file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
144 auto-save-default
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
145 (auto-save-mode t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
146 (rmail-maybe-set-message-counters)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
147 (widen)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
148 (narrow-to-region (point-max) (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
149 (insert-buffer-substring tembuf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
150 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
151 (widen)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
152 (search-backward "\n\^_")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
153 (narrow-to-region (point) (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
154 (rmail-count-new-messages t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
155 (if (rmail-summary-exists)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
156 (rmail-select-summary
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
157 (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
158 (rmail-show-message-1 msg)))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
159
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
160 (defun rmail-convert-to-babyl-format ()
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
161 (let ((count 0) (start (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
162 (case-fold-search nil)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
163 (buffer-undo-list t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
164 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
165 (save-restriction
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
166 (unless (looking-at "^From ")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
167 (error "Invalid mbox message"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
168 (insert "\^L\n0, unseen,,\n*** EOOH ***\n")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
169 (rmail-nuke-pinhead-header)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
170 ;; Decode base64 or quoted printable contents, Rmail style.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
171 (let* ((header-end (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
172 (and (re-search-forward "\n\n" nil t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
173 (1- (point)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
174 (case-fold-search t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
175 (quoted-printable-header-field-end
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
176 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
177 (re-search-forward
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
178 "^content-transfer-encoding:\\(\n?[\t ]\\)*quoted-printable\\(\n?[\t ]\\)*"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
179 header-end t)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
180 (base64-header-field-end
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
181 (and
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
182 ;; Don't decode non-text data.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
183 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
184 (re-search-forward
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
185 "^content-type:\\(\n?[\t ]\\)\\(text\\|message\\)/"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
186 header-end t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
187 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
188 (re-search-forward
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
189 "^content-transfer-encoding:\\(\n?[\t ]\\)*base64\\(\n?[\t ]\\)*"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
190 header-end t)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
191
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
192 (goto-char (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
193 (if quoted-printable-header-field-end
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
194 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
195 (unless (mail-unquote-printable-region
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
196 header-end (point) nil t t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
197 (message "Malformed MIME quoted-printable message"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
198 ;; Change "quoted-printable" to "8bit",
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
199 ;; to reflect the decoding we just did.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
200 (goto-char quoted-printable-header-field-end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
201 (delete-region (point) (search-backward ":"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
202 (insert ": 8bit")))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
203 (if base64-header-field-end
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
204 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
205 (when (condition-case nil
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
206 (progn
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
207 (base64-decode-region
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
208 (1+ header-end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
209 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
210 ;; Prevent base64-decode-region
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
211 ;; from removing newline characters.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
212 (skip-chars-backward "\n\t ")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
213 (point)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
214 t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
215 (error nil))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
216 ;; Change "base64" to "8bit", to reflect the
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
217 ;; decoding we just did.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
218 (goto-char base64-header-field-end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
219 (delete-region (point) (search-backward ":"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
220 (insert ": 8bit")))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
221 ;; Transform anything within the message text
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
222 ;; 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
223 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
224 (save-restriction
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
225 (narrow-to-region start (point))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
226 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
227 (while (search-forward "\n\^_" nil t) ; single char
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
228 (replace-match "\n^_")))) ; 2 chars: "^" and "_"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
229 ;; 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
230 ;; 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
231 ;; there are some.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
232 (or (bolp) (newline))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
233 (insert ?\^_)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
234 (setq last-coding-system-used nil)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
235 ;; Decode coding system, following specs in the message header,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
236 ;; and record what coding system was decoded.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
237 (if rmail-output-decode-coding
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
238 (let ((mime-charset
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
239 (if (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
240 (goto-char start)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
241 (search-forward "\n\n" nil t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
242 (let ((case-fold-search t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
243 (re-search-backward
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
244 rmail-mime-charset-pattern
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
245 start t)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
246 (intern (downcase (match-string 1))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
247 (rmail-decode-region start (point) mime-charset)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
248 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
249 (goto-char start)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
250 (forward-line 3)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
251 (insert "X-Coding-System: "
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
252 (symbol-name last-coding-system-used)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
253 "\n")))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
254
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
255 ;; Delete the "From ..." line, creating various other headers with
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
256 ;; information from it if they don't already exist. Now puts the
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
257 ;; original line into a mail-from: header line for debugging and for
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
258 ;; use by the rmail-output function.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
259 (defun rmail-nuke-pinhead-header ()
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
260 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
261 (save-restriction
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
262 (let ((start (point))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
263 (end (progn
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
264 (condition-case ()
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
265 (search-forward "\n\n")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
266 (error
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
267 (goto-char (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
268 (insert "\n\n")))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
269 (point)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
270 has-from has-date)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
271 (narrow-to-region start end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
272 (let ((case-fold-search t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
273 (goto-char start)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
274 (setq has-from (search-forward "\nFrom:" nil t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
275 (goto-char start)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
276 (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
277 (goto-char start))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
278 (let ((case-fold-search nil))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
279 (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
280 (replace-match
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
281 (concat
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
282 "Mail-from: \\&"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
283 ;; Keep and reformat the date if we don't
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
284 ;; have a Date: field.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
285 (if has-date
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
286 ""
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 "Date: \\2, \\4 \\3 \\9 \\5 "
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
289
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
290 ;; 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
291 ;; If neither of them matched, assume EST, since only
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
292 ;; Easterners would be so sloppy.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
293 ;; 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
294 (cond
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
295 ((/= (match-beginning 7) (match-end 7)) "\\7")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
296 ((/= (match-beginning 10) (match-end 10))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
297 (buffer-substring (match-beginning 10)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
298 (match-end 10)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
299 (t "EST"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
300 "\n"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
301 ;; Keep and reformat the sender if we don't
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
302 ;; have a From: field.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
303 (if has-from
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
304 ""
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
305 "From: \\1\n"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
306 t)))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
307
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
308 (defun rmail-output-as-mbox (file-name nomsg &optional as-seen)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
309 "Convert the current buffer's text to mbox Babyl and output to FILE-NAME.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
310 It alters the current buffer's text, so call with a temp buffer current.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
311 If FILE-NAME is visited, output into its buffer instead.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
312 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
313 (let ((case-fold-search t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
314 mail-from mime-version content-type)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
315
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
316 ;; Preserve the Mail-From and MIME-Version fields
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
317 ;; even if they have been pruned.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
318 (search-forward "\n\n" nil 'move)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
319 (narrow-to-region (point-min) (point))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
320
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
321 (rmail-delete-unwanted-fields
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
322 (if rmail-enable-mime "Mail-From"
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
323 "Mail-From\\|MIME-Version\\|Content-type"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
324
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
325 (widen)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
326
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
327 ;; Make sure message ends with blank line.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
328 (goto-char (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
329 (unless (bolp)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
330 (insert "\n"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
331 (unless (looking-back "\n\n")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
332 (insert "\n"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
333
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
334 ;; Generate a From line from other header fields
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
335 ;; if necessary.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
336 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
337 (unless (looking-at "From ")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
338 (insert "From "
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
339 (mail-strip-quoted-names
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
340 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
341 (save-restriction
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 (narrow-to-region
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
344 (point)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
345 (or (search-forward "\n\n" nil)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
346 (point-max)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
347 (or (mail-fetch-field "from")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
348 (mail-fetch-field "really-from")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
349 (mail-fetch-field "sender")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
350 "unknown"))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
351 " " (current-time-string) "\n"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
352
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
353 (let ((buf (find-buffer-visiting file-name))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
354 (tembuf (current-buffer)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
355 (if (null buf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
356 (let ((coding-system-for-write 'raw-text-unix))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
357 (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
358 (if (eq buf (current-buffer))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
359 (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
360 ;; File has been visited, in buffer BUF.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
361 (set-buffer buf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
362 (let ((inhibit-read-only t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
363 (msg (and (boundp 'rmail-current-message)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
364 rmail-current-message)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
365 (and msg as-seen
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
366 (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
367 (if msg
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
368 (rmail-output-to-rmail-buffer tembuf msg)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
369 ;; 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
370 (narrow-to-region (point-min) (1+ (buffer-size)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
371 (goto-char (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
372 (insert-buffer-substring tembuf)))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
373
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
374 ;; Called only if rmail-summary-exists, which means rmailsum is loaded.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
375 (declare-function rmail-update-summary "rmailsum" (&rest ignore))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
376
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
377 (defun rmail-output-to-rmail-buffer (tembuf msg)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
378 "Copy msg in TEMBUF from BEG to END into this Rmail buffer.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
379 Do what is necessary to make Rmail know about the new message.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
380 Then display message number MSG."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
381 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
382 (rmail-swap-buffers-maybe)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
383 ;; Turn on Auto Save mode, if it's off in this
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
384 ;; buffer but enabled by default.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
385 (and (not buffer-auto-save-file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
386 auto-save-default
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
387 (auto-save-mode t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
388 (rmail-maybe-set-message-counters)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
389 (narrow-to-region (point-max) (point-max))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
390 (insert-buffer-substring tembuf)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
391 (rmail-count-new-messages t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
392 (if (rmail-summary-exists)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
393 (rmail-select-summary
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
394 (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
395 (rmail-show-message-1 msg)))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
396
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
397 ;;; 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
398 ;;; look at them before you change the calling method.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
399 ;;;###autoload
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
400 (defun rmail-output (file-name &optional count noattribute from-gnus)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
401 "Append this message to mail file FILE-NAME.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
402 This works with both mbox format and Babyl format files,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
403 outputting in the appropriate format for each.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
404 The default file name comes from `rmail-default-file',
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
405 which is updated to the name you use in this command.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
406
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
407 A prefix argument COUNT says to output that many consecutive messages,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
408 starting with the current one. Deleted messages are skipped and don't count.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
409 When called from Lisp code, COUNT may be omitted and defaults to 1.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
410
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
411 This command always outputs the complete message header,
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
412 even if the header display is currently pruned.
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
413
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
414 The optional third argument NOATTRIBUTE, if non-nil, says not
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
415 to set the `filed' attribute, and not to display a message.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
416
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
417 The optional fourth argument FROM-GNUS is set when called from GNUS."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
418 (interactive
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
419 (list (rmail-output-read-file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
420 (prefix-numeric-value current-prefix-arg)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
421 (or count (setq count 1))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
422 (setq file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
423 (expand-file-name file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
424 (and rmail-default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
425 (file-name-directory rmail-default-file))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
426
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
427 ;; Warn about creating new file.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
428 (or (find-buffer-visiting file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
429 (file-exists-p file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
430 (yes-or-no-p
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
431 (concat "\"" file-name "\" does not exist, create it? "))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
432 (error "Output file does not exist"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
433
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
434 (set-buffer rmail-buffer)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
435
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
436 (let ((orig-count count)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
437 (case-fold-search t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
438 (tembuf (get-buffer-create " rmail-output"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
439 (babyl-format
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
440 (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
441
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
442 (unwind-protect
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
443 (while (> count 0)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
444 (with-current-buffer rmail-buffer
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
445 (let (cur beg end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
446 (setq beg (rmail-msgbeg rmail-current-message)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
447 end (rmail-msgend rmail-current-message))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
448 ;; All access to the buffer's local variables is now finished...
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
449 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
450 ;; ... so it is ok to go to a different buffer.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
451 (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
452 (setq cur (current-buffer))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
453 (save-restriction
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
454 (widen)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
455 (with-current-buffer tembuf
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
456 (insert-buffer-substring cur beg end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
457 ;; Convert the text to one format or another and output.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
458 (if babyl-format
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
459 (rmail-output-as-babyl file-name (if noattribute 'nomsg))
101538
cf5cba9728ee Remove leading `*' from defcustom docs.
Glenn Morris <rgm@gnu.org>
parents: 101375
diff changeset
460 (rmail-output-as-mbox file-name
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
461 (if noattribute 'nomsg))))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
462
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
463 ;; Mark message as "filed".
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
464 (unless noattribute
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
465 (rmail-set-attribute rmail-filed-attr-index t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
466
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
467 (setq count (1- count))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
468
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
469 (or from-gnus
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
470 (let ((next-message-p
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
471 (if rmail-delete-after-output
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
472 (rmail-delete-forward)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
473 (if (> count 0)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
474 (rmail-next-undeleted-message 1))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
475 (num-appended (- orig-count count)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
476 (if (and (> count 0) (not next-message-p))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
477 (error "Only %d message%s appended" num-appended
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
478 (if (= num-appended 1) "" "s"))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
479 (kill-buffer tembuf))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
480
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
481 (defun rmail-output-as-seen (file-name &optional count noattribute from-gnus)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
482 "Append this message to system-inbox-format mail file named FILE-NAME.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
483 A prefix argument COUNT says to output that many consecutive messages,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
484 starting with the current one. Deleted messages are skipped and don't count.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
485 When called from Lisp code, COUNT may be omitted and defaults to 1.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
486
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
487 This outputs the message header as you see it.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
488
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
489 The default file name comes from `rmail-default-file',
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
490 which is updated to the name you use in this command.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
491
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
492 The optional third argument NOATTRIBUTE, if non-nil, says not
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
493 to set the `filed' attribute, and not to display a message.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
494
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
495 The optional fourth argument FROM-GNUS is set when called from GNUS."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
496 (interactive
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
497 (list (rmail-output-read-file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
498 (prefix-numeric-value current-prefix-arg)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
499 (or count (setq count 1))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
500 (setq file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
501 (expand-file-name file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
502 (and rmail-default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
503 (file-name-directory rmail-default-file))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
504 (set-buffer rmail-buffer)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
505
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
506 ;; Warn about creating new file.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
507 (or (find-buffer-visiting file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
508 (file-exists-p file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
509 (yes-or-no-p
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
510 (concat "\"" file-name "\" does not exist, create it? "))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
511 (error "Output file does not exist"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
512
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
513 (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
514 (error "Cannot output `as seen' to a Babyl file"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
515
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
516 (let ((orig-count count)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
517 (case-fold-search t)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
518 (tembuf (get-buffer-create " rmail-output")))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
519
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
520 (unwind-protect
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
521 (while (> count 0)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
522 (let (cur beg end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
523 ;; If operating from whole-mbox buffer, get message bounds.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
524 (if (not (rmail-buffers-swapped-p))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
525 (setq beg (rmail-msgbeg rmail-current-message)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
526 end (rmail-msgend rmail-current-message)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
527 ;; All access to the buffer's local variables is now finished...
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
528 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
529 (setq cur (current-buffer))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
530 (save-restriction
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
531 (widen)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
532 ;; If operating from the view buffer, get the bounds.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
533 (unless beg
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
534 (setq beg (point-min)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
535 end (point-max)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
536
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
537 (with-current-buffer tembuf
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
538 (insert-buffer-substring cur beg end)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
539 ;; Convert the text to one format or another and output.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
540 (rmail-output-as-mbox file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
541 (if noattribute 'nomsg)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
542 t)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
543
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
544 ;; Mark message as "filed".
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
545 (unless noattribute
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
546 (rmail-set-attribute rmail-filed-attr-index t))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
547
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
548 (setq count (1- count))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
549
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
550 (or from-gnus
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
551 (let ((next-message-p
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
552 (if rmail-delete-after-output
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
553 (rmail-delete-forward)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
554 (if (> count 0)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
555 (rmail-next-undeleted-message 1))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
556 (num-appended (- orig-count count)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
557 (if (and (> count 0) (not next-message-p))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
558 (error "Only %d message%s appended" num-appended
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
559 (if (= num-appended 1) "" "s"))))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
560 (kill-buffer tembuf))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
561
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
562
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
563 ;;;###autoload
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
564 (defun rmail-output-body-to-file (file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
565 "Write this message body to the file FILE-NAME.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
566 FILE-NAME defaults, interactively, from the Subject field of the message."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
567 (interactive
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
568 (let ((default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
569 (or (mail-fetch-field "Subject")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
570 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
571 (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
572 (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
573 (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
574 (replace-regexp-in-string " " "-" default-file))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
575 (list (setq rmail-default-body-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
576 (read-file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
577 "Output message body to file: "
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
578 (and default-file (file-name-directory default-file))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
579 default-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
580 nil default-file)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
581 (setq file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
582 (expand-file-name file-name
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
583 (and rmail-default-body-file
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
584 (file-name-directory rmail-default-body-file))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
585 (save-excursion
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
586 (goto-char (point-min))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
587 (search-forward "\n\n")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
588 (and (file-exists-p file-name)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
589 (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
590 (error "Operation aborted"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
591 (write-region (point) (point-max) file-name))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
592 (if rmail-delete-after-output
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
593 (rmail-delete-forward)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
594
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
595 ;; arch-tag: 4059abf0-f249-4be4-8e0d-602d370d01d1
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
596 ;;; rmailout.el ends here