annotate lisp/mail/undigest.el @ 96673:5dc035add002

(Glossary): Remove xref to Text Characters.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 15 Jul 2008 15:29:24 +0000
parents ef65fa4dca3b
children a9dc0e7c3f2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
74509
f7702c5f335d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
3 ;; Copyright (C) 1985, 1986, 1994, 1996, 2001, 2002, 2003, 2004,
79712
de499b20517a Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 78558
diff changeset
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
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
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
48868
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
26 ;; 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
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
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
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
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
33 (defconst rmail-mail-separator
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
34 "\^_\^L\n0, unseen,,\n*** EOOH ***\n"
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
35 "String for separating messages in an rmail file.")
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
36
49547
b020ca291f89 (rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents: 49110
diff changeset
37 (defcustom rmail-forward-separator-regex
b020ca291f89 (rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents: 49110
diff changeset
38 "^----.*\\([Ff]orwarded\\|[Oo]riginal\\).*[Mm]essage"
b020ca291f89 (rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents: 49110
diff changeset
39 "*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
40 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
41 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
42 :type 'regexp
b020ca291f89 (rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents: 49110
diff changeset
43 :group 'rmail-headers)
b020ca291f89 (rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents: 49110
diff changeset
44
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
45
48868
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
46 (defconst rmail-digest-methods
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
47 '(rmail-digest-parse-mime
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
48 rmail-digest-parse-rfc1153strict
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
49 rmail-digest-parse-rfc1153sloppy
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
50 rmail-digest-parse-rfc934)
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
51 "List of digest parsing functions, first tried first.
48868
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
52
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
53 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
54 A function returns nil if it cannot parse the digest. If it can, it
48868
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
55 returns a list of cons pairs containing the start and end positions of
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
56 each undigestified message as markers.")
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
57
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
58 (defun rmail-digest-parse-mime ()
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
59 (goto-char (point-min))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
60 (when (let ((head-end (progn (search-forward "\n\n" nil t) (point))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
61 (goto-char (point-min))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
62 (and head-end
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
63 (re-search-forward
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
64 (concat
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
65 "^Content-type: multipart/digest;"
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
66 "\\s-* boundary=\"?\\([^\";\n]+\\)[\";\n]") head-end t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
67 (search-forward (match-string 1) nil t)))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
68 ;; Ok, prolog separator found
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
69 (let ((start (make-marker))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
70 (end (make-marker))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
71 (separator (concat "\n--" (match-string 0) "\n\n"))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
72 result)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
73 (while (search-forward separator nil t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
74 (move-marker start (match-beginning 0))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
75 (move-marker end (match-end 0))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
76 (add-to-list 'result (cons (copy-marker start) (copy-marker end t))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
77 ;; Return the list of marker pairs
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
78 (nreverse result))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
79
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
80 (defun rmail-digest-parse-rfc1153strict ()
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
81 "Parse following strictly the method defined in RFC 1153.
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
82 See rmail-digest-methods."
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
83 (rmail-digest-rfc1153
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
84 "^-\\{70\\}\n\n"
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
85 "^\n-\\{30\\}\n\n"
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
86 "^\n-\\{30\\}\n\nEnd of .* Digest.*\n\\*\\{15,\\}\n+\'"))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
87
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
88 (defun rmail-digest-parse-rfc1153sloppy ()
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
89 "Parse using the method defined in RFC 1153, allowing for some sloppiness.
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
90 See rmail-digest-methods."
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
91 (rmail-digest-rfc1153
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
92 "^-\\{55,\\}\n\n"
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
93 "^\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
94 ;; 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
95 ;; 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
96 ;; 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
97 ;; _______________________________________________
ce34261da54f (rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
98 ;; <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
99 ;;
ce34261da54f (rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
100 ;; 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
101 ;; **************************************
ce34261da54f (rmail-digest-parse-rfc1153sloppy): Be even sloppier, for the sake of
Glenn Morris <rgm@gnu.org>
parents: 78232
diff changeset
102 "^\nEnd of"))
48868
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
103
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
104 (defun rmail-digest-rfc1153 (prolog-sep message-sep trailer-sep)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
105 (goto-char (point-min))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
106 (when (re-search-forward prolog-sep nil t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
107 ;; Ok, prolog separator found
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
108 (let ((start (make-marker))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
109 (end (make-marker))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
110 separator result)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
111 (move-marker start (match-beginning 0))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
112 (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
113 (setq result (list (cons (copy-marker start) (copy-marker end t))))
48868
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
114 (when (re-search-forward message-sep nil t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
115 ;; Ok, at least one message separator found
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
116 (setq separator (match-string 0))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
117 (when (re-search-forward trailer-sep nil t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
118 ;; Wonderful, we found a trailer, too. Now, go on splitting
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
119 ;; the digest into separate rmail messages
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
120 (goto-char (cdar result))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
121 (while (search-forward separator nil t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
122 (move-marker start (match-beginning 0))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
123 (move-marker end (match-end 0))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
124 (add-to-list 'result
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
125 (cons (copy-marker start) (copy-marker end t))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
126 ;; Undo masking of separators inside digestified messages
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
127 (goto-char (point-min))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
128 (while (search-forward
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
129 (replace-regexp-in-string "\n-" "\n " separator) nil t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
130 (replace-match separator))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
131 ;; Return the list of marker pairs
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
132 (nreverse result))))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
133
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
134 (defun rmail-digest-parse-rfc934 ()
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
135 (goto-char (point-min))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
136 (when (re-search-forward "^\n?-[^ ].*\n\n?" nil t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
137 ;; Message separator found
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
138 (let ((start (make-marker))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
139 (end (make-marker))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
140 (separator (match-string 0))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
141 result)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
142 (goto-char (point-min))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
143 (while (search-forward separator nil t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
144 (move-marker start (match-beginning 0))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
145 (move-marker end (match-end 0))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
146 (add-to-list 'result (cons (copy-marker start) (copy-marker end t))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
147 ;; Undo masking of separators inside digestified messages
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
148 (goto-char (point-min))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
149 (while (search-forward "\n- -" nil t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
150 (replace-match "\n-"))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
151 ;; Return the list of marker pairs
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
152 (nreverse result))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
153
86440
4aedd218aad1 * mail/mspools.el (rmail-get-new-mail):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78558
diff changeset
154 (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
155
16348
2cf33d3c5540 Add many autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents: 15438
diff changeset
156 ;;;###autoload
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (defun undigestify-rmail-message ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 "Break up a digest message into its constituent messages.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 Leaves original message, deleted, before the undigestified messages."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 (interactive)
20520
7be5edf3710f (undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents: 18383
diff changeset
161 (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
162 (widen)
7be5edf3710f (undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents: 18383
diff changeset
163 (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
164 (buffer-read-only nil))
48868
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
165 (goto-char (rmail-msgend rmail-current-message))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
166 (let ((msg-copy (buffer-substring (rmail-msgbeg rmail-current-message)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
167 (rmail-msgend rmail-current-message))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
168 (narrow-to-region (point) (point))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
169 (insert msg-copy))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
170 (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
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
7be5edf3710f (undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents: 18383
diff changeset
173 (save-restriction
7be5edf3710f (undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents: 18383
diff changeset
174 (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
175 (delete-region (point-min)
48868
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
176 (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
177 (point)))
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
178 (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
179 (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
180 (point-max))
48868
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
181 (let ((fill-prefix "")
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
182 (case-fold-search t)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
183 digest-name type start end separator fun-list sep-list)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
184 (setq digest-name (mail-strip-quoted-names
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
185 (save-restriction
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
186 (search-forward "\n\n" nil 'move)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
187 (setq start (point))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
188 (narrow-to-region (point-min) start)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
189 (or (mail-fetch-field "Reply-To")
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
190 (mail-fetch-field "To")
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
191 (mail-fetch-field "Apparently-To")
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
192 (mail-fetch-field "From")))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
193 (unless digest-name
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
194 (error "Message is not a digest--bad header"))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
195
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
196 (setq fun-list rmail-digest-methods)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
197 (while (and fun-list
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
198 (null (setq sep-list (funcall (car fun-list)))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
199 (setq fun-list (cdr fun-list)))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
200 (unless sep-list
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
201 (error "Message is not a digest--no messages found"))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
202
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
203 ;;; Split the digest into separate rmail messages
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
204 (while sep-list
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
205 (let ((start (caar sep-list))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
206 (end (cdar sep-list)))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
207 (delete-region start end)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
208 (goto-char start)
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
209 (insert rmail-mail-separator)
48868
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
210 (search-forward "\n\n" (caar (cdr sep-list)) 'move)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
211 (save-restriction
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
212 (narrow-to-region end (point))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
213 (unless (mail-fetch-field "To")
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
214 (goto-char start)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
215 (insert "To: " digest-name "\n")))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
216 (set-marker start nil)
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
217 (set-marker end nil))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
218 (setq sep-list (cdr sep-list)))))
3395df62dc04 Now supports MIME too.
Francesco Potortì <pot@gnu.org>
parents: 48122
diff changeset
219
20520
7be5edf3710f (undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents: 18383
diff changeset
220 (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
221 (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
222 (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
223 (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
224 (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
225 (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
226 (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
227 (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
228 (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
229 (cond (error
7be5edf3710f (undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents: 18383
diff changeset
230 (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
231 (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
232 (rmail-show-message rmail-current-message)))))))
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
233
16348
2cf33d3c5540 Add many autoload cookies.
Richard M. Stallman <rms@gnu.org>
parents: 15438
diff changeset
234 ;;;###autoload
14630
584eb99710a6 (unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
235 (defun unforward-rmail-message ()
584eb99710a6 (unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
236 "Extract a forwarded message from the containing message.
584eb99710a6 (unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
237 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
238 following the containing message."
584eb99710a6 (unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
239 (interactive)
20520
7be5edf3710f (undigestify-rmail-message): If in summary, switch to the Rmail buffer.
Richard M. Stallman <rms@gnu.org>
parents: 18383
diff changeset
240 ;; 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
241 (unwind-protect
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
242 (with-current-buffer rmail-buffer
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
243 (goto-char (point-min))
49878
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
244 (narrow-to-region (point)
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
245 (save-excursion (search-forward "\n\n") (point)))
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
246 (let ((buffer-read-only nil)
49878
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
247 (old-fwd-from (mail-fetch-field "Forwarded-From" nil nil t))
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
248 (old-fwd-date (mail-fetch-field "Forwarded-Date" nil nil t))
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
249 (fwd-from (mail-fetch-field "From"))
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
250 (fwd-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
251 beg end prefix forward-msg)
49878
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
252 (narrow-to-region (rmail-msgbeg rmail-current-message)
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
253 (rmail-msgend rmail-current-message))
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
254 (goto-char (point-min))
49547
b020ca291f89 (rmail-forward-separator-regex): New custom variable.
Francesco Potortì <pot@gnu.org>
parents: 49110
diff changeset
255 (cond ((re-search-forward rmail-forward-separator-regex nil t)
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
256 (forward-line 1)
49097
217ecd0c470e (unforward-rmail-message): Skip all newlines
Francesco Potortì <pot@gnu.org>
parents: 48957
diff changeset
257 (skip-chars-forward "\n")
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
258 (setq beg (point))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
259 (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
260 (match-beginning 0) (point-max)))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
261 (setq forward-msg
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
262 (replace-regexp-in-string
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
263 "^- -" "-" (buffer-substring beg end))))
48957
d8dfc5e743b6 (unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents: 48901
diff changeset
264 ((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
265 (setq beg (match-beginning 0))
49109
39d762048cdd (unforward-rmail-message): Simplified. No functional change.
Francesco Potortì <pot@gnu.org>
parents: 49097
diff changeset
266 (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
267 (goto-char beg)
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
268 (looking-at (concat "\\(" prefix ".+\n\\)*"
49109
39d762048cdd (unforward-rmail-message): Simplified. No functional change.
Francesco Potortì <pot@gnu.org>
parents: 49097
diff changeset
269 prefix "Date: ."))
48957
d8dfc5e743b6 (unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents: 48901
diff changeset
270 (looking-at (concat "\\(" prefix ".+\n\\)*"
d8dfc5e743b6 (unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents: 48901
diff changeset
271 prefix "From: .+\n"
d8dfc5e743b6 (unforward-rmail-message): Do not assume that
Francesco Potortì <pot@gnu.org>
parents: 48901
diff changeset
272 "\\(" prefix ".+\n\\)*"
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
273 "\\(> ?\\)?\n" prefix)))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
274 (re-search-forward "^[^>\n]" nil 'move)
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
275 (backward-char)
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
276 (skip-chars-backward " \t\n")
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
277 (forward-line 1)
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
278 (setq end (point))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
279 (setq forward-msg
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
280 (replace-regexp-in-string
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
281 (if (string= prefix ">") "^>" "> ?")
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
282 "" (buffer-substring beg end))))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
283 (t
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
284 (error "No forwarded message found")))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
285 (widen)
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
286 (goto-char (rmail-msgend rmail-current-message))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
287 (narrow-to-region (point) (point))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
288 (insert rmail-mail-separator)
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
289 (narrow-to-region (point) (point))
49878
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
290 (while old-fwd-from
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
291 (insert "Forwarded-From: " (car old-fwd-from) "\n")
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
292 (insert "Forwarded-Date: " (car old-fwd-date) "\n")
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
293 (setq old-fwd-from (cdr old-fwd-from))
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
294 (setq old-fwd-date (cdr old-fwd-date)))
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
295 (insert "Forwarded-From: " fwd-from "\n")
3e58b8375243 (unforward-rmail-message): Allow nested
Francesco Potortì <pot@gnu.org>
parents: 49547
diff changeset
296 (insert "Forwarded-Date: " fwd-date "\n")
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
297 (insert forward-msg)
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
298 (save-restriction
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
299 (goto-char (point-min))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
300 (re-search-forward "\n$" nil 'move)
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
301 (narrow-to-region (point-min) (point))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
302 (goto-char (point-min))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
303 (while (not (eobp))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
304 (unless (looking-at "^[a-zA-Z-]+: ")
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
305 (insert "\t"))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
306 (forward-line)))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
307 (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
308 (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
309 (rmail-forget-messages)
756931f84374 (unforward-rmail-message): Don't use global variable `n'.
Kim F. Storm <storm@cua.dk>
parents: 49109
diff changeset
310 (rmail-show-message n))
48901
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
311 (if (rmail-summary-exists)
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
312 (rmail-select-summary
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
313 (rmail-update-summary)))))
6f912a2e94c1 (rmail-mail-separator): Renamed from
Francesco Potortì <pot@gnu.org>
parents: 48871
diff changeset
314
14630
584eb99710a6 (unforward-rmail-message): New command.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
315
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 16348
diff changeset
316 (provide 'undigest)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 16348
diff changeset
317
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 87649
diff changeset
318 ;; arch-tag: 3a28b9fb-c1f5-43ef-9278-285f3e4b874d
657
fec3f9a1e3e5 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 35
diff changeset
319 ;;; undigest.el ends here