annotate lisp/gnus/nnmairix.el @ 103923:36e758da137c

Remove non-existent (?) bindings: w, C-u o, U, delete. Fix bindings: delete marked files = D, not X; flag garbage = % &, not &.
author Glenn Morris <rgm@gnu.org>
date Thu, 16 Jul 2009 03:13:21 +0000
parents 827a8db0b5ad
children 1d1d5d9bd884
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; nnmairix.el --- Mairix back end for Gnus, the Emacs newsreader
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2
100908
a9dc0e7c3f2b Add 2009 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 98102
diff changeset
3 ;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
4
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
5 ;; Author: David Engster <dengste@eml.cc>
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; Keywords: mail searching
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
7 ;; Version: 0.6
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
8
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
9 ;; This file is part of GNU Emacs.
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
10
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92359
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92359
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92359
diff changeset
14 ;; (at your option) any later version.
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
15
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
20
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92359
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
23
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
24 ;;; Commentary:
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
25
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
26 ;; This is a back end for using the mairix search engine with
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
27 ;; Gnus. Mairix is a tool for searching words in locally stored
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
28 ;; mail. Mairix is very fast which allows using it efficiently for
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
29 ;; "smart folders", e.g. folders which are associated with search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
30 ;; queries. Of course, you can also use this back end just for
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
31 ;; calling mairix with some search query.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
32 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
33 ;; Mairix is written by Richard Curnow. More information can be found at
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
34 ;; http://www.rpcurnow.force9.co.uk/mairix/
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
35
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
36 ;; Commentary on the code: nnmairix sits between Gnus and the "real"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
37 ;; back end which handles the mail (currently nnml, nnimap and
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
38 ;; nnmaildir were tested). I know this is all a bit hacky, but so far
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
39 ;; it works for me. This is the first back end I've written for Gnus,
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
40 ;; so I'd appreciate any comments, suggestions, bug reports (and, of
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
41 ;; course, patches) for improving nnmairix.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
42
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
43 ;; nnmairix does not use an active file, since I wanted to contain the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
44 ;; back end "inside Gnus" as much as possible without the need of an
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
45 ;; external file. It stores the query/folder information in the group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
46 ;; parameters instead. This also implies that once you kill a mairix
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
47 ;; group, it's gone for good. I don't think that this is really
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
48 ;; problematic, since I don't see the need in unsubscribing and
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
49 ;; re-subscribing search groups
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
50
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
51 ;; Every mairix server is "responsible" for one mairix installation,
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
52 ;; i.e. you can have several mairix servers for different mairix
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
53 ;; configurations. Not that I think anyone will actually do this, but
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
54 ;; I thought it would be a "nice to have feature"...
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
55
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
56 ;; KNOWN BUGS:
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
57 ;; * Mairix does only support us-ascii characters.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
58
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
59 ;; TODO/MISSING FEATURES:
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
60 ;; * Support of more back ends (nnmh, nnfolder, nnmbox...)?
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
61 ;; * Maybe use an active file instead of group parameters?
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
62 ;; * Maybe use "-a" when updating groups which are not newly created?
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
63
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
64 ;;; Changelog:
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
65 ;; 05/30/2008 - version 0.6
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
66 ;;
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
67 ;; * It is now possible to propagate marks from the nnmairix groups
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
68 ;; to the original messages (and for maildir also vice versa). See
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
69 ;; the docs for details on this feature - it's pretty delicate
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
70 ;; and currently needs a patched mairix binary to work smoothly.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
71 ;;
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
72 ;; * Keep messages in nnmairix groups always read/unread
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
73 ;; (bound to 'G b r').
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
74 ;;
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
75 ;; * Recreate back end folder for nnmairix groups in case you
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
76 ;; somehow get wrong article counts (bound to 'G b d').
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
77 ;;
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
78 ;; * New group parameter 'allow-fast'. Toggling of parameter bound
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
79 ;; to 'G b a'. The default is nil, meaning that the group will
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
80 ;; always be updated with a mairix search, even when only entered.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
81 ;;
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
82 ;; * More/Better use of the registry (if available). Can now also
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
83 ;; deal with duplicate messages in different groups.
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
84 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
85 ;; 02/06/2008 - version 0.5
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
86 ;;
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
87 ;; * New function: nnmairix-goto-original-article. Uses the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
88 ;; registry or the mail file path for determining original group.
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
89 ;;
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
90 ;; * Deal with empty Xref header
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
91 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
92 ;; * Changed summary mode keybindings since the old ones were
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
93 ;; already taken
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
94 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
95 ;; (Thanks to Tassilo Horn and Ted Zlatanov for their help)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
96 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
97 ;; 01/07/2008 - version 0.4
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
98 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
99 ;; * New/fixed doc strings and code cleanup.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
100 ;;
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
101 ;; 11/18/2007 - version 0.3
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
102 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
103 ;; * Fixed bugs when dealing with nnml and native servers
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
104 ;;
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
105 ;; * Make variables customizable
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
106 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
107 ;; 10/10/2007 - version 0.2
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
108 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
109 ;; * Use nnml-directory/directory server variables for nnml and
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
110 ;; nnmaildir back ends as path for search folders. This way it
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
111 ;; becomes independent of 'base' setting in .mairixirc (but not for
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
112 ;; nnimap).
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
113 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
114 ;; * As a result: Changed nnmairix-backend-to-server so that user
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
115 ;; is asked when more than one nnmairix server exists and we do not
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
116 ;; know which one is responsible for current back end.
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
117 ;;
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
118 ;; * Rename files when using nnml back ends so that there are no
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
119 ;; holes in article numbers. This should fix all problems regarding
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
120 ;; wrong article counts with nnml.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
121 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
122 ;; * More commands for creating queries (using widgets or the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
123 ;; minibuffer).
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
124 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
125 ;; * Fixed bug in nnmairix-create-search-group-from-message
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
126 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
127 ;; * Changed copyright to FSF
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
128 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
129 ;; (Thanks to Georg C. F. Greve and Bastien for suggestions and
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
130 ;; ideas!)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
132 ;; 10/03/2007 - version 0.1 - first release
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
133
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
134
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
135 ;;; Code:
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
136
96273
a9507acee802 Require CL.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 96024
diff changeset
137 (eval-when-compile (require 'cl)) ;For (pop (cdr ogroup)).
a9507acee802 Require CL.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 96024
diff changeset
138
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 (require 'nnoo)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
140 (require 'gnus-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 (require 'gnus-sum)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
142 (require 'message)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
143 (require 'nnml)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 (require 'widget)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
145
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
146 (nnoo-declare nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
147
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
148 ;;; === Keymaps
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
149
95451
15ffd5c2dc17 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
150 (eval-when-compile
15ffd5c2dc17 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
151 (when (featurep 'xemacs)
15ffd5c2dc17 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
152 ;; The `kbd' macro requires that the `read-kbd-macro' macro is available.
15ffd5c2dc17 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
153 (require 'edmacro)))
15ffd5c2dc17 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 94662
diff changeset
154
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
155 ;; Group mode
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
156 (defun nnmairix-group-mode-hook ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
157 "Nnmairix group mode keymap."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
158 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
159 (kbd "G b") (make-sparse-keymap))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
160 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
161 (kbd "G b g") 'nnmairix-create-search-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
162 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
163 (kbd "G b c") 'nnmairix-create-server-and-default-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
164 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
165 (kbd "G b q") 'nnmairix-group-change-query-this-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
166 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
167 (kbd "G b t") 'nnmairix-group-toggle-threads-this-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
168 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
169 (kbd "G b u") 'nnmairix-update-database)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
170 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
171 (kbd "G b s") 'nnmairix-search)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
172 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
173 (kbd "G b i") 'nnmairix-search-interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
174 (define-key gnus-group-mode-map
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
175 (kbd "G b m") 'nnmairix-widget-search)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
176 (define-key gnus-group-mode-map
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
177 (kbd "G b p") 'nnmairix-group-toggle-propmarks-this-group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
178 (define-key gnus-group-mode-map
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
179 (kbd "G b r") 'nnmairix-group-toggle-readmarks-this-group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
180 (define-key gnus-group-mode-map
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
181 (kbd "G b d") 'nnmairix-group-delete-recreate-this-group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
182 (define-key gnus-group-mode-map
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
183 (kbd "G b a") 'nnmairix-group-toggle-allowfast-this-group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
184 (define-key gnus-group-mode-map
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
185 (kbd "G b o") 'nnmairix-propagate-marks))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
186
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
187 ;; Summary mode
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
188 (defun nnmairix-summary-mode-hook ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
189 "Nnmairix summary mode keymap."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
190 (define-key gnus-summary-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
191 (kbd "$ t") 'nnmairix-search-thread-this-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
192 (define-key gnus-summary-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
193 (kbd "$ f") 'nnmairix-search-from-this-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
194 (define-key gnus-summary-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
195 (kbd "$ m") 'nnmairix-widget-search-from-this-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
196 (define-key gnus-summary-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
197 (kbd "$ g") 'nnmairix-create-search-group-from-message)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
198 (define-key gnus-summary-mode-map
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
199 (kbd "$ o") 'nnmairix-goto-original-article)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
200 (define-key gnus-summary-mode-map
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
201 (kbd "$ u") 'nnmairix-remove-tick-mark-original-article))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
202
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
203 (add-hook 'gnus-group-mode-hook 'nnmairix-group-mode-hook)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
204 (add-hook 'gnus-summary-mode-hook 'nnmairix-summary-mode-hook)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
205
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
206 ;; ;;;###autoload
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
207 ;; (defun nnmairix-initalize (&optional force)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
208 ;; (interactive "P")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
209 ;; (if (not (or (file-readable-p "~/.mairixrc")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
210 ;; force))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
211 ;; (message "No file `~/.mairixrc', skipping nnmairix setup")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
212 ;; (add-hook 'gnus-group-mode-hook 'nnmairix-group-mode-hook)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
213 ;; (add-hook 'gnus-summary-mode-hook 'nnmairix-summary-mode-hook)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
214
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
215 ;; Customizable stuff
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
216
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
217 (defgroup nnmairix nil
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
218 "Back end for the Mairix mail search engine."
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
219 :group 'gnus)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
220
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
221 (defcustom nnmairix-group-prefix "zz_mairix"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
222 "Prefix for mairix search groups on back end server.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
223 nnmairix will create these groups automatically on the back end
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
224 server for each nnmairix search group. The name on the back end
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
225 server will be this prefix plus a random number. You can delete
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
226 unused nnmairix groups on the back end using
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
227 `nnmairix-purge-old-groups'."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
228 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
229 :type 'string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
230 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
231
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
232 (defcustom nnmairix-mairix-output-buffer "*mairix output*"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
233 "Buffer used for mairix output."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
234 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
235 :type 'string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
236 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
237
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
238 (defcustom nnmairix-customize-query-buffer "*mairix query*"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
239 "Name of the buffer for customizing Mairix queries."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
240 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
241 :type 'string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
242 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
243
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
244 (defcustom nnmairix-mairix-update-options '("-F" "-Q")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
245 "Options when calling mairix for updating the database.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
246 The default is '-F' and '-Q' for making updates faster. You
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
247 should call mairix without these options from time to
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
248 time (e.g. via cron job)."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
249 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
250 :type '(repeat string)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
251 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
252
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
253 (defcustom nnmairix-mairix-search-options '("-Q")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
254 "Options when calling mairix for searching.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
255 The default is '-Q' for making searching faster."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
256 :version "23.1"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
257 :type '(repeat string)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
258 :group 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
259
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
260 (defcustom nnmairix-mairix-synchronous-update nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
261 "Set this to t if you want Emacs to wait for mairix updating the database."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
262 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
263 :type 'boolean
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
264 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
265
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
266 (defcustom nnmairix-rename-files-for-nnml t
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
267 "Rename nnml mail files so that they are consecutively numbered.
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
268 When using nnml as back end, mairix might produce holes in the
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
269 article numbers which will produce wrong article counts by
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
270 Gnus. This option controls whether nnmairix should rename the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
271 files consecutively."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
272 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
273 :type 'boolean
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
274 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
275
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
276 (defcustom nnmairix-widget-fields-list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
277 '(("from" "f" "From") ("to" "t" "To") ("cc" "c" "Cc")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
278 ("subject" "s" "Subject") ("to" "tc" "To or Cc")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
279 ("from" "a" "Address") (nil "b" "Body") (nil "n" "Attachment")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
280 ("Message-ID" "m" "Message ID") (nil "s" "Size") (nil "d" "Date"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
281 "Fields that should be editable during interactive query customization.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
282
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
283 Header, corresponding mairix command and description for editable
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
284 fields in interactive query customization. The header specifies
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
285 which header contents should be inserted into the editable field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
286 when creating a Mairix query based on the current message (can be
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
287 nil for disabling this)."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
288 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
289 :type '(repeat (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
290 (choice :tag "Field"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
291 (const :tag "none" nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
292 (const :tag "From" "from")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
293 (const :tag "To" "to")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
294 (const :tag "Cc" "cc")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
295 (const :tag "Subject" "subject")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
296 (const :tag "Message ID" "Message-ID"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
297 (string :tag "Command")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
298 (string :tag "Description")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
299 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
300
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
301 (defcustom nnmairix-widget-select-window-function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
302 (lambda () (select-window (get-largest-window)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
303 "Function for selecting the window for customizing the mairix query.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
304 The default chooses the largest window in the current frame."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
305 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
306 :type 'function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
307 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
308
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
309 (defcustom nnmairix-propagate-marks-upon-close t
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
310 "Flag if marks should be propagated upon closing a group.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
311 The default of this variable is t. If set to 'ask, the
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
312 user will be asked if the flags should be propagated when the
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
313 group is closed. If set to nil, the user will have to manually
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
314 call 'nnmairix-propagate-marks'."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
315 :version "23.1"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
316 :type '(choice (const :tag "always" t)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
317 (const :tag "ask" 'ask)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
318 (const :tag "never" nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
319 :group 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
320
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
321 (defcustom nnmairix-propagate-marks-to-nnmairix-groups nil
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
322 "Flag if marks from original articles should be seen in nnmairix groups.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
323 The default is nil since it will only work if the articles are in
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
324 maildir format and NOT managed by the nnmaildir back end but
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
325 e.g. an IMAP server (which stores the marks in the maildir file
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
326 name). You may safely set this to t for testing - the worst that
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
327 can happen are wrong marks in nnmairix groups."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
328 :version "23.1"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
329 :type 'boolean
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
330 :group 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
331
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
332 (defcustom nnmairix-only-use-registry nil
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
333 "Use only the registry for determining original group(s).
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
334 If set to t, nnmairix will only use the registry for determining
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
335 the original group(s) of an article (which is also necessary for
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
336 propapagting marks). If set to nil, it will also try to determine
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
337 the group from an additional mairix search which might be slow
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
338 when propagating lots of marks."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
339 :version "23.1"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
340 :type 'boolean
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
341 :group 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
342
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
343 (defcustom nnmairix-allowfast-default nil
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
344 "Whether fast entering should be the default for nnmairix groups.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
345 You may set this to t to make entering the group faster, but note that
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
346 this might lead to problems, especially when used with marks propagation."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
347 :version "23.1"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
348 :type 'boolean
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
349 :group 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
350
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
351 ;; ==== Other variables
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
352
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
353 (defvar nnmairix-widget-other
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
354 '(threads flags)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
355 "Other editable mairix commands when using customization widgets.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
356 Currently there are 'threads and 'flags.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
357
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
358 (defvar nnmairix-interactive-query-parameters
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
359 '((?f "from" "f" "From") (?t "to" "t" "To") (?c "to" "tc" "To or Cc")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
360 (?a "from" "a" "Address") (?s "subject" "s" "Subject") (?b nil "b" "Body")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
361 (?d nil "d" "Date") (?n nil "n" "Attachment"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
362 "Things that should be editable during interactive query generation.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
363 Every list element consists of the following entries: Keystroke,
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
364 message field (if any), mairix command and description.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
365
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
366 (defvar nnmairix-delete-and-create-on-change '(nnimap nnmaildir nnml)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
367 "Controls on which back ends groups should be deleted and re-created.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
368 This variable is a list of back ends where the search group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
369 should be completely deleted and re-created when the query or
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
370 thread parameter changes. The default is to this for all
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
371 currently supported back ends. It usually also corrects the
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
372 problem of \"holes\" in the article numbers which often lead to a
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
373 wrong count of total articles shown by Gnus.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
374
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
375 ;;; === Server variables
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
376
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
377 (defvoo nnmairix-backend nil
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
378 "Back end where mairix stores its searches.")
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
379
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
380 (defvoo nnmairix-backend-server nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
381 "Name of the server where mairix stores its searches.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
382
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
383 (defvoo nnmairix-mairix-command "mairix"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
384 "Command to call mairix for this nnmairix server.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
385
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
386 (defvoo nnmairix-hidden-folders nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
387 "Set this to t if the back end server uses hidden directories for
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
388 its maildir mail folders (e.g. the Dovecot IMAP server or mutt).")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
389
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
390 (defvoo nnmairix-default-group nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
391 "Default search group. This is the group which is used for all
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
392 temporary searches, e.g. nnmairix-search.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
393
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
394 ;;; === Internal variables
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
395
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
396 (defconst nnmairix-group-regexp
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
397 (format "%s-\\(.*\\)-[0-9]+" nnmairix-group-prefix)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
398 "Regexp for mairix groups on back end.")
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
399
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
400 (defconst nnmairix-valid-backends '(nnimap nnml nnmaildir)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
401 "Back ends supported by nnmairix.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
402 Other back ends might or might not work.")
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
403
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
404 (defvar nnmairix-last-server nil
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
405 "Last chosen server.")
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
406
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
407 (defvar nnmairix-current-server nil
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
408 "Current server.")
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
409
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
410 (defvar nnmairix-marks-cache nil
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
411 "Cache for marks which should be set upon closing current group.")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
412
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
413 (defvar nnmairix-version-output nil
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
414 "Version string of mairix binary.")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
415
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
416 ;;; === Gnus back end functions
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
417
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
418 (nnoo-define-basics nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
419
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
420 (gnus-declare-backend "nnmairix" 'mail 'address)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
421
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
422 (deffoo nnmairix-open-server (server &optional definitions)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
423 ;; just set server variables
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
424 (setq nnmairix-current-server server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
425 (nnoo-change-server 'nnmairix server definitions))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
426
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
427 (deffoo nnmairix-request-group (group &optional server fast)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
428 ;; Call mairix and request group on back end server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
429 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
430 (let* ((qualgroup (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
431 (gnus-group-prefixed-name group (list 'nnmairix server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
432 group))
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
433 (folder (gnus-group-get-parameter qualgroup 'folder))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
434 (allowfast (gnus-group-get-parameter qualgroup 'allow-fast))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
435 (query (gnus-group-get-parameter qualgroup 'query t))
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
436 (threads (gnus-group-get-parameter qualgroup 'threads))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
437 (backendmethod (gnus-server-to-method
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
438 (format "%s:%s" (symbol-name nnmairix-backend)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
439 nnmairix-backend-server)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
440 rval mfolder folderpath args)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
441 (cond
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
442 ((not folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
443 ;; No folder parameter -> error
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
444 (nnheader-report 'nnmairix "Check folder parameter for group %s" group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
445 nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
446 ((not query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
447 ;; No query -> return empty group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
448 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
449 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
450 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
451 (insert (concat "211 0 1 0 " group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
452 t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
453 (t
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
454 ;; For maildir++ folders: create a hidden directory (prepend dot)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
455 (setq mfolder (if (and nnmairix-hidden-folders
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
456 (not (string-match "^\\." folder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
457 (concat "." folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
458 folder))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
459 ;; For nnml and nnmaildir, precede mfolder with directory where mail
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
460 ;; is actually stored so that it's independent of 'base' setting
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
461 ;; in .mairixrc.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
462 (when (eq nnmairix-backend 'nnml)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
463 (setq folderpath (cadr (assoc 'nnml-directory backendmethod)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
464 ;; if nnml-directory is not explicitly set, use global value
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
465 (when (not folderpath)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
466 (setq folderpath nnml-directory)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
467 (when (eq nnmairix-backend 'nnmaildir)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
468 (setq folderpath
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
469 (cadr (assoc 'directory backendmethod))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
470 (when folderpath
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
471 (setq mfolder
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
472 (concat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
473 (file-name-as-directory
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
474 (expand-file-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
475 folderpath))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
476 mfolder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
477 ;; If (not fast), call Mairix binary
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
478 ;; recreate underlying folder on the back end
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
479 (setq rval
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
480 (if (and fast allowfast)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
481 0
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
482 (nnmairix-call-mairix-binary
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
483 (split-string nnmairix-mairix-command)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
484 mfolder query threads)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
485 ;; Check return value
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
486 (cond
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
487 ((zerop rval) ; call was succesful
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
488 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
489 "open-server" nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
490 ;; If we're dealing with nnml, rename files
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
491 ;; consecutively and make new active file for this
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
492 ;; group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
493 (when (eq nnmairix-backend 'nnml)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
494 (when nnmairix-rename-files-for-nnml
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
495 (nnmairix-rename-files-consecutively mfolder))
103352
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
496 (nnml-generate-nov-databases-directory mfolder nil t))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
497 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
498 "request-scan" folder nnmairix-backend-server)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
499 (if (and fast allowfast)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
500 t
92359
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
501 (nnmairix-request-group-with-article-number-correction
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
502 folder qualgroup)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
503 ((and (= rval 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
504 (save-excursion (set-buffer nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
505 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
506 (looking-at "^Matched 0 messages")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
507 ;; No messages found -> return empty group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
508 (nnheader-message 5 "Mairix: No matches found.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
509 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
510 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
511 (insert (concat "211 0 1 0 " group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
512 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
513 ;; Everything else is an error
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
514 (t
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
515 (nnheader-report
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
516 'nnmairix "Error running marix. See buffer %s for details"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
517 nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
518 nil))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
519
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
520
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
521 (deffoo nnmairix-request-create-group (group &optional server args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
522 (let ((qualgroup (if server (gnus-group-prefixed-name group (list 'nnmairix server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
523 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
524 (exist t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
525 (count 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
526 groupname info)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
527 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
528 (gnus-group-add-parameter qualgroup '(query . nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
529 (gnus-group-add-parameter qualgroup '(threads . nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
530 (while exist
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
531 (setq count (1+ count))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
532 (setq groupname (format "%s-%s-%s" nnmairix-group-prefix group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
533 (number-to-string count)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
534 (setq exist (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
535 "request-group" groupname nnmairix-backend-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
536 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
537 "request-create-group" groupname nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
538 (gnus-group-add-parameter qualgroup '(folder . nil))
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
539 (when nnmairix-allowfast-default
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
540 (gnus-group-add-parameter qualgroup '(allow-fast . t)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
541 (gnus-group-set-parameter qualgroup 'folder groupname))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
542 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
543
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
544
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
545 (deffoo nnmairix-retrieve-headers (articles group &optional server fetch-old)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
546 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
547 (let* ((folder (nnmairix-get-backend-folder group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
548 (corr (nnmairix-get-numcorr group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
549 (numcorr 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
550 rval)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
551 (when (and corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
552 (not (zerop (cadr corr)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
553 (numberp (car articles)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
554 (setq numcorr (cadr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
555 (setq articles
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
556 (mapcar
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
557 (lambda (arg) (- arg numcorr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
558 articles)))
103352
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
559 (setq rval
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
560 (if (eq nnmairix-backend 'nnimap)
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
561 (let ((gnus-nov-is-evil t))
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
562 (nnmairix-call-backend
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
563 "retrieve-headers" articles folder nnmairix-backend-server fetch-old))
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
564 (nnmairix-call-backend
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
565 "retrieve-headers" articles folder nnmairix-backend-server fetch-old)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
566 (when (eq rval 'nov)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
567 (nnmairix-replace-group-and-numbers articles folder group numcorr)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
568 rval)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
569
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
570 (deffoo nnmairix-request-article (article &optional group server to-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
571 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
572 (let ((folder (nnmairix-get-backend-folder group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
573 (corr (nnmairix-get-numcorr group server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
574 (when (and
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
575 (numberp article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
576 corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
577 (not (zerop (cadr corr))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
578 (setq article (- article (cadr corr))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
579 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
580 "request-article" article folder nnmairix-backend-server to-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
581 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
582
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
583 (deffoo nnmairix-request-list (&optional server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
584 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
585 (if (nnmairix-call-backend "request-list" nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
586 (let (cpoint cur qualgroup folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
587 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
588 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
589 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
590 (setq cpoint (point))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
591 (while (re-search-forward nnmairix-group-regexp (point-max) t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
592 (setq cur (match-string 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
593 qualgroup (gnus-group-prefixed-name cur
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
594 (list 'nnmairix server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
595 (if (and (gnus-group-entry qualgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
596 (string= (match-string 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
597 (gnus-group-get-parameter qualgroup 'folder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
598 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
599 (replace-match cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
600 (delete-region cpoint (point-at-bol))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
601 (forward-line)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
602 (setq cpoint (point)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
603 (forward-line)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
604 (delete-region cpoint (point-max)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
605 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
606 nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
607
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
608 ;; Silence byte-compiler.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
609 (defvar gnus-registry-install)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
610 (autoload 'gnus-registry-fetch-group "gnus-registry")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
611 (autoload 'gnus-registry-fetch-groups "gnus-registry")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
612 (autoload 'gnus-registry-add-group "gnus-registry")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
613
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
614 (deffoo nnmairix-request-set-mark (group actions &optional server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
615 (when server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
616 (nnmairix-open-server server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
617 (let* ((qualgroup (gnus-group-prefixed-name group (list 'nnmairix nnmairix-current-server)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
618 (propmarks (gnus-group-get-parameter qualgroup 'propmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
619 (propto (gnus-group-get-parameter qualgroup 'propto t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
620 (corr (nnmairix-get-numcorr group server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
621 (folder (nnmairix-get-backend-folder group server)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
622 (save-excursion
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
623 (dolist (cur actions)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
624 (let ((type (nth 1 cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
625 (cmdmarks (nth 2 cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
626 (range (gnus-uncompress-range (nth 0 cur)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
627 mid ogroup number method temp)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
628 (when (and corr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
629 (not (zerop (cadr corr))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
630 (setq range (mapcar (lambda (arg)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
631 (- arg (cadr corr)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
632 range)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
633 (when propmarks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
634 (nnheader-message 7 "nnmairix: Setting marks...")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
635 (dolist (article range)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
636 ;; get article (header) and extract message id
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
637 ;; we try to determine as many original articles as possible
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
638 (catch 'problem
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
639 (nnmairix-call-backend "open-server" nnmairix-backend-server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
640 (unless (gnus-request-head
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
641 article
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
642 (gnus-group-prefixed-name
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
643 folder
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
644 (list nnmairix-backend nnmairix-backend-server)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
645 (nnheader-message
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
646 3 "Unable to set mark: couldn't fetch article header for article number %d"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
647 article)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
648 (throw 'problem nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
649 (set-buffer nntp-server-buffer)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
650 (goto-char (point-min))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
651 (let ((case-fold-search t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
652 (re-search-forward "^message-id:.*\\(<.+>\\)" nil t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
653 (setq mid (match-string 1))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
654 (unless mid
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
655 (nnheader-message
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
656 3 "Unable to set mark: article number %d has no message-id header"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
657 article)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
658 (throw 'problem nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
659 ;; get original group. First try registry, then file path
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
660 (setq ogroup
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
661 (nnmairix-determine-original-group-from-registry mid))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
662 (unless (or ogroup
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
663 nnmairix-only-use-registry)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
664 (setq ogroup
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
665 (nnmairix-determine-original-group-from-path
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
666 mid nnmairix-current-server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
667 ;; if available and allowed, add this entry to the registry
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
668 (when (and (boundp 'gnus-registry-install)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
669 gnus-registry-install)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
670 (dolist (cur ogroup)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
671 (unless (gnus-parameter-registry-ignore cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
672 (gnus-registry-add-group mid cur)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
673 (unless ogroup
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
674 (nnheader-message
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
675 3 "Unable to set mark: couldn't find original group for %s" mid)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
676 (throw 'problem nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
677 ;; store original groups with mid's. We cannot get
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
678 ;; the article number immediately since this would
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
679 ;; generate problems with maildir (articles might
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
680 ;; get moved from /new to /cur and further marks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
681 ;; could then not be set)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
682 (dolist (cur ogroup)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
683 (setq temp (assoc cur
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
684 nnmairix-marks-cache))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
685 (if temp
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
686 (nconc temp (list (list mid type cmdmarks)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
687 (push (list cur (list mid type cmdmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
688 nnmairix-marks-cache)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
689 (nnheader-message 7 "nnmairix: Setting marks... done")))))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
690
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
691 (deffoo nnmairix-close-group (group &optional server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
692 (when server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
693 (nnmairix-open-server server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
694 (let* ((qualgroup (gnus-group-prefixed-name group (list 'nnmairix nnmairix-current-server)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
695 (propmarks (gnus-group-get-parameter qualgroup 'propmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
696 method)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
697 (when (and propmarks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
698 nnmairix-marks-cache)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
699 (when (or (eq nnmairix-propagate-marks-upon-close t)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
700 (and (eq nnmairix-propagate-marks-upon-close 'ask)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
701 (y-or-n-p "Propagate marks to original articles? ")))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
702 (save-excursion
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
703 (set-buffer gnus-group-buffer)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
704 (nnmairix-propagate-marks)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
705 ;; update mairix group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
706 (gnus-group-jump-to-group qualgroup)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
707 (gnus-group-get-new-news-this-group))))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
708
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
709 (autoload 'nnimap-request-update-info-internal "nnimap")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
710
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
711 (deffoo nnmairix-request-update-info (group info &optional server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
712 ;; propagate info from underlying IMAP folder to nnmairix group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
713 ;; This is currently experimental and must be explicitly activated
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
714 ;; with nnmairix-propagate-marks-to-nnmairix-group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
715 (when server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
716 (nnmairix-open-server server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
717 (let* ((qualgroup (gnus-group-prefixed-name
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
718 group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
719 (list 'nnmairix nnmairix-current-server)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
720 (readmarks (gnus-group-get-parameter qualgroup 'readmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
721 (propmarks (gnus-group-get-parameter qualgroup 'propmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
722 (folder (nnmairix-get-backend-folder group server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
723 (corr (nnmairix-get-numcorr group server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
724 (docorr (and corr (not (zerop (cadr corr)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
725 (folderinfo `(,group 1 ((1 . 1))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
726 readrange marks)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
727 (when (and propmarks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
728 nnmairix-propagate-marks-to-nnmairix-groups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
729 ;; these groups are not subscribed, so we have to ask the back end directly
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
730 (if (eq nnmairix-backend 'nnimap)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
731 (nnimap-request-update-info-internal folder folderinfo nnmairix-backend-server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
732 (nnmairix-call-backend "request-update-info" folder folderinfo nnmairix-backend-server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
733 ;; set range of read articles
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
734 (gnus-info-set-read
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
735 info
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
736 (if docorr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
737 (nnmairix-map-range
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
738 `(lambda (x) (+ x ,(cadr corr)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
739 (gnus-info-read folderinfo))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
740 (gnus-info-read folderinfo)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
741 ;; set other marks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
742 (gnus-info-set-marks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
743 info
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
744 (if docorr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
745 (mapcar (lambda (cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
746 (cons
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
747 (car cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
748 (nnmairix-map-range
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
749 `(lambda (x) (+ x ,(cadr corr)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
750 (list (cadr cur)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
751 (gnus-info-marks folderinfo))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
752 (gnus-info-marks folderinfo))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
753 (when (eq readmarks 'unread)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
754 (gnus-info-set-read info nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
755 (when (eq readmarks 'read)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
756 (gnus-info-set-read info (gnus-active qualgroup))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
757 t)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
758
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
759 (nnoo-define-skeleton nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
760
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
761
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
762 ;;; === Interactive functions
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
763
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
764 (defun nnmairix-create-search-group (server group query threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
765 "Create on SERVER nnmairix search group GROUP with QUERY.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
766 If THREADS is t, include whole threads from found messages. If
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
767 called interactively, user will be asked for parameters."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
768 (interactive
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
769 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
770 (gnus-server-to-method (car (nnmairix-get-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
771 (read-string "Group name: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
772 (read-string "Query: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
773 (y-or-n-p "Include threads? ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
774 (when (and (stringp query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
775 (string-match "\\s-" query))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
776 (setq query (split-string query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
777 (when (not (listp query))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
778 (setq query (list query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
779 (when (and server group query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
780 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
781 (let ((groupname (gnus-group-prefixed-name group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
782 info)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
783 (set-buffer gnus-group-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
784 (gnus-group-make-group group server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
785 (gnus-group-set-parameter groupname 'query query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
786 (gnus-group-set-parameter groupname 'threads threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
787 (nnmairix-update-and-clear-marks groupname)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
788
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
789 (defun nnmairix-search-interactive ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
790 "Create mairix search interactively with the minibuffer."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
791 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
792 (let ((char-header nnmairix-interactive-query-parameters)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
793 header finished query achar)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
794 (while (not finished)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
795 (while (not achar)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
796 (message "Query (%s): " (nnmairix-create-message-line-for-search))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
797 (setq achar (read-char))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
798 (when (not (assoc achar char-header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
799 (setq achar nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
800 (setq header (read-string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
801 (concat "Match " (nth 3 (assoc achar char-header)) " on: ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
802 (push (concat (nth 2 (assoc achar char-header)) ":" header) query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
803 (setq finished (not (y-or-n-p "Add another search query? "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
804 achar nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
805 (nnmairix-search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
806 (mapconcat 'identity query " ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
807 (car (nnmairix-get-server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
808 (y-or-n-p "Include whole threads? "))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
809
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
810 (defun nnmairix-create-search-group-from-message ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
811 "Interactively create search group with query based on current message."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
812 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
813 (let ((char-header nnmairix-interactive-query-parameters)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
814 (server (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
815 query achar header finished group threads cq)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
816 (when (or (not (gnus-buffer-live-p gnus-article-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
817 (not (gnus-buffer-live-p gnus-summary-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
818 (error "No article or summary buffer"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
819 (when (not server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
820 (error "No nnmairix server found for back end %s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
821 (symbol-name (car gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
822 (nth 1 gnus-current-select-method)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
823 (while (not finished)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
824 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
825 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
826 (while (not achar)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
827 (message "Query (%s): " (nnmairix-create-message-line-for-search))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
828 (setq achar (read-char))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
829 (when (not (assoc achar char-header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
830 (setq achar nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
831 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
832 (setq header nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
833 (when (setq cq (nth 1 (assoc achar char-header)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
834 (setq header
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
835 (nnmairix-replace-illegal-chars
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
836 (gnus-fetch-field (nth 1 (assoc achar char-header))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
837 (setq header (read-string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
838 (concat "Match " (nth 3 (assoc achar char-header)) " on: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
839 header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
840 (push (concat (nth 2 (assoc achar char-header)) ":" header) query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
841 (setq finished (not (y-or-n-p "Add another search query? "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
842 achar nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
843 (setq threads (y-or-n-p "Include whole threads? "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
844 (setq group (read-string "Group name: "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
845 (set-buffer gnus-summary-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
846 (message "Creating group %s on server %s with query %s." group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
847 (gnus-method-to-server server) (mapconcat 'identity query " "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
848 (nnmairix-create-search-group server group query threads)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
849
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
850 (defun nnmairix-create-server-and-default-group ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
851 "Interactively create new nnmairix server with default search group.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
852 All necessary information will be queried from the user."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
853 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
854 (let* ((name (read-string "Name of the mairix server: "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
855 (server (completing-read "Back end server (TAB for completion): "
98102
172640e67bed Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 96273
diff changeset
856 (nnmairix-get-valid-servers) nil 1))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
857 (mairix (read-string "Command to call mairix: " "mairix"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
858 (defaultgroup (read-string "Default search group: "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
859 (backend (symbol-name (car (gnus-server-to-method server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
860 (servername (nth 1 (gnus-server-to-method server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
861 (hidden (and (string-match "^nn\\(imap\\|maildir\\)$" backend)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
862 (y-or-n-p
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
863 "Does the back end server work with maildir++ (i.e. hidden directories)? ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
864 create)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
865
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
866 (apply (intern (format "%s-%s" backend "open-server"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
867 (list servername))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
868
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
869 (when (and hidden
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
870 (string-match "^\\." defaultgroup))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
871 (setq defaultgroup (substring defaultgroup 1)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
872 ;; Create default search group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
873 (gnus-group-make-group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
874 defaultgroup (list 'nnmairix name (list 'nnmairix-backend (intern backend))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
875 (list 'nnmairix-backend-server servername)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
876 (list 'nnmairix-mairix-command mairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
877 (list 'nnmairix-hidden-folders hidden)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
878 (list 'nnmairix-default-group defaultgroup)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
879
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
880 (defun nnmairix-group-change-query-this-group (&optional query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
881 "Set QUERY for group under cursor."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
882 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
883 (let* ((group (gnus-group-group-name))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
884 (method (gnus-find-method-for-group group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
885 (oldquery (gnus-group-get-parameter group 'query t)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
886 (if (eq (car method) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
887 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
888 (when (listp oldquery)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
889 (setq oldquery (mapconcat 'identity oldquery " ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
890 (setq query (or query
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
891 (read-string "New query: " oldquery)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
892 (when (stringp query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
893 (setq query (split-string query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
894 (when query
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
895 (gnus-group-set-parameter group 'query query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
896 (nnmairix-update-and-clear-marks group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
897 (error "This is no nnmairix group"))))
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
898
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
899
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
900 (defun nnmairix-group-toggle-threads-this-group (&optional threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
901 "Toggle threads parameter for this group.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
902 If THREADS is a positive number, set threads parameter to t.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
903 If THREADS is a negative number, set it to nil."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
904 (interactive)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
905 (let ((group (gnus-group-group-name)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
906 (when (nnmairix-group-toggle-parameter
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
907 group 'threads "Threads" threads)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
908 (nnmairix-update-and-clear-marks group))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
909
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
910 (defun nnmairix-group-toggle-propmarks-this-group (&optional propmarks)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
911 "Toggle marks propagation for this group.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
912 If PROPMARKS is a positive number, set parameter to t.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
913 If PROPMARKS is a negative number, set it to nil."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
914 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
915 (unless (nnmairix-check-mairix-version "maildirpatch")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
916 (error "You need a mairix binary with maildir patch to use this feature. See docs for details"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
917 (let ((group (gnus-group-group-name)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
918 (when (or (not (string= (gnus-group-short-name group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
919 (cadr (assoc 'nnmairix-default-group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
920 (gnus-find-method-for-group group)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
921 (y-or-n-p "You should not activate marks propagation for the default \
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
922 search group. Are you sure? "))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
923 (nnmairix-group-toggle-parameter
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
924 group 'propmarks "Marks propagation" propmarks))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
925
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
926 (defun nnmairix-group-toggle-allowfast-this-group (&optional allowfast)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
927 "Toggle fast entering for this group.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
928 If ALLOWFAST is a positive number, set parameter to t.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
929 If ALLOWFAST is a negative number, set it to nil."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
930 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
931 (nnmairix-group-toggle-parameter
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
932 (gnus-group-group-name) 'allow-fast "Fast entering" allowfast))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
933
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
934
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
935 (defun nnmairix-group-toggle-readmarks-this-group (&optional readmarks)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
936 "Toggle read/unread marks for this group.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
937 If READMARKS is a positive number, articles will always be read.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
938 If READMARKS is a negative number, articles will always be unread.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
939 If READMARKS is t or zero, marks will stay unchanged."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
940 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
941 (let* ((group (gnus-group-group-name))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
942 (method (gnus-find-method-for-group group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
943 (readmarks (or readmarks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
944 (gnus-group-get-parameter group 'readmarks))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
945 (if (eq (car method) 'nnmairix)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
946 (cond
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
947 ((or (and (numberp readmarks) (< readmarks 0))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
948 (eq readmarks 'read))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
949 (gnus-group-set-parameter group 'readmarks 'unread)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
950 (nnheader-message 3 "Articles in %s always unread." group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
951 ((or (and (numberp readmarks) (> readmarks 0))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
952 (not readmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
953 (gnus-group-set-parameter group 'readmarks 'read)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
954 (nnheader-message 3 "Articles in %s always read." group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
955 (t
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
956 (gnus-group-set-parameter group 'readmarks nil)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
957 (nnheader-message 3 "Read marks in %s stay unchanged." group)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
958 (error "This is no nnmairix group"))))
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
959
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
960
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
961 (defun nnmairix-search (query &optional server threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
962 "Sends QUERY to nnmairix backend SERVER, using default its search group.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
963
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
964 Default search group is automatically entered and results are shown.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
965 If THREADS is t, enable threads.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
966 If THREADS is a negative number, disable threads.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
967 Otherwise, leave threads parameter as it is."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
968 (interactive (list (read-string "Query: ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
969 (when (not server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
970 (setq server (car (nnmairix-get-server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
971 (if (not server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
972 (error "No opened nnmairix server found")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
973 (setq server (gnus-server-to-method server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
974 (nnmairix-open-server (nth 1 server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
975 (let* ((qualgroup (gnus-group-prefixed-name nnmairix-default-group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
976 (list 'nnmairix (nth 1 server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
977 (set-buffer gnus-group-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
978 (when (stringp query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
979 (setq query (split-string query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
980 (gnus-group-set-parameter qualgroup 'query query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
981 (if (symbolp threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
982 (when (eq threads 't)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
983 (gnus-group-set-parameter qualgroup 'threads t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
984 (when (< threads 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
985 (gnus-group-set-parameter qualgroup 'threads nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
986 (nnmairix-update-and-clear-marks qualgroup)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
987 (unless (equal (gnus-active qualgroup) '(1 . 0))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
988 (gnus-group-read-group nil t qualgroup))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
989
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
990 (defun nnmairix-search-thread-this-article ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
991 "Search thread for the current article.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
992 This is effectively a shortcut for calling `nnmairix-search'
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
993 with m:msgid of the current article and enabled threads."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
994 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
995 (let* ((server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
996 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
997 mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
998 (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
999 (if (gnus-buffer-live-p gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1000 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1001 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1002 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1003 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1004 (setq mid (message-fetch-field "Message-ID")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1005 (while (string-match "[<>]" mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1006 (setq mid (replace-match "" t t mid)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1007 (nnmairix-search (concat "m:" mid) server t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1008 (message "No article buffer."))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1009 (error "No nnmairix server found for back end %s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1010 (symbol-name (car gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1011 (nth 1 gnus-current-select-method)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1012
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1013 (defun nnmairix-search-from-this-article ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1014 "Search messages from sender of the current article.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1015 This is effectively a shortcut for calling `nnmairix-search' with
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1016 f:current_from."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1017 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1018 (let* ((server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1019 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1020 from)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1021 (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1022 (if (gnus-buffer-live-p gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1023 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1024 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1025 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1026 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1027 (setq from (cadr (gnus-extract-address-components
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1028 (gnus-fetch-field "From"))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1029 (nnmairix-search (concat "f:" from) server -1)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1030 (message "No article buffer."))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1031 (error "No nnmairix server found for back end %s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1032 (symbol-name (car gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1033 (nth 1 gnus-current-select-method)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1034
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1035
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1036 (defun nnmairix-purge-old-groups (&optional dontask server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1037 "Delete mairix search groups which are no longer used.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1038
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1039 You may want to call this from time to time if you are creating
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1040 and deleting lots of nnmairix groups. If DONTASK is t, do not ask
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1041 before deleting a group on the back end. SERVER specifies nnmairix server."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1042 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1043 (let ((server (or server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1044 (gnus-server-to-method (car (nnmairix-get-server))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1045 (if (nnmairix-open-server (nth 1 server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1046 (when (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1047 "request-list" nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1048 (let (cur qualgroup folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1049 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1050 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1051 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1052 (while (re-search-forward nnmairix-group-regexp (point-max) t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1053 (setq cur (match-string 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1054 qualgroup (gnus-group-prefixed-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1055 (match-string 1) server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1056 (when (not (and (gnus-group-entry qualgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1057 (string= cur
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1058 (gnus-group-get-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1059 qualgroup 'folder))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1060 (when (or dontask
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1061 (y-or-n-p
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1062 (concat "Delete group " cur
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1063 " on server " nnmairix-backend-server "? ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1064 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1065 "request-delete-group" cur t nnmairix-backend-server)))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1066 (message "Couldn't open server %s" (nth 1 server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1067
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1068
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1069 (defun nnmairix-update-database (&optional servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1070 "Call mairix for updating the database for SERVERS.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1071
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1072 If SERVERS is nil, do update for all nnmairix servers. Mairix
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1073 will be called asynchronously unless
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1074 `nnmairix-mairix-synchronous-update' is t. Mairix will be called
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1075 with `nnmairix-mairix-update-options'."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1076 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1077 (let ((servers (or servers
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1078 (nnmairix-get-nnmairix-servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1079 args cur commandsplit)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1080 (while servers
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1081 (setq cur (car (pop servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1082 (nnmairix-open-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1083 (nth 1 (gnus-server-to-method cur)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1084 (setq commandsplit (split-string nnmairix-mairix-command))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1085 (nnheader-message 7 "Updating mairix database for %s..." cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1086 (if nnmairix-mairix-synchronous-update
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1087 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1088 (setq args (append (list (car commandsplit) nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1089 (get-buffer nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1090 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1091 (if (> (length commandsplit) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1092 (setq args (append args (cdr commandsplit) nnmairix-mairix-update-options))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1093 (setq args (append args nnmairix-mairix-update-options)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1094 (apply 'call-process args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1095 (nnheader-message 7 "Updating mairix database for %s... done" cur))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1096 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1097 (setq args (append (list cur (get-buffer nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1098 (car commandsplit))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1099 (if (> (length commandsplit) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1100 (setq args (append args (cdr commandsplit) nnmairix-mairix-update-options))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1101 (setq args (append args nnmairix-mairix-update-options)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1102 (set-process-sentinel (apply 'start-process args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1103 'nnmairix-sentinel-mairix-update-finished))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1104
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1105 (defun nnmairix-group-delete-recreate-this-group ()
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1106 "Deletes and recreates group on the back end.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1107 You can use this function on nnmairix groups which continously
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1108 show wrong article counts."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1109 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1110 (let* ((group (gnus-group-group-name))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1111 (method (gnus-find-method-for-group group)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1112 (unless (eq (car method) 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1113 (error "This is not a nnmairix group"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1114 (when (y-or-n-p
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1115 (format "Really recreate group %s on the back end? " group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1116 (nnmairix-delete-recreate-group group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1117 (gnus-group-get-new-news-this-group))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1118
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1119 (defun nnmairix-propagate-marks (&optional server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1120 "Propagate marks from nnmairix group to original articles.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1121 Unless SERVER is explicitly specified, will use the last opened
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1122 nnmairix server. Only marks from current session will be set."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1123 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1124 (if server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1125 (nnmairix-open-server server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1126 (unless (eq (car gnus-current-select-method) 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1127 (if nnmairix-current-server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1128 (nnmairix-open-server nnmairix-current-server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1129 (error "No opened nnmairix server"))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1130 (if nnmairix-marks-cache
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1131 (let (number ogroup number-cache method mid-marks temp)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1132 ;; first we get the article numbers
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1133 (catch 'problem
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1134 (while (setq ogroup (pop nnmairix-marks-cache))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1135 (while (setq mid-marks (pop (cdr ogroup)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1136 (setq number
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1137 (cdr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1138 (gnus-request-head (car mid-marks) (car ogroup))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1139 (unless number
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1140 (nnheader-message
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1141 3 "Unable to set mark: couldn't determine article number for %s in %s"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1142 (car mid-marks) (car ogroup))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1143 (throw 'problem nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1144 (setq temp (assoc (car ogroup) number-cache))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1145 (if temp
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1146 (catch 'done
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1147 (dolist (cur (cdr temp))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1148 (when (equal (cdr cur) (list (nth 1 mid-marks) (nth 2 mid-marks)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1149 (nconc (car cur) (list number))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1150 (throw 'done nil)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1151 (nconc temp (list (list (list number) (nth 1 mid-marks) (nth 2 mid-marks)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1152 (push (list (car ogroup) (list (list number) (nth 1 mid-marks) (nth 2 mid-marks)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1153 number-cache)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1154 ;; now we set the marks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1155 (save-excursion
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1156 (set-buffer gnus-group-buffer)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1157 (nnheader-message 5 "nnmairix: Propagating marks...")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1158 (dolist (cur number-cache)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1159 (setq method (gnus-find-method-for-group (car cur)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1160 (apply (intern (format "%s-%s"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1161 (symbol-name (car method))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1162 "request-set-mark"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1163 (gnus-group-short-name (car cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1164 (cdr cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1165 (list (nth 1 method)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1166 (gnus-group-jump-to-group (car cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1167 (gnus-group-get-new-news-this-group)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1168 (nnheader-message 5 "nnmairix: Propagating marks... done"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1169 (nnheader-message 3 "No marks to propagate.")))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1170
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1171 (defun nnmairix-update-groups (servername &optional skipdefault updatedb)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1172 "Update all search groups on SERVERNAME.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1173 If SKIPDEFAULT is t, the default search group will not be
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1174 updated.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1175 If UPDATEDB is t, database for SERVERNAME will be updated first."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1176 (interactive (list (completing-read "Update groups on server: "
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1177 (nnmairix-get-nnmairix-servers))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1178 (save-excursion
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1179 (when (string-match ".*:\\(.*\\)" servername)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1180 (setq servername (match-string 1 servername)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1181 (if (not (assoc (format "nnmairix:%s" servername)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1182 (nnmairix-get-nnmairix-servers)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1183 (nnheader-message 3 "Server %s not opened" servername)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1184 (when updatedb
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1185 (let ((nnmairix-mairix-synchronous-update t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1186 (nnmairix-update-database
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1187 (list (list (format "nnmairix:%s" servername))))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1188 (let ((groups (nnmairix-get-groups-from-server servername))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1189 default)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1190 (when skipdefault
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1191 (setq default
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1192 (format "nnmairix+%s:%s"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1193 servername
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1194 (cadr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1195 (assoc 'nnmairix-default-group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1196 (gnus-server-to-method
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1197 (format "nnmairix:%s" servername)))))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1198 (dolist (cur groups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1199 (unless (and skipdefault
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1200 (string= (car cur) default))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1201 (gnus-group-jump-to-group (car cur))
103352
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
1202 (gnus-group-mark-group 1)))
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
1203 (gnus-group-get-new-news-this-group)))))
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1204
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1205 (defun nnmairix-remove-tick-mark-original-article ()
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1206 "Remove tick mark from original article.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1207 Marks propagation has to be enabled for this to work."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1208 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1209 (unless (eq (car gnus-current-select-method) 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1210 (error "Not in a nnmairix group"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1211 (save-excursion
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1212 (let ((mid (mail-header-message-id (gnus-summary-article-header)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1213 groups cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1214 (when mid
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1215 (setq groups (nnmairix-determine-original-group-from-registry mid))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1216 (unless (or groups
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1217 nnmairix-only-use-registry)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1218 (setq groups
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1219 (nnmairix-determine-original-group-from-path mid nnmairix-current-server)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1220 (unless groups
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1221 (error "Couldn't find original article"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1222 (dolist (cur groups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1223 (push `(,cur (,mid del (tick))) nnmairix-marks-cache))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1224 (nnheader-message 5 "Will remove tick mark for %s upon closing." mid)))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1225
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1226 ;;; ==== Helper functions
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1227
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1228 (defun nnmairix-request-group-with-article-number-correction (folder qualgroup)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1229 "Request FOLDER on back end for nnmairix QUALGROUP and article number correction."
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1230 (save-excursion
92359
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
1231 (nnmairix-call-backend "request-group" folder nnmairix-backend-server)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1232 (set-buffer nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1233 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1234 (re-search-forward "^Matched.*messages")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1235 (nnheader-message 7 (match-string 0))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1236 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1237 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1238 (let ((status (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1239 (total (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1240 (low (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1241 (high (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1242 (corr (gnus-group-get-parameter qualgroup 'numcorr t)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1243 (if (= status 211)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1244 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1245 ;; Article number correction
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1246 (if (and corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1247 (> (+ (car (cddr corr)) high) 0))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1248 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1249 (when (car corr) ;Group has changed
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1250 (setq corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1251 (list nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1252 (car (cddr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1253 (+ (car (cddr corr)) high)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1254 (gnus-group-set-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1255 qualgroup 'numcorr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1256 (setq low (+ low (cadr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1257 high (+ high (cadr corr))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1258 (when (member nnmairix-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1259 nnmairix-delete-and-create-on-change)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1260 (gnus-group-set-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1261 qualgroup 'numcorr (list nil 0 high))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1262 (erase-buffer)
92260
261f98568bde (nnmairix-request-group): Bind nnmairix-fast and nnmairix-group around
Glenn Morris <rgm@gnu.org>
parents: 92259
diff changeset
1263 (insert (format "%d %d %d %d %s" status total low high
92359
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
1264 (gnus-group-real-name qualgroup)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1265 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1266 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1267 (nnheader-report
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1268 'nnmairix "Error calling back end on group %s" folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1269 nil)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1270
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1271 (defun nnmairix-call-mairix-binary (command folder searchquery threads)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1272 "Call mairix binary with COMMAND, using FOLDER and SEARCHQUERY.
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1273 If THREADS is non-nil, enable full threads."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1274 (let ((args (cons (car command) '(nil t nil))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1275 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1276 (set-buffer
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1277 (get-buffer-create nnmairix-mairix-output-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1278 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1279 (when (> (length command) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1280 (setq args (append args (cdr command))))
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1281 (when nnmairix-mairix-search-options
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1282 (setq args (append args nnmairix-mairix-search-options)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1283 ;; If we have a patched mairix binary, call it with "-c"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1284 (when (nnmairix-check-mairix-version "maildirpatch")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1285 (setq args (append args '("-c"))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1286 (when threads
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1287 (setq args (append args '("-t"))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1288 (apply 'call-process
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1289 (append args (list "-o" folder) searchquery)))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1290
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1291 (defun nnmairix-call-mairix-binary-raw (command query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1292 "Call mairix binary with COMMAND and QUERY in raw mode."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1293 (let ((args (cons (car command) '(nil t nil))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1294 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1295 (set-buffer
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1296 (get-buffer-create nnmairix-mairix-output-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1297 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1298 (when (> (length command) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1299 (setq args (append args (cdr command))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1300 (setq args (append args '("-r")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1301 (apply 'call-process
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1302 (append args query)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1303
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1304 (defun nnmairix-get-server ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1305 "If there exists just one nnmairix server, return its value.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1306 Otherwise, ask user for server."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1307 (let ((openedserver (nnmairix-get-nnmairix-servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1308 (when (not openedserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1309 (error "No opened nnmairix server found"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1310 (if (> (length openedserver) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1311 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1312 (while
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1313 (equal '("")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1314 (setq nnmairix-last-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1315 (list (completing-read "Server: " openedserver nil 1
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1316 (or nnmairix-last-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1317 "nnmairix:"))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1318 nnmairix-last-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1319 (car openedserver))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1320
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1321 (defun nnmairix-get-nnmairix-servers (&optional all)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1322 "Return available nnmairix servers.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1323 If ALL is t, return also the unopened/failed ones."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1324 (let ((alist gnus-opened-servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1325 server openedserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1326 (while alist
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1327 (setq server (pop alist))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1328 (when (and server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1329 (or all
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1330 (eq (cadr server) 'ok))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1331 (eq (caar server) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1332 (not (member (car server) gnus-ephemeral-servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1333 (setq server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1334 (concat (symbol-name (caar server)) ":" (nth 1 (car server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1335 (push (list server) openedserver)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1336 openedserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1337
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1338 (defun nnmairix-get-valid-servers ()
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1339 "Return list of valid back end servers for nnmairix groups."
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1340 (let ((alist gnus-opened-servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1341 (mairixservers (nnmairix-get-nnmairix-servers t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1342 server mserver openedserver occ cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1343 ;; Get list of all nnmairix backends (i.e. backends which are
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1344 ;; already occupied)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1345 (dolist (cur mairixservers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1346 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1347 (concat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1348 (symbol-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1349 (cadr (assoc 'nnmairix-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1350 (gnus-server-to-method (car cur)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1351 ":"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1352 (cadr (assoc 'nnmairix-backend-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1353 (gnus-server-to-method (car cur)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1354 occ))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1355 (while alist
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1356 (setq server (pop alist))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1357 (setq mserver (gnus-method-to-server (car server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1358 ;; If this is the native server, convert it to the real server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1359 ;; name to avoid confusion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1360 (when (string= mserver "native")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1361 (setq mserver (format "%s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1362 (caar server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1363 (nth 1 (car server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1364 (when (and server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1365 (eq (cadr server) 'ok)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1366 (member (caar server) nnmairix-valid-backends)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1367 (not (member (car server) gnus-ephemeral-servers))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1368 (not (member (gnus-method-to-server (car server)) occ)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1369 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1370 (list mserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1371 openedserver)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1372 openedserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1373
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1374 (defun nnmairix-get-groups-from-server (servername)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1375 "Return all groups for nnmairix server SERVERNAME."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1376 (let ((searchstring (format "nnmairix\\+%s:" servername))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1377 groups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1378 (dolist (cur gnus-newsrc-alist)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1379 (when (string-match searchstring
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1380 (car cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1381 (push (list (car cur)) groups)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1382 groups))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1383
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1384 (defun nnmairix-call-backend (func &rest args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1385 "Call a function FUNC on backend with ARGS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1386 (apply (intern (format "%s-%s" (symbol-name nnmairix-backend) func)) args))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1387
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1388 (defun nnmairix-get-backend-folder (group &optional server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1389 "Return back end GROUP from nnmairix group on SERVER."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1390 (let* ((qualgroup (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1391 (gnus-group-prefixed-name group (list 'nnmairix server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1392 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1393 (folder (gnus-group-get-parameter qualgroup 'folder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1394 folder))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1395
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1396 (defun nnmairix-get-numcorr (group &optional server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1397 "Return values for article number correction nnmairix GROUP on SERVER."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1398 (let* ((qualgroup (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1399 (gnus-group-prefixed-name group (list 'nnmairix server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1400 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1401 (corr (gnus-group-get-parameter qualgroup 'numcorr t)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1402 corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1403
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1404
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1405 (defun nnmairix-rename-files-consecutively (path)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1406 "Rename all nnml mail files in PATH so that they have consecutive numbers.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1407 This should correct problems of wrong article counts when using
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1408 nnmairix with nnml backends."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1409 (let* ((files
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1410 (sort
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1411 (mapcar 'string-to-number
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1412 (directory-files path nil "[0-9]+" t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1413 '<))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1414 (lastplusone (car files))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1415 (path (file-name-as-directory path)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1416 (dolist (cur files)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1417 (when (not (= cur lastplusone))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1418 (rename-file (concat path
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1419 (number-to-string cur))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1420 (concat path
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1421 (number-to-string lastplusone)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1422 (setq cur lastplusone))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1423 (setq lastplusone (1+ cur)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1424
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1425 (defun nnmairix-replace-group-and-numbers (articles backendgroup mairixgroup numc)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1426 "Replace folder names in Xref header and correct article numbers.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1427 Do this for all ARTICLES on BACKENDGROUP. Replace using
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1428 MAIRIXGROUP. NUMC contains values for article number correction."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1429 (let ((buf (get-buffer-create " *nnmairix buffer*"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1430 (corr (not (zerop numc)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1431 (name (buffer-name nntp-server-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1432 header cur xref)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1433 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1434 (set-buffer buf)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1435 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1436 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1437 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1438 (nnheader-message 7 "nnmairix: Rewriting headers...")
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1439 (mapc
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1440 (lambda (article)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1441 (when (or (looking-at (number-to-string article))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1442 (nnheader-find-nov-line article))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1443 (setq cur (nnheader-parse-nov))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1444 (when corr
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1445 (setq article (+ (mail-header-number cur) numc))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1446 (mail-header-set-number cur article))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1447 (setq xref (mail-header-xref cur))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1448 (when (and (stringp xref)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1449 (string-match (format "[ \t]%s:[0-9]+" backendgroup) xref))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1450 (setq xref (replace-match (format " %s:%d" mairixgroup article) t nil xref))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1451 (mail-header-set-xref cur xref))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1452 (set-buffer buf)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1453 (nnheader-insert-nov cur)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1454 (set-buffer nntp-server-buffer)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1455 (when (not (eobp))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1456 (forward-line 1))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1457 articles)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1458 (nnheader-message 7 "nnmairix: Rewriting headers... done")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1459 (kill-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1460 (set-buffer buf)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1461 (rename-buffer name)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1462 (setq nntp-server-buffer buf))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1463
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1464 (defun nnmairix-backend-to-server (server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1465 "Return nnmairix server most probably responsible for back end SERVER.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1466 User will be asked if this cannot be determined. Result is saved in
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1467 parameter 'indexed-servers of corresponding default search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1468 group."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1469 (let ((allservers (nnmairix-get-nnmairix-servers))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1470 mairixserver found defaultgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1471 (if (> (length allservers) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1472 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1473 ;; If there is more than one nnmairix server, we go through them
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1474 (while (and allservers (not found))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1475 (setq mairixserver (gnus-server-to-method (car (pop allservers))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1476 ;; First we look if SERVER is the backend of current nnmairix server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1477 (setq found (and (eq (cadr (assoc 'nnmairix-backend mairixserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1478 (car server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1479 (string= (cadr (assoc 'nnmairix-backend-server mairixserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1480 (nth 1 server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1481 ;; If that's not the case, we look at 'indexed-servers
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1482 ;; variable in default search group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1483 (when (not found)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1484 (setq defaultgroup (cadr (assoc 'nnmairix-default-group mairixserver)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1485 (setq found (member (gnus-method-to-server server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1486 (gnus-group-get-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1487 (gnus-group-prefixed-name defaultgroup
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1488 mairixserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1489 'indexed-servers t)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1490 ;; If still not found, we ask user
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1491 (when (not found)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1492 (setq mairixserver
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1493 (gnus-server-to-method
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1494 (completing-read
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1495 (format "Cannot determine which nnmairix server indexes %s. Please specify: "
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1496 (gnus-method-to-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1497 (nnmairix-get-nnmairix-servers) nil nil "nnmairix:")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1498 ;; Save result in parameter of default search group so that
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1499 ;; we don't have to ask again
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1500 (setq defaultgroup (gnus-group-prefixed-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1501 (cadr (assoc 'nnmairix-default-group mairixserver)) mairixserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1502 (gnus-group-set-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1503 defaultgroup
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1504 'indexed-servers
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1505 (append (gnus-group-get-parameter defaultgroup 'indexed-servers t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1506 (list (gnus-method-to-server server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1507 mairixserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1508 ;; If there is just one (or none) nnmairix server:
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1509 (gnus-server-to-method (caar allservers)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1510
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1511
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1512 (defun nnmairix-delete-recreate-group (group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1513 "Delete and recreate folder from GROUP on the back end."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1514 (when (member nnmairix-backend nnmairix-delete-and-create-on-change)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1515 (let ((folder (gnus-group-get-parameter group 'folder)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1516 (if (string-match nnmairix-group-regexp folder)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1517 (progn
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1518 (nnmairix-call-backend "open-server"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1519 nnmairix-backend-server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1520 (nnmairix-call-backend "request-delete-group"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1521 folder t nnmairix-backend-server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1522 (nnmairix-call-backend "request-create-group"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1523 folder nnmairix-backend-server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1524 (error "`nnmairix-delete-recreate-group' called on \
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1525 non-mairix group. Check folder parameter")))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1526
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1527 (defun nnmairix-update-and-clear-marks (group &optional method)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1528 "Update group and clear all marks from GROUP using METHOD."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1529 (let ((method (or method
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1530 (gnus-find-method-for-group group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1531 (corr (gnus-group-get-parameter group 'numcorr t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1532 info)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1533 (unless (or (gnus-group-prefixed-p group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1534 (not method))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1535 (setq group (gnus-group-prefixed-name group method)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1536 (if (eq (nth 0 method) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1537 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1538 (nnmairix-open-server (nth 1 method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1539 (set-buffer gnus-group-buffer)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1540 ;; (gnus-group-set-parameter group 'propmarks nil)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1541 (setq info (gnus-get-info group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1542 ;; Clear active and info
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1543 (gnus-set-active group nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1544 (gnus-info-clear-data info)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1545 ;; Delete and re-create group if needed
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1546 (nnmairix-delete-recreate-group group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1547 ;; set flag that group has changed for article number correction
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1548 (when (member nnmairix-backend nnmairix-delete-and-create-on-change)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1549 (when corr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1550 (setcar corr t)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1551 (gnus-group-set-parameter group 'numcorr corr)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1552 (gnus-group-jump-to-group group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1553 (gnus-group-get-new-news-this-group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1554 (error "`nnmairix-update-and-clear-marks' called with non-nnmairix group"))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1555
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1556 (defun nnmairix-sentinel-mairix-update-finished (proc status)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1557 "Sentinel for mairix update process PROC with STATUS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1558 (if (equal status "finished\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1559 (nnheader-message 7 "Updating mairix database for %s... done" proc)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1560 (error "There was an error updating the mairix database for server %s. \
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1561 See %s for details" proc nnmairix-mairix-output-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1562
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1563 (defun nnmairix-create-message-line-for-search ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1564 "Create message line for interactive query in minibuffer."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1565 (mapconcat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1566 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1567 (lambda (cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1568 (format "%c=%s" (car cur) (nth 3 cur))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1569 nnmairix-interactive-query-parameters ","))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1570
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1571 (defun nnmairix-replace-illegal-chars (header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1572 "Replace illegal characters in HEADER for mairix query."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1573 (when header
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1574 (if (> emacs-major-version 20)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1575 (while (string-match "[^-.@/,& [:alnum:]]" header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1576 (setq header (replace-match "" t t header)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1577 (while (string-match "[[]{}:<>]" header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1578 (setq header (replace-match "" t t header))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1579 (while (string-match "[-& ]" header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1580 (setq header (replace-match "," t t header)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1581 header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1582
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1583 (defun nnmairix-group-toggle-parameter (group parameter description &optional par)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1584 "Toggle on GROUP a certain PARAMETER.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1585 DESCRIPTION will be shown to the user with the activation
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1586 status. If PAR is a positive number, the group parameter will be
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1587 set to t and to nil otherwise."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1588 (let* ((method (gnus-find-method-for-group group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1589 (par (or par
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1590 (not (gnus-group-get-parameter group parameter)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1591 (if (eq (car method) 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1592 (progn
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1593 (when (numberp par)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1594 (setq par (> par 0)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1595 (gnus-group-set-parameter group parameter par)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1596 (if par
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1597 (message "%s activated for group %s" description group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1598 (message "%s deactivated for group %s" description group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1599 t)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1600 (error "This is no nnmairix group")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1601 nil)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1602
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1603 ;; Search for original article helper functions
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1604
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1605 (defun nnmairix-goto-original-article (&optional no-registry)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1606 "Jump to the original group and display article.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1607 The original group of the article is first determined with the
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1608 registry (if enabled). If the registry is not enabled or did not
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1609 find the article or the prefix NO-REGISTRY is non-nil, this
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1610 function will try to determine the original group form the path
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1611 of the mail file. The path is obtained through another mairix
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1612 search in raw mode."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1613 (interactive "P")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1614 (when (not (eq (car gnus-current-select-method) 'nnmairix))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1615 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1616 (if (eq (car method) 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1617 (nnmairix-open-server (nth 1 method))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1618 (error "Not in a nnmairix group"))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1619 (when (not (gnus-buffer-live-p gnus-article-buffer))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1620 (error "No article buffer available"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1621 (let ((server (nth 1 gnus-current-select-method))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1622 mid rval group allgroups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1623 ;; get message id
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1624 (save-excursion
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1625 (set-buffer gnus-article-buffer)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1626 (gnus-summary-toggle-header 1)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1627 (setq mid (message-fetch-field "Message-ID"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1628 ;; first check the registry (if available)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1629 (unless no-registry
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1630 (setq allgroups (nnmairix-determine-original-group-from-registry mid)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1631 (unless (or allgroups
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1632 nnmairix-only-use-registry)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1633 ;; registry was not available or did not find article
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1634 ;; so we search again with mairix in raw mode to get filename
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1635 (setq allgroups
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1636 (nnmairix-determine-original-group-from-path mid server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1637 ;; if available and allowed, add this entry to the registry
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1638 (when (and (not no-registry)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1639 (boundp 'gnus-registry-install)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1640 gnus-registry-install)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1641 (dolist (cur allgroups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1642 (unless (gnus-parameter-registry-ignore cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1643 (gnus-registry-add-group mid cur)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1644 (if (> (length allgroups) 1)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1645 (setq group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1646 (completing-read
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1647 "Message exists in more than one group. Choose: "
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1648 allgroups nil t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1649 (setq group (car allgroups))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1650 (if group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1651 ;; show article in summary buffer
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1652 (nnmairix-show-original-article group mid)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1653 (nnheader-message 3 "Couldn't find original article"))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1654
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1655 (defun nnmairix-determine-original-group-from-registry (mid)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1656 "Try to determinale original group for message-id MID from the registry."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1657 (when (and (boundp 'gnus-registry-install)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1658 gnus-registry-install)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1659 (unless (string-match "^<" mid)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1660 (set mid (concat "<" mid)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1661 (unless (string-match ">$" mid)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1662 (set mid (concat mid ">")))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1663 (gnus-registry-fetch-groups mid)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1664
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1665 (defun nnmairix-determine-original-group-from-path (mid server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1666 "Determine original group(s) for message-id MID from the file path.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1667 The file path is obtained through a mairix search for the id on
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1668 SERVER."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1669 (nnmairix-open-server server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1670 (while (string-match "[<>]" mid)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1671 (setq mid (replace-match "" t t mid)))
103352
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
1672 ;; mairix somehow does not like '$' in message-id
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
1673 (when (string-match "\\$" mid)
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
1674 (setq mid (concat mid "=")))
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
1675 (while (string-match "\\$" mid)
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
1676 (setq mid (replace-match "=," t t mid)))
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1677 (let (allgroups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1678 (if (zerop (nnmairix-call-mairix-binary-raw
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1679 (split-string nnmairix-mairix-command)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1680 (list (concat "m:" mid))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1681 (save-excursion
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1682 (set-buffer nnmairix-mairix-output-buffer)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1683 (goto-char (point-min))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1684 (while (re-search-forward "^/.*$" nil t)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1685 (push (nnmairix-get-group-from-file-path (match-string 0))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1686 allgroups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1687 (forward-line 1)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1688 (error "Mairix could not find original article. See buffer %s for details"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1689 nnmairix-mairix-output-buffer))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1690 allgroups))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1691
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1692 (defun nnmairix-get-group-from-file-path (file)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1693 "Get group by parsing the message location FILE."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1694 (let (path filename serverbase group maildirflag allgroups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1695 (string-match "^\\(.*\\)/\\(.*?\\)$" file)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1696 (setq path (expand-file-name (match-string 1 file)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1697 (setq filename (match-string 2 file))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1698 ;; when we deal with maildir, remove cur/new/tmp from path
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1699 (setq maildirflag (string-match ".+\\..+\\..+" filename))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1700 (when maildirflag
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1701 (setq path
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1702 (replace-regexp-in-string
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1703 ".*\\(/cur\\|/new\\|/tmp\\)$" "" path t t 1)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1704 ;; we first check nnml and nnmaildir servers
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1705 (setq
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1706 group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1707 (catch 'found
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1708 (dolist (cur gnus-opened-servers)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1709 (when (or (and (not maildirflag)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1710 (eq (caar cur) 'nnml))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1711 (and maildirflag
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1712 (eq (caar cur) 'nnmaildir)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1713 ;; get base path from server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1714 (if maildirflag
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1715 (setq serverbase (cadr (assoc 'directory (car cur))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1716 (setq serverbase (cadr (assoc 'nnml-directory (car cur))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1717 (unless serverbase
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1718 (setq serverbase nnml-directory)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1719 (setq serverbase (file-name-as-directory
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1720 (expand-file-name serverbase)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1721 (when (string-match (concat serverbase "\\(.*\\)") path)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1722 ;; looks good - rest of the path should be the group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1723 (setq group (match-string 1 path))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1724 (when (string-match "/$" group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1725 (setq group (replace-match "" t t group)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1726 (unless maildirflag
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1727 ;; for nnml: convert slashes to dots
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1728 (while (string-match "/" group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1729 (setq group (replace-match "." t t group))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1730 (setq group (gnus-group-prefixed-name group (car cur)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1731 ;; check whether this group actually exists
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1732 (when (gnus-group-entry group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1733 (throw 'found group)))))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1734 (unless group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1735 ;; we haven't found it yet --> look for nnimap groups. Assume
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1736 ;; last element of the path is the group. This might fail since
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1737 ;; IMAP servers may present groups to the client in arbitrary
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1738 ;; ways...
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1739 (string-match "^.*/\\.?\\(.*\\)$" path)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1740 (setq group (match-string 1 path))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1741 ;; convert dots to slashes (nested group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1742 (while (string-match "\\." group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1743 (setq group (replace-match "/" t t group)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1744 (dolist (cur gnus-opened-servers)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1745 (when (eq (caar cur) 'nnimap)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1746 (when (gnus-group-entry
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1747 (gnus-group-prefixed-name group (car cur)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1748 (push
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1749 (gnus-group-prefixed-name group (car cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1750 allgroups))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1751 (if (> (length allgroups) 1)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1752 (setq group (completing-read
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1753 "Group %s exists on more than one IMAP server. Choose: "
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1754 allgroups nil t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1755 (setq group (car allgroups))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1756 group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1757
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1758 (defun nnmairix-show-original-article (group mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1759 "Switch to GROUP and display Article with message-id MID."
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1760 (unless (string-match "^<" mid)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1761 (set mid (concat "<" mid)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1762 (unless (string-match ">$" mid)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1763 (set mid (concat mid ">")))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1764 (when (string-match "Summary" (buffer-name (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1765 (gnus-summary-exit))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1766 (pop-to-buffer gnus-group-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1767 (gnus-group-jump-to-group group)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1768 (gnus-summary-read-group group 1 t)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1769 (gnus-summary-refer-article mid)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1770 (gnus-summary-limit-to-headers (format "message-id: %s" mid))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1771 (gnus-summary-select-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1772 ;; Force redisplay
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1773 (gnus-summary-show-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1774 (nnheader-message 5 "Switched to group %s." group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1775
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1776 (defun nnmairix-map-range (func range)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1777 "Map function FUNC on all members of RANGE."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1778 (cond
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1779 ((numberp range)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1780 (funcall func range))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1781 (t
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1782 (mapcar (lambda (cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1783 (cond
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1784 ((listp cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1785 (cons
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1786 (funcall func (car cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1787 (funcall func (cdr cur))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1788 ((numberp cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1789 (funcall func cur))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1790 range))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1791
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1792 (defun nnmairix-check-mairix-version (version &optional server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1793 "Check mairix VERSION on SERVER.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1794 If VERSION is a number: specifies the minimum version.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1795 If VERSION is a string: must be contained in mairix version output."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1796 (unless server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1797 (setq server nnmairix-current-server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1798 (let ((versionstring (cadr (assoc server nnmairix-version-output))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1799 (unless versionstring
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1800 ;; call "mairix -V" to get the version string
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1801 (with-temp-buffer
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1802 (setq versionstring
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1803 (let* ((commandsplit (split-string nnmairix-mairix-command))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1804 (args (append (list (car commandsplit))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1805 `(nil t nil) (cdr commandsplit) '("-V"))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1806 (apply 'call-process args)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1807 (goto-char (point-min))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1808 (re-search-forward "mairix.*")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1809 (match-string 0))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1810 ;; save version string for current session
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1811 (setq nnmairix-version-output
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1812 (append nnmairix-version-output
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1813 (list (list server versionstring)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1814 (cond
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1815 ((stringp version)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1816 (string-match version versionstring))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1817 ((numberp version)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1818 (<= version (string-to-number
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1819 (progn
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1820 (string-match "mairix \\([0-9\\.]+\\)" versionstring)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1821 (match-string 1 versionstring))))))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1822
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1823 ;; ==== Widget stuff
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1824
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1825 (defvar nnmairix-widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1826 (defvar nnmairix-widgets-values nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1827
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1828 (defun nnmairix-widget-search-from-this-article ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1829 "Create mairix query based on current article using graphical widgets."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1830 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1831 (nnmairix-widget-search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1832 (nnmairix-widget-get-values)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1833
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1834 (defun nnmairix-widget-get-values ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1835 "Create values for editable fields from current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1836 (if (not (gnus-buffer-live-p gnus-article-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1837 (error "No article buffer available")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1838 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1839 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1840 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1841 (mapcar
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1842 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1843 (lambda (field)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1844 (list (car (cddr field))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1845 (if (car field)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1846 (nnmairix-replace-illegal-chars
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1847 (gnus-fetch-field (car field)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1848 nil))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1849 nnmairix-widget-fields-list))))
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1850
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1851
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1852 (defun nnmairix-widget-search (&optional mvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1853 "Create mairix query interactively using graphical widgets.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1854 MVALUES may contain values from current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1855 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1856 ;; Select window for mairix customization
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1857 (funcall nnmairix-widget-select-window-function)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1858 ;; generate widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1859 (nnmairix-widget-create-query mvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1860 ;; generate Buttons
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1861 (widget-create 'push-button
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1862 :notify
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1863 (if mvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1864 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1865 (nnmairix-widget-send-query nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1866 t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1867 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1868 (nnmairix-widget-send-query nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1869 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1870 "Send Query")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1871 (widget-insert " ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1872 (widget-create 'push-button
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1873 :notify
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1874 (if mvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1875 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1876 (nnmairix-widget-create-group nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1877 t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1878 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1879 (nnmairix-widget-create-group nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1880 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1881 "Create permanent group")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1882 (widget-insert " ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1883 (widget-create 'push-button
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1884 :notify (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1885 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1886 "Cancel")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1887 (use-local-map widget-keymap)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1888 (widget-setup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1889 (goto-char (point-min)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1890
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1891 (defun nnmairix-widget-send-query (widgets &optional withvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1892 "Send query from WIDGETS to mairix binary.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1893 If WITHVALUES is t, query is based on current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1894 (nnmairix-search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1895 (nnmairix-widget-make-query-from-widgets widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1896 (if withvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1897 (gnus-method-to-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1898 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1899 (car (nnmairix-get-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1900 (if (widget-value (cadr (assoc "Threads" widgets)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1901 t
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1902 -1))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1903 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1904
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1905 (defun nnmairix-widget-create-group (widgets &optional withvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1906 "Create nnmairix group based on current widget values WIDGETS.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1907 If WITHVALUES is t, query is based on current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1908 (let ((group (read-string "Name of the group: ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1909 (when (not (zerop (length group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1910 (nnmairix-create-search-group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1911 (if withvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1912 (gnus-method-to-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1913 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1914 (car (nnmairix-get-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1915 group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1916 (nnmairix-widget-make-query-from-widgets widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1917 (widget-value (cadr (assoc "Threads" widgets))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1918 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1919
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1920
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1921 (defun nnmairix-widget-make-query-from-widgets (widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1922 "Create mairix query from widget values WIDGETS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1923 (let (query temp flag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1924 ;; first we do the editable fields
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1925 (dolist (cur nnmairix-widget-fields-list)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1926 ;; See if checkbox is checked
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1927 (when (widget-value
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1928 (cadr (assoc (concat "c" (car (cddr cur))) widgets)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1929 ;; create query for the field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1930 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1931 (concat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1932 (nth 1 cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1933 ":"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1934 (nnmairix-replace-illegal-chars
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1935 (widget-value
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1936 (cadr (assoc (concat "e" (car (cddr cur))) widgets)))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1937 query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1938 ;; Flags
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1939 (when (member 'flags nnmairix-widget-other)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1940 (setq flag
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1941 (mapconcat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1942 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1943 (lambda (flag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1944 (setq temp
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1945 (widget-value (cadr (assoc (car flag) nnmairix-widgets))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1946 (if (string= "yes" temp)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1947 (cadr flag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1948 (if (string= "no" temp)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1949 (concat "-" (cadr flag))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1950 '(("seen" "s") ("replied" "r") ("flagged" "f")) ""))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1951 (when (not (zerop (length flag)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1952 (push (concat "F:" flag) query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1953 ;; return query string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1954 (mapconcat 'identity query " ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1955
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1956
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1957 (defun nnmairix-widget-create-query (&optional values)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1958 "Create widgets for creating mairix queries.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1959 Fill in VALUES if based on an article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1960 (let (allwidgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1961 (when (get-buffer nnmairix-customize-query-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1962 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1963 (switch-to-buffer nnmairix-customize-query-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1964 (kill-all-local-variables)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1965 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1966 (widget-insert "Specify your query for Mairix (check boxes for activating fields):\n\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1967 (widget-insert "(Whitespaces will be converted to ',' (i.e. AND). Use '/' for OR.)\n\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1968 ; (make-local-variable 'nnmairix-widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1969 (setq nnmairix-widgets (nnmairix-widget-build-editable-fields values))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1970 (when (member 'flags nnmairix-widget-other)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1971 (widget-insert "\nFlags:\n Seen: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1972 (nnmairix-widget-add "seen"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1973 'menu-choice
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1974 :value "ignore"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1975 '(item "yes") '(item "no") '(item "ignore"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1976 (widget-insert " Replied: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1977 (nnmairix-widget-add "replied"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1978 'menu-choice
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1979 :value "ignore"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1980 '(item "yes") '(item "no") '(item "ignore"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1981 (widget-insert " Ticked: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1982 (nnmairix-widget-add "flagged"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1983 'menu-choice
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1984 :value "ignore"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1985 '(item "yes") '(item "no") '(item "ignore")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1986 (when (member 'threads nnmairix-widget-other)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1987 (widget-insert "\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1988 (nnmairix-widget-add "Threads" 'checkbox nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1989 (widget-insert " Show full threads\n\n")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1990
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1991 (defun nnmairix-widget-build-editable-fields (values)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1992 "Build editable field widgets in `nnmairix-widget-fields-list'.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1993 VALUES may contain values for editable fields from current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1994 ;; how can this be done less ugly?
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1995 (let ((ret))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1996 (mapc
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1997 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1998 (lambda (field)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1999 (setq field (car (cddr field)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2000 (setq ret
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2001 (nconc
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2002 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2003 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2004 (concat "c" field)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2005 (widget-create 'checkbox
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2006 :tag field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2007 :notify (lambda (widget &rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2008 (nnmairix-widget-toggle-activate widget))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2009 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2010 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2011 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2012 (concat "e" field)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2013 (widget-create 'editable-field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2014 :size 60
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2015 :format (concat " " field ":"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2016 (make-string (- 11 (length field)) ?\ )
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2017 "%v")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2018 :value (or (cadr (assoc field values)) ""))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2019 ret))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2020 (widget-insert "\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2021 ;; Deactivate editable field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2022 (widget-apply (cadr (nth 1 ret)) :deactivate)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2023 nnmairix-widget-fields-list)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2024 ret))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2025
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2026 (defun nnmairix-widget-add (name &rest args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2027 "Add a widget NAME with optional ARGS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2028 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2029 (list name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2030 (apply 'widget-create args))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2031 nnmairix-widgets))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2032
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2033 (defun nnmairix-widget-toggle-activate (widget)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
2034 "Toggle activation status of WIDGET depending on corresponding checkbox value."
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2035 (let ((field (widget-get widget :tag)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2036 (if (widget-value widget)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2037 (widget-apply
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2038 (cadr (assoc (concat "e" field) nnmairix-widgets))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2039 :activate)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2040 (widget-apply
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2041 (cadr (assoc (concat "e" field) nnmairix-widgets))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2042 :deactivate)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2043 (widget-setup))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2044
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2045 (provide 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2046
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2047 ;; arch-tag: bb187498-b229-4a55-8c07-6d3f80713e94
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2048 ;;; nnmairix.el ends here