Mercurial > emacs
annotate lisp/mail/undigest.el @ 13769:a17778d3f5f3
(syms_of_fileio): Doc fix.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 21 Dec 1995 17:00:42 +0000 |
parents | d383abe2f9f3 |
children | 83f275dcd93a |
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 |
7300 | 3 ;; Copyright (C) 1985, 1986, 1994 Free Software Foundation, Inc. |
841 | 4 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
5 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
6 ;; Keywords: mail |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
7 |
35 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
35 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
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 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
26 ;; See Internet RFC 934 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
27 |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
657
diff
changeset
|
28 ;;; Code: |
35 | 29 |
7038
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
30 (require 'rmail) |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
31 |
35 | 32 (defun undigestify-rmail-message () |
33 "Break up a digest message into its constituent messages. | |
34 Leaves original message, deleted, before the undigestified messages." | |
35 (interactive) | |
36 (widen) | |
37 (let ((buffer-read-only nil) | |
38 (msg-string (buffer-substring (rmail-msgbeg rmail-current-message) | |
39 (rmail-msgend rmail-current-message)))) | |
40 (goto-char (rmail-msgend rmail-current-message)) | |
41 (narrow-to-region (point) (point)) | |
42 (insert msg-string) | |
43 (narrow-to-region (point-min) (1- (point-max)))) | |
44 (let ((error t) | |
45 (buffer-read-only nil)) | |
46 (unwind-protect | |
47 (progn | |
48 (save-restriction | |
49 (goto-char (point-min)) | |
50 (delete-region (point-min) | |
51 (progn (search-forward "\n*** EOOH ***\n") | |
52 (point))) | |
53 (insert "\^_\^L\n0, unseen,,\n*** EOOH ***\n") | |
54 (narrow-to-region (point) | |
55 (point-max)) | |
56 (let* ((fill-prefix "") | |
57 (case-fold-search t) | |
13080
21a1494b450c
(undigestify-rmail-message): Scan back as far as start
Richard M. Stallman <rms@gnu.org>
parents:
11498
diff
changeset
|
58 start |
35 | 59 (digest-name |
60 (mail-strip-quoted-names | |
61 (or (save-restriction | |
62 (search-forward "\n\n") | |
13080
21a1494b450c
(undigestify-rmail-message): Scan back as far as start
Richard M. Stallman <rms@gnu.org>
parents:
11498
diff
changeset
|
63 (setq start (point)) |
35 | 64 (narrow-to-region (point-min) (point)) |
65 (goto-char (point-max)) | |
66 (or (mail-fetch-field "Reply-To") | |
67 (mail-fetch-field "To") | |
68 (mail-fetch-field "Apparently-To") | |
69 (mail-fetch-field "From"))) | |
13088
d383abe2f9f3
(undigestify-rmail-message): Better error messages.
Richard M. Stallman <rms@gnu.org>
parents:
13080
diff
changeset
|
70 (error "Message is not a digest--bad header"))))) |
35 | 71 (save-excursion |
72 (goto-char (point-max)) | |
73 (skip-chars-backward " \t\n") | |
13080
21a1494b450c
(undigestify-rmail-message): Scan back as far as start
Richard M. Stallman <rms@gnu.org>
parents:
11498
diff
changeset
|
74 (let (found) |
35 | 75 ;; compensate for broken un*x digestifiers. Sigh Sigh. |
13080
21a1494b450c
(undigestify-rmail-message): Scan back as far as start
Richard M. Stallman <rms@gnu.org>
parents:
11498
diff
changeset
|
76 (while (and (> (point) start) (not found)) |
35 | 77 (forward-line -1) |
78 (if (looking-at (concat "End of.*Digest.*\n" | |
79 (regexp-quote "*********") "*" | |
80 "\\(\n------*\\)*")) | |
81 (setq found t))) | |
13088
d383abe2f9f3
(undigestify-rmail-message): Better error messages.
Richard M. Stallman <rms@gnu.org>
parents:
13080
diff
changeset
|
82 (if (not found) |
d383abe2f9f3
(undigestify-rmail-message): Better error messages.
Richard M. Stallman <rms@gnu.org>
parents:
13080
diff
changeset
|
83 (error "Message is not a digest--no end line")))) |
35 | 84 (re-search-forward (concat "^" (make-string 55 ?-) "-*\n*")) |
85 (replace-match "\^_\^L\n0, unseen,,\n*** EOOH ***\n") | |
86 (save-restriction | |
87 (narrow-to-region (point) | |
88 (progn (search-forward "\n\n") | |
89 (point))) | |
90 (if (mail-fetch-field "To") nil | |
91 (goto-char (point-min)) | |
92 (insert "To: " digest-name "\n"))) | |
93 (while (re-search-forward | |
94 (concat "\n\n" (make-string 27 ?-) "-*\n*") | |
95 nil t) | |
96 (replace-match "\n\n\^_\^L\n0, unseen,,\n*** EOOH ***\n") | |
97 (save-restriction | |
98 (if (looking-at "End ") | |
99 (insert "To: " digest-name "\n\n") | |
100 (narrow-to-region (point) | |
101 (progn (search-forward "\n\n" | |
102 nil 'move) | |
103 (point)))) | |
11498
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
104 (if (mail-fetch-field "To") |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
105 nil |
35 | 106 (goto-char (point-min)) |
11498
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
107 (insert "To: " digest-name "\n"))) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
108 ;; Digestifiers may insert `- ' on lines that start with `-'. |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
109 ;; Undo that. |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
110 (save-excursion |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
111 (goto-char (point-min)) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
112 (if (re-search-forward |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
113 "\n\n----------------------------*\n*" |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
114 nil t) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
115 (let ((end (point-marker))) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
116 (goto-char (point-min)) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
117 (while (re-search-forward "^- " end t) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
118 (delete-char -2))))) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
119 ))) |
35 | 120 (setq error nil) |
121 (message "Message successfully undigestified") | |
122 (let ((n rmail-current-message)) | |
123 (rmail-forget-messages) | |
124 (rmail-show-message n) | |
7038
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
125 (rmail-delete-forward) |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
126 (if (rmail-summary-exists) |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
127 (rmail-select-summary |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
128 (rmail-update-summary))))) |
35 | 129 (cond (error |
130 (narrow-to-region (point-min) (1+ (point-max))) | |
131 (delete-region (point-min) (point-max)) | |
132 (rmail-show-message rmail-current-message)))))) | |
133 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
134 ;;; undigest.el ends here |