1 ;;; undigest.el --- digest-cracking support for the RMAIL mail reader
4 ;; Last-Modified: 14 Jul 1992
7 ;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
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.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
27 ;; See Internet RFC 934
31 (defun undigestify-rmail-message ()
32 "Break up a digest message into its constituent messages.
33 Leaves original message, deleted, before the undigestified messages."
36 (let ((buffer-read-only nil
)
37 (msg-string (buffer-substring (rmail-msgbeg rmail-current-message
)
38 (rmail-msgend rmail-current-message
))))
39 (goto-char (rmail-msgend rmail-current-message
))
40 (narrow-to-region (point) (point))
42 (narrow-to-region (point-min) (1- (point-max))))
44 (buffer-read-only nil
))
48 (goto-char (point-min))
49 (delete-region (point-min)
50 (progn (search-forward "\n*** EOOH ***\n")
52 (insert "\^_\^L\n0, unseen,,\n*** EOOH ***\n")
53 (narrow-to-region (point)
55 (let* ((fill-prefix "")
58 (mail-strip-quoted-names
60 (search-forward "\n\n")
61 (narrow-to-region (point-min) (point))
62 (goto-char (point-max))
63 (or (mail-fetch-field "Reply-To")
64 (mail-fetch-field "To")
65 (mail-fetch-field "Apparently-To")
66 (mail-fetch-field "From")))
67 (error "Message is not a digest")))))
69 (goto-char (point-max))
70 (skip-chars-backward " \t\n")
71 (let ((count 10) found
)
72 ;; compensate for broken un*x digestifiers. Sigh Sigh.
73 (while (and (> count
0) (not found
))
75 (setq count
(1- count
))
76 (if (looking-at (concat "End of.*Digest.*\n"
77 (regexp-quote "*********") "*"
80 (if (not found
) (error "Message is not a digest"))))
81 (re-search-forward (concat "^" (make-string 55 ?-
) "-*\n*"))
82 (replace-match "\^_\^L\n0, unseen,,\n*** EOOH ***\n")
84 (narrow-to-region (point)
85 (progn (search-forward "\n\n")
87 (if (mail-fetch-field "To") nil
88 (goto-char (point-min))
89 (insert "To: " digest-name
"\n")))
90 (while (re-search-forward
91 (concat "\n\n" (make-string 27 ?-
) "-*\n*")
93 (replace-match "\n\n\^_\^L\n0, unseen,,\n*** EOOH ***\n")
95 (if (looking-at "End ")
96 (insert "To: " digest-name
"\n\n")
97 (narrow-to-region (point)
98 (progn (search-forward "\n\n"
101 (if (mail-fetch-field "To") nil
102 (goto-char (point-min))
103 (insert "To: " digest-name
"\n"))))))
105 (message "Message successfully undigestified")
106 (let ((n rmail-current-message
))
107 (rmail-forget-messages)
108 (rmail-show-message n
)
109 (rmail-delete-forward)))
111 (narrow-to-region (point-min) (1+ (point-max)))
112 (delete-region (point-min) (point-max))
113 (rmail-show-message rmail-current-message
))))))
115 ;;; undigest.el ends here