Mercurial > emacs
annotate lisp/mail/rmailout.el @ 5312:aad805608eec
(makefile-ignored-files-in-pickup-regex): Supply missing \\.
(makefile-insert-target-ref): Fix typo.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 23 Dec 1993 04:57:18 +0000 |
parents | 92268e08c166 |
children | a74ffe260236 |
rev | line source |
---|---|
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
202
diff
changeset
|
1 ;;; rmailout.el --- "RMAIL" mail reader for Emacs: output message to a file. |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
202
diff
changeset
|
2 |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
3 ;; Copyright (C) 1985, 1987, 1993 Free Software Foundation, Inc. |
845 | 4 |
788
c8d4eb38ebfc
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
713
diff
changeset
|
5 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: mail |
788
c8d4eb38ebfc
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
713
diff
changeset
|
7 |
63 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
788
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
63 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
788
c8d4eb38ebfc
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
713
diff
changeset
|
24 ;;; Code: |
63 | 25 |
26 ;; Temporary until Emacs always has this variable. | |
27 (defvar rmail-delete-after-output nil | |
28 "*Non-nil means automatically delete a message that is copied to a file.") | |
29 | |
145 | 30 (defvar rmail-output-file-alist nil |
31 "*Alist matching regexps to suggested output Rmail files. | |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
32 This is a list of elements of the form (REGEXP . NAME-EXP). |
4851
b70799eabd57
(rmail-output-file-alist): Doc fix.
Roland McGrath <roland@gnu.org>
parents:
4836
diff
changeset
|
33 The suggestion is taken if REGEXP matches anywhere in the message buffer. |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
34 NAME-EXP may be a string constant giving the file name to use, |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
35 or more generally it may be any kind of expression that returns |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
36 a file name as a string.") |
145 | 37 |
1866
a712cff3b6e7
* rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents:
1460
diff
changeset
|
38 ;;; There are functions elsewhere in Emacs that use this function; check |
a712cff3b6e7
* rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents:
1460
diff
changeset
|
39 ;;; them out before you change the calling method. |
a712cff3b6e7
* rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents:
1460
diff
changeset
|
40 (defun rmail-output-to-rmail-file (file-name &optional count) |
63 | 41 "Append the current message to an Rmail file named FILE-NAME. |
42 If the file does not exist, ask if it should be created. | |
43 If file is being visited, the message is appended to the Emacs | |
44 buffer visiting that file. | |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
45 If the file exists and is not an Rmail file, |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
46 the message is appended in inbox format. |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
47 |
63 | 48 A prefix argument N says to output N consecutive messages |
49 starting with the current one. Deleted messages are skipped and don't count." | |
3657
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
50 (interactive |
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
51 (let ((default-file |
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
52 (let (answer tail) |
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
53 (setq tail rmail-output-file-alist) |
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
54 ;; Suggest a file based on a pattern match. |
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
55 (while (and tail (not answer)) |
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
56 (save-excursion |
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
57 (goto-char (point-min)) |
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
58 (if (re-search-forward (car (car tail)) nil t) |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
59 (setq answer (eval (cdr (car tail))))) |
3657
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
60 (setq tail (cdr tail)))) |
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
61 ;; If not suggestions, use same file as last time. |
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
62 (or answer rmail-last-rmail-file)))) |
4264
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
63 (list (setq rmail-last-rmail-file |
5278
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
64 (expand-file-name |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
65 (or |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
66 (read-file-name |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
67 (concat "Output message to Rmail file: (default " |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
68 (file-name-nondirectory default-file) |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
69 ") ") |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
70 (file-name-directory default-file) |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
71 default-file) |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
72 default-file) |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
73 (file-name-directory default-file))) |
3657
7503a402c721
(rmail-output-to-rmail-file): Use the smart default in the prompt.
Richard M. Stallman <rms@gnu.org>
parents:
2717
diff
changeset
|
74 (prefix-numeric-value current-prefix-arg)))) |
1866
a712cff3b6e7
* rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents:
1460
diff
changeset
|
75 (or count (setq count 1)) |
202 | 76 (setq file-name |
77 (expand-file-name file-name | |
78 (file-name-directory rmail-last-rmail-file))) | |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
79 (if (and (file-readable-p file-name) (not (rmail-file-p file-name))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
80 (rmail-output file-name count) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
81 (rmail-maybe-set-message-counters) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
82 (setq file-name (abbreviate-file-name file-name)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
83 (or (get-file-buffer file-name) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
84 (file-exists-p file-name) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
85 (if (yes-or-no-p |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
86 (concat "\"" file-name "\" does not exist, create it? ")) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
87 (let ((file-buffer (create-file-buffer file-name))) |
63 | 88 (save-excursion |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
89 (set-buffer file-buffer) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
90 (rmail-insert-rmail-file-header) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
91 (let ((require-final-newline nil)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
92 (write-region (point-min) (point-max) file-name t 1))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
93 (kill-buffer file-buffer)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
94 (error "Output file does not exist"))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
95 (while (> count 0) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
96 (let (redelete) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
97 (unwind-protect |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
98 (progn |
5278
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
99 ;; Temporarily turn off Deleted attribute. |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
100 ;; Do this outside the save-restriction, since it would |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
101 ;; shift the place in the buffer where the visible text starts. |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
102 (if (rmail-message-deleted-p rmail-current-message) |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
103 (progn (setq redelete t) |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
104 (rmail-set-attribute "deleted" nil))) |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
105 (save-restriction |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
106 (widen) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
107 ;; Decide whether to append to a file or to an Emacs buffer. |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
108 (save-excursion |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
109 (let ((buf (get-file-buffer file-name)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
110 (cur (current-buffer)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
111 (beg (1+ (rmail-msgbeg rmail-current-message))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
112 (end (1+ (rmail-msgend rmail-current-message)))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
113 (if (not buf) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
114 (append-to-file beg end file-name) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
115 (if (eq buf (current-buffer)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
116 (error "Can't output message to same file it's already in")) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
117 ;; File has been visited, in buffer BUF. |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
118 (set-buffer buf) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
119 (let ((buffer-read-only nil) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
120 (msg (and (boundp 'rmail-current-message) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
121 rmail-current-message))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
122 ;; If MSG is non-nil, buffer is in RMAIL mode. |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
123 (if msg |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
124 (progn |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
125 (rmail-maybe-set-message-counters) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
126 (widen) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
127 (narrow-to-region (point-max) (point-max)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
128 (insert-buffer-substring cur beg end) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
129 (goto-char (point-min)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
130 (widen) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
131 (search-backward "\n\^_") |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
132 (narrow-to-region (point) (point-max)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
133 (rmail-count-new-messages t) |
5278
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
134 (if (rmail-summary-exists) |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
135 (rmail-select-summary |
92268e08c166
(rmail-output-to-rmail-file): Call rmail-update-summary.
Richard M. Stallman <rms@gnu.org>
parents:
5051
diff
changeset
|
136 (rmail-update-summary))) |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
137 (rmail-show-message msg)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
138 ;; Output file not in rmail mode => just insert at the end. |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
139 (narrow-to-region (point-min) (1+ (buffer-size))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
140 (goto-char (point-max)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
141 (insert-buffer-substring cur beg end))))))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
142 (rmail-set-attribute "filed" t)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
143 (if redelete (rmail-set-attribute "deleted" t)))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
144 (setq count (1- count)) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
145 (if rmail-delete-after-output |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
146 (rmail-delete-forward) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
147 (if (> count 0) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
148 (rmail-next-undeleted-message 1)))))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
149 |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
150 ;; Returns t if file FILE is an Rmail file. |
5051
26abd5d13762
(rmail-file-p): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
5011
diff
changeset
|
151 ;;;###autoload |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
152 (defun rmail-file-p (file) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
153 (let ((buf (generate-new-buffer " *rmail-file-p*"))) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
154 (unwind-protect |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
155 (save-excursion |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
156 (set-buffer buf) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
157 (insert-file-contents file nil 0 100) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
158 (looking-at "BABYL OPTIONS:")) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
159 (kill-buffer buf)))) |
63 | 160 |
1866
a712cff3b6e7
* rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents:
1460
diff
changeset
|
161 ;;; There are functions elsewhere in Emacs that use this function; check |
a712cff3b6e7
* rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents:
1460
diff
changeset
|
162 ;;; them out before you change the calling method. |
5011
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
163 (defun rmail-output (file-name &optional count noattribute from-gnus) |
63 | 164 "Append this message to Unix mail file named FILE-NAME. |
165 A prefix argument N says to output N consecutive messages | |
1866
a712cff3b6e7
* rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents:
1460
diff
changeset
|
166 starting with the current one. Deleted messages are skipped and don't count. |
4265
2812d8619305
(rmail-output): New arg NOATTRIBUTE.
Richard M. Stallman <rms@gnu.org>
parents:
4264
diff
changeset
|
167 When called from lisp code, N may be omitted. |
2812d8619305
(rmail-output): New arg NOATTRIBUTE.
Richard M. Stallman <rms@gnu.org>
parents:
4264
diff
changeset
|
168 |
4836
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
169 If the pruned message header is shown on the current message, then |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
170 messages will be appended with pruned headers; otherwise, messages |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
171 will be appended with their original headers. |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
172 |
4265
2812d8619305
(rmail-output): New arg NOATTRIBUTE.
Richard M. Stallman <rms@gnu.org>
parents:
4264
diff
changeset
|
173 The optional third argument NOATTRIBUTE, if non-nil, says not |
5011
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
174 to set the `filed' attribute, and not to display a message. |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
175 |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
176 The optional fourth argument FROM-GNUS is set when called from GNUS." |
63 | 177 (interactive |
4264
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
178 (list (setq rmail-last-file |
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
179 (read-file-name |
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
180 (concat "Output message to Unix mail file" |
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
181 (if rmail-last-file |
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
182 (concat " (default " |
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
183 (file-name-nondirectory rmail-last-file) |
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
184 "): " ) |
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
185 ": ")) |
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
186 (and rmail-last-file (file-name-directory rmail-last-file)) |
af1bbadc70c7
(rmail-output-to-rmail-file): Set rmail-last-rmail-file
Richard M. Stallman <rms@gnu.org>
parents:
4058
diff
changeset
|
187 rmail-last-file)) |
1866
a712cff3b6e7
* rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents:
1460
diff
changeset
|
188 (prefix-numeric-value current-prefix-arg))) |
a712cff3b6e7
* rmailout.el (rmail-output, rmail-output-to-mail-file): Reverse
Jim Blandy <jimb@redhat.com>
parents:
1460
diff
changeset
|
189 (or count (setq count 1)) |
202 | 190 (setq file-name |
191 (expand-file-name file-name | |
192 (and rmail-last-file | |
193 (file-name-directory rmail-last-file)))) | |
4058
af785cbe489a
Fix typos in previous change.
Richard M. Stallman <rms@gnu.org>
parents:
4056
diff
changeset
|
194 (if (and (file-readable-p file-name) (rmail-file-p file-name)) |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
195 (rmail-output-to-rmail-file file-name count) |
4836
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
196 (let ((orig-count count) |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
197 (rmailbuf (current-buffer)) |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
198 (case-fold-search t) |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
199 (tembuf (get-buffer-create " rmail-output")) |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
200 (original-headers-p |
5011
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
201 (and (not from-gnus) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
202 (save-excursion |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
203 (save-restriction |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
204 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max)) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
205 (goto-char (point-min)) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
206 (forward-line 1) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
207 (= (following-char) ?0))))) |
4836
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
208 header-beginning |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
209 mail-from) |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
210 (while (> count 0) |
5011
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
211 (or from-gnus |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
212 (setq mail-from |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
213 (save-excursion |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
214 (save-restriction |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
215 (widen) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
216 (goto-char (rmail-msgbeg rmail-current-message)) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
217 (setq header-beginning (point)) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
218 (search-forward "\n*** EOOH ***\n") |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
219 (narrow-to-region header-beginning (point)) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
220 (mail-fetch-field "Mail-From"))))) |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
221 (save-excursion |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
222 (set-buffer tembuf) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
223 (erase-buffer) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
224 (insert-buffer-substring rmailbuf) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
225 (insert "\n") |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
226 (goto-char (point-min)) |
4836
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
227 (if mail-from |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
228 (insert mail-from "\n") |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
229 (insert "From " |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
230 (mail-strip-quoted-names (or (mail-fetch-field "from") |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
231 (mail-fetch-field "really-from") |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
232 (mail-fetch-field "sender") |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
233 "unknown")) |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
234 " " (current-time-string) "\n")) |
4056
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
235 ;; ``Quote'' "\nFrom " as "\n>From " |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
236 ;; (note that this isn't really quoting, as there is no requirement |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
237 ;; that "\n[>]+From " be quoted in the same transparent way.) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
238 (while (search-forward "\nFrom " nil t) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
239 (forward-char -5) |
419e92a78e6f
(rmail-output): If file is an Rmail file,
Richard M. Stallman <rms@gnu.org>
parents:
3832
diff
changeset
|
240 (insert ?>)) |
4265
2812d8619305
(rmail-output): New arg NOATTRIBUTE.
Richard M. Stallman <rms@gnu.org>
parents:
4264
diff
changeset
|
241 (write-region (point-min) (point-max) file-name t |
2812d8619305
(rmail-output): New arg NOATTRIBUTE.
Richard M. Stallman <rms@gnu.org>
parents:
4264
diff
changeset
|
242 (if noattribute 'nomsg))) |
4836
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
243 (or noattribute |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
244 (if (equal major-mode 'rmail-mode) |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
245 (rmail-set-attribute "filed" t))) |
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
246 (setq count (1- count)) |
5011
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
247 (or from-gnus |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
248 (let ((next-message-p |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
249 (if rmail-delete-after-output |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
250 (rmail-delete-forward) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
251 (if (> count 0) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
252 (rmail-next-undeleted-message 1)))) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
253 (num-appended (- orig-count count))) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
254 (if (and next-message-p original-headers-p) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
255 (rmail-toggle-header)) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
256 (if (and (> count 0) (not next-message-p)) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
257 (progn |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
258 (error |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
259 (save-excursion |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
260 (set-buffer rmailbuf) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
261 (format "Only %d message%s appended" num-appended |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
262 (if (= num-appended 1) "" "s")))) |
22c7b341d536
(rmail-output): New argument FROM-GNUS.
Richard M. Stallman <rms@gnu.org>
parents:
4851
diff
changeset
|
263 (setq count 0)))))) |
4836
38a0f0209707
(rmail-output): If message was shown with full headers,
Richard M. Stallman <rms@gnu.org>
parents:
4265
diff
changeset
|
264 (kill-buffer tembuf)))) |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
202
diff
changeset
|
265 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
202
diff
changeset
|
266 ;;; rmailout.el ends here |