Mercurial > emacs
annotate lisp/mail/undigest.el @ 49518:0736ffffe240
*** empty log message ***
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 29 Jan 2003 13:12:27 +0000 |
parents | 756931f84374 |
children | b020ca291f89 |
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 |
48868 | 3 ;; Copyright (C) 1985, 1986, 1994, 1996, 2002 |
4 ;; Free Software Foundation, Inc. | |
841 | 5 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
6 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: mail |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
8 |
35 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; 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
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
35 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
35 | 25 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
26 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
27 |
48868 | 28 ;; See Internet RFC 934 and RFC 1153 |
48871
0d1bd8730873
(rmail-digest-methods, rmail-digest-mail-separator): New variables.
Francesco Potortì <pot@gnu.org>
parents:
48868
diff
changeset
|
29 ;; Also limited support for MIME digest encapsulation |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
30 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
31 ;;; Code: |
35 | 32 |
7038
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
33 (require 'rmail) |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
34 |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
35 (defconst rmail-mail-separator |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
36 "\^_\^L\n0, unseen,,\n*** EOOH ***\n" |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
37 "String for separating messages in an rmail file.") |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
38 |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
39 |
48868 | 40 (defconst rmail-digest-methods |
41 '(rmail-digest-parse-mime | |
42 rmail-digest-parse-rfc1153strict | |
43 rmail-digest-parse-rfc1153sloppy | |
44 rmail-digest-parse-rfc934) | |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
45 "List of digest parsing functions, first tried first. |
48868 | 46 |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
47 These functions operate on the current narrowing, and take no argument. |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
48 A function returns nil if it cannot parse the digest. If it can, it |
48868 | 49 returns a list of cons pairs containing the start and end positions of |
50 each undigestified message as markers.") | |
51 | |
52 (defun rmail-digest-parse-mime () | |
53 (goto-char (point-min)) | |
54 (when (let ((head-end (progn (search-forward "\n\n" nil t) (point)))) | |
55 (goto-char (point-min)) | |
56 (and head-end | |
57 (re-search-forward | |
58 (concat | |
59 "^Content-type: multipart/digest;" | |
60 "\\s-* boundary=\"?\\([^\";\n]+\\)[\";\n]") head-end t) | |
61 (search-forward (match-string 1) nil t))) | |
62 ;; Ok, prolog separator found | |
63 (let ((start (make-marker)) | |
64 (end (make-marker)) | |
65 (separator (concat "\n--" (match-string 0) "\n\n")) | |
66 result) | |
67 (while (search-forward separator nil t) | |
68 (move-marker start (match-beginning 0)) | |
69 (move-marker end (match-end 0)) | |
70 (add-to-list 'result (cons (copy-marker start) (copy-marker end t)))) | |
71 ;; Return the list of marker pairs | |
72 (nreverse result)))) | |
73 | |
74 (defun rmail-digest-parse-rfc1153strict () | |
75 "Parse following strictly the method defined in RFC 1153. | |
76 See rmail-digest-methods." | |
77 (rmail-digest-rfc1153 | |
78 "^-\\{70\\}\n\n" | |
79 "^\n-\\{30\\}\n\n" | |
80 "^\n-\\{30\\}\n\nEnd of .* Digest.*\n\\*\\{15,\\}\n+\'")) | |
81 | |
82 (defun rmail-digest-parse-rfc1153sloppy () | |
83 "Parse using the method defined in RFC 1153, allowing for some sloppiness. | |
84 See rmail-digest-methods." | |
85 (rmail-digest-rfc1153 | |
86 "^-\\{55,\\}\n\n" | |
87 "^\n-\\{27,\\}\n\n" | |
88 "^\n-\\{27,\\}\n\nEnd of")) | |
89 | |
90 (defun rmail-digest-rfc1153 (prolog-sep message-sep trailer-sep) | |
91 (goto-char (point-min)) | |
92 (when (re-search-forward prolog-sep nil t) | |
93 ;; Ok, prolog separator found | |
94 (let ((start (make-marker)) | |
95 (end (make-marker)) | |
96 separator result) | |
97 (move-marker start (match-beginning 0)) | |
98 (move-marker end (match-end 0)) | |
99 (setq result (cons (copy-marker start) (copy-marker end t))) | |
100 (when (re-search-forward message-sep nil t) | |
101 ;; Ok, at least one message separator found | |
102 (setq separator (match-string 0)) | |
103 (when (re-search-forward trailer-sep nil t) | |
104 ;; Wonderful, we found a trailer, too. Now, go on splitting | |
105 ;; the digest into separate rmail messages | |
106 (goto-char (cdar result)) | |
107 (while (search-forward separator nil t) | |
108 (move-marker start (match-beginning 0)) | |
109 (move-marker end (match-end 0)) | |
110 (add-to-list 'result | |
111 (cons (copy-marker start) (copy-marker end t)))) | |
112 ;; Undo masking of separators inside digestified messages | |
113 (goto-char (point-min)) | |
114 (while (search-forward | |
115 (replace-regexp-in-string "\n-" "\n " separator) nil t) | |
116 (replace-match separator)) | |
117 ;; Return the list of marker pairs | |
118 (nreverse result)))))) | |
119 | |
120 (defun rmail-digest-parse-rfc934 () | |
121 (goto-char (point-min)) | |
122 (when (re-search-forward "^\n?-[^ ].*\n\n?" nil t) | |
123 ;; Message separator found | |
124 (let ((start (make-marker)) | |
125 (end (make-marker)) | |
126 (separator (match-string 0)) | |
127 result) | |
128 (goto-char (point-min)) | |
129 (while (search-forward separator nil t) | |
130 (move-marker start (match-beginning 0)) | |
131 (move-marker end (match-end 0)) | |
132 (add-to-list 'result (cons (copy-marker start) (copy-marker end t)))) | |
133 ;; Undo masking of separators inside digestified messages | |
134 (goto-char (point-min)) | |
135 (while (search-forward "\n- -" nil t) | |
136 (replace-match "\n-")) | |
137 ;; Return the list of marker pairs | |
138 (nreverse result)))) | |
139 | |
16348
2cf33d3c5540
Add many autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
15438
diff
changeset
|
140 ;;;###autoload |
35 | 141 (defun undigestify-rmail-message () |
142 "Break up a digest message into its constituent messages. | |
143 Leaves original message, deleted, before the undigestified messages." | |
144 (interactive) | |
20520
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
145 (with-current-buffer rmail-buffer |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
146 (widen) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
147 (let ((error t) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
148 (buffer-read-only nil)) |
48868 | 149 (goto-char (rmail-msgend rmail-current-message)) |
150 (let ((msg-copy (buffer-substring (rmail-msgbeg rmail-current-message) | |
151 (rmail-msgend rmail-current-message)))) | |
152 (narrow-to-region (point) (point)) | |
153 (insert msg-copy)) | |
154 (narrow-to-region (point-min) (1- (point-max))) | |
20520
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
155 (unwind-protect |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
156 (progn |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
157 (save-restriction |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
158 (goto-char (point-min)) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
159 (delete-region (point-min) |
48868 | 160 (progn (search-forward "\n*** EOOH ***\n" nil t) |
20520
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
161 (point))) |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
162 (insert "\n" rmail-mail-separator) |
20520
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
163 (narrow-to-region (point) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
164 (point-max)) |
48868 | 165 (let ((fill-prefix "") |
166 (case-fold-search t) | |
167 digest-name type start end separator fun-list sep-list) | |
168 (setq digest-name (mail-strip-quoted-names | |
169 (save-restriction | |
170 (search-forward "\n\n" nil 'move) | |
171 (setq start (point)) | |
172 (narrow-to-region (point-min) start) | |
173 (or (mail-fetch-field "Reply-To") | |
174 (mail-fetch-field "To") | |
175 (mail-fetch-field "Apparently-To") | |
176 (mail-fetch-field "From"))))) | |
177 (unless digest-name | |
178 (error "Message is not a digest--bad header")) | |
179 | |
180 (setq fun-list rmail-digest-methods) | |
181 (while (and fun-list | |
182 (null (setq sep-list (funcall (car fun-list))))) | |
183 (setq fun-list (cdr fun-list))) | |
184 (unless sep-list | |
185 (error "Message is not a digest--no messages found")) | |
186 | |
187 ;;; Split the digest into separate rmail messages | |
188 (while sep-list | |
189 (let ((start (caar sep-list)) | |
190 (end (cdar sep-list))) | |
191 (delete-region start end) | |
192 (goto-char start) | |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
193 (insert rmail-mail-separator) |
48868 | 194 (search-forward "\n\n" (caar (cdr sep-list)) 'move) |
195 (save-restriction | |
196 (narrow-to-region end (point)) | |
197 (unless (mail-fetch-field "To") | |
198 (goto-char start) | |
199 (insert "To: " digest-name "\n"))) | |
200 (set-marker start nil) | |
201 (set-marker end nil)) | |
202 (setq sep-list (cdr sep-list))))) | |
203 | |
20520
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
204 (setq error nil) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
205 (message "Message successfully undigestified") |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
206 (let ((n rmail-current-message)) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
207 (rmail-forget-messages) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
208 (rmail-show-message n) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
209 (rmail-delete-forward) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
210 (if (rmail-summary-exists) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
211 (rmail-select-summary |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
212 (rmail-update-summary))))) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
213 (cond (error |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
214 (narrow-to-region (point-min) (1+ (point-max))) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
215 (delete-region (point-min) (point-max)) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
216 (rmail-show-message rmail-current-message))))))) |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
217 |
16348
2cf33d3c5540
Add many autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
15438
diff
changeset
|
218 ;;;###autoload |
14630
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
219 (defun unforward-rmail-message () |
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
220 "Extract a forwarded message from the containing message. |
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
221 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
|
222 following the containing message." |
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
223 (interactive) |
20520
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
224 ;; If we are in a summary buffer, switch to the Rmail buffer. |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
225 (unwind-protect |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
226 (with-current-buffer rmail-buffer |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
227 (narrow-to-region (rmail-msgbeg rmail-current-message) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
228 (rmail-msgend rmail-current-message)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
229 (goto-char (point-min)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
230 (let ((buffer-read-only nil) |
48957
d8dfc5e743b6
(unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents:
48901
diff
changeset
|
231 (forwarded-from (mail-fetch-field "From")) |
d8dfc5e743b6
(unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents:
48901
diff
changeset
|
232 (forwarded-date (mail-fetch-field "Date")) |
49110
756931f84374
(unforward-rmail-message): Don't use global variable `n'.
Kim F. Storm <storm@cua.dk>
parents:
49109
diff
changeset
|
233 beg end prefix forward-msg) |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
234 (cond ((re-search-forward |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
235 "^----.*\\([Ff]orwarded\\|[Oo]riginal\\).*[Mm]essage" nil t) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
236 (forward-line 1) |
49097
217ecd0c470e
(unforward-rmail-message): Skip all newlines
Francesco Potortì <pot@gnu.org>
parents:
48957
diff
changeset
|
237 (skip-chars-forward "\n") |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
238 (setq beg (point)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
239 (setq end (if (re-search-forward "^----.*[^- \t\n]" nil t) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
240 (match-beginning 0) (point-max))) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
241 (setq forward-msg |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
242 (replace-regexp-in-string |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
243 "^- -" "-" (buffer-substring beg end)))) |
48957
d8dfc5e743b6
(unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents:
48901
diff
changeset
|
244 ((and (re-search-forward "^\\(> ?\\)[a-zA-Z-]+: .*\n" nil t) |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
245 (setq beg (match-beginning 0)) |
49109
39d762048cdd
(unforward-rmail-message): Simplified. No functional change.
Francesco Potortì <pot@gnu.org>
parents:
49097
diff
changeset
|
246 (setq prefix (match-string-no-properties 1)) |
48957
d8dfc5e743b6
(unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents:
48901
diff
changeset
|
247 (goto-char beg) |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
248 (looking-at (concat "\\(" prefix ".+\n\\)*" |
49109
39d762048cdd
(unforward-rmail-message): Simplified. No functional change.
Francesco Potortì <pot@gnu.org>
parents:
49097
diff
changeset
|
249 prefix "Date: .")) |
48957
d8dfc5e743b6
(unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents:
48901
diff
changeset
|
250 (looking-at (concat "\\(" prefix ".+\n\\)*" |
d8dfc5e743b6
(unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents:
48901
diff
changeset
|
251 prefix "From: .+\n" |
d8dfc5e743b6
(unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents:
48901
diff
changeset
|
252 "\\(" prefix ".+\n\\)*" |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
253 "\\(> ?\\)?\n" prefix))) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
254 (re-search-forward "^[^>\n]" nil 'move) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
255 (backward-char) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
256 (skip-chars-backward " \t\n") |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
257 (forward-line 1) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
258 (setq end (point)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
259 (setq forward-msg |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
260 (replace-regexp-in-string |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
261 (if (string= prefix ">") "^>" "> ?") |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
262 "" (buffer-substring beg end)))) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
263 (t |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
264 (error "No forwarded message found"))) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
265 (widen) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
266 (goto-char (rmail-msgend rmail-current-message)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
267 (narrow-to-region (point) (point)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
268 (insert rmail-mail-separator) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
269 (narrow-to-region (point) (point)) |
49097
217ecd0c470e
(unforward-rmail-message): Skip all newlines
Francesco Potortì <pot@gnu.org>
parents:
48957
diff
changeset
|
270 (insert "Forwarded-From: " forwarded-from "\n") |
217ecd0c470e
(unforward-rmail-message): Skip all newlines
Francesco Potortì <pot@gnu.org>
parents:
48957
diff
changeset
|
271 (insert "Forwarded-Date: " forwarded-date "\n") |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
272 (insert forward-msg) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
273 (save-restriction |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
274 (goto-char (point-min)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
275 (re-search-forward "\n$" nil 'move) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
276 (narrow-to-region (point-min) (point)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
277 (goto-char (point-min)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
278 (while (not (eobp)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
279 (unless (looking-at "^[a-zA-Z-]+: ") |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
280 (insert "\t")) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
281 (forward-line))) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
282 (goto-char (point-min)))) |
49110
756931f84374
(unforward-rmail-message): Don't use global variable `n'.
Kim F. Storm <storm@cua.dk>
parents:
49109
diff
changeset
|
283 (let ((n rmail-current-message)) |
756931f84374
(unforward-rmail-message): Don't use global variable `n'.
Kim F. Storm <storm@cua.dk>
parents:
49109
diff
changeset
|
284 (rmail-forget-messages) |
756931f84374
(unforward-rmail-message): Don't use global variable `n'.
Kim F. Storm <storm@cua.dk>
parents:
49109
diff
changeset
|
285 (rmail-show-message n)) |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
286 (if (rmail-summary-exists) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
287 (rmail-select-summary |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
288 (rmail-update-summary))))) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
289 |
14630
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
290 |
18383 | 291 (provide 'undigest) |
292 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
293 ;;; undigest.el ends here |