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