annotate lisp/mail/rmailsum.el @ 783:59dc833c4e0c

*** empty log message ***
author Eric S. Raymond <esr@snark.thyrsus.com>
date Wed, 15 Jul 1992 18:48:42 +0000
parents 7cbd4fcd8b0f
children 4f28bd14272c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 130
diff changeset
1 ;;; rmailsum.el --- "RMAIL" mail reader for Emacs.
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 130
diff changeset
2
130
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5 ;; This file is part of GNU Emacs.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
8 ;; it under the terms of the GNU General Public License as published by
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9 ;; the Free Software Foundation; either version 1, or (at your option)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;; any later version.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; GNU Emacs is distributed in the hope that it will be useful,
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; GNU General Public License for more details.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; You should have received a copy of the GNU General Public License
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; summary things
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 (defun rmail-summary ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 "Display a summary of all messages, one line per message."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
27 (rmail-new-summary "All" nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
28
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
29 (defun rmail-summary-by-labels (labels)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
30 "Display a summary of all messages with one or more LABELS.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31 LABELS should be a string containing the desired labels, separated by commas."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 (interactive "sLabels to summarize by: ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 (if (string= labels "")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
34 (setq labels (or rmail-last-multi-labels
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
35 (error "No label specified"))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
36 (setq rmail-last-multi-labels labels)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
37 (rmail-new-summary (concat "labels " labels)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
38 'rmail-message-labels-p
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
39 (concat ", \\(" (mail-comma-list-regexp labels) "\\),")))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
40
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
41 (defun rmail-summary-by-recipients (recipients &optional primary-only)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42 "Display a summary of all messages with the given RECIPIENTS.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
43 Normally checks the To, From and Cc fields of headers;
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
44 but if PRIMARY-ONLY is non-nil (prefix arg given),
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 only look in the To and From fields.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 RECIPIENTS is a string of names separated by commas."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 (interactive "sRecipients to summarize by: \nP")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48 (rmail-new-summary
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 (concat "recipients " recipients)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 'rmail-message-recipients-p
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 (mail-comma-list-regexp recipients) primary-only))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 (defun rmail-message-recipients-p (msg recipients &optional primary-only)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54 (save-restriction
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 (goto-char (rmail-msgbeg msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 (search-forward "\n*** EOOH ***\n")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 (narrow-to-region (point) (progn (search-forward "\n\n") (point)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 (or (string-match recipients (or (mail-fetch-field "To") ""))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 (string-match recipients (or (mail-fetch-field "From") ""))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (if (not primary-only)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61 (string-match recipients (or (mail-fetch-field "Cc") ""))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
62
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
63 (defun rmail-summary-by-regexp (regexp)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
64 "Display a summary of all messages according to regexp REGEXP.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
65 If the regular expression is found in the header of the message
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
66 \(including in the date and other lines, as well as the subject line),
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 Emacs will list the header line in the RMAIL-summary."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 (interactive "sRegexp to summarize by: ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 (if (string= regexp "")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70 (setq regexp (or rmail-last-regexp
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 (error "No regexp specified"))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 (setq rmail-last-regexp regexp)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
73 (rmail-new-summary (concat "regexp " regexp)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 'rmail-message-regexp-p
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 regexp))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 (defun rmail-message-regexp-p (msg regexp)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 "Return t, if for message number MSG, regexp REGEXP matches in the header."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 (goto-char (rmail-msgbeg msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 (let ((end
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 (save-excursion
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 (search-forward "*** EOOH ***" (point-max)) (point))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 (re-search-forward regexp end t)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 (defun rmail-new-summary (description function &rest args)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 "Create a summary of selected messages.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 DESCRIPTION makes part of the mode line of the summary buffer.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 For each message, FUNCTION is applied to the message number and ARGS...
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 and if the result is non-nil, that message is included.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 nil for FUNCTION means all messages."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 (message "Computing summary lines...")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 (or (and rmail-summary-buffer
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 (buffer-name rmail-summary-buffer))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 (setq rmail-summary-buffer
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 (generate-new-buffer (concat (buffer-name) "-summary"))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 (let ((summary-msgs ())
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 (new-summary-line-count 0))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 (let ((msgnum 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 (buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 (save-restriction
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 (save-excursion
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 (widen)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 (goto-char (point-min))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 (while (>= rmail-total-messages msgnum)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 (if (or (null function)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 (apply function (cons msgnum args)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 (setq summary-msgs
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 (cons (rmail-make-summary-line msgnum)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 summary-msgs)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (setq msgnum (1+ msgnum))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 (let ((sbuf rmail-summary-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 (rbuf (current-buffer))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 (total rmail-total-messages)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 (mesg rmail-current-message))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 (pop-to-buffer sbuf)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 ;; Our scroll command should always scroll the Rmail buffer.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 (make-local-variable 'other-window-scroll-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 (setq other-window-scroll-buffer rbuf)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 (let ((buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 (erase-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 (cond (summary-msgs
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 (princ (nreverse summary-msgs) sbuf)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 (delete-char -1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 (subst-char-in-region 1 2 ?\( ?\ ))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (setq buffer-read-only t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 (goto-char (point-min))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 (rmail-summary-mode)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 (make-local-variable 'minor-mode-alist)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129 (setq minor-mode-alist (list ": " description))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130 (setq rmail-buffer rbuf
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 rmail-total-messages total)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 (rmail-summary-goto-msg mesg t)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 (message "Computing summary lines...done"))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (defun rmail-make-summary-line (msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (let ((line (or (aref rmail-summary-vector (1- msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 (setq new-summary-line-count
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 (1+ new-summary-line-count))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 (if (zerop (% new-summary-line-count 10))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (message "Computing summary lines...%d"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 new-summary-line-count))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 (rmail-make-summary-line-1 msg)))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 ;; Fix up the part of the summary that says "deleted" or "unseen".
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 (aset line 4
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 (if (rmail-message-deleted-p msg) ?\D
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (if (= ?0 (char-after (+ 3 (rmail-msgbeg msg))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148 ?\- ?\ )))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 line))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151 (defun rmail-make-summary-line-1 (msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 (goto-char (rmail-msgbeg msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (let* ((lim (save-excursion (forward-line 2) (point)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 pos
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 (labels
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 (forward-char 3)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 (concat
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 ; (if (save-excursion (re-search-forward ",answered," lim t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 ; "*" "")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 ; (if (save-excursion (re-search-forward ",filed," lim t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 ; "!" "")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 (if (progn (search-forward ",,") (eolp))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164 ""
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 (concat "{"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 (buffer-substring (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 (progn (end-of-line) (point)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 "} ")))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 (line
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171 (forward-line 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 (if (looking-at "Summary-line: ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 (goto-char (match-end 0))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
175 (setq line
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 (buffer-substring (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
177 (progn (forward-line 1) (point)))))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
178 ;; Obsolete status lines lacking a # should be flushed.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179 (and line
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 (not (string-match "#" line))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 (delete-region (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183 (progn (forward-line -1) (point)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 (setq line nil)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 ;; If we didn't get a valid status line from the message,
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 ;; make a new one and put it in the message.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 (or line
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
188 (let* ((case-fold-search t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 (next (rmail-msgend msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 (beg (if (progn (goto-char (rmail-msgbeg msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
191 (search-forward "\n*** EOOH ***\n" next t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
192 (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
193 (forward-line 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 (point)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 (end (progn (search-forward "\n\n" nil t) (point))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 (save-restriction
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 (narrow-to-region beg end)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 (goto-char beg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 (setq line (rmail-make-basic-summary-line)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 (goto-char (rmail-msgbeg msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 (forward-line 2)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 (insert "Summary-line: " line)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 (setq pos (string-match "#" line))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 (aset rmail-summary-vector (1- msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 (concat (format "%4d " msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 (substring line 0 pos)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207 labels
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
208 (substring line (1+ pos))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 (defun rmail-make-basic-summary-line ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 (goto-char (point-min))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
212 (concat (save-excursion
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (if (not (re-search-forward "^Date:" nil t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 " "
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 (cond ((re-search-forward "\\([^0-9:]\\)\\([0-3]?[0-9]\\)\\([- \t_]+\\)\\([adfjmnos][aceopu][bcglnprtvy]\\)"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 (save-excursion (end-of-line) (point)) t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 (format "%2d-%3s"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 (string-to-int (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 (match-beginning 2)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (match-end 2)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 (match-beginning 4) (match-end 4))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 ((re-search-forward "\\([^a-z]\\)\\([adfjmnos][acepou][bcglnprtvy]\\)\\([-a-z \t_]*\\)\\([0-9][0-9]?\\)"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (save-excursion (end-of-line) (point)) t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 (format "%2d-%3s"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (string-to-int (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 (match-beginning 4)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 (match-end 4)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 (match-beginning 2) (match-end 2))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 (t "??????"))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 " "
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 (save-excursion
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 (if (not (re-search-forward "^From:[ \t]*" nil t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 " "
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 (let* ((from (mail-strip-quoted-names
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238 (1- (point))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (progn (end-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 (skip-chars-backward " \t")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 (point)))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242 len mch lo)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 (if (string-match (concat "^"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 (regexp-quote (user-login-name))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 "\\($\\|@\\)")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 from)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 (save-excursion
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (goto-char (point-min))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 (if (not (re-search-forward "^To:[ \t]*" nil t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 nil
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (setq from
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (concat "to: "
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (mail-strip-quoted-names
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (buffer-substring
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (progn (end-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 (skip-chars-backward " \t")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (point)))))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 (setq len (length from))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 (setq mch (string-match "[@%]" from))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (format "%25s"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 (if (or (not mch) (<= len 25))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 (substring from (max 0 (- len 25)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 (substring from
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 (setq lo (cond ((< (- mch 9) 0) 0)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 ((< len (+ mch 16))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (- len 25))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (t (- mch 9))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (min len (+ lo 25))))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 " #"
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 (if (re-search-forward "^Subject:" nil t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 (progn (skip-chars-forward " \t")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (buffer-substring (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (progn (end-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 (point))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 (re-search-forward "[\n][\n]+" nil t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 (buffer-substring (point) (progn (end-of-line) (point))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 "\n"))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 (defun rmail-summary-next-all (&optional number)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 (interactive "p")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 (forward-line (if number number 1))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 (rmail-summary-goto-msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 (defun rmail-summary-previous-all (&optional number)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (interactive "p")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 (forward-line (- (if number number 1)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (rmail-summary-goto-msg))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 (defun rmail-summary-next-msg (&optional number)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 (interactive "p")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (forward-line 0)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 (and (> number 0) (forward-line 1))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 (let ((count (if (< number 0) (- number) number))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (search (if (> number 0) 're-search-forward 're-search-backward))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 end)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
297 (while (and (> count 0) (funcall search "^.....[^D]" nil t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 (setq count (1- count)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 (rmail-summary-goto-msg)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301 (defun rmail-summary-previous-msg (&optional number)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 (interactive "p")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 (rmail-summary-next-msg (- (if number number 1))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305 (defun rmail-summary-delete-forward ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 (let (end)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 (rmail-summary-goto-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 (pop-to-buffer rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 (rmail-delete-message)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 (pop-to-buffer rmail-summary-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312 (let ((buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (skip-chars-forward " ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 (skip-chars-forward "[0-9]")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315 (delete-char 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 (insert "D"))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 (rmail-summary-next-msg 1)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319 (defun rmail-summary-delete-backward ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 (let (end)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 (rmail-summary-goto-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 (pop-to-buffer rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (rmail-delete-message)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 (pop-to-buffer rmail-summary-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 (let ((buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 (skip-chars-forward " ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 (skip-chars-forward "[0-9]")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (delete-char 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 (insert "D"))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 (rmail-summary-next-msg -1)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
333 (defun rmail-summary-undelete ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 (let ((buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 (end-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (cond ((re-search-backward "\\(^ *[0-9]*\\)\\(D\\)" nil t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 (replace-match "\\1 ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 (rmail-summary-goto-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 (pop-to-buffer rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 (and (rmail-message-deleted-p rmail-current-message)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342 (rmail-undelete-previous-message))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 (pop-to-buffer rmail-summary-buffer))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 (t
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 (rmail-summary-goto-msg)))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 ;; Rmail Summary mode is suitable only for specially formatted data.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
348 (put 'rmail-summary-mode 'mode-class 'special)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 (defun rmail-summary-mode ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 "Major mode in effect in Rmail summary buffer.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 A subset of the Rmail mode commands are supported in this mode.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 As commands are issued in the summary buffer the corresponding
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
354 mail message is displayed in the rmail buffer.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 n Move to next undeleted message, or arg messages.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
357 p Move to previous undeleted message, or arg messages.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
358 M-n Move to next, or forward arg messages.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
359 M-p Move to previous, or previous arg messages.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 j Jump to the message at the cursor location.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361 d Delete the message at the cursor location and move to next message.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 C-d Delete the message at the cursor location and move to previous message.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 u Undelete this or previous deleted message.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
364 q Quit Rmail.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 x Exit and kill the summary window.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 space Scroll message in other window forward.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 delete Scroll message backward.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 Entering this mode calls value of hook variable rmail-summary-mode-hook."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 (kill-all-local-variables)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 (make-local-variable 'rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 (make-local-variable 'rmail-total-messages)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (setq major-mode 'rmail-summary-mode)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (setq mode-name "RMAIL Summary")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (use-local-map rmail-summary-mode-map)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 (setq truncate-lines t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 (setq buffer-read-only t)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 (set-syntax-table text-mode-syntax-table)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 (run-hooks 'rmail-summary-mode-hook))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
382 (defun rmail-summary-goto-msg (&optional n nowarn)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 (interactive "P")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 (if (consp n) (setq n (prefix-numeric-value n)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 (if (eobp) (forward-line -1))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 (beginning-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 (let ((buf rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 (cur (point))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 (curmsg (string-to-int
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390 (buffer-substring (point)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 (min (point-max) (+ 5 (point)))))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 (if (not n)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
393 (setq n curmsg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394 (if (< n 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 (progn (message "No preceding message")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 (setq n 1)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 (if (> n rmail-total-messages)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 (progn (message "No following message")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
399 (goto-char (point-max))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 (rmail-summary-goto-msg)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (goto-char (point-min))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (if (not (re-search-forward (concat "^ *" (int-to-string n)) nil t))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 (progn (or nowarn (message "Message %d not found" n))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404 (setq n curmsg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 (goto-char cur))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 (beginning-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 (skip-chars-forward " ")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 (skip-chars-forward "0-9")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 (save-excursion (if (= (following-char) ?-)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410 (let ((buffer-read-only nil))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 (delete-char 1)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 (insert " "))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (beginning-of-line)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414 (pop-to-buffer buf)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 (rmail-show-message n)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 (pop-to-buffer rmail-summary-buffer)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 (defvar rmail-summary-mode-map nil)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 (if rmail-summary-mode-map
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421 nil
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 (setq rmail-summary-mode-map (make-keymap))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 (suppress-keymap rmail-summary-mode-map)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 (define-key rmail-summary-mode-map "j" 'rmail-summary-goto-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 (define-key rmail-summary-mode-map "n" 'rmail-summary-next-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 (define-key rmail-summary-mode-map "p" 'rmail-summary-previous-msg)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (define-key rmail-summary-mode-map "\en" 'rmail-summary-next-all)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 (define-key rmail-summary-mode-map "\ep" 'rmail-summary-previous-all)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429 (define-key rmail-summary-mode-map " " 'rmail-summary-scroll-msg-up)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (define-key rmail-summary-mode-map "q" 'rmail-summary-quit)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (define-key rmail-summary-mode-map "u" 'rmail-summary-undelete)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (define-key rmail-summary-mode-map "x" 'rmail-summary-exit)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (define-key rmail-summary-mode-map "\177" 'rmail-summary-scroll-msg-down)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 (define-key rmail-summary-mode-map "d" 'rmail-summary-delete-forward)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 (define-key rmail-summary-mode-map "\C-d" 'rmail-summary-delete-backward))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (defun rmail-summary-scroll-msg-up (&optional dist)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 "Scroll other window forward."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439 (interactive "P")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 (let ((window (selected-window))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 (new-window (display-buffer rmail-buffer)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 (unwind-protect
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444 (select-window new-window)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 (scroll-up dist))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 (select-window window))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 (defun rmail-summary-scroll-msg-down (&optional dist)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 "Scroll other window backward."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 (interactive "P")
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 (let ((window (selected-window))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 (new-window (display-buffer rmail-buffer)))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (unwind-protect
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 (progn
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (select-window new-window)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 (scroll-down dist))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 (select-window window))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (defun rmail-summary-quit ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 "Quit out of rmail and rmail summary."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 (rmail-summary-exit)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 (rmail-quit))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 (defun rmail-summary-exit ()
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 "Exit rmail summary, remaining within rmail."
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 (interactive)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 (bury-buffer (current-buffer))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469 (if (get-buffer-window rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
470 ;; Select the window with rmail in it, then delete this window.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 (select-window (prog1
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 (get-buffer-window rmail-buffer)
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 (delete-window (selected-window))))
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474 ;; Switch to the rmail buffer in this window.
ad8219ab7a97 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (switch-to-buffer rmail-buffer)))
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 130
diff changeset
476
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 130
diff changeset
477 ;;; rmailsum.el ends here