Mercurial > emacs
annotate lisp/mail/rmailkwd.el @ 88302:6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
rmail-maybe-set-message-counters. Use with-current-buffer.
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 30 Jan 2006 11:31:06 +0000 |
parents | b589e7b4f4c4 |
children | afd76e7b9651 |
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 |
88155 | 3 ;; Copyright (C) 1985, 1988, 1994, 2001, 2002, 2003, 2004, |
88216
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
4 ;; 2005, 2006 Free Software Foundation, Inc. |
845 | 5 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
6 ;; Maintainer: FSF |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: mail |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
8 |
36 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; 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
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
36 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
88155 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
36 | 25 |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
37612
diff
changeset
|
26 ;;; Commentary: |
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
37612
diff
changeset
|
27 |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
28 ;; 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
|
29 ;; variable `rmail-keywords'. |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
30 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
658
diff
changeset
|
31 ;;; Code: |
36 | 32 |
88155 | 33 (defvar rmail-buffer) |
34 (defvar rmail-current-message) | |
35 (defvar rmail-last-label) | |
36 (defvar rmail-last-multi-labels) | |
37 (defvar rmail-summary-vector) | |
38 (defvar rmail-total-messages) | |
39 | |
36 | 40 ;; Global to all RMAIL buffers. It exists primarily for the sake of |
41 ;; completion. It is better to use strings with the label functions | |
42 ;; and let them worry about making the label. | |
43 | |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
44 (provide 'rmailkwd) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
45 |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
46 (eval-when-compile |
88193
ee955ad919b1
Don't require rmail.
Henrik Enberg <henrik.enberg@telia.com>
parents:
88185
diff
changeset
|
47 (require 'mail-utils)) |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
48 |
36 | 49 (defvar rmail-label-obarray (make-vector 47 0)) |
50 | |
51 ;; Named list of symbols representing valid message attributes in RMAIL. | |
52 | |
53 (defconst rmail-attributes | |
54 (cons 'rmail-keywords | |
11508
f04aa4cd5182
(rmail-attributes): Recognize "resent" attribute.
Karl Heuer <kwzh@gnu.org>
parents:
7300
diff
changeset
|
55 (mapcar (function (lambda (s) (intern s rmail-label-obarray))) |
f04aa4cd5182
(rmail-attributes): Recognize "resent" attribute.
Karl Heuer <kwzh@gnu.org>
parents:
7300
diff
changeset
|
56 '("deleted" "answered" "filed" "forwarded" "unseen" "edited" |
f04aa4cd5182
(rmail-attributes): Recognize "resent" attribute.
Karl Heuer <kwzh@gnu.org>
parents:
7300
diff
changeset
|
57 "resent")))) |
36 | 58 |
59 (defconst rmail-deleted-label (intern "deleted" rmail-label-obarray)) | |
60 | |
61 ;; Named list of symbols representing valid message keywords in RMAIL. | |
62 | |
16289
38aee5b6ac73
(rmail-keywords): Don't initialize.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
63 (defvar rmail-keywords) |
36 | 64 |
88141
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
65 ;;;; Low-level functions. |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
66 |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
67 ;; Return a list of symbols for all the keywords (labels) recorded in |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
68 ;; this file's Labels. |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
69 (defun rmail-keywords () |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
70 "Return a list of all known keywords." |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
71 (or rmail-keywords (rmail-keyword-init))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
72 |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
73 (defun rmail-keyword-init () |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
74 "Initialize the variable `rmail-keywords' to hold no keywords. |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
75 The value is actually (nil), since (cdr rmail-keywords) is the |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
76 actual list of keywords." |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
77 (setq rmail-keywords (cons 'rmail-keywords nil))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
78 |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
79 (defun rmail-attribute-p (s) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
80 (let ((symbol (rmail-make-label s))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
81 (if (memq symbol (cdr rmail-attributes)) symbol))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
82 |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
83 (defun rmail-keyword-p (s) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
84 "Non-nil if S is a known keyword for this Rmail file." |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
85 (let ((symbol (rmail-make-label s))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
86 (if (memq symbol (cdr (rmail-keywords))) symbol))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
87 |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
88 (defun rmail-make-label (s &optional forcep) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
89 (cond ((symbolp s) s) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
90 (forcep (intern (downcase s) rmail-label-obarray)) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
91 (t (intern-soft (downcase s) rmail-label-obarray)))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
92 |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
93 ;;; (defun rmail-force-make-label (s) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
94 ;;; (intern (downcase s) rmail-label-obarray)) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
95 |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
96 (defun rmail-quote-label-name (label) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
97 (regexp-quote (symbol-name (rmail-make-label label t)))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
98 |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
99 ;;;###autoload |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
100 (defun rmail-keyword-register-keywords (keyword-list) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
101 "Add the strings in KEYWORD-LIST to `rmail-keywords'. |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
102 Return a list of the keywords newly added (those that were |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
103 not already known)." |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
104 (delq nil (mapcar 'rmail-install-keyword keyword-list))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
105 |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
106 ;;; mbox: ready |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
107 ;; Add WORD to the list in the file's Labels option. |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
108 ;; Any keyword used for the first time needs this done. |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
109 (defun rmail-install-keyword (word) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
110 "Append WORD to the global list of keywords. Ignore duplicates. |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
111 Return WORD if it is a new entry, nil otherwise." |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
112 (let ((keyword (rmail-make-label word t)) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
113 (keywords (rmail-keywords))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
114 (if (not (or (rmail-attribute-p keyword) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
115 (rmail-keyword-p keyword))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
116 (progn |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
117 (setcdr keywords (cons keyword (cdr keywords))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
118 keyword)))) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
119 |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
120 ;;;; Adding and removing message keywords. |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
121 |
16345
22d0a2f6a374
(rmail-read-label, rmail-add-label, rmail-kill-label)
Richard M. Stallman <rms@gnu.org>
parents:
16289
diff
changeset
|
122 ;;;###autoload |
36 | 123 (defun rmail-add-label (string) |
88216
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
124 "Add LABEL to labels associated with current RMAIL message." |
36 | 125 (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
|
126 (rmail-set-label string t) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
127 (rmail-display-labels)) |
36 | 128 |
16345
22d0a2f6a374
(rmail-read-label, rmail-add-label, rmail-kill-label)
Richard M. Stallman <rms@gnu.org>
parents:
16289
diff
changeset
|
129 ;;;###autoload |
36 | 130 (defun rmail-kill-label (string) |
88216
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
131 "Remove LABEL from labels associated with current RMAIL message." |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
132 (interactive (list (rmail-read-label "Remove label" t))) |
36 | 133 (rmail-set-label string nil)) |
134 | |
16345
22d0a2f6a374
(rmail-read-label, rmail-add-label, rmail-kill-label)
Richard M. Stallman <rms@gnu.org>
parents:
16289
diff
changeset
|
135 ;;;###autoload |
88216
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
136 (defun rmail-read-label (prompt &optional existing) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
137 "Ask for a label using PROMPT. |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
138 If EXISTING is non-nil, ask for one of the labels of the current |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
139 message." |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
140 (when (= rmail-total-messages 0) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
141 (error "No messages in this file")) |
37612
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
142 (with-current-buffer rmail-buffer |
88216
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
143 (let ((result (if existing |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
144 (let* ((keywords (rmail-desc-get-keywords |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
145 rmail-current-message)) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
146 (last (symbol-name rmail-last-label)) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
147 (default (if (member last keywords) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
148 last |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
149 (car keywords)))) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
150 (unless keywords |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
151 (error "No labels for the current message")) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
152 (completing-read |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
153 (concat prompt " (default " default "): ") |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
154 keywords nil t nil nil default)) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
155 (let ((default (symbol-name rmail-last-label))) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
156 (completing-read |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
157 (concat prompt (if rmail-last-label |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
158 (concat " (default " default "): ") |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
159 ": ")) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
160 rmail-label-obarray nil nil nil nil default))))) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
161 (setq rmail-last-label (rmail-make-label result t))))) |
36 | 162 |
163 (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
|
164 "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
|
165 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
|
166 possibly narrowed, displays a message." |
88141
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
167 (if (= rmail-total-messages 0) |
71b644d983a9
(rmail-read-label, rmail-set-label): Immediate error if file is empty.
Richard M. Stallman <rms@gnu.org>
parents:
88134
diff
changeset
|
168 (error "No messages in this file")) |
37612
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
169 (with-current-buffer rmail-buffer |
15fa3a1c6e88
(rmail-read-label): Be sure to work in the
Gerd Moellmann <gerd@gnu.org>
parents:
16345
diff
changeset
|
170 (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
|
171 (save-restriction |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
172 (widen) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
173 (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
|
174 (if (rmail-attribute-p l) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
175 (rmail-set-attribute l state n) |
88185
b6b65e7ea49f
Removed some spurious comments.
Alex Schroeder <alex@gnu.org>
parents:
88155
diff
changeset
|
176 ;; Make sure the keyword is registered. |
88127
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
177 (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
|
178 (let ((keyword (symbol-name l))) |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
179 (if state |
9c783aa2b379
Attempt to eliminate some byte compiler warnings.
Paul Reilly <pmr@pajato.com>
parents:
38412
diff
changeset
|
180 (rmail-desc-add-keyword keyword n) |
88216
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
181 (rmail-desc-remove-keyword keyword n))) |
a965d43e06ea
(rmail-add-label): Doc fix.
Alex Schroeder <alex@gnu.org>
parents:
88193
diff
changeset
|
182 ;; FIXME: handle redisplay in the summary buffer |
88227
b589e7b4f4c4
(rmail-set-label): Call rmail-summary-update at the
Alex Schroeder <alex@gnu.org>
parents:
88216
diff
changeset
|
183 (rmail-display-labels)))) |
b589e7b4f4c4
(rmail-set-label): Call rmail-summary-update at the
Alex Schroeder <alex@gnu.org>
parents:
88216
diff
changeset
|
184 ;; Deal with the summary buffer. |
b589e7b4f4c4
(rmail-set-label): Call rmail-summary-update at the
Alex Schroeder <alex@gnu.org>
parents:
88216
diff
changeset
|
185 (when rmail-summary-buffer |
b589e7b4f4c4
(rmail-set-label): Call rmail-summary-update at the
Alex Schroeder <alex@gnu.org>
parents:
88216
diff
changeset
|
186 (rmail-summary-update n))) |
36 | 187 |
188 ;; Motion on messages with keywords. | |
189 | |
16345
22d0a2f6a374
(rmail-read-label, rmail-add-label, rmail-kill-label)
Richard M. Stallman <rms@gnu.org>
parents:
16289
diff
changeset
|
190 ;;;###autoload |
195 | 191 (defun rmail-previous-labeled-message (n labels) |
192 "Show previous message with one of the labels LABELS. | |
193 LABELS should be a comma-separated list of label names. | |
194 If LABELS is empty, the last set of labels specified is used. | |
36 | 195 With prefix argument N moves backward N messages with these labels." |
196 (interactive "p\nsMove to previous msg with labels: ") | |
195 | 197 (rmail-next-labeled-message (- n) labels)) |
36 | 198 |
16345
22d0a2f6a374
(rmail-read-label, rmail-add-label, rmail-kill-label)
Richard M. Stallman <rms@gnu.org>
parents:
16289
diff
changeset
|
199 ;;;###autoload |
36 | 200 (defun rmail-next-labeled-message (n labels) |
195 | 201 "Show next message with one of the labels LABELS. |
202 LABELS should be a comma-separated list of label names. | |
203 If LABELS is empty, the last set of labels specified is used. | |
36 | 204 With prefix argument N moves forward N messages with these labels." |
205 (interactive "p\nsMove to next msg with labels: ") | |
88302
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
206 (when (string= labels "") |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
207 (setq labels rmail-last-multi-labels)) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
208 (unless labels |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
209 (error "No labels to find have been specified previously")) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
210 (with-current-buffer rmail-buffer |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
211 (setq rmail-last-multi-labels labels) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
212 (let ((lastwin rmail-current-message) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
213 (current rmail-current-message) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
214 (regexp (concat ", ?\\(" |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
215 (mail-comma-list-regexp labels) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
216 "\\),"))) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
217 (save-restriction |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
218 (widen) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
219 (while (and (> n 0) (< current rmail-total-messages)) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
220 (setq current (1+ current)) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
221 (when (rmail-message-labels-p current regexp) |
36 | 222 (setq lastwin current n (1- n)))) |
88302
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
223 (while (and (< n 0) (> current 1)) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
224 (setq current (1- current)) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
225 (when (rmail-message-labels-p current regexp) |
36 | 226 (setq lastwin current n (1+ n))))) |
88302
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
227 (rmail-show-message lastwin) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
228 (when (< n 0) |
36 | 229 (message "No previous message with labels %s" labels)) |
88302
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
230 (when (> n 0) |
6ea0b1ca44b7
(rmail-next-labeled-message): Don't call
Henrik Enberg <henrik.enberg@telia.com>
parents:
88227
diff
changeset
|
231 (message "No following message with labels %s" labels))))) |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
195
diff
changeset
|
232 |
88155 | 233 ;;; arch-tag: b26b3392-99ca-4e1d-933a-dab59b04e9a8 |
658
7cbd4fcd8b0f
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
195
diff
changeset
|
234 ;;; rmailkwd.el ends here |