Mercurial > emacs
annotate lisp/mail/undigest.el @ 19161:248ec4d8a5e6
(mail-mode): Fix previous change.
Treat a supercite prefix not followed by text
as a paragraph separator.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 05 Aug 1997 06:41:51 +0000 |
parents | 11218164bc54 |
children | 7be5edf3710f |
rev | line source |
---|---|
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
1 ;;; undigest.el --- digest-cracking support for the RMAIL mail reader |
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
2 |
14734 | 3 ;; Copyright (C) 1985, 1986, 1994, 1996 Free Software Foundation, Inc. |
841 | 4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
5 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: mail |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
7 |
35 | 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:
657
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
35 | 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 | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
35 | 24 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
25 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
26 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
27 ;; See Internet RFC 934 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
28 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
29 ;;; Code: |
35 | 30 |
7038
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
31 (require 'rmail) |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
32 |
16348
2cf33d3c5540
Add many autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
15438
diff
changeset
|
33 ;;;###autoload |
35 | 34 (defun undigestify-rmail-message () |
35 "Break up a digest message into its constituent messages. | |
36 Leaves original message, deleted, before the undigestified messages." | |
37 (interactive) | |
38 (widen) | |
39 (let ((buffer-read-only nil) | |
40 (msg-string (buffer-substring (rmail-msgbeg rmail-current-message) | |
41 (rmail-msgend rmail-current-message)))) | |
42 (goto-char (rmail-msgend rmail-current-message)) | |
43 (narrow-to-region (point) (point)) | |
44 (insert msg-string) | |
45 (narrow-to-region (point-min) (1- (point-max)))) | |
46 (let ((error t) | |
47 (buffer-read-only nil)) | |
48 (unwind-protect | |
49 (progn | |
50 (save-restriction | |
51 (goto-char (point-min)) | |
52 (delete-region (point-min) | |
53 (progn (search-forward "\n*** EOOH ***\n") | |
54 (point))) | |
55 (insert "\^_\^L\n0, unseen,,\n*** EOOH ***\n") | |
56 (narrow-to-region (point) | |
57 (point-max)) | |
58 (let* ((fill-prefix "") | |
59 (case-fold-search t) | |
13080
21a1494b450c
(undigestify-rmail-message): Scan back as far as start
Richard M. Stallman <rms@gnu.org>
parents:
11498
diff
changeset
|
60 start |
35 | 61 (digest-name |
62 (mail-strip-quoted-names | |
63 (or (save-restriction | |
64 (search-forward "\n\n") | |
13080
21a1494b450c
(undigestify-rmail-message): Scan back as far as start
Richard M. Stallman <rms@gnu.org>
parents:
11498
diff
changeset
|
65 (setq start (point)) |
35 | 66 (narrow-to-region (point-min) (point)) |
67 (goto-char (point-max)) | |
68 (or (mail-fetch-field "Reply-To") | |
69 (mail-fetch-field "To") | |
70 (mail-fetch-field "Apparently-To") | |
71 (mail-fetch-field "From"))) | |
13088
d383abe2f9f3
(undigestify-rmail-message): Better error messages.
Richard M. Stallman <rms@gnu.org>
parents:
13080
diff
changeset
|
72 (error "Message is not a digest--bad header"))))) |
35 | 73 (save-excursion |
74 (goto-char (point-max)) | |
75 (skip-chars-backward " \t\n") | |
13080
21a1494b450c
(undigestify-rmail-message): Scan back as far as start
Richard M. Stallman <rms@gnu.org>
parents:
11498
diff
changeset
|
76 (let (found) |
35 | 77 ;; compensate for broken un*x digestifiers. Sigh Sigh. |
13080
21a1494b450c
(undigestify-rmail-message): Scan back as far as start
Richard M. Stallman <rms@gnu.org>
parents:
11498
diff
changeset
|
78 (while (and (> (point) start) (not found)) |
35 | 79 (forward-line -1) |
80 (if (looking-at (concat "End of.*Digest.*\n" | |
81 (regexp-quote "*********") "*" | |
82 "\\(\n------*\\)*")) | |
83 (setq found t))) | |
13088
d383abe2f9f3
(undigestify-rmail-message): Better error messages.
Richard M. Stallman <rms@gnu.org>
parents:
13080
diff
changeset
|
84 (if (not found) |
d383abe2f9f3
(undigestify-rmail-message): Better error messages.
Richard M. Stallman <rms@gnu.org>
parents:
13080
diff
changeset
|
85 (error "Message is not a digest--no end line")))) |
35 | 86 (re-search-forward (concat "^" (make-string 55 ?-) "-*\n*")) |
87 (replace-match "\^_\^L\n0, unseen,,\n*** EOOH ***\n") | |
88 (save-restriction | |
89 (narrow-to-region (point) | |
90 (progn (search-forward "\n\n") | |
91 (point))) | |
92 (if (mail-fetch-field "To") nil | |
93 (goto-char (point-min)) | |
94 (insert "To: " digest-name "\n"))) | |
95 (while (re-search-forward | |
96 (concat "\n\n" (make-string 27 ?-) "-*\n*") | |
97 nil t) | |
98 (replace-match "\n\n\^_\^L\n0, unseen,,\n*** EOOH ***\n") | |
99 (save-restriction | |
100 (if (looking-at "End ") | |
101 (insert "To: " digest-name "\n\n") | |
102 (narrow-to-region (point) | |
103 (progn (search-forward "\n\n" | |
104 nil 'move) | |
105 (point)))) | |
11498
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
106 (if (mail-fetch-field "To") |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
107 nil |
35 | 108 (goto-char (point-min)) |
11498
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
109 (insert "To: " digest-name "\n"))) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
110 ;; Digestifiers may insert `- ' on lines that start with `-'. |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
111 ;; Undo that. |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
112 (save-excursion |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
113 (goto-char (point-min)) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
114 (if (re-search-forward |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
115 "\n\n----------------------------*\n*" |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
116 nil t) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
117 (let ((end (point-marker))) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
118 (goto-char (point-min)) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
119 (while (re-search-forward "^- " end t) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
120 (delete-char -2))))) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
121 ))) |
35 | 122 (setq error nil) |
123 (message "Message successfully undigestified") | |
124 (let ((n rmail-current-message)) | |
125 (rmail-forget-messages) | |
126 (rmail-show-message n) | |
7038
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
127 (rmail-delete-forward) |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
128 (if (rmail-summary-exists) |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
129 (rmail-select-summary |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
130 (rmail-update-summary))))) |
35 | 131 (cond (error |
132 (narrow-to-region (point-min) (1+ (point-max))) | |
133 (delete-region (point-min) (point-max)) | |
134 (rmail-show-message rmail-current-message)))))) | |
135 | |
16348
2cf33d3c5540
Add many autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
15438
diff
changeset
|
136 ;;;###autoload |
14630
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
137 (defun unforward-rmail-message () |
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
138 "Extract a forwarded message from the containing message. |
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
139 This puts the forwarded message into a separate rmail message |
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
140 following the containing message." |
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
141 (interactive) |
15438
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
142 ;; Don't use save-excursion because we don't want to restore point |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
143 ;; in the case where we do not switch buffers. |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
144 (let ((obuf (current-buffer))) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
145 (unwind-protect |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
146 (progn |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
147 ;; If we are in a summary buffer, switch to the Rmail buffer. |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
148 (if (local-variable-p 'rmail-buffer) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
149 (set-buffer rmail-buffer)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
150 (narrow-to-region (rmail-msgbeg rmail-current-message) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
151 (rmail-msgend rmail-current-message)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
152 (goto-char (point-min)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
153 (let (beg end (buffer-read-only nil) msg-string who-forwarded-it) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
154 (setq who-forwarded-it (mail-fetch-field "From")) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
155 (if (re-search-forward "^----" nil t) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
156 nil |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
157 (error "No forwarded message")) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
158 (forward-line 1) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
159 (setq beg (point)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
160 (if (re-search-forward "^----" nil t) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
161 (setq end (match-beginning 0)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
162 (error "No terminator for forwarded message")) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
163 (widen) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
164 (setq msg-string (buffer-substring beg end)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
165 (goto-char (rmail-msgend rmail-current-message)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
166 (narrow-to-region (point) (point)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
167 (insert "\^_\^L\n0, unseen,,\n*** EOOH ***\n") |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
168 (narrow-to-region (point) (point)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
169 (insert "Forwarded-by: " who-forwarded-it "\n") |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
170 (insert msg-string) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
171 (goto-char (point-min)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
172 (while (not (eobp)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
173 (if (looking-at "- ") |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
174 (delete-region (point) (+ 2 (point)))) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
175 (forward-line 1)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
176 (let ((n rmail-current-message)) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
177 (rmail-forget-messages) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
178 (rmail-show-message n) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
179 (if (rmail-summary-exists) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
180 (rmail-select-summary |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
181 (rmail-update-summary)))))) |
fb91eb76bead
(unforward-rmail-message): In summary buffer,
Richard M. Stallman <rms@gnu.org>
parents:
14748
diff
changeset
|
182 (set-buffer obuf)))) |
14630
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
183 |
18383 | 184 (provide 'undigest) |
185 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
186 ;;; undigest.el ends here |