annotate lisp/mail/rmailkwd.el @ 101794:182f3f4f03c3

*** empty log message ***
author Jason Rumney <jasonr@gnu.org>
date Wed, 04 Feb 2009 09:13:18 +0000
parents 119f13a715df
children e6f035f6e27e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
1 ;;; rmailkwd.el --- part of the "RMAIL" mail reader for Emacs
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
2
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
3 ;; Copyright (C) 1985, 1988, 1994, 2001, 2002, 2003, 2004, 2005, 2006,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
4 ;; 2007, 2008, 2009 Free Software Foundation, Inc.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
5
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
6 ;; Maintainer: FSF
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
7 ;; Keywords: mail
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
8
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
10
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
14 ;; (at your option) any later version.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
15
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
20
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
23
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
24 ;;; Commentary:
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
25
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
26 ;;; Code:
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
27
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
28 (require 'rmail)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
29
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
30 ;; Global to all RMAIL buffers. It exists for the sake of completion.
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
31 ;; It is better to use strings with the label functions and let them
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
32 ;; worry about making the label.
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
33 (defvar rmail-label-obarray (make-vector 47 0)
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
34 "Obarray of labels used by Rmail.
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
35 `rmail-read-label' uses this to offer completion.")
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
36
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
37 ;; Initialize with the standard labels.
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
38 (mapc (lambda (s) (intern (cadr s) rmail-label-obarray))
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
39 rmail-attr-array)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
40
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
41 (defun rmail-make-label (s)
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
42 "Convert string S to a downcased symbol in `rmail-label-obarray'."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
43 (intern (downcase s) rmail-label-obarray))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
44
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
45 ;;;###autoload
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
46 (defun rmail-add-label (label)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
47 "Add LABEL to labels associated with current RMAIL message.
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
48 Completes (see `rmail-read-label') over known labels when reading.
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
49 LABEL may be a symbol or string."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
50 (interactive (list (rmail-read-label "Add label")))
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
51 (rmail-set-label label t))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
52
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
53 ;;;###autoload
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
54 (defun rmail-kill-label (label)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
55 "Remove LABEL from labels associated with current RMAIL message.
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
56 Completes (see `rmail-read-label') over known labels when reading.
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
57 LABEL may be a symbol or string."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
58 (interactive (list (rmail-read-label "Remove label")))
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
59 (rmail-set-label label nil))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
60
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
61 ;;;###autoload
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
62 (defun rmail-read-label (prompt)
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
63 "Read a label with completion, prompting with PROMPT.
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
64 Completions are chosen from `rmail-label-obarray'. The default
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
65 is `rmail-last-label', if that is non-nil. Updates `rmail-last-label'
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
66 according to the choice made, and returns a symbol."
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
67 (let ((result
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
68 (completing-read (concat prompt
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
69 (if rmail-last-label
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
70 (concat " (default "
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
71 (symbol-name rmail-last-label)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
72 "): ")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
73 ": "))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
74 rmail-label-obarray
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
75 nil
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
76 nil)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
77 (if (string= result "")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
78 rmail-last-label
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
79 (setq rmail-last-label (rmail-make-label result)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
80
101631
13338e3ca8a7 (rmail-set-label): Update the summary, if there is one, after a label
Glenn Morris <rgm@gnu.org>
parents: 101414
diff changeset
81 (declare-function rmail-summary-update-line "rmailsum" (n))
13338e3ca8a7 (rmail-set-label): Update the summary, if there is one, after a label
Glenn Morris <rgm@gnu.org>
parents: 101414
diff changeset
82
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
83 (defun rmail-set-label (label state &optional msg)
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
84 "Set LABEL as present or absent according to STATE in message MSG.
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
85 LABEL may be a symbol or string."
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
86 (or (stringp label) (setq label (symbol-name label)))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
87 (with-current-buffer rmail-buffer
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
88 (rmail-maybe-set-message-counters)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
89 (if (not msg) (setq msg rmail-current-message))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
90 ;; Force recalculation of summary for this message.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
91 (aset rmail-summary-vector (1- msg) nil)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
92 (let (attr-index)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
93 ;; Is this label an attribute?
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
94 (dotimes (i (length rmail-attr-array))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
95 (if (string= (cadr (aref rmail-attr-array i)) label)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
96 (setq attr-index i)))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
97 (if attr-index
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
98 ;; If so, set it as an attribute.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
99 (rmail-set-attribute attr-index state msg)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
100 ;; Is this keyword already present in msg's keyword list?
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
101 (let* ((header (rmail-get-header rmail-keyword-header msg))
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
102 (regexp (concat ", " (regexp-quote label) ","))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
103 (present (string-match regexp (concat ", " header ","))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
104 ;; If current state is not correct,
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
105 (unless (eq present state)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
106 ;; either add it or delete it.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
107 (rmail-set-header
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
108 rmail-keyword-header msg
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
109 (if state
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
110 ;; Add this keyword at the end.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
111 (if (and header (not (string= header "")))
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
112 (concat header ", " label)
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
113 label)
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
114 ;; Delete this keyword.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
115 (let ((before (substring header 0
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
116 (max 0 (- (match-beginning 0) 2))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
117 (after (substring header
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
118 (min (length header)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
119 (- (match-end 0) 1)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
120 (cond ((string= before "")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
121 after)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
122 ((string= after "")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
123 before)
101765
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
124 (t (concat before ", " after))))))))))
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
125 (if (rmail-summary-exists)
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
126 (rmail-select-summary
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
127 (rmail-summary-update-line msg)))
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
128 (if (= msg rmail-current-message)
119f13a715df (rmail-label-obarray): Initialize using rmail-attr-array.
Glenn Morris <rgm@gnu.org>
parents: 101631
diff changeset
129 (rmail-display-labels))))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
130
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
131 ;; Motion on messages with keywords.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
132
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
133 ;;;###autoload
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
134 (defun rmail-previous-labeled-message (n labels)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
135 "Show previous message with one of the labels LABELS.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
136 LABELS should be a comma-separated list of label names.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
137 If LABELS is empty, the last set of labels specified is used.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
138 With prefix argument N moves backward N messages with these labels."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
139 (interactive "p\nsMove to previous msg with labels: ")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
140 (rmail-next-labeled-message (- n) labels))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
141
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
142 (declare-function mail-comma-list-regexp "mail-utils" (labels))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
143
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
144 ;;;###autoload
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
145 (defun rmail-next-labeled-message (n labels)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
146 "Show next message with one of the labels LABELS.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
147 LABELS should be a comma-separated list of label names.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
148 If LABELS is empty, the last set of labels specified is used.
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
149 With prefix argument N moves forward N messages with these labels."
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
150 (interactive "p\nsMove to next msg with labels: ")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
151 (if (string= labels "")
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
152 (setq labels rmail-last-multi-labels))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
153 (or labels
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
154 (error "No labels to find have been specified previously"))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
155 (set-buffer rmail-buffer)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
156 (setq rmail-last-multi-labels labels)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
157 (rmail-maybe-set-message-counters)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
158 (let ((lastwin rmail-current-message)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
159 (current rmail-current-message)
101413
7030664ae12c Fix last change.
Chong Yidong <cyd@stupidchicken.com>
parents: 101412
diff changeset
160 (regexp (concat " \\("
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
161 (mail-comma-list-regexp labels)
101414
2614891fe7fd Fix last fix.
Chong Yidong <cyd@stupidchicken.com>
parents: 101413
diff changeset
162 "\\)\\(,\\|\\'\\)")))
101360
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
163 (while (and (> n 0) (< current rmail-total-messages))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
164 (setq current (1+ current))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
165 (if (string-match regexp (rmail-get-labels current))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
166 (setq lastwin current n (1- n))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
167 (while (and (< n 0) (> current 1))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
168 (setq current (1- current))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
169 (if (string-match regexp (rmail-get-labels current))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
170 (setq lastwin current n (1+ n))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
171 (if (< n 0)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
172 (error "No previous message with labels %s" labels)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
173 (if (> n 0)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
174 (error "No following message with labels %s" labels)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
175 (rmail-show-message lastwin)))))
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
176
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
177 (provide 'rmailkwd)
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
178
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
179 ;; arch-tag: 1149979c-8e47-4333-9629-cf3dc887a6a7
b10df8502c4a Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff changeset
180 ;;; rmailkwd.el ends here