Mercurial > emacs
annotate lisp/mail/rmailkwd.el @ 88127:9c783aa2b379
Attempt to eliminate some byte compiler warnings.
(rmail-add-label): Force the display of the labels.
(rmail-read-label): Remove call to rmail-parse-file-keywords which is
no longer used.
(rmail-set-label): Rewrite.
(rmail-keywords): Use (rmail-keyword-init).
(rmail-keyword-init, rmail-keyword-register-keywords): New function.
(rmail-install-keyword): Rewrite.
author | Paul Reilly <pmr@pajato.com> |
---|---|
date | Sat, 15 Feb 2003 15:12:08 +0000 |
parents | 253f761ad37b |
children | abff0bc9014b |
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 |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
27 ;; This library manages keywords (labels). Labels are stored in the |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
28 ;; variable `rmail-keywords'. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
29 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
30 ;;; Code: |
36 | 31 |
32 ;; Global to all RMAIL buffers. It exists primarily for the sake of | |
33 ;; completion. It is better to use strings with the label functions | |
34 ;; and let them worry about making the label. | |
35 | |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
36 (provide 'rmailkwd) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
37 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
38 (eval-when-compile |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
39 (require 'mail-utils) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
40 (require 'rmail)) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
41 |
36 | 42 (defvar rmail-label-obarray (make-vector 47 0)) |
43 | |
44 ;; Named list of symbols representing valid message attributes in RMAIL. | |
45 | |
46 (defconst rmail-attributes | |
47 (cons 'rmail-keywords | |
11508
f04aa4cd5182
(rmail-attributes): Recognize "resent" attribute.
Karl Heuer <kwzh@gnu.org>
parents:
7300
diff
changeset
|
48 (mapcar (function (lambda (s) (intern s rmail-label-obarray))) |
f04aa4cd5182
(rmail-attributes): Recognize "resent" attribute.
Karl Heuer <kwzh@gnu.org>
parents:
7300
diff
changeset
|
49 '("deleted" "answered" "filed" "forwarded" "unseen" "edited" |
f04aa4cd5182
(rmail-attributes): Recognize "resent" attribute.
Karl Heuer <kwzh@gnu.org>
parents:
7300
diff
changeset
|
50 "resent")))) |
36 | 51 |
52 (defconst rmail-deleted-label (intern "deleted" rmail-label-obarray)) | |
53 | |
54 ;; Named list of symbols representing valid message keywords in RMAIL. | |
55 | |
16289
38aee5b6ac73
(rmail-keywords): Don't initialize.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
56 (defvar rmail-keywords) |
36 | 57 |
16345
22d0a2f6a374
(rmail-read-label, rmail-add-label, rmail-kill-label)
Richard M. Stallman <rms@gnu.org>
parents:
16289
diff
changeset
|
58 ;;;###autoload |
36 | 59 (defun rmail-add-label (string) |
60 "Add LABEL to labels associated with current RMAIL message. | |
61 Completion is performed over known labels when reading." | |
62 (interactive (list (rmail-read-label "Add label"))) | |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
63 (rmail-set-label string t) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
64 (rmail-display-labels)) |
36 | 65 |
16345
22d0a2f6a374
(rmail-read-label, rmail-add-label, rmail-kill-label)
Richard M. Stallman <rms@gnu.org>
parents:
16289
diff
changeset
|
66 ;;;###autoload |
36 | 67 (defun rmail-kill-label (string) |
68 "Remove LABEL from labels associated with current RMAIL message. | |
69 Completion is performed over known labels when reading." | |
70 (interactive (list (rmail-read-label "Remove label"))) | |
71 (rmail-set-label string nil)) | |
72 | |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
73 ;;; mbox: not ready |
16345
22d0a2f6a374
(rmail-read-label, rmail-add-label, rmail-kill-label)
Richard M. Stallman <rms@gnu.org>
parents:
16289
diff
changeset
|
74 ;;;###autoload |
36 | 75 (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
|
76 (with-current-buffer rmail-buffer |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
77 (let ((result |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
78 (completing-read (concat prompt |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
79 (if rmail-last-label |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
80 (concat " (default " |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
81 (symbol-name rmail-last-label) |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
82 "): ") |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
83 ": ")) |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
84 rmail-label-obarray |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
85 nil |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
86 nil))) |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
87 (if (string= result "") |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
88 rmail-last-label |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
89 (setq rmail-last-label (rmail-make-label result t)))))) |
36 | 90 |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
91 ;;; mbox: not ready |
36 | 92 (defun rmail-set-label (l state &optional n) |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
93 "Add (STATE is non-nil) or remove (STATE is nil) label L in message N. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
94 If N is nil then use the current Rmail message. The current buffer, |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
95 possibly narrowed, displays a message." |
37612
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
96 (with-current-buffer rmail-buffer |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
97 (if (not n) (setq n rmail-current-message)) |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
98 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
99 ;; Make message N the curent message. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
100 (save-restriction |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
101 (widen) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
102 (narrow-to-region (rmail-desc-get-start n) (rmail-desc-get-end n)) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
103 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
104 (if (rmail-attribute-p l) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
105 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
106 ;; Handle the case where the label is one of the predefined |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
107 ;; attributes by using rmail code to set the attribute. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
108 (rmail-set-attribute l state n) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
109 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
110 ;; Handle the case where the label is a keyword. Make sure the |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
111 ;; keyword is registered. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
112 (or (rmail-keyword-p l) (rmail-install-keyword l)) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
113 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
114 ;; Determine if we are adding or removing the keyword. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
115 (let ((keyword (symbol-name l))) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
116 (if state |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
117 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
118 ;; Add the keyword to this message. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
119 (rmail-desc-add-keyword keyword n) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
120 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
121 ;; Remove the keyword from the keyword header. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
122 (rmail-desc-remove-keyword keyword n))))))) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
123 |
36 | 124 |
125 ;; Commented functions aren't used by RMAIL but might be nice for user | |
126 ;; packages that do stuff with RMAIL. Note that rmail-message-labels-p | |
195 | 127 ;; is in rmail.el now. |
36 | 128 |
129 ;(defun rmail-message-label-p (label &optional n) | |
130 ; "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
|
131 ; (rmail-message-labels-p (or n rmail-current-message) (regexp-quote label))) |
36 | 132 |
133 ;(defun rmail-parse-message-labels (&optional n) | |
134 ; "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
|
135 ;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
|
136 ;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
|
137 ; (let (atts keys) |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
138 ; (save-restriction |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
139 ; (widen) |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
140 ; (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
|
141 ; (forward-line 1) |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
142 ; (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
|
143 ; (forward-char 2) |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
144 ; (while (looking-at "[ \t]*\\([^ \t\n,]+\\),") |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
145 ; (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
|
146 ; atts)) |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
147 ; (goto-char (match-end 0))) |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
148 ; (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
|
149 ; (forward-char 1) |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
150 ; (while (looking-at "[ \t]*\\([^ \t\n,]+\\),") |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
151 ; (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
|
152 ; keys)) |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
153 ; (goto-char (match-end 0))) |
82404c81aac8
(rmail-message-label-p, rmail-parse-message-labels):
Karl Heuer <kwzh@gnu.org>
parents:
845
diff
changeset
|
154 ; (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
|
155 ; (list (nreverse atts) (nreverse keys))))) |
36 | 156 |
157 (defun rmail-attribute-p (s) | |
158 (let ((symbol (rmail-make-label s))) | |
159 (if (memq symbol (cdr rmail-attributes)) symbol))) | |
160 | |
161 (defun rmail-keyword-p (s) | |
162 (let ((symbol (rmail-make-label s))) | |
163 (if (memq symbol (cdr (rmail-keywords))) symbol))) | |
164 | |
165 (defun rmail-make-label (s &optional forcep) | |
166 (cond ((symbolp s) s) | |
167 (forcep (intern (downcase s) rmail-label-obarray)) | |
168 (t (intern-soft (downcase s) rmail-label-obarray)))) | |
169 | |
170 (defun rmail-force-make-label (s) | |
171 (intern (downcase s) rmail-label-obarray)) | |
172 | |
173 (defun rmail-quote-label-name (label) | |
174 (regexp-quote (symbol-name (rmail-make-label label t)))) | |
175 | |
176 ;; Motion on messages with keywords. | |
177 | |
16345
22d0a2f6a374
(rmail-read-label, rmail-add-label, rmail-kill-label)
Richard M. Stallman <rms@gnu.org>
parents:
16289
diff
changeset
|
178 ;;;###autoload |
195 | 179 (defun rmail-previous-labeled-message (n labels) |
180 "Show previous message with one of the labels LABELS. | |
181 LABELS should be a comma-separated list of label names. | |
182 If LABELS is empty, the last set of labels specified is used. | |
36 | 183 With prefix argument N moves backward N messages with these labels." |
184 (interactive "p\nsMove to previous msg with labels: ") | |
195 | 185 (rmail-next-labeled-message (- n) labels)) |
36 | 186 |
16345
22d0a2f6a374
(rmail-read-label, rmail-add-label, rmail-kill-label)
Richard M. Stallman <rms@gnu.org>
parents:
16289
diff
changeset
|
187 ;;;###autoload |
36 | 188 (defun rmail-next-labeled-message (n labels) |
195 | 189 "Show next message with one of the labels LABELS. |
190 LABELS should be a comma-separated list of label names. | |
191 If LABELS is empty, the last set of labels specified is used. | |
36 | 192 With prefix argument N moves forward N messages with these labels." |
193 (interactive "p\nsMove to next msg with labels: ") | |
194 (if (string= labels "") | |
195 (setq labels rmail-last-multi-labels)) | |
196 (or labels | |
197 (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
|
198 (set-buffer rmail-buffer) |
36 | 199 (setq rmail-last-multi-labels labels) |
200 (rmail-maybe-set-message-counters) | |
201 (let ((lastwin rmail-current-message) | |
202 (current rmail-current-message) | |
203 (regexp (concat ", ?\\(" | |
204 (mail-comma-list-regexp labels) | |
205 "\\),"))) | |
206 (save-restriction | |
207 (widen) | |
208 (while (and (> n 0) (< current rmail-total-messages)) | |
209 (setq current (1+ current)) | |
210 (if (rmail-message-labels-p current regexp) | |
211 (setq lastwin current n (1- n)))) | |
212 (while (and (< n 0) (> current 1)) | |
213 (setq current (1- current)) | |
214 (if (rmail-message-labels-p current regexp) | |
215 (setq lastwin current n (1+ n))))) | |
216 (rmail-show-message lastwin) | |
217 (if (< n 0) | |
218 (message "No previous message with labels %s" labels)) | |
219 (if (> n 0) | |
220 (message "No following message with labels %s" labels)))) | |
221 | |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
222 ;;;; Manipulate the file's Labels option. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
223 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
224 ;; Return a list of symbols for all the keywords (labels) recorded in |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
225 ;; this file's Labels. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
226 (defun rmail-keywords () |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
227 "Return a list of all known keywords." |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
228 (or rmail-keywords (rmail-keyword-init))) |
36 | 229 |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
230 (defun rmail-keyword-init () |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
231 "Initialize the variable `rmail-keywords' to an empty list." |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
232 (setq rmail-keywords (cons 'rmail-keywords nil))) |
36 | 233 |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
234 ;;;###autoload |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
235 (defun rmail-keyword-register-keywords (keyword-list) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
236 "Add the strings in KEYWORD-LIST to `rmail-keywords'. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
237 If a symbol already exists, then ignore that string. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
238 Return a list of the keywords added." |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
239 (delq nil (mapcar 'rmail-install-keyword keyword-list))) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
240 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
241 ;;; mbox: deprecated |
36 | 242 ;; Set rmail-keywords to a list of symbols for all |
243 ;; the keywords (labels) recorded in this file's Labels option. | |
244 (defun rmail-parse-file-keywords () | |
245 (save-restriction | |
246 (save-excursion | |
247 (widen) | |
248 (goto-char 1) | |
249 (setq rmail-keywords | |
250 (if (search-forward "\nLabels:" (rmail-msgbeg 1) t) | |
251 (progn | |
252 (narrow-to-region (point) (progn (end-of-line) (point))) | |
253 (goto-char (point-min)) | |
254 (cons 'rmail-keywords | |
255 (mapcar 'rmail-force-make-label | |
256 (mail-parse-comma-list))))))))) | |
257 | |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
258 ;;; mbox: ready |
36 | 259 ;; Add WORD to the list in the file's Labels option. |
260 ;; Any keyword used for the first time needs this done. | |
261 (defun rmail-install-keyword (word) | |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
262 "Append WORD to the global list of keywords. Ignore duplicates. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
263 Return WORD if it is a new entry, nil otherwise." |
36 | 264 (let ((keyword (rmail-make-label word t)) |
265 (keywords (rmail-keywords))) | |
266 (if (not (or (rmail-attribute-p keyword) | |
267 (rmail-keyword-p keyword))) | |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
268 (progn |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
269 (setcdr keywords (cons keyword (cdr keywords))) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
270 keyword)))) |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
195
diff
changeset
|
271 |
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
195
diff
changeset
|
272 ;;; rmailkwd.el ends here |