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