Mercurial > emacs
annotate lisp/mail/undigest.el @ 105531:ac0c30ffce5c
(report-emacs-bug): Also print `features'.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Fri, 09 Oct 2009 06:29:56 +0000 |
parents | 6a35503cf20b |
children | 1d1d5d9bd884 |
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 |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
3 ;; Copyright (C) 1985, 1986, 1994, 1996, 2001, 2002, 2003, 2004, 2005, |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
4 ;; 2006, 2007, 2008, 2009 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 | |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
35 | 12 ;; it under the terms of the GNU General Public License as published by |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
35 | 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 | |
94674
ef65fa4dca3b
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
35 | 23 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
24 ;;; Commentary: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
25 |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
26 ;; See Internet RFC 934 and RFC 1153. |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
27 ;; Also limited support for MIME digest encapsulation. |
807
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 |
49547
b020ca291f89
(rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents:
49110
diff
changeset
|
33 (defcustom rmail-forward-separator-regex |
b020ca291f89
(rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents:
49110
diff
changeset
|
34 "^----.*\\([Ff]orwarded\\|[Oo]riginal\\).*[Mm]essage" |
b020ca291f89
(rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents:
49110
diff
changeset
|
35 "*Regexp to match the string that introduces forwarded messages. |
b020ca291f89
(rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents:
49110
diff
changeset
|
36 This is not a header, but a string contained in the body of the message. |
63177
284a9ec95650
(rmail-forward-separator-regex): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
52401
diff
changeset
|
37 You may need to customize it for local needs." |
49547
b020ca291f89
(rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents:
49110
diff
changeset
|
38 :type 'regexp |
b020ca291f89
(rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents:
49110
diff
changeset
|
39 :group 'rmail-headers) |
b020ca291f89
(rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents:
49110
diff
changeset
|
40 |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
41 |
48868 | 42 (defconst rmail-digest-methods |
43 '(rmail-digest-parse-mime | |
44 rmail-digest-parse-rfc1153strict | |
45 rmail-digest-parse-rfc1153sloppy | |
46 rmail-digest-parse-rfc934) | |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
47 "List of digest parsing functions, first tried first. |
48868 | 48 |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
49 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
|
50 A function returns nil if it cannot parse the digest. If it can, it |
48868 | 51 returns a list of cons pairs containing the start and end positions of |
52 each undigestified message as markers.") | |
53 | |
54 (defun rmail-digest-parse-mime () | |
55 (goto-char (point-min)) | |
56 (when (let ((head-end (progn (search-forward "\n\n" nil t) (point)))) | |
57 (goto-char (point-min)) | |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
58 (and head-end ; FIXME always true |
48868 | 59 (re-search-forward |
60 (concat | |
61 "^Content-type: multipart/digest;" | |
62 "\\s-* boundary=\"?\\([^\";\n]+\\)[\";\n]") head-end t) | |
63 (search-forward (match-string 1) nil t))) | |
64 ;; Ok, prolog separator found | |
65 (let ((start (make-marker)) | |
66 (end (make-marker)) | |
67 (separator (concat "\n--" (match-string 0) "\n\n")) | |
68 result) | |
69 (while (search-forward separator nil t) | |
70 (move-marker start (match-beginning 0)) | |
71 (move-marker end (match-end 0)) | |
72 (add-to-list 'result (cons (copy-marker start) (copy-marker end t)))) | |
73 ;; Return the list of marker pairs | |
74 (nreverse result)))) | |
75 | |
76 (defun rmail-digest-parse-rfc1153strict () | |
77 "Parse following strictly the method defined in RFC 1153. | |
78 See rmail-digest-methods." | |
79 (rmail-digest-rfc1153 | |
80 "^-\\{70\\}\n\n" | |
81 "^\n-\\{30\\}\n\n" | |
82 "^\n-\\{30\\}\n\nEnd of .* Digest.*\n\\*\\{15,\\}\n+\'")) | |
83 | |
84 (defun rmail-digest-parse-rfc1153sloppy () | |
85 "Parse using the method defined in RFC 1153, allowing for some sloppiness. | |
86 See rmail-digest-methods." | |
87 (rmail-digest-rfc1153 | |
88 "^-\\{55,\\}\n\n" | |
89 "^\n-\\{27,\\}\n\n" | |
78558
ce34261da54f
(rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
90 ;; GNU Mailman knowingly (see comment at line 353 of ToDigest.py in |
ce34261da54f
(rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
91 ;; Mailman source) produces non-conformant rfc 1153 digests, in that |
ce34261da54f
(rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
92 ;; the trailer contains a "digest footer" like this: |
ce34261da54f
(rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
93 ;; _______________________________________________ |
ce34261da54f
(rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
94 ;; <one or more lines of list blurb> |
ce34261da54f
(rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
95 ;; |
ce34261da54f
(rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
96 ;; End of Foo Digest... |
ce34261da54f
(rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
97 ;; ************************************** |
ce34261da54f
(rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
98 "^\nEnd of")) |
48868 | 99 |
100 (defun rmail-digest-rfc1153 (prolog-sep message-sep trailer-sep) | |
101 (goto-char (point-min)) | |
102 (when (re-search-forward prolog-sep nil t) | |
103 ;; Ok, prolog separator found | |
104 (let ((start (make-marker)) | |
105 (end (make-marker)) | |
106 separator result) | |
107 (move-marker start (match-beginning 0)) | |
108 (move-marker end (match-end 0)) | |
78558
ce34261da54f
(rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents:
78232
diff
changeset
|
109 (setq result (list (cons (copy-marker start) (copy-marker end t)))) |
48868 | 110 (when (re-search-forward message-sep nil t) |
111 ;; Ok, at least one message separator found | |
112 (setq separator (match-string 0)) | |
113 (when (re-search-forward trailer-sep nil t) | |
114 ;; Wonderful, we found a trailer, too. Now, go on splitting | |
115 ;; the digest into separate rmail messages | |
116 (goto-char (cdar result)) | |
117 (while (search-forward separator nil t) | |
118 (move-marker start (match-beginning 0)) | |
119 (move-marker end (match-end 0)) | |
120 (add-to-list 'result | |
121 (cons (copy-marker start) (copy-marker end t)))) | |
122 ;; Undo masking of separators inside digestified messages | |
123 (goto-char (point-min)) | |
124 (while (search-forward | |
125 (replace-regexp-in-string "\n-" "\n " separator) nil t) | |
126 (replace-match separator)) | |
127 ;; Return the list of marker pairs | |
128 (nreverse result)))))) | |
129 | |
130 (defun rmail-digest-parse-rfc934 () | |
131 (goto-char (point-min)) | |
132 (when (re-search-forward "^\n?-[^ ].*\n\n?" nil t) | |
133 ;; Message separator found | |
134 (let ((start (make-marker)) | |
135 (end (make-marker)) | |
136 (separator (match-string 0)) | |
137 result) | |
138 (goto-char (point-min)) | |
139 (while (search-forward separator nil t) | |
140 (move-marker start (match-beginning 0)) | |
141 (move-marker end (match-end 0)) | |
142 (add-to-list 'result (cons (copy-marker start) (copy-marker end t)))) | |
143 ;; Undo masking of separators inside digestified messages | |
144 (goto-char (point-min)) | |
145 (while (search-forward "\n- -" nil t) | |
146 (replace-match "\n-")) | |
147 ;; Return the list of marker pairs | |
148 (nreverse result)))) | |
149 | |
86440
4aedd218aad1
* mail/mspools.el (rmail-get-new-mail):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78558
diff
changeset
|
150 (declare-function rmail-update-summary "rmailsum" (&rest ignore)) |
4aedd218aad1
* mail/mspools.el (rmail-get-new-mail):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78558
diff
changeset
|
151 |
16348
2cf33d3c5540
Add many autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
15438
diff
changeset
|
152 ;;;###autoload |
35 | 153 (defun undigestify-rmail-message () |
154 "Break up a digest message into its constituent messages. | |
155 Leaves original message, deleted, before the undigestified messages." | |
156 (interactive) | |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
157 (set-buffer rmail-buffer) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
158 (let ((buff (current-buffer)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
159 (current rmail-current-message) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
160 (msgbeg (rmail-msgbeg rmail-current-message)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
161 (msgend (rmail-msgend rmail-current-message))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
162 (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer)) |
20520
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
163 (widen) |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
164 (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
|
165 (buffer-read-only nil)) |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
166 (goto-char msgend) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
167 (let ((msg-copy (buffer-substring-no-properties msgbeg msgend))) |
48868 | 168 (narrow-to-region (point) (point)) |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
169 (insert "\n" msg-copy)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
170 (goto-char (point-min)) |
20520
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
171 (unwind-protect |
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
172 (progn |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
173 (let ((fill-prefix "") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
174 (case-fold-search t) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
175 digest-name fun-list sep-list start end) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
176 (setq digest-name (mail-strip-quoted-names |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
177 (save-restriction |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
178 (search-forward "\n\n" nil 'move) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
179 (narrow-to-region (point-min) (point)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
180 (or (mail-fetch-field "Reply-To") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
181 (mail-fetch-field "To") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
182 (mail-fetch-field "Apparently-To") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
183 (mail-fetch-field "From"))))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
184 (unless digest-name |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
185 (error "Message is not a digest--bad header")) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
186 (setq fun-list rmail-digest-methods) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
187 (while (and fun-list |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
188 (null (setq sep-list (funcall (car fun-list))))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
189 (setq fun-list (cdr fun-list))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
190 (unless sep-list |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
191 (error "Message is not a digest--no messages found")) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
192 ;; Split the digest into separate rmail messages. |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
193 (while sep-list |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
194 (setq start (caar sep-list) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
195 end (cdar sep-list)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
196 (delete-region start end) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
197 (goto-char start) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
198 (search-forward "\n\n" (caar (cdr sep-list)) 'move) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
199 (save-restriction |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
200 (narrow-to-region end (point)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
201 (goto-char (point-min)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
202 (insert "\nFrom rmail@localhost " (current-time-string) "\n") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
203 (save-excursion |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
204 (forward-line -1) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
205 (rmail-add-mbox-headers)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
206 (unless (mail-fetch-field "To") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
207 (insert "To: " digest-name "\n"))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
208 (set-marker start nil) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
209 (set-marker end nil) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
210 (setq sep-list (cdr sep-list)))) |
20520
7be5edf3710f
(undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents:
18383
diff
changeset
|
211 (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
|
212 (message "Message successfully undigestified") |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
213 (set-buffer buff) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
214 (rmail-swap-buffers-maybe) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
215 (goto-char (point-max)) |
104907
6a35503cf20b
Put autoloads in rmail.el rather than loaddefs.el.
Glenn Morris <rgm@gnu.org>
parents:
101827
diff
changeset
|
216 ;; FIXME use rmail-count-new-messages. |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
217 (rmail-set-message-counters) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
218 (set-buffer-modified-p t) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
219 (rmail-show-message current) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
220 (rmail-delete-forward) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
221 (if (rmail-summary-exists) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
222 (rmail-select-summary (rmail-update-summary)))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
223 (when error |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
224 (delete-region (point-min) (point-max)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
225 (set-buffer buff) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
226 (rmail-show-message current)))))) |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
227 |
16348
2cf33d3c5540
Add many autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents:
15438
diff
changeset
|
228 ;;;###autoload |
14630
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
229 (defun unforward-rmail-message () |
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
230 "Extract a forwarded message from the containing message. |
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
231 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
|
232 following the containing message." |
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
233 (interactive) |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
234 (set-buffer rmail-buffer) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
235 (let ((buff (current-buffer)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
236 (current rmail-current-message) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
237 (beg (rmail-msgbeg rmail-current-message)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
238 (msgend (rmail-msgend rmail-current-message)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
239 (error t)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
240 (unwind-protect |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
241 (progn |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
242 (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer)) |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
243 (widen) |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
244 (goto-char beg) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
245 (search-forward "\n\n" msgend) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
246 (narrow-to-region beg (point)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
247 (let ((old-fwd-from (mail-fetch-field "Forwarded-From" nil nil t)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
248 (old-fwd-date (mail-fetch-field "Forwarded-Date" nil nil t)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
249 (fwd-from (mail-fetch-field "From")) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
250 (fwd-date (mail-fetch-field "Date")) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
251 (buffer-read-only nil) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
252 prefix forward-msg end) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
253 (widen) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
254 (narrow-to-region beg msgend) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
255 (cond ((re-search-forward rmail-forward-separator-regex nil t) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
256 (forward-line 1) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
257 (skip-chars-forward "\n") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
258 (setq beg (point)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
259 (setq end (if (re-search-forward "^----.*[^- \t\n]" nil t) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
260 (match-beginning 0) (point-max))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
261 (setq forward-msg |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
262 (replace-regexp-in-string |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
263 "^- -" "-" (buffer-substring beg end)))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
264 ((and (re-search-forward "^\\(> ?\\)[a-zA-Z-]+: .*\n" nil t) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
265 (setq beg (match-beginning 0)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
266 (setq prefix (match-string-no-properties 1)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
267 (goto-char beg) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
268 (looking-at (concat "\\(" prefix ".+\n\\)*" |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
269 prefix "Date: .")) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
270 (looking-at (concat "\\(" prefix ".+\n\\)*" |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
271 prefix "From: .+\n" |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
272 "\\(" prefix ".+\n\\)*" |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
273 "\\(> ?\\)?\n" prefix))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
274 (re-search-forward "^[^>\n]" nil 'move) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
275 (backward-char) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
276 (skip-chars-backward " \t\n") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
277 (forward-line 1) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
278 (setq end (point)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
279 (setq forward-msg |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
280 (replace-regexp-in-string |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
281 (if (string= prefix ">") "^>" "> ?") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
282 "" (buffer-substring beg end)))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
283 (t |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
284 (error "No forwarded message found"))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
285 (widen) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
286 (goto-char msgend) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
287 ;; Insert a fake From line. |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
288 ;; FIXME we could construct one using the From and Date headers |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
289 ;; of the forwarded message - is it worth it? |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
290 (insert "\n\nFrom rmail@localhost " (current-time-string) "\n") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
291 (setq beg (point)) ; start of header |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
292 (while old-fwd-from |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
293 (insert "Forwarded-From: " (car old-fwd-from) "\n") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
294 (insert "Forwarded-Date: " (car old-fwd-date) "\n") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
295 (setq old-fwd-from (cdr old-fwd-from)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
296 (setq old-fwd-date (cdr old-fwd-date))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
297 (insert "Forwarded-From: " fwd-from "\n") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
298 (insert "Forwarded-Date: " fwd-date "\n") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
299 (insert forward-msg "\n") |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
300 (goto-char beg) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
301 (re-search-forward "\n$" nil 'move) ; end of header |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
302 (narrow-to-region beg (point)) |
48901
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
303 (goto-char (point-min)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
304 (while (not (eobp)) |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
305 (unless (looking-at "^[a-zA-Z-]+: ") |
6f912a2e94c1
(rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents:
48871
diff
changeset
|
306 (insert "\t")) |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
307 (forward-line)) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
308 (widen) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
309 (goto-char beg) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
310 (forward-line -1) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
311 (rmail-add-mbox-headers)) ; marks as unseen |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
312 (setq error nil) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
313 (set-buffer buff) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
314 (rmail-swap-buffers-maybe) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
315 (goto-char (point-max)) |
104907
6a35503cf20b
Put autoloads in rmail.el rather than loaddefs.el.
Glenn Morris <rgm@gnu.org>
parents:
101827
diff
changeset
|
316 ;; FIXME use rmail-count-new-messages. |
101827
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
317 (rmail-set-message-counters) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
318 (set-buffer-modified-p t) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
319 (rmail-show-message current) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
320 (if (rmail-summary-exists) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
321 (rmail-select-summary (rmail-update-summary)))) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
322 (when error |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
323 (set-buffer buff) |
ec4427ac212e
(rmail-mail-separator): Delete.
Glenn Morris <rgm@gnu.org>
parents:
100908
diff
changeset
|
324 (rmail-show-message current))))) |
14630
584eb99710a6
(unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents:
14169
diff
changeset
|
325 |
18383 | 326 (provide 'undigest) |
327 | |
104907
6a35503cf20b
Put autoloads in rmail.el rather than loaddefs.el.
Glenn Morris <rgm@gnu.org>
parents:
101827
diff
changeset
|
328 ;; Local Variables: |
6a35503cf20b
Put autoloads in rmail.el rather than loaddefs.el.
Glenn Morris <rgm@gnu.org>
parents:
101827
diff
changeset
|
329 ;; generated-autoload-file: "rmail.el" |
6a35503cf20b
Put autoloads in rmail.el rather than loaddefs.el.
Glenn Morris <rgm@gnu.org>
parents:
101827
diff
changeset
|
330 ;; End: |
6a35503cf20b
Put autoloads in rmail.el rather than loaddefs.el.
Glenn Morris <rgm@gnu.org>
parents:
101827
diff
changeset
|
331 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
87649
diff
changeset
|
332 ;; arch-tag: 3a28b9fb-c1f5-43ef-9278-285f3e4b874d |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
333 ;;; undigest.el ends here |