Mercurial > emacs
annotate lisp/mail/pmailout.el @ 100345:b814c7996a93
* syntax.c (Fmodify_syntax_entry): Doc fix.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Thu, 11 Dec 2008 01:49:46 +0000 |
parents | 1afe9b0dcf0e |
children | 241987bb5332 |
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 () |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
46 "Read the file name to use for `pmail-output-to-pmail-file'. |
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 |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
115 (defun pmail-output-to-pmail-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) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
173 (pmail-set-attribute "deleted" nil))) |
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))))))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
231 (pmail-set-attribute "filed" t)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
232 (if redelete (pmail-set-attribute "deleted" t)))) |
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 |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
245 ;;;###autoload |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
246 (defcustom pmail-fields-not-to-output nil |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
247 "*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
|
248 :type '(choice (const :tag "None" nil) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
249 regexp) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
250 :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
|
251 |
100223
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
252 ;; 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
|
253 ;; 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
|
254 ;; and *** EOOH *** that a message in an Pmail file has. |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
255 (defun pmail-delete-unwanted-fields (&optional not-pmail) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
256 (if pmail-fields-not-to-output |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
257 (save-excursion |
97528
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
258 (goto-char (point-min)) |
100223
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
259 ;; Find the end of the header. |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
260 (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
|
261 (search-forward "\n\n" nil t)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
262 (let ((end (point-marker))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
263 (goto-char (point-min)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
264 (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
|
265 (beginning-of-line) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
266 (delete-region (point) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
267 (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
|
268 |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
269 ;;; 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
|
270 ;;; 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
|
271 ;;;###autoload |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
272 (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
|
273 "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
|
274 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
|
275 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
|
276 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
|
277 |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
278 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
|
279 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
|
280 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
|
281 |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
282 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
|
283 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
|
284 |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
285 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
|
286 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
|
287 |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
288 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
|
289 (interactive |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
290 (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
|
291 (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
|
292 (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
|
293 (setq file-name |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
294 (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
|
295 (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
|
296 (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
|
297 (if (and (file-readable-p file-name) (mail-file-babyl-p file-name)) |
100223
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
298 (pmail-output-to-pmail-file file-name count) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
299 (set-buffer pmail-buffer) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
300 (let ((orig-count count) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
301 (pmailbuf (current-buffer)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
302 (case-fold-search t) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
303 (tembuf (get-buffer-create " pmail-output")) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
304 (original-headers-p |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
305 (and (not from-gnus) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
306 (save-excursion |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
307 (save-restriction |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
308 (narrow-to-region (pmail-msgbeg pmail-current-message) (point-max)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
309 (goto-char (point-min)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
310 (forward-line 1) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
311 (= (following-char) ?0))))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
312 header-beginning |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
313 mail-from mime-version content-type) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
314 (while (> count 0) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
315 ;; Preserve the Mail-From and MIME-Version fields |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
316 ;; even if they have been pruned. |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
317 (or from-gnus |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
318 (save-excursion |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
319 (save-restriction |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
320 (widen) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
321 (goto-char (pmail-msgbeg pmail-current-message)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
322 (setq header-beginning (point)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
323 (search-forward "\n*** EOOH ***\n") |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
324 (narrow-to-region header-beginning (point)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
325 (setq mail-from (mail-fetch-field "Mail-From")) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
326 (unless pmail-enable-mime |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
327 (setq mime-version (mail-fetch-field "MIME-Version") |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
328 content-type (mail-fetch-field "Content-type")))))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
329 (save-excursion |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
330 (set-buffer tembuf) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
331 (erase-buffer) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
332 (insert-buffer-substring pmailbuf) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
333 (when pmail-enable-mime |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
334 (if original-headers-p |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
335 (delete-region (goto-char (point-min)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
336 (if (search-forward "\n*** EOOH ***\n") |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
337 (match-end 0))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
338 (goto-char (point-min)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
339 (forward-line 2) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
340 (delete-region (point-min)(point)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
341 (search-forward "\n*** EOOH ***\n") |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
342 (delete-region (match-beginning 0) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
343 (if (search-forward "\n\n") |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
344 (1- (match-end 0))))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
345 (setq buffer-file-coding-system (or pmail-file-coding-system |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
346 'raw-text))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
347 (pmail-delete-unwanted-fields t) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
348 (or (bolp) (insert "\n")) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
349 (goto-char (point-min)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
350 (if mail-from |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
351 (insert mail-from "\n") |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
352 (insert "From " |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
353 (mail-strip-quoted-names (or (mail-fetch-field "from") |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
354 (mail-fetch-field "really-from") |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
355 (mail-fetch-field "sender") |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
356 "unknown")) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
357 " " (current-time-string) "\n")) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
358 (when mime-version |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
359 (insert "MIME-Version: " mime-version) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
360 ;; Some malformed MIME messages set content-type to nil. |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
361 (when content-type |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
362 (insert "\nContent-type: " content-type "\n"))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
363 ;; ``Quote'' "\nFrom " as "\n>From " |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
364 ;; (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
|
365 ;; that "\n[>]+From " be quoted in the same transparent way.) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
366 (let ((case-fold-search nil)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
367 (while (search-forward "\nFrom " nil t) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
368 (forward-char -5) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
369 (insert ?>))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
370 (write-region (point-min) (point-max) file-name t |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
371 (if noattribute 'nomsg))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
372 (or noattribute |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
373 (if (equal major-mode 'pmail-mode) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
374 (pmail-set-attribute "filed" t))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
375 (setq count (1- count)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
376 (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
|
377 (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
|
378 (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
|
379 (pmail-delete-forward) |
100223
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
380 (if (> count 0) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
381 (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
|
382 (num-appended (- orig-count count))) |
100223
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
383 (if (and next-message-p original-headers-p) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
384 (pmail-toggle-header)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
385 (if (and (> count 0) (not next-message-p)) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
386 (progn |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
387 (error "%s" |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
388 (save-excursion |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
389 (set-buffer pmailbuf) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
390 (format "Only %d message%s appended" num-appended |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
391 (if (= num-appended 1) "" "s")))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
392 (setq count 0)))))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
393 (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
|
394 |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
395 ;;;###autoload |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
396 (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
|
397 "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
|
398 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
|
399 (interactive |
100223
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
400 (let ((default-file |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
401 (or (mail-fetch-field "Subject") |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
402 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
|
403 (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
|
404 (read-file-name |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
405 "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
|
406 (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
|
407 default-file |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
408 nil default-file))))) |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
409 (setq file-name |
100223
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
410 (expand-file-name file-name |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
411 (and pmail-default-body-file |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
412 (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
|
413 (save-excursion |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
414 (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
|
415 (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
|
416 (and (file-exists-p file-name) |
100223
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
417 (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
|
418 (error "Operation aborted")) |
184bb2071e3f
mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff
changeset
|
419 (write-region (point) (point-max) file-name) |
100223
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
420 (if (equal major-mode 'pmail-mode) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
421 (pmail-set-attribute "stored" t))) |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
422 (if pmail-delete-after-output |
ecb3dba6e932
Sync with rmailout.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
98019
diff
changeset
|
423 (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
|
424 |
98019
72564311fb7b
Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents:
97967
diff
changeset
|
425 ;; Local Variables: |
72564311fb7b
Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents:
97967
diff
changeset
|
426 ;; 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
|
427 ;; End: |
72564311fb7b
Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents:
97967
diff
changeset
|
428 |
97533 | 429 ;; 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
|
430 ;;; pmailout.el ends here |