annotate lisp/rmail/rmailkwd.el @ 172:a38aed19690b

Added tag r20-3b12 for changeset 929b76928fce
author cvs
date Mon, 13 Aug 2007 09:47:55 +0200
parents 0293115a14e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; rmailkwd.el --- part of the "RMAIL" mail reader for Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985, 1988 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: mail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 0
diff changeset
23 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; Global to all RMAIL buffers. It exists primarily for the sake of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; completion. It is better to use strings with the label functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; and let them worry about making the label.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defvar rmail-label-obarray (make-vector 47 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; Named list of symbols representing valid message attributes in RMAIL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (defconst rmail-attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (cons 'rmail-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (mapcar '(lambda (s) (intern s rmail-label-obarray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 '("deleted" "answered" "filed" "forwarded" "unseen" "edited"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defconst rmail-deleted-label (intern "deleted" rmail-label-obarray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; Named list of symbols representing valid message keywords in RMAIL.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defvar rmail-keywords nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (defun rmail-add-label (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 "Add LABEL to labels associated with current RMAIL message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 Completion is performed over known labels when reading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (interactive (list (rmail-read-label "Add label")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (rmail-set-label string t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defun rmail-kill-label (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "Remove LABEL from labels associated with current RMAIL message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 Completion is performed over known labels when reading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (interactive (list (rmail-read-label "Remove label")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 (rmail-set-label string nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 (defun rmail-read-label (prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (if (not rmail-keywords) (rmail-parse-file-keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (let ((result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (completing-read (concat prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (if rmail-last-label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (concat " (default "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (symbol-name rmail-last-label)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 "): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ": "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 rmail-label-obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (if (string= result "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 rmail-last-label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (setq rmail-last-label (rmail-make-label result t)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (defun rmail-set-label (l state &optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (rmail-maybe-set-message-counters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (if (not n) (setq n rmail-current-message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (aset rmail-summary-vector (1- n) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (let* ((attribute (rmail-attribute-p l))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (keyword (and (not attribute)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (or (rmail-keyword-p l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (rmail-install-keyword l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (label (or attribute keyword)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (if label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (let ((omax (- (buffer-size) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (omin (- (buffer-size) (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (case-fold-search t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (goto-char (rmail-msgbeg n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (if (not (looking-at "[01],"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (let ((start (1+ (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (bound))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (narrow-to-region (point) (progn (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (setq bound (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (search-backward ",," nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (if attribute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (setq bound (1+ (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (setq start (1+ (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ; (while (re-search-forward "[ \t]*,[ \t]*" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ; (replace-match ","))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ; (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (concat ", " (rmail-quote-label-name label) ",")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 bound
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 'move)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (if (not state) (replace-match ","))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (if state (insert " " (symbol-name label) ",")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (if (eq label rmail-deleted-label)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (rmail-set-message-deleted-p n state)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (narrow-to-region (- (buffer-size) omin) (- (buffer-size) omax))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (if (= n rmail-current-message) (rmail-display-labels)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; Commented functions aren't used by RMAIL but might be nice for user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; packages that do stuff with RMAIL. Note that rmail-message-labels-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; is in rmail.el now.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;(defun rmail-message-attribute-p (attribute &optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ; "Returns t if ATTRIBUTE on NTH or current message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ; (rmail-message-labels-p (rmail-make-label attribute t) n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;(defun rmail-message-keyword-p (keyword &optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ; "Returns t if KEYWORD on NTH or current message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ; (rmail-message-labels-p (rmail-make-label keyword t) n t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;(defun rmail-message-label-p (label &optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ; "Returns symbol if LABEL (attribute or keyword) on NTH or current message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ; (rmail-message-labels-p (rmail-make-label label t) n 'all))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; Not used by RMAIL but might be nice for user package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;(defun rmail-parse-message-labels (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ; "Returns labels associated with NTH or current RMAIL message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;Results is a list of two lists. The first is the message attributes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;and the second is the message keywords. Labels are represented as symbols."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ; (let ((omin (- (buffer-size) (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ; (omax (- (buffer-size) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ; (result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ; (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ; (let ((beg (rmail-msgbeg (or n rmail-current-message))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ; (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ; (goto-char beg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ; (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ; (if (looking-at "[01],")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ; (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ; (narrow-to-region (point) (save-excursion (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ; (rmail-nuke-whitespace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ; (goto-char (1+ (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ; (list (mail-parse-comma-list) (mail-parse-comma-list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ; (narrow-to-region (- (buffer-size) omin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ; (- (buffer-size) omax))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ; nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (defun rmail-attribute-p (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (let ((symbol (rmail-make-label s)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if (memq symbol (cdr rmail-attributes)) symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (defun rmail-keyword-p (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (let ((symbol (rmail-make-label s)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (if (memq symbol (cdr (rmail-keywords))) symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defun rmail-make-label (s &optional forcep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (cond ((symbolp s) s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (forcep (intern (downcase s) rmail-label-obarray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (t (intern-soft (downcase s) rmail-label-obarray))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defun rmail-force-make-label (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (intern (downcase s) rmail-label-obarray))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (defun rmail-quote-label-name (label)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (regexp-quote (symbol-name (rmail-make-label label t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;; Motion on messages with keywords.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (defun rmail-previous-labeled-message (n labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 "Show previous message with one of the labels LABELS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 LABELS should be a comma-separated list of label names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 If LABELS is empty, the last set of labels specified is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 With prefix argument N moves backward N messages with these labels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (interactive "p\nsMove to previous msg with labels: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (rmail-next-labeled-message (- n) labels))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defun rmail-next-labeled-message (n labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 "Show next message with one of the labels LABELS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 LABELS should be a comma-separated list of label names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 If LABELS is empty, the last set of labels specified is used.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 With prefix argument N moves forward N messages with these labels."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (interactive "p\nsMove to next msg with labels: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (if (string= labels "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (setq labels rmail-last-multi-labels))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (or labels
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (error "No labels to find have been specified previously"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (setq rmail-last-multi-labels labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (rmail-maybe-set-message-counters)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (let ((lastwin rmail-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (current rmail-current-message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (regexp (concat ", ?\\("
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (mail-comma-list-regexp labels)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 "\\),")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (while (and (> n 0) (< current rmail-total-messages))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (setq current (1+ current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (if (rmail-message-labels-p current regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (setq lastwin current n (1- n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (while (and (< n 0) (> current 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq current (1- current))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (if (rmail-message-labels-p current regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (setq lastwin current n (1+ n)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (rmail-show-message lastwin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (if (< n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (message "No previous message with labels %s" labels))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (if (> n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (message "No following message with labels %s" labels))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;;; Manipulate the file's Labels option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; Return a list of symbols for all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;; the keywords (labels) recorded in this file's Labels option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (defun rmail-keywords ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (or rmail-keywords (rmail-parse-file-keywords)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; Set rmail-keywords to a list of symbols for all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;; the keywords (labels) recorded in this file's Labels option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defun rmail-parse-file-keywords ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (setq rmail-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (if (search-forward "\nLabels:" (rmail-msgbeg 1) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (narrow-to-region (point) (progn (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (cons 'rmail-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (mapcar 'rmail-force-make-label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (mail-parse-comma-list)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;; Add WORD to the list in the file's Labels option.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 ;; Any keyword used for the first time needs this done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (defun rmail-install-keyword (word)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (let ((keyword (rmail-make-label word t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (keywords (rmail-keywords)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (if (not (or (rmail-attribute-p keyword)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (rmail-keyword-p keyword)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (let ((omin (- (buffer-size) (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (omax (- (buffer-size) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (goto-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (let ((case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (buffer-read-only nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (or (search-forward "\nLabels:" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (insert "\nLabels:")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (delete-region (point) (progn (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (setcdr keywords (cons keyword (cdr keywords)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (while (setq keywords (cdr keywords))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (insert (symbol-name (car keywords)) ","))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (delete-char -1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (narrow-to-region (- (buffer-size) omin)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (- (buffer-size) omax)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 keyword))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;;; rmailkwd.el ends here