Mercurial > emacs
annotate lisp/mail/undigest.el @ 12675:8c9369149a9d
Move #define of bcopy to after #include <string.h>.
author | David J. MacKenzie <djm@gnu.org> |
---|---|
date | Wed, 26 Jul 1995 17:54:50 +0000 |
parents | da7bbadf9999 |
children | 21a1494b450c |
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) | |
58 (digest-name | |
59 (mail-strip-quoted-names | |
60 (or (save-restriction | |
61 (search-forward "\n\n") | |
62 (narrow-to-region (point-min) (point)) | |
63 (goto-char (point-max)) | |
64 (or (mail-fetch-field "Reply-To") | |
65 (mail-fetch-field "To") | |
66 (mail-fetch-field "Apparently-To") | |
67 (mail-fetch-field "From"))) | |
68 (error "Message is not a digest"))))) | |
69 (save-excursion | |
70 (goto-char (point-max)) | |
71 (skip-chars-backward " \t\n") | |
72 (let ((count 10) found) | |
73 ;; compensate for broken un*x digestifiers. Sigh Sigh. | |
74 (while (and (> count 0) (not found)) | |
75 (forward-line -1) | |
76 (setq count (1- count)) | |
77 (if (looking-at (concat "End of.*Digest.*\n" | |
78 (regexp-quote "*********") "*" | |
79 "\\(\n------*\\)*")) | |
80 (setq found t))) | |
81 (if (not found) (error "Message is not a digest")))) | |
82 (re-search-forward (concat "^" (make-string 55 ?-) "-*\n*")) | |
83 (replace-match "\^_\^L\n0, unseen,,\n*** EOOH ***\n") | |
84 (save-restriction | |
85 (narrow-to-region (point) | |
86 (progn (search-forward "\n\n") | |
87 (point))) | |
88 (if (mail-fetch-field "To") nil | |
89 (goto-char (point-min)) | |
90 (insert "To: " digest-name "\n"))) | |
91 (while (re-search-forward | |
92 (concat "\n\n" (make-string 27 ?-) "-*\n*") | |
93 nil t) | |
94 (replace-match "\n\n\^_\^L\n0, unseen,,\n*** EOOH ***\n") | |
95 (save-restriction | |
96 (if (looking-at "End ") | |
97 (insert "To: " digest-name "\n\n") | |
98 (narrow-to-region (point) | |
99 (progn (search-forward "\n\n" | |
100 nil 'move) | |
101 (point)))) | |
11498
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
102 (if (mail-fetch-field "To") |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
103 nil |
35 | 104 (goto-char (point-min)) |
11498
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
105 (insert "To: " digest-name "\n"))) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
106 ;; 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
|
107 ;; Undo that. |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
108 (save-excursion |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
109 (goto-char (point-min)) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
110 (if (re-search-forward |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
111 "\n\n----------------------------*\n*" |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
112 nil t) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
113 (let ((end (point-marker))) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
114 (goto-char (point-min)) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
115 (while (re-search-forward "^- " end t) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
116 (delete-char -2))))) |
da7bbadf9999
(undigestify-rmail-message): Strip "^- " which is
Richard M. Stallman <rms@gnu.org>
parents:
7300
diff
changeset
|
117 ))) |
35 | 118 (setq error nil) |
119 (message "Message successfully undigestified") | |
120 (let ((n rmail-current-message)) | |
121 (rmail-forget-messages) | |
122 (rmail-show-message n) | |
7038
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
123 (rmail-delete-forward) |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
124 (if (rmail-summary-exists) |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
125 (rmail-select-summary |
e640d438df9a
(undigestify-rmail-message): Update summary buffer.
Karl Heuer <kwzh@gnu.org>
parents:
841
diff
changeset
|
126 (rmail-update-summary))))) |
35 | 127 (cond (error |
128 (narrow-to-region (point-min) (1+ (point-max))) | |
129 (delete-region (point-min) (point-max)) | |
130 (rmail-show-message rmail-current-message)))))) | |
131 | |
657
fec3f9a1e3e5
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
35
diff
changeset
|
132 ;;; undigest.el ends here |