annotate lisp/mail/unrmail.el @ 50683:11093cda819e

Don't call filesets-init.
author Richard M. Stallman <rms@gnu.org>
date Thu, 24 Apr 2003 01:55:38 +0000
parents 433ae412d00f
children 695cf19ef79e 0ccb1fcb32c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 18383
diff changeset
1 ;;; unrmail.el --- convert Rmail files to mailbox files
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 982
diff changeset
2
47631
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
3 ;;; Copyright (C) 1992, 2002 Free Software Foundation, Inc.
982
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
38695
01c7199c0ee7 Specify FSF as Maintainer.
Pavel Janík <Pavel@Janik.cz>
parents: 38414
diff changeset
5 ;; Maintainer: FSF
2247
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2233
diff changeset
6 ;; Keywords: mail
2c7997f249eb Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2233
diff changeset
7
982
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13113
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13113
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13113
diff changeset
23 ;; Boston, MA 02111-1307, USA.
982
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
38414
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 18383
diff changeset
25 ;;; Commentary:
67b464da13ec Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 18383
diff changeset
26
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 982
diff changeset
27 ;;; Code:
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 982
diff changeset
28
982
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 (defvar command-line-args-left) ;Avoid 'free variable' warning
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;;;###autoload
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 (defun batch-unrmail ()
6618
8d8033687586 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4266
diff changeset
33 "Convert Rmail files to system inbox format.
982
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 Specify the input Rmail file names as command line arguments.
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 For each Rmail file, the corresponding output file name
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 is made by adding `.mail' at the end.
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 For example, invoke `emacs -batch -f batch-unrmail RMAIL'."
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;; command-line-args-left is what is left of the command line (from startup.el)
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 (if (not noninteractive)
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (error "`batch-unrmail' is to be used only with -batch"))
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 (let ((error nil))
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 (while command-line-args-left
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 (or (unrmail (car command-line-args-left)
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (concat (car command-line-args-left) ".mail"))
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 (setq error t))
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (setq command-line-args-left (cdr command-line-args-left)))
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (message "Done")
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 (kill-emacs (if error 1 0))))
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;;;###autoload
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 (defun unrmail (file to-file)
6618
8d8033687586 Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 4266
diff changeset
52 "Convert Rmail file FILE to system inbox format file TO-FILE."
4266
5a7266ff9af1 (unrmail): Total rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
53 (interactive "fUnrmail (rmail file): \nFUnrmail into (new mailbox file): ")
47631
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
54 (let ((message-count 1)
11177
6a26526998f6 (unrmail): Don't make or switch to a summary buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6618
diff changeset
55 ;; Prevent rmail from making, or switching to, a summary buffer.
6a26526998f6 (unrmail): Don't make or switch to a summary buffer.
Richard M. Stallman <rms@gnu.org>
parents: 6618
diff changeset
56 (rmail-display-summary nil)
47631
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
57 (rmail-delete-after-output nil)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
58 (temp-buffer (get-buffer-create " unrmail")))
982
595f9517f205 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (rmail file)
14296
e3e1d7c2e7e5 (unrmail): Default the directory of TO-FILE based on FILE.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
60 ;; Default the directory of TO-FILE based on where FILE is.
e3e1d7c2e7e5 (unrmail): Default the directory of TO-FILE based on FILE.
Karl Heuer <kwzh@gnu.org>
parents: 14169
diff changeset
61 (setq to-file (expand-file-name to-file default-directory))
47631
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
62 (condition-case ()
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
63 (delete-file to-file)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
64 (file-error nil))
4266
5a7266ff9af1 (unrmail): Total rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
65 (message "Writing messages to %s..." to-file)
47631
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
66 (save-restriction
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
67 (widen)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
68 (while (<= message-count rmail-total-messages)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
69 (let ((beg (rmail-msgbeg message-count))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
70 (end (rmail-msgbeg (1+ message-count)))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
71 (from-buffer (current-buffer))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
72 (coding (or rmail-file-coding-system 'raw-text))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
73 label-line attrs keywords
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
74 header-beginning mail-from)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
75 (save-excursion
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
76 (goto-char (rmail-msgbeg message-count))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
77 (setq header-beginning (point))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
78 (search-forward "\n*** EOOH ***\n")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
79 (forward-line -1)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
80 (search-forward "\n\n")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
81 (save-restriction
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
82 (narrow-to-region header-beginning (point))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
83 (setq mail-from
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
84 (or (mail-fetch-field "Mail-From")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
85 (concat "From "
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
86 (mail-strip-quoted-names (or (mail-fetch-field "from")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
87 (mail-fetch-field "really-from")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
88 (mail-fetch-field "sender")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
89 "unknown"))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
90 " " (current-time-string))))))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
91 (with-current-buffer temp-buffer
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
92 (setq buffer-undo-list t)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
93 (erase-buffer)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
94 (setq buffer-file-coding-system coding)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
95 (insert-buffer-substring from-buffer beg end)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
96 (goto-char (point-min))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
97 (forward-line 1)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
98 (setq label-line
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
99 (buffer-substring (point)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
100 (progn (forward-line 1)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
101 (point))))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
102 (forward-line -1)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
103 (search-forward ",,")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
104 (unless (eolp)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
105 (setq keywords
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
106 (buffer-substring (point)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
107 (progn (end-of-line)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
108 (1- (point)))))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
109 (setq keywords
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
110 (replace-regexp-in-string ", " "," keywords)))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
111
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
112 (setq attrs
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
113 (list
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
114 (if (string-match ", answered," label-line) ?A ?-)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
115 (if (string-match ", deleted," label-line) ?D ?-)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
116 (if (string-match ", edited," label-line) ?E ?-)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
117 (if (string-match ", filed," label-line) ?F ?-)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
118 (if (string-match ", resent," label-line) ?R ?-)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
119 (if (string-match ", unseen," label-line) ?\ ?-)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
120 (if (string-match ", stored," label-line) ?S ?-)))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
121 (unrmail-unprune)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
122 (goto-char (point-min))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
123 (insert mail-from "\n")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
124 (insert "X-BABYL-V6-ATTRIBUTES: " (apply 'string attrs) "\n")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
125 (when keywords
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
126 (insert "X-BABYL-V6-KEYWORDS: " keywords "\n"))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
127 (goto-char (point-min))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
128 ;; ``Quote'' "\nFrom " as "\n>From "
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
129 ;; (note that this isn't really quoting, as there is no requirement
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
130 ;; that "\n[>]+From " be quoted in the same transparent way.)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
131 (let ((case-fold-search nil))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
132 (while (search-forward "\nFrom " nil t)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
133 (forward-char -5)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
134 (insert ?>)))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
135 (write-region (point-min) (point-max) to-file t
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
136 'nomsg)))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
137 (setq message-count (1+ message-count))))
4266
5a7266ff9af1 (unrmail): Total rewrite.
Richard M. Stallman <rms@gnu.org>
parents: 2247
diff changeset
138 (message "Writing messages to %s...done" to-file)))
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 982
diff changeset
139
47631
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
140 (defun unrmail-unprune ()
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
141 (let* ((pruned
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
142 (save-excursion
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
143 (goto-char (point-min))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
144 (forward-line 1)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
145 (= (following-char) ?1))))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
146 (if pruned
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
147 (progn
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
148 (goto-char (point-min))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
149 (forward-line 2)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
150 ;; Delete Summary-Line headers.
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
151 (let ((case-fold-search t))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
152 (while (looking-at "Summary-Line:")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
153 (forward-line 1)))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
154 (delete-region (point-min) (point))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
155 ;; Delete the old reformatted header.
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
156 (re-search-forward "^[*][*][*] EOOH [*][*][*]\n")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
157 (forward-line -1)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
158 (let ((start (point)))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
159 (search-forward "\n\n")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
160 (delete-region start (point))))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
161 ;; Delete everything up to the real header.
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
162 (goto-char (point-min))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
163 (re-search-forward "^[*][*][*] EOOH [*][*][*]\n")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
164 (delete-region (point-min) (point)))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
165 (goto-char (point-min))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
166 (when (re-search-forward "^Mail-from:")
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
167 (beginning-of-line)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
168 (delete-region (point)
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
169 (progn (forward-line 1) (point))))))
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
170
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
171
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 14296
diff changeset
172 (provide 'unrmail)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 14296
diff changeset
173
2233
fb0ed5a1d0f3 Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 982
diff changeset
174 ;;; unrmail.el ends here
47631
433ae412d00f (unrmail): Do the work directly,
Richard M. Stallman <rms@gnu.org>
parents: 38695
diff changeset
175