annotate lisp/mail/pmailout.el @ 100377:241987bb5332

(pmail-output): Rewrite to handle mbox format. (pmail-output-to-babyl-file): Renamed from pmail-output-to-pmail-file.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 12 Dec 2008 15:26:28 +0000
parents 1afe9b0dcf0e
children e5f10d15806c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
1 ;;; pmailout.el --- "PMAIL" mail reader for Emacs: output message to a file
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
2
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
3 ;; Copyright (C) 1985, 1987, 1993, 1994, 2001, 2002, 2003, 2004,
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
5
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
6 ;; Maintainer: FSF
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
7 ;; Keywords: mail
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
8
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
10
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
14 ;; (at your option) any later version.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
15
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
20
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
23
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
24 ;;; Commentary:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
25
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
26 ;;; Code:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
27
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
28 (require 'pmail)
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
29 (provide 'pmailout)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
30
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
31 ;;;###autoload
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
32 (defcustom pmail-output-file-alist nil
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
33 "*Alist matching regexps to suggested output Pmail files.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
34 This is a list of elements of the form (REGEXP . NAME-EXP).
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
35 The suggestion is taken if REGEXP matches anywhere in the message buffer.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
36 NAME-EXP may be a string constant giving the file name to use,
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
37 or more generally it may be any kind of expression that returns
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
38 a file name as a string."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
39 :type '(repeat (cons regexp
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
40 (choice :value ""
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
41 (string :tag "File Name")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
42 sexp)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
43 :group 'pmail-output)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
44
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
45 (defun pmail-output-read-pmail-file-name ()
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
46 "Read the file name to use for `pmail-output-to-babyl-file'.
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
47 Set `pmail-default-pmail-file' to this name as well as returning it."
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
48 (let ((default-file
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
49 (let (answer tail)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
50 (setq tail pmail-output-file-alist)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
51 ;; Suggest a file based on a pattern match.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
52 (while (and tail (not answer))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
53 (save-excursion
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
54 (set-buffer pmail-buffer)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
55 (goto-char (point-min))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
56 (if (re-search-forward (car (car tail)) nil t)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
57 (setq answer (eval (cdr (car tail)))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
58 (setq tail (cdr tail))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
59 ;; If no suggestions, use same file as last time.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
60 (expand-file-name (or answer pmail-default-pmail-file)))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
61 (let ((read-file
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
62 (expand-file-name
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
63 (read-file-name
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
64 (concat "Output message to Pmail file (default "
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
65 (file-name-nondirectory default-file)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
66 "): ")
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
67 (file-name-directory default-file)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
68 (abbreviate-file-name default-file))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
69 (file-name-directory default-file))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
70 ;; If the user enters just a directory,
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
71 ;; use the name within that directory chosen by the default.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
72 (setq pmail-default-pmail-file
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
73 (if (file-directory-p read-file)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
74 (expand-file-name (file-name-nondirectory default-file)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
75 read-file)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
76 read-file)))))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
77
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
78 (defun pmail-output-read-file-name ()
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
79 "Read the file name to use for `pmail-output'.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
80 Set `pmail-default-file' to this name as well as returning it."
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
81 (let ((default-file
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
82 (let (answer tail)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
83 (setq tail pmail-output-file-alist)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
84 ;; Suggest a file based on a pattern match.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
85 (while (and tail (not answer))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
86 (save-excursion
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
87 (goto-char (point-min))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
88 (if (re-search-forward (car (car tail)) nil t)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
89 (setq answer (eval (cdr (car tail)))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
90 (setq tail (cdr tail))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
91 ;; If no suggestion, use same file as last time.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
92 (or answer pmail-default-file))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
93 (let ((read-file
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
94 (expand-file-name
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
95 (read-file-name
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
96 (concat "Output message to Unix mail file (default "
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
97 (file-name-nondirectory default-file)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
98 "): ")
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
99 (file-name-directory default-file)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
100 (abbreviate-file-name default-file))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
101 (file-name-directory default-file))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
102 (setq pmail-default-file
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
103 (if (file-directory-p read-file)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
104 (expand-file-name (file-name-nondirectory default-file)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
105 read-file)
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
106 (expand-file-name
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
107 (or read-file (file-name-nondirectory default-file))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
108 (file-name-directory default-file)))))))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
109
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
110 (declare-function pmail-update-summary "pmailsum" (&rest ignore))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
111
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
112 ;;; There are functions elsewhere in Emacs that use this function;
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
113 ;;; look at them before you change the calling method.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
114 ;;;###autoload
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
115 (defun pmail-output-to-babyl-file (file-name &optional count stay)
100339
1afe9b0dcf0e (pmail-output-to-pmail-file): Don't call
Chong Yidong <cyd@stupidchicken.com>
parents: 100223
diff changeset
116 "Append the current message to a Babyl file named FILE-NAME.
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
117 If the file does not exist, ask if it should be created.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
118 If file is being visited, the message is appended to the Emacs
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
119 buffer visiting that file.
100339
1afe9b0dcf0e (pmail-output-to-pmail-file): Don't call
Chong Yidong <cyd@stupidchicken.com>
parents: 100223
diff changeset
120 If the file exists and is not a Babyl file, the message is
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
121 appended in inbox format, the same way `pmail-output' does it.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
122
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
123 The default file name comes from `pmail-default-pmail-file',
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
124 which is updated to the name you use in this command.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
125
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
126 A prefix argument COUNT says to output that many consecutive messages,
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
127 starting with the current one. Deleted messages are skipped and don't count.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
128
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
129 If the optional argument STAY is non-nil, then leave the last filed
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
130 message up instead of moving forward to the next non-deleted message."
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
131 (interactive
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
132 (list (pmail-output-read-pmail-file-name)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
133 (prefix-numeric-value current-prefix-arg)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
134 (or count (setq count 1))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
135 (setq file-name
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
136 (expand-file-name file-name
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
137 (file-name-directory pmail-default-pmail-file)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
138 (if (and (file-readable-p file-name) (not (mail-file-babyl-p file-name)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
139 (pmail-output file-name count)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
140 (pmail-maybe-set-message-counters)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
141 (setq file-name (abbreviate-file-name file-name))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
142 (or (find-buffer-visiting file-name)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
143 (file-exists-p file-name)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
144 (if (yes-or-no-p
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
145 (concat "\"" file-name "\" does not exist, create it? "))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
146 (let ((file-buffer (create-file-buffer file-name)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
147 (save-excursion
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
148 (set-buffer file-buffer)
100339
1afe9b0dcf0e (pmail-output-to-pmail-file): Don't call
Chong Yidong <cyd@stupidchicken.com>
parents: 100223
diff changeset
149 (let ((buffer-read-only nil))
1afe9b0dcf0e (pmail-output-to-pmail-file): Don't call
Chong Yidong <cyd@stupidchicken.com>
parents: 100223
diff changeset
150 (insert "BABYL OPTIONS: -*- pmail -*-
1afe9b0dcf0e (pmail-output-to-pmail-file): Don't call
Chong Yidong <cyd@stupidchicken.com>
parents: 100223
diff changeset
151 Version: 5
1afe9b0dcf0e (pmail-output-to-pmail-file): Don't call
Chong Yidong <cyd@stupidchicken.com>
parents: 100223
diff changeset
152 Labels:
1afe9b0dcf0e (pmail-output-to-pmail-file): Don't call
Chong Yidong <cyd@stupidchicken.com>
parents: 100223
diff changeset
153 Note: This is the header of an pmail file.
1afe9b0dcf0e (pmail-output-to-pmail-file): Don't call
Chong Yidong <cyd@stupidchicken.com>
parents: 100223
diff changeset
154 Note: If you are seeing it in pmail,
1afe9b0dcf0e (pmail-output-to-pmail-file): Don't call
Chong Yidong <cyd@stupidchicken.com>
parents: 100223
diff changeset
155 Note: it means the file has no messages in it.\n\^_"))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
156 (let ((require-final-newline nil)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
157 (coding-system-for-write
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
158 (or pmail-file-coding-system
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
159 'emacs-mule-unix)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
160 (write-region (point-min) (point-max) file-name t 1)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
161 (kill-buffer file-buffer))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
162 (error "Output file does not exist")))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
163 (while (> count 0)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
164 (let (redelete)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
165 (unwind-protect
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
166 (progn
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
167 (set-buffer pmail-buffer)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
168 ;; Temporarily turn off Deleted attribute.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
169 ;; Do this outside the save-restriction, since it would
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
170 ;; shift the place in the buffer where the visible text starts.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
171 (if (pmail-message-deleted-p pmail-current-message)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
172 (progn (setq redelete t)
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
173 (pmail-set-attribute pmail-deleted-attr-index nil)))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
174 (save-restriction
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
175 (widen)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
176 ;; Decide whether to append to a file or to an Emacs buffer.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
177 (save-excursion
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
178 (let ((buf (find-buffer-visiting file-name))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
179 (cur (current-buffer))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
180 (beg (1+ (pmail-msgbeg pmail-current-message)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
181 (end (1+ (pmail-msgend pmail-current-message)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
182 (coding-system-for-write
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
183 (or pmail-file-coding-system
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
184 'emacs-mule-unix)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
185 (if (not buf)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
186 ;; Output to a file.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
187 (if pmail-fields-not-to-output
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
188 ;; Delete some fields while we output.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
189 (let ((obuf (current-buffer)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
190 (set-buffer (get-buffer-create " pmail-out-temp"))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
191 (insert-buffer-substring obuf beg end)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
192 (pmail-delete-unwanted-fields)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
193 (append-to-file (point-min) (point-max) file-name)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
194 (set-buffer obuf)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
195 (kill-buffer (get-buffer " pmail-out-temp")))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
196 (append-to-file beg end file-name))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
197 (if (eq buf (current-buffer))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
198 (error "Can't output message to same file it's already in"))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
199 ;; File has been visited, in buffer BUF.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
200 (set-buffer buf)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
201 (let ((buffer-read-only nil)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
202 (msg (and (boundp 'pmail-current-message)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
203 pmail-current-message)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
204 ;; If MSG is non-nil, buffer is in PMAIL mode.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
205 (if msg
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
206 (progn
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
207 ;; Turn on auto save mode, if it's off in this
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
208 ;; buffer but enabled by default.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
209 (and (not buffer-auto-save-file-name)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
210 auto-save-default
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
211 (auto-save-mode t))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
212 (pmail-maybe-set-message-counters)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
213 (widen)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
214 (narrow-to-region (point-max) (point-max))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
215 (insert-buffer-substring cur beg end)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
216 (goto-char (point-min))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
217 (widen)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
218 (search-backward "\n\^_")
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
219 (narrow-to-region (point) (point-max))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
220 (pmail-delete-unwanted-fields)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
221 (pmail-count-new-messages t)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
222 (if (pmail-summary-exists)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
223 (pmail-select-summary
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
224 (pmail-update-summary)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
225 (pmail-show-message msg))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
226 ;; Output file not in pmail mode => just insert at the end.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
227 (narrow-to-region (point-min) (1+ (buffer-size)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
228 (goto-char (point-max))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
229 (insert-buffer-substring cur beg end)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
230 (pmail-delete-unwanted-fields)))))))
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
231 (pmail-set-attribute pmail-filed-attr-index t))
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
232 (if redelete (pmail-set-attribute pmail-deleted-attr-index t))))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
233 (setq count (1- count))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
234 (if pmail-delete-after-output
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
235 (unless
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
236 (if (and (= count 0) stay)
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
237 (pmail-delete-message)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
238 (pmail-delete-forward))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
239 (setq count 0))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
240 (if (> count 0)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
241 (unless
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
242 (if (not stay) (pmail-next-undeleted-message 1))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
243 (setq count 0)))))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
244
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
245 (defalias 'pmail-output-to-pmail-file 'pmail-output-to-babyl-file)
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
246
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
247 ;;;###autoload
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
248 (defcustom pmail-fields-not-to-output nil
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
249 "*Regexp describing fields to exclude when outputting a message to a file."
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
250 :type '(choice (const :tag "None" nil)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
251 regexp)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
252 :group 'pmail-output)
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
253
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
254 ;; Delete from the buffer header fields we don't want output.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
255 ;; NOT-PMAIL if t means this buffer does not have the full header
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
256 ;; and *** EOOH *** that a message in an Pmail file has.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
257 (defun pmail-delete-unwanted-fields (&optional not-pmail)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
258 (if pmail-fields-not-to-output
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
259 (save-excursion
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
260 (goto-char (point-min))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
261 ;; Find the end of the header.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
262 (if (and (or not-pmail (search-forward "\n*** EOOH ***\n" nil t))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
263 (search-forward "\n\n" nil t))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
264 (let ((end (point-marker)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
265 (goto-char (point-min))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
266 (while (re-search-forward pmail-fields-not-to-output end t)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
267 (beginning-of-line)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
268 (delete-region (point)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
269 (progn (forward-line 1) (point)))))))))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
270
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
271 ;;; There are functions elsewhere in Emacs that use this function;
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
272 ;;; look at them before you change the calling method.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
273 ;;;###autoload
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
274 (defun pmail-output (file-name &optional count noattribute from-gnus)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
275 "Append this message to system-inbox-format mail file named FILE-NAME.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
276 A prefix argument COUNT says to output that many consecutive messages,
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
277 starting with the current one. Deleted messages are skipped and don't count.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
278 When called from lisp code, COUNT may be omitted and defaults to 1.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
279
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
280 If the pruned message header is shown on the current message, then
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
281 messages will be appended with pruned headers; otherwise, messages
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
282 will be appended with their original headers.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
283
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
284 The default file name comes from `pmail-default-file',
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
285 which is updated to the name you use in this command.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
286
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
287 The optional third argument NOATTRIBUTE, if non-nil, says not
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
288 to set the `filed' attribute, and not to display a message.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
289
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
290 The optional fourth argument FROM-GNUS is set when called from GNUS."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
291 (interactive
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
292 (list (pmail-output-read-file-name)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
293 (prefix-numeric-value current-prefix-arg)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
294 (or count (setq count 1))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
295 (setq file-name
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
296 (expand-file-name file-name
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
297 (and pmail-default-file
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
298 (file-name-directory pmail-default-file))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
299 (if (and (file-readable-p file-name) (mail-file-babyl-p file-name))
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
300 (pmail-output-to-babyl-file file-name count)
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
301 (set-buffer pmail-buffer)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
302 (let ((orig-count count)
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
303 (pmailbuf pmail-buffer)
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
304 (case-fold-search t)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
305 (tembuf (get-buffer-create " pmail-output"))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
306 header-beginning
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
307 mail-from mime-version content-type)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
308 (while (> count 0)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
309 ;; Preserve the Mail-From and MIME-Version fields
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
310 ;; even if they have been pruned.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
311 (or from-gnus
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
312 (save-excursion
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
313 (save-restriction
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
314 (goto-char (if pmail-buffers-swapped-p
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
315 (point-min)
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
316 (pmail-msgbeg pmail-current-message)))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
317 (setq header-beginning (point))
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
318 (search-forward "\n\n" nil 'move)
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
319 (narrow-to-region header-beginning (point))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
320 (setq mail-from (mail-fetch-field "Mail-From"))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
321 (unless pmail-enable-mime
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
322 (setq mime-version (mail-fetch-field "MIME-Version")
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
323 content-type (mail-fetch-field "Content-type"))))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
324 (save-excursion
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
325 (set-buffer tembuf)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
326 (erase-buffer)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
327 (insert-buffer-substring pmailbuf)
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
328 (save-excursion
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
329 (goto-char (min (point-min) (- (point-max) 2)))
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
330 (unless (looking-at "\n\n")
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
331 (goto-char (point-max))
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
332 (insert "\n\n")))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
333 (when pmail-enable-mime
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
334 (goto-char (point-min))
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
335 (forward-line 2)
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
336 (delete-region (point-min) (point))
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
337 (search-forward "\n\n")
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
338 (delete-region (match-beginning 0)
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
339 (if (search-forward "\n\n")
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
340 (1- (match-end 0))))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
341 (setq buffer-file-coding-system (or pmail-file-coding-system
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
342 'raw-text)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
343 (pmail-delete-unwanted-fields t)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
344 (or (bolp) (insert "\n"))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
345 (goto-char (point-min))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
346 (if mail-from
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
347 (insert mail-from "\n")
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
348 (insert "From "
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
349 (mail-strip-quoted-names
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
350 (save-excursion
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
351 (save-restriction
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
352 (goto-char (point-min))
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
353 (narrow-to-region
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
354 (point)
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
355 (or (search-forward "\n\n" nil)
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
356 (point-max)))
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
357 (or (mail-fetch-field "from")
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
358 (mail-fetch-field "really-from")
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
359 (mail-fetch-field "sender")
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
360 "unknown"))))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
361 " " (current-time-string) "\n"))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
362 (when mime-version
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
363 (insert "MIME-Version: " mime-version)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
364 ;; Some malformed MIME messages set content-type to nil.
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
365 (when content-type
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
366 (insert "\nContent-type: " content-type "\n")))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
367 ;; ``Quote'' "\nFrom " as "\n>From "
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
368 ;; (note that this isn't really quoting, as there is no requirement
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
369 ;; that "\n[>]+From " be quoted in the same transparent way.)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
370 (let ((case-fold-search nil))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
371 (while (search-forward "\nFrom " nil t)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
372 (forward-char -5)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
373 (insert ?>)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
374 (write-region (point-min) (point-max) file-name t
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
375 (if noattribute 'nomsg)))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
376 (or noattribute
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
377 (if (equal major-mode 'pmail-mode)
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
378 (pmail-set-attribute pmail-filed-attr-index t)))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
379 (setq count (1- count))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
380 (or from-gnus
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
381 (let ((next-message-p
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
382 (if pmail-delete-after-output
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
383 (pmail-delete-forward)
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
384 (if (> count 0)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
385 (pmail-next-undeleted-message 1))))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
386 (num-appended (- orig-count count)))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
387 (if (and (> count 0) (not next-message-p))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
388 (progn
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
389 (error "%s"
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
390 (save-excursion
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
391 (set-buffer pmailbuf)
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
392 (format "Only %d message%s appended" num-appended
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
393 (if (= num-appended 1) "" "s"))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
394 (setq count 0))))))
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
395 (kill-buffer tembuf))))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
396
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
397 ;;;###autoload
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
398 (defun pmail-output-body-to-file (file-name)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
399 "Write this message body to the file FILE-NAME.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
400 FILE-NAME defaults, interactively, from the Subject field of the message."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
401 (interactive
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
402 (let ((default-file
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
403 (or (mail-fetch-field "Subject")
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
404 pmail-default-body-file)))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
405 (list (setq pmail-default-body-file
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
406 (read-file-name
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
407 "Output message body to file: "
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
408 (and default-file (file-name-directory default-file))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
409 default-file
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
410 nil default-file)))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
411 (setq file-name
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
412 (expand-file-name file-name
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
413 (and pmail-default-body-file
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
414 (file-name-directory pmail-default-body-file))))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
415 (save-excursion
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
416 (goto-char (point-min))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
417 (search-forward "\n\n")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
418 (and (file-exists-p file-name)
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
419 (not (y-or-n-p (format "File %s exists; overwrite? " file-name)))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
420 (error "Operation aborted"))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
421 (write-region (point) (point-max) file-name)
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
422 (if (equal major-mode 'pmail-mode)
100377
241987bb5332 (pmail-output): Rewrite to handle mbox format.
Chong Yidong <cyd@stupidchicken.com>
parents: 100339
diff changeset
423 (pmail-set-attribute pmail-stored-attr-index t)))
100223
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
424 (if pmail-delete-after-output
ecb3dba6e932 Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 98019
diff changeset
425 (pmail-delete-forward)))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
426
98019
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 97967
diff changeset
427 ;; Local Variables:
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 97967
diff changeset
428 ;; change-log-default-name: "ChangeLog.pmail"
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 97967
diff changeset
429 ;; End:
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 97967
diff changeset
430
97533
ec1125c7ac26 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 97532
diff changeset
431 ;; arch-tag: 4059abf0-f249-4be4-8e0d-602d370d01d1
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
432 ;;; pmailout.el ends here