annotate lisp/gnus/nnmairix.el @ 110615:84a76c5e1b1c

Merge changes made in Gnus trunk. sieve-manage.el (sieve-manage-default-stream): Make default stream customizable. nnimap.el (nnimap-request-accept-article): Send a "." at the end, which may or may not help. nnimap.el (nnimap-open-connection): Have the `network' nnimap connection use STARTTLS opportunistically. gnus-sum.el (gnus-summary-insert-new-articles): Copy the old-high watermark so that nothing alters it while scanning for new messages. nnimap.el (nnimap-request-accept-article): Remove the "." at the end, since some servers don't like it. nnimap.el (nnimap-open-connection): Forget credentials if the server says the password was wrong. nnimap.el (nnimap-parse-line): Protect against invalid data. gnus-art.el, gnus-sum.el, nnimap.el: Allow setting the partial fetch per server instead of globally. message.el (message-cite-prefix-regexp): Revert last edit. nnmairix.el: Make it work with latest changes in nnimap. gnus-sum.el (gnus-summary-move-article): Don't alter gnus-newsgroup-active. gnus-sum.el (gnus-summary-exit): Kill the article buffer later, so that you don't get flashes of other buffers. nnimap.el: Fix up partial nnimap fetching. gnus-sum.el: Rework the `/ N' based on the new gnus-newsgroup-highest variable.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Mon, 27 Sep 2010 23:07:47 +0000
parents 4d2f8b81bb01
children 2b8ece636433
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
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 103352
diff changeset
3 ;; Copyright (C) 2007, 2008, 2009, 2010 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
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110410
diff changeset
427 (deffoo nnmairix-request-group (group &optional server fast info)
92255
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
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
448 (with-current-buffer nntp-server-buffer
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
449 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
450 (insert (concat "211 0 1 0 " group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
451 t))
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 ;; For maildir++ folders: create a hidden directory (prepend dot)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
454 (setq mfolder (if (and nnmairix-hidden-folders
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
455 (not (string-match "^\\." folder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
456 (concat "." folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
457 folder))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
458 ;; For nnml and nnmaildir, precede mfolder with directory where mail
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
459 ;; 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
460 ;; in .mairixrc.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
461 (when (eq nnmairix-backend 'nnml)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
462 (setq folderpath (cadr (assoc 'nnml-directory backendmethod)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
463 ;; if nnml-directory is not explicitly set, use global value
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
464 (when (not folderpath)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
465 (setq folderpath nnml-directory)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
466 (when (eq nnmairix-backend 'nnmaildir)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
467 (setq folderpath
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
468 (cadr (assoc 'directory backendmethod))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
469 (when folderpath
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
470 (setq mfolder
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
471 (concat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
472 (file-name-as-directory
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
473 (expand-file-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
474 folderpath))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
475 mfolder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
476 ;; If (not fast), call Mairix binary
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
477 ;; recreate underlying folder on the back end
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
478 (setq rval
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
479 (if (and fast allowfast)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
480 0
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
481 (nnmairix-call-mairix-binary
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
482 (split-string nnmairix-mairix-command)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
483 mfolder query threads)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
484 ;; Check return value
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
485 (cond
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
486 ((zerop rval) ; call was succesful
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
487 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
488 "open-server" nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
489 ;; If we're dealing with nnml, rename files
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
490 ;; consecutively and make new active file for this
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
491 ;; group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
492 (when (eq nnmairix-backend 'nnml)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
493 (when nnmairix-rename-files-for-nnml
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
494 (nnmairix-rename-files-consecutively mfolder))
103352
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
495 (nnml-generate-nov-databases-directory mfolder nil t))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
496 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
497 "request-scan" folder nnmairix-backend-server)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
498 (if (and fast allowfast)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
499 t
92359
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
500 (nnmairix-request-group-with-article-number-correction
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
501 folder qualgroup)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
502 ((and (= rval 1)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
503 (with-current-buffer nnmairix-mairix-output-buffer
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
504 (goto-char (point-min))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
505 (looking-at "^Matched 0 messages")))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
506 ;; No messages found -> return empty group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
507 (nnheader-message 5 "Mairix: No matches found.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
508 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
509 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
510 (insert (concat "211 0 1 0 " group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
511 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
512 ;; Everything else is an error
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
513 (t
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
514 (nnheader-report
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
515 'nnmairix "Error running marix. See buffer %s for details"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
516 nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
517 nil))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
518
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 (deffoo nnmairix-request-create-group (group &optional server args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
521 (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
522 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
523 (exist t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
524 (count 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
525 groupname info)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
526 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
527 (gnus-group-add-parameter qualgroup '(query . nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
528 (gnus-group-add-parameter qualgroup '(threads . nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
529 (while exist
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
530 (setq count (1+ count))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
531 (setq groupname (format "%s-%s-%s" nnmairix-group-prefix group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
532 (number-to-string count)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
533 (setq exist (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
534 "request-group" groupname nnmairix-backend-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
535 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
536 "request-create-group" groupname nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
537 (gnus-group-add-parameter qualgroup '(folder . nil))
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
538 (when nnmairix-allowfast-default
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
539 (gnus-group-add-parameter qualgroup '(allow-fast . t)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
540 (gnus-group-set-parameter qualgroup 'folder groupname))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
541 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
542
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 (deffoo nnmairix-retrieve-headers (articles group &optional server fetch-old)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
545 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
546 (let* ((folder (nnmairix-get-backend-folder group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
547 (corr (nnmairix-get-numcorr group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
548 (numcorr 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
549 rval)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
550 (when (and corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
551 (not (zerop (cadr corr)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
552 (numberp (car articles)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
553 (setq numcorr (cadr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
554 (setq articles
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
555 (mapcar
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
556 (lambda (arg) (- arg numcorr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
557 articles)))
110111
5b9f64b04a04 Delete all trailing white space.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
558 (setq rval
103352
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
559 (if (eq nnmairix-backend 'nnimap)
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
560 (let ((gnus-nov-is-evil t))
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
561 (nnmairix-call-backend
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
562 "retrieve-headers" articles folder nnmairix-backend-server fetch-old))
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
563 (nnmairix-call-backend
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
564 "retrieve-headers" articles folder nnmairix-backend-server fetch-old)))
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
565 (nnmairix-replace-group-and-numbers articles folder group numcorr rval)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
566 rval))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
567
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
568 (deffoo nnmairix-request-article (article &optional group server to-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
569 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
570 (let ((folder (nnmairix-get-backend-folder group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
571 (corr (nnmairix-get-numcorr group server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
572 (when (and
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
573 (numberp article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
574 corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
575 (not (zerop (cadr corr))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
576 (setq article (- article (cadr corr))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
577 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
578 "request-article" article folder nnmairix-backend-server to-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
579 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
580
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
581 (deffoo nnmairix-request-list (&optional server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
582 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
583 (if (nnmairix-call-backend "request-list" nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
584 (let (cpoint cur qualgroup folder)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
585 (with-current-buffer nntp-server-buffer
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
586 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
587 (setq cpoint (point))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
588 (while (re-search-forward nnmairix-group-regexp (point-max) t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
589 (setq cur (match-string 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
590 qualgroup (gnus-group-prefixed-name cur
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
591 (list 'nnmairix server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
592 (if (and (gnus-group-entry qualgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
593 (string= (match-string 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
594 (gnus-group-get-parameter qualgroup 'folder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
595 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
596 (replace-match cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
597 (delete-region cpoint (point-at-bol))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
598 (forward-line)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
599 (setq cpoint (point)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
600 (forward-line)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
601 (delete-region cpoint (point-max)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
602 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
603 nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
604
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
605 ;; Silence byte-compiler.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
606 (defvar gnus-registry-install)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
607 (autoload 'gnus-registry-fetch-group "gnus-registry")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
608 (autoload 'gnus-registry-fetch-groups "gnus-registry")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
609 (autoload 'gnus-registry-add-group "gnus-registry")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
610
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
611 (deffoo nnmairix-request-set-mark (group actions &optional server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
612 (when server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
613 (nnmairix-open-server server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
614 (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
615 (propmarks (gnus-group-get-parameter qualgroup 'propmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
616 (propto (gnus-group-get-parameter qualgroup 'propto t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
617 (corr (nnmairix-get-numcorr group server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
618 (folder (nnmairix-get-backend-folder group server)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
619 (save-excursion
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
620 (dolist (cur actions)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
621 (let ((type (nth 1 cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
622 (cmdmarks (nth 2 cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
623 (range (gnus-uncompress-range (nth 0 cur)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
624 mid ogroup number method temp)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
625 (when (and corr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
626 (not (zerop (cadr corr))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
627 (setq range (mapcar (lambda (arg)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
628 (- arg (cadr corr)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
629 range)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
630 (when propmarks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
631 (nnheader-message 7 "nnmairix: Setting marks...")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
632 (dolist (article range)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
633 ;; get article (header) and extract message id
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
634 ;; 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
635 (catch 'problem
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
636 (nnmairix-call-backend "open-server" nnmairix-backend-server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
637 (unless (gnus-request-head
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
638 article
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
639 (gnus-group-prefixed-name
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
640 folder
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
641 (list nnmairix-backend nnmairix-backend-server)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
642 (nnheader-message
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
643 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
644 article)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
645 (throw 'problem nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
646 (set-buffer nntp-server-buffer)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
647 (goto-char (point-min))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
648 (let ((case-fold-search t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
649 (re-search-forward "^message-id:.*\\(<.+>\\)" nil t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
650 (setq mid (match-string 1))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
651 (unless mid
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
652 (nnheader-message
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
653 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
654 article)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
655 (throw 'problem nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
656 ;; get original group. First try registry, then file path
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
657 (setq ogroup
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
658 (nnmairix-determine-original-group-from-registry mid))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
659 (unless (or ogroup
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
660 nnmairix-only-use-registry)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
661 (setq ogroup
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
662 (nnmairix-determine-original-group-from-path
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
663 mid nnmairix-current-server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
664 ;; 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
665 (when (and (boundp 'gnus-registry-install)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
666 gnus-registry-install)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
667 (dolist (cur ogroup)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
668 (unless (gnus-parameter-registry-ignore cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
669 (gnus-registry-add-group mid cur)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
670 (unless ogroup
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
671 (nnheader-message
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
672 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
673 (throw 'problem nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
674 ;; store original groups with mid's. We cannot get
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
675 ;; the article number immediately since this would
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
676 ;; generate problems with maildir (articles might
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
677 ;; get moved from /new to /cur and further marks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
678 ;; could then not be set)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
679 (dolist (cur ogroup)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
680 (setq temp (assoc cur
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
681 nnmairix-marks-cache))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
682 (if temp
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
683 (nconc temp (list (list mid type cmdmarks)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
684 (push (list cur (list mid type cmdmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
685 nnmairix-marks-cache)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
686 (nnheader-message 7 "nnmairix: Setting marks... done")))))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
687
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
688 (deffoo nnmairix-close-group (group &optional server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
689 (when server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
690 (nnmairix-open-server server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
691 (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
692 (propmarks (gnus-group-get-parameter qualgroup 'propmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
693 method)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
694 (when (and propmarks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
695 nnmairix-marks-cache)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
696 (when (or (eq nnmairix-propagate-marks-upon-close t)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
697 (and (eq nnmairix-propagate-marks-upon-close 'ask)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
698 (y-or-n-p "Propagate marks to original articles? ")))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
699 (with-current-buffer gnus-group-buffer
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
700 (nnmairix-propagate-marks)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
701 ;; update mairix group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
702 (gnus-group-jump-to-group qualgroup)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
703 (gnus-group-get-new-news-this-group))))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
704
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
705 (autoload 'nnimap-request-update-info-internal "nnimap")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
706
110516
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110422
diff changeset
707 (deffoo nnmairix-request-marks (group info &optional server)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
708 ;; propagate info from underlying IMAP folder to nnmairix group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
709 ;; This is currently experimental and must be explicitly activated
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
710 ;; with nnmairix-propagate-marks-to-nnmairix-group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
711 (when server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
712 (nnmairix-open-server server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
713 (let* ((qualgroup (gnus-group-prefixed-name
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
714 group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
715 (list 'nnmairix nnmairix-current-server)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
716 (readmarks (gnus-group-get-parameter qualgroup 'readmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
717 (propmarks (gnus-group-get-parameter qualgroup 'propmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
718 (folder (nnmairix-get-backend-folder group server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
719 (corr (nnmairix-get-numcorr group server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
720 (docorr (and corr (not (zerop (cadr corr)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
721 (folderinfo `(,group 1 ((1 . 1))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
722 readrange marks)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
723 (when (and propmarks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
724 nnmairix-propagate-marks-to-nnmairix-groups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
725 ;; 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
726 (if (eq nnmairix-backend 'nnimap)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
727 (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
728 (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
729 ;; set range of read articles
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
730 (gnus-info-set-read
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
731 info
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
732 (if docorr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
733 (nnmairix-map-range
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
734 `(lambda (x) (+ x ,(cadr corr)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
735 (gnus-info-read folderinfo))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
736 (gnus-info-read folderinfo)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
737 ;; set other marks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
738 (gnus-info-set-marks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
739 info
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
740 (if docorr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
741 (mapcar (lambda (cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
742 (cons
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
743 (car cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
744 (nnmairix-map-range
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
745 `(lambda (x) (+ x ,(cadr corr)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
746 (list (cadr cur)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
747 (gnus-info-marks folderinfo))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
748 (gnus-info-marks folderinfo))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
749 (when (eq readmarks 'unread)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
750 (gnus-info-set-read info nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
751 (when (eq readmarks 'read)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
752 (gnus-info-set-read info (gnus-active qualgroup))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
753 t)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
754
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
755 (nnoo-define-skeleton nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
756
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
757
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
758 ;;; === Interactive functions
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
759
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
760 (defun nnmairix-create-search-group (server group query threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
761 "Create on SERVER nnmairix search group GROUP with QUERY.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
762 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
763 called interactively, user will be asked for parameters."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
764 (interactive
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
765 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
766 (gnus-server-to-method (car (nnmairix-get-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
767 (read-string "Group name: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
768 (read-string "Query: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
769 (y-or-n-p "Include threads? ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
770 (when (and (stringp query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
771 (string-match "\\s-" query))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
772 (setq query (split-string query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
773 (when (not (listp query))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
774 (setq query (list query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
775 (when (and server group query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
776 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
777 (let ((groupname (gnus-group-prefixed-name group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
778 info)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
779 (set-buffer gnus-group-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
780 (gnus-group-make-group group server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
781 (gnus-group-set-parameter groupname 'query query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
782 (gnus-group-set-parameter groupname 'threads threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
783 (nnmairix-update-and-clear-marks groupname)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
784
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
785 (defun nnmairix-search-interactive ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
786 "Create mairix search interactively with the minibuffer."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
787 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
788 (let ((char-header nnmairix-interactive-query-parameters)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
789 header finished query achar)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
790 (while (not finished)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
791 (while (not achar)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
792 (message "Query (%s): " (nnmairix-create-message-line-for-search))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
793 (setq achar (read-char))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
794 (when (not (assoc achar char-header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
795 (setq achar nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
796 (setq header (read-string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
797 (concat "Match " (nth 3 (assoc achar char-header)) " on: ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
798 (push (concat (nth 2 (assoc achar char-header)) ":" header) query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
799 (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
800 achar nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
801 (nnmairix-search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
802 (mapconcat 'identity query " ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
803 (car (nnmairix-get-server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
804 (y-or-n-p "Include whole threads? "))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
805
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
806 (defun nnmairix-create-search-group-from-message ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
807 "Interactively create search group with query based on current message."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
808 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
809 (let ((char-header nnmairix-interactive-query-parameters)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
810 (server (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
811 query achar header finished group threads cq)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
812 (when (or (not (gnus-buffer-live-p gnus-article-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
813 (not (gnus-buffer-live-p gnus-summary-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
814 (error "No article or summary buffer"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
815 (when (not server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
816 (error "No nnmairix server found for back end %s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
817 (symbol-name (car gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
818 (nth 1 gnus-current-select-method)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
819 (while (not finished)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
820 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
821 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
822 (while (not achar)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
823 (message "Query (%s): " (nnmairix-create-message-line-for-search))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
824 (setq achar (read-char))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
825 (when (not (assoc achar char-header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
826 (setq achar nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
827 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
828 (setq header nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
829 (when (setq cq (nth 1 (assoc achar char-header)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
830 (setq header
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
831 (nnmairix-replace-illegal-chars
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
832 (gnus-fetch-field (nth 1 (assoc achar char-header))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
833 (setq header (read-string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
834 (concat "Match " (nth 3 (assoc achar char-header)) " on: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
835 header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
836 (push (concat (nth 2 (assoc achar char-header)) ":" header) query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
837 (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
838 achar nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
839 (setq threads (y-or-n-p "Include whole threads? "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
840 (setq group (read-string "Group name: "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
841 (set-buffer gnus-summary-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
842 (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
843 (gnus-method-to-server server) (mapconcat 'identity query " "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
844 (nnmairix-create-search-group server group query threads)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
845
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
846 (defun nnmairix-create-server-and-default-group ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
847 "Interactively create new nnmairix server with default search group.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
848 All necessary information will be queried from the user."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
849 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
850 (let* ((name (read-string "Name of the mairix server: "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
851 (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
852 (nnmairix-get-valid-servers) nil 1))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
853 (mairix (read-string "Command to call mairix: " "mairix"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
854 (defaultgroup (read-string "Default search group: "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
855 (backend (symbol-name (car (gnus-server-to-method server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
856 (servername (nth 1 (gnus-server-to-method server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
857 (hidden (and (string-match "^nn\\(imap\\|maildir\\)$" backend)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
858 (y-or-n-p
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
859 "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
860 create)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
861
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
862 (apply (intern (format "%s-%s" backend "open-server"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
863 (list servername))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
864
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
865 (when (and hidden
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
866 (string-match "^\\." defaultgroup))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
867 (setq defaultgroup (substring defaultgroup 1)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
868 ;; Create default search group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
869 (gnus-group-make-group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
870 defaultgroup (list 'nnmairix name (list 'nnmairix-backend (intern backend))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
871 (list 'nnmairix-backend-server servername)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
872 (list 'nnmairix-mairix-command mairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
873 (list 'nnmairix-hidden-folders hidden)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
874 (list 'nnmairix-default-group defaultgroup)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
875
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
876 (defun nnmairix-group-change-query-this-group (&optional query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
877 "Set QUERY for group under cursor."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
878 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
879 (let* ((group (gnus-group-group-name))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
880 (method (gnus-find-method-for-group group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
881 (oldquery (gnus-group-get-parameter group 'query t)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
882 (if (eq (car method) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
883 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
884 (when (listp oldquery)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
885 (setq oldquery (mapconcat 'identity oldquery " ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
886 (setq query (or query
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
887 (read-string "New query: " oldquery)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
888 (when (stringp query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
889 (setq query (split-string query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
890 (when query
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
891 (gnus-group-set-parameter group 'query query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
892 (nnmairix-update-and-clear-marks group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
893 (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
894
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
895
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
896 (defun nnmairix-group-toggle-threads-this-group (&optional threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
897 "Toggle threads parameter for this group.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
898 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
899 If THREADS is a negative number, set it to nil."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
900 (interactive)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
901 (let ((group (gnus-group-group-name)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
902 (when (nnmairix-group-toggle-parameter
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
903 group 'threads "Threads" threads)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
904 (nnmairix-update-and-clear-marks group))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
905
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
906 (defun nnmairix-group-toggle-propmarks-this-group (&optional propmarks)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
907 "Toggle marks propagation for this group.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
908 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
909 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
910 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
911 (unless (nnmairix-check-mairix-version "maildirpatch")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
912 (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
913 (let ((group (gnus-group-group-name)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
914 (when (or (not (string= (gnus-group-short-name group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
915 (cadr (assoc 'nnmairix-default-group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
916 (gnus-find-method-for-group group)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
917 (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
918 search group. Are you sure? "))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
919 (nnmairix-group-toggle-parameter
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
920 group 'propmarks "Marks propagation" propmarks))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
921
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
922 (defun nnmairix-group-toggle-allowfast-this-group (&optional allowfast)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
923 "Toggle fast entering for this group.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
924 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
925 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
926 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
927 (nnmairix-group-toggle-parameter
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
928 (gnus-group-group-name) 'allow-fast "Fast entering" allowfast))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
929
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
930
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
931 (defun nnmairix-group-toggle-readmarks-this-group (&optional readmarks)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
932 "Toggle read/unread marks for this group.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
933 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
934 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
935 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
936 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
937 (let* ((group (gnus-group-group-name))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
938 (method (gnus-find-method-for-group group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
939 (readmarks (or readmarks
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
940 (gnus-group-get-parameter group 'readmarks))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
941 (if (eq (car method) 'nnmairix)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
942 (cond
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
943 ((or (and (numberp readmarks) (< readmarks 0))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
944 (eq readmarks 'read))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
945 (gnus-group-set-parameter group 'readmarks 'unread)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
946 (nnheader-message 3 "Articles in %s always unread." group))
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 (not readmarks))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
949 (gnus-group-set-parameter group 'readmarks 'read)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
950 (nnheader-message 3 "Articles in %s always read." group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
951 (t
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
952 (gnus-group-set-parameter group 'readmarks nil)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
953 (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
954 (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
955
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
956
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
957 (defun nnmairix-search (query &optional server threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
958 "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
959
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
960 Default search group is automatically entered and results are shown.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
961 If THREADS is t, enable threads.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
962 If THREADS is a negative number, disable threads.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
963 Otherwise, leave threads parameter as it is."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
964 (interactive (list (read-string "Query: ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
965 (when (not server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
966 (setq server (car (nnmairix-get-server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
967 (if (not server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
968 (error "No opened nnmairix server found")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
969 (setq server (gnus-server-to-method server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
970 (nnmairix-open-server (nth 1 server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
971 (let* ((qualgroup (gnus-group-prefixed-name nnmairix-default-group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
972 (list 'nnmairix (nth 1 server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
973 (set-buffer gnus-group-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
974 (when (stringp query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
975 (setq query (split-string query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
976 (gnus-group-set-parameter qualgroup 'query query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
977 (if (symbolp threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
978 (when (eq threads 't)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
979 (gnus-group-set-parameter qualgroup 'threads t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
980 (when (< threads 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
981 (gnus-group-set-parameter qualgroup 'threads nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
982 (nnmairix-update-and-clear-marks qualgroup)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
983 (unless (equal (gnus-active qualgroup) '(1 . 0))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
984 (gnus-group-read-group nil t qualgroup))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
985
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
986 (defun nnmairix-search-thread-this-article ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
987 "Search thread for the current article.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
988 This is effectively a shortcut for calling `nnmairix-search'
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
989 with m:msgid of the current article and enabled threads."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
990 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
991 (let* ((server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
992 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
993 mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
994 (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
995 (if (gnus-buffer-live-p gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
996 (progn
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
997 (with-current-buffer gnus-article-buffer
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
998 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
999 (setq mid (message-fetch-field "Message-ID")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1000 (while (string-match "[<>]" mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1001 (setq mid (replace-match "" t t mid)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1002 (nnmairix-search (concat "m:" mid) server t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1003 (message "No article buffer."))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1004 (error "No nnmairix server found for back end %s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1005 (symbol-name (car gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1006 (nth 1 gnus-current-select-method)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1007
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1008 (defun nnmairix-search-from-this-article ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1009 "Search messages from sender of the current article.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1010 This is effectively a shortcut for calling `nnmairix-search' with
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1011 f:current_from."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1012 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1013 (let* ((server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1014 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1015 from)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1016 (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1017 (if (gnus-buffer-live-p gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1018 (progn
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
1019 (with-current-buffer gnus-article-buffer
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1020 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1021 (setq from (cadr (gnus-extract-address-components
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1022 (gnus-fetch-field "From"))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1023 (nnmairix-search (concat "f:" from) server -1)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1024 (message "No article buffer."))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1025 (error "No nnmairix server found for back end %s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1026 (symbol-name (car gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1027 (nth 1 gnus-current-select-method)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1028
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1029
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1030 (defun nnmairix-purge-old-groups (&optional dontask server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1031 "Delete mairix search groups which are no longer used.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1032
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1033 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
1034 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
1035 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
1036 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1037 (let ((server (or server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1038 (gnus-server-to-method (car (nnmairix-get-server))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1039 (if (nnmairix-open-server (nth 1 server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1040 (when (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1041 "request-list" nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1042 (let (cur qualgroup folder)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
1043 (with-current-buffer nntp-server-buffer
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1044 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1045 (while (re-search-forward nnmairix-group-regexp (point-max) t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1046 (setq cur (match-string 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1047 qualgroup (gnus-group-prefixed-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1048 (match-string 1) server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1049 (when (not (and (gnus-group-entry qualgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1050 (string= cur
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1051 (gnus-group-get-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1052 qualgroup 'folder))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1053 (when (or dontask
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1054 (y-or-n-p
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1055 (concat "Delete group " cur
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1056 " on server " nnmairix-backend-server "? ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1057 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1058 "request-delete-group" cur t nnmairix-backend-server)))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1059 (message "Couldn't open server %s" (nth 1 server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1060
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1061
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1062 (defun nnmairix-update-database (&optional servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1063 "Call mairix for updating the database for SERVERS.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1064
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1065 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
1066 will be called asynchronously unless
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1067 `nnmairix-mairix-synchronous-update' is t. Mairix will be called
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1068 with `nnmairix-mairix-update-options'."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1069 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1070 (let ((servers (or servers
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1071 (nnmairix-get-nnmairix-servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1072 args cur commandsplit)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1073 (while servers
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1074 (setq cur (car (pop servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1075 (nnmairix-open-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1076 (nth 1 (gnus-server-to-method cur)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1077 (setq commandsplit (split-string nnmairix-mairix-command))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1078 (nnheader-message 7 "Updating mairix database for %s..." cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1079 (if nnmairix-mairix-synchronous-update
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1080 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1081 (setq args (append (list (car commandsplit) nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1082 (get-buffer nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1083 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1084 (if (> (length commandsplit) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1085 (setq args (append args (cdr commandsplit) nnmairix-mairix-update-options))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1086 (setq args (append args nnmairix-mairix-update-options)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1087 (apply 'call-process args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1088 (nnheader-message 7 "Updating mairix database for %s... done" cur))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1089 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1090 (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
1091 (car commandsplit))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1092 (if (> (length commandsplit) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1093 (setq args (append args (cdr commandsplit) nnmairix-mairix-update-options))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1094 (setq args (append args nnmairix-mairix-update-options)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1095 (set-process-sentinel (apply 'start-process args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1096 'nnmairix-sentinel-mairix-update-finished))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1097
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1098 (defun nnmairix-group-delete-recreate-this-group ()
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1099 "Deletes and recreates group on the back end.
106876
ad7558737bc7 Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 106815
diff changeset
1100 You can use this function on nnmairix groups which continuously
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1101 show wrong article counts."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1102 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1103 (let* ((group (gnus-group-group-name))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1104 (method (gnus-find-method-for-group group)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1105 (unless (eq (car method) 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1106 (error "This is not a nnmairix group"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1107 (when (y-or-n-p
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1108 (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
1109 (nnmairix-delete-recreate-group group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1110 (gnus-group-get-new-news-this-group))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1111
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1112 (defun nnmairix-propagate-marks (&optional server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1113 "Propagate marks from nnmairix group to original articles.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1114 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
1115 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
1116 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1117 (if server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1118 (nnmairix-open-server server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1119 (unless (eq (car gnus-current-select-method) 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1120 (if nnmairix-current-server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1121 (nnmairix-open-server nnmairix-current-server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1122 (error "No opened nnmairix server"))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1123 (if nnmairix-marks-cache
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1124 (let (number ogroup number-cache method mid-marks temp)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1125 ;; first we get the article numbers
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1126 (catch 'problem
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1127 (while (setq ogroup (pop nnmairix-marks-cache))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1128 (while (setq mid-marks (pop (cdr ogroup)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1129 (setq number
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1130 (cdr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1131 (gnus-request-head (car mid-marks) (car ogroup))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1132 (unless number
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1133 (nnheader-message
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1134 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
1135 (car mid-marks) (car ogroup))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1136 (throw 'problem nil))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1137 (setq temp (assoc (car ogroup) number-cache))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1138 (if temp
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1139 (catch 'done
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1140 (dolist (cur (cdr temp))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1141 (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
1142 (nconc (car cur) (list number))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1143 (throw 'done nil)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1144 (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
1145 (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
1146 number-cache)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1147 ;; now we set the marks
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
1148 (with-current-buffer gnus-group-buffer
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1149 (nnheader-message 5 "nnmairix: Propagating marks...")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1150 (dolist (cur number-cache)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1151 (setq method (gnus-find-method-for-group (car cur)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1152 (apply (intern (format "%s-%s"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1153 (symbol-name (car method))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1154 "request-set-mark"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1155 (gnus-group-short-name (car cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1156 (cdr cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1157 (list (nth 1 method)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1158 (gnus-group-jump-to-group (car cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1159 (gnus-group-get-new-news-this-group)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1160 (nnheader-message 5 "nnmairix: Propagating marks... done"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1161 (nnheader-message 3 "No marks to propagate.")))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1162
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1163 (defun nnmairix-update-groups (servername &optional skipdefault updatedb)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1164 "Update all search groups on SERVERNAME.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1165 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
1166 updated.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1167 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
1168 (interactive (list (completing-read "Update groups on server: "
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1169 (nnmairix-get-nnmairix-servers))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1170 (save-excursion
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1171 (when (string-match ".*:\\(.*\\)" servername)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1172 (setq servername (match-string 1 servername)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1173 (if (not (assoc (format "nnmairix:%s" servername)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1174 (nnmairix-get-nnmairix-servers)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1175 (nnheader-message 3 "Server %s not opened" servername)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1176 (when updatedb
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1177 (let ((nnmairix-mairix-synchronous-update t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1178 (nnmairix-update-database
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1179 (list (list (format "nnmairix:%s" servername))))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1180 (let ((groups (nnmairix-get-groups-from-server servername))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1181 default)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1182 (when skipdefault
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1183 (setq default
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1184 (format "nnmairix+%s:%s"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1185 servername
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1186 (cadr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1187 (assoc 'nnmairix-default-group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1188 (gnus-server-to-method
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1189 (format "nnmairix:%s" servername)))))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1190 (dolist (cur groups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1191 (unless (and skipdefault
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1192 (string= (car cur) default))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1193 (gnus-group-jump-to-group (car cur))
103352
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
1194 (gnus-group-mark-group 1)))
827a8db0b5ad Synch with Gnus trunk:
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100908
diff changeset
1195 (gnus-group-get-new-news-this-group)))))
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1196
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1197 (defun nnmairix-remove-tick-mark-original-article ()
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1198 "Remove tick mark from original article.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1199 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
1200 (interactive)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1201 (unless (eq (car gnus-current-select-method) 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1202 (error "Not in a nnmairix group"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1203 (save-excursion
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1204 (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
1205 groups cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1206 (when mid
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1207 (setq groups (nnmairix-determine-original-group-from-registry mid))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1208 (unless (or groups
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1209 nnmairix-only-use-registry)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1210 (setq groups
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1211 (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
1212 (unless groups
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1213 (error "Couldn't find original article"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1214 (dolist (cur groups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1215 (push `(,cur (,mid del (tick))) nnmairix-marks-cache))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1216 (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
1217
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1218 ;;; ==== Helper functions
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1219
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1220 (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
1221 "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
1222 (save-excursion
92359
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
1223 (nnmairix-call-backend "request-group" folder nnmairix-backend-server)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1224 (set-buffer nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1225 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1226 (re-search-forward "^Matched.*messages")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1227 (nnheader-message 7 (match-string 0))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1228 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1229 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1230 (let ((status (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1231 (total (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1232 (low (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1233 (high (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1234 (corr (gnus-group-get-parameter qualgroup 'numcorr t)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1235 (if (= status 211)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1236 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1237 ;; Article number correction
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1238 (if (and corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1239 (> (+ (car (cddr corr)) high) 0))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1240 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1241 (when (car corr) ;Group has changed
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1242 (setq corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1243 (list nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1244 (car (cddr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1245 (+ (car (cddr corr)) high)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1246 (gnus-group-set-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1247 qualgroup 'numcorr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1248 (setq low (+ low (cadr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1249 high (+ high (cadr corr))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1250 (when (member nnmairix-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1251 nnmairix-delete-and-create-on-change)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1252 (gnus-group-set-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1253 qualgroup 'numcorr (list nil 0 high))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1254 (erase-buffer)
92260
261f98568bde (nnmairix-request-group): Bind nnmairix-fast and nnmairix-group around
Glenn Morris <rgm@gnu.org>
parents: 92259
diff changeset
1255 (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
1256 (gnus-group-real-name qualgroup)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1257 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1258 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1259 (nnheader-report
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1260 'nnmairix "Error calling back end on group %s" folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1261 nil)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1262
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1263 (defun nnmairix-call-mairix-binary (command folder searchquery threads)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1264 "Call mairix binary with COMMAND, using FOLDER and SEARCHQUERY.
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1265 If THREADS is non-nil, enable full threads."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1266 (let ((args (cons (car command) '(nil t nil))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
1267 (with-current-buffer
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
1268 (get-buffer-create nnmairix-mairix-output-buffer)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1269 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1270 (when (> (length command) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1271 (setq args (append args (cdr command))))
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1272 (when nnmairix-mairix-search-options
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1273 (setq args (append args nnmairix-mairix-search-options)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1274 ;; 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
1275 (when (nnmairix-check-mairix-version "maildirpatch")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1276 (setq args (append args '("-c"))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1277 (when threads
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1278 (setq args (append args '("-t"))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1279 (apply 'call-process
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1280 (append args (list "-o" folder) searchquery)))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1281
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1282 (defun nnmairix-call-mairix-binary-raw (command query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1283 "Call mairix binary with COMMAND and QUERY in raw mode."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1284 (let ((args (cons (car command) '(nil t nil))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
1285 (with-current-buffer
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
1286 (get-buffer-create nnmairix-mairix-output-buffer)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1287 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1288 (when (> (length command) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1289 (setq args (append args (cdr command))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1290 (setq args (append args '("-r")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1291 (apply 'call-process
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1292 (append args query)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1293
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1294 (defun nnmairix-get-server ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1295 "If there exists just one nnmairix server, return its value.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1296 Otherwise, ask user for server."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1297 (let ((openedserver (nnmairix-get-nnmairix-servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1298 (when (not openedserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1299 (error "No opened nnmairix server found"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1300 (if (> (length openedserver) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1301 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1302 (while
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1303 (equal '("")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1304 (setq nnmairix-last-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1305 (list (completing-read "Server: " openedserver nil 1
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1306 (or nnmairix-last-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1307 "nnmairix:"))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1308 nnmairix-last-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1309 (car openedserver))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1310
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1311 (defun nnmairix-get-nnmairix-servers (&optional all)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1312 "Return available nnmairix servers.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1313 If ALL is t, return also the unopened/failed ones."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1314 (let ((alist gnus-opened-servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1315 server openedserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1316 (while alist
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1317 (setq server (pop alist))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1318 (when (and server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1319 (or all
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1320 (eq (cadr server) 'ok))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1321 (eq (caar server) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1322 (not (member (car server) gnus-ephemeral-servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1323 (setq server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1324 (concat (symbol-name (caar server)) ":" (nth 1 (car server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1325 (push (list server) openedserver)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1326 openedserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1327
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1328 (defun nnmairix-get-valid-servers ()
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1329 "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
1330 (let ((alist gnus-opened-servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1331 (mairixservers (nnmairix-get-nnmairix-servers t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1332 server mserver openedserver occ cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1333 ;; 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
1334 ;; already occupied)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1335 (dolist (cur mairixservers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1336 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1337 (concat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1338 (symbol-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1339 (cadr (assoc 'nnmairix-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1340 (gnus-server-to-method (car cur)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1341 ":"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1342 (cadr (assoc 'nnmairix-backend-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1343 (gnus-server-to-method (car cur)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1344 occ))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1345 (while alist
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1346 (setq server (pop alist))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1347 (setq mserver (gnus-method-to-server (car server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1348 ;; 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
1349 ;; name to avoid confusion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1350 (when (string= mserver "native")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1351 (setq mserver (format "%s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1352 (caar server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1353 (nth 1 (car server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1354 (when (and server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1355 (eq (cadr server) 'ok)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1356 (member (caar server) nnmairix-valid-backends)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1357 (not (member (car server) gnus-ephemeral-servers))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1358 (not (member (gnus-method-to-server (car server)) occ)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1359 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1360 (list mserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1361 openedserver)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1362 openedserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1363
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1364 (defun nnmairix-get-groups-from-server (servername)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1365 "Return all groups for nnmairix server SERVERNAME."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1366 (let ((searchstring (format "nnmairix\\+%s:" servername))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1367 groups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1368 (dolist (cur gnus-newsrc-alist)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1369 (when (string-match searchstring
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1370 (car cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1371 (push (list (car cur)) groups)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1372 groups))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1373
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1374 (defun nnmairix-call-backend (func &rest args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1375 "Call a function FUNC on backend with ARGS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1376 (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
1377
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1378 (defun nnmairix-get-backend-folder (group &optional server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1379 "Return back end GROUP from nnmairix group on SERVER."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1380 (let* ((qualgroup (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1381 (gnus-group-prefixed-name group (list 'nnmairix server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1382 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1383 (folder (gnus-group-get-parameter qualgroup 'folder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1384 folder))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1385
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1386 (defun nnmairix-get-numcorr (group &optional server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1387 "Return values for article number correction nnmairix GROUP on SERVER."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1388 (let* ((qualgroup (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1389 (gnus-group-prefixed-name group (list 'nnmairix server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1390 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1391 (corr (gnus-group-get-parameter qualgroup 'numcorr t)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1392 corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1393
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1394
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1395 (defun nnmairix-rename-files-consecutively (path)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1396 "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
1397 This should correct problems of wrong article counts when using
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1398 nnmairix with nnml backends."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1399 (let* ((files
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1400 (sort
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1401 (mapcar 'string-to-number
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1402 (directory-files path nil "[0-9]+" t))
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 (lastplusone (car files))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1405 (path (file-name-as-directory path)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1406 (dolist (cur files)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1407 (when (not (= cur lastplusone))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1408 (rename-file (concat path
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1409 (number-to-string cur))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1410 (concat path
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1411 (number-to-string lastplusone)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1412 (setq cur lastplusone))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1413 (setq lastplusone (1+ cur)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1414
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1415 (defun nnmairix-replace-group-and-numbers (articles backendgroup mairixgroup numc type)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1416 "Replace folder names in Xref header and correct article numbers.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1417 Do this for all ARTICLES on BACKENDGROUP. Replace using
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1418 MAIRIXGROUP. NUMC contains values for article number correction.
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1419 TYPE is either 'nov or 'headers."
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1420 (nnheader-message 7 "nnmairix: Rewriting headers...")
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1421 (cond
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1422 ((eq type 'nov)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1423 (let ((buf (get-buffer-create " *nnmairix buffer*"))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1424 (corr (not (zerop numc)))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1425 (name (buffer-name nntp-server-buffer))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1426 header cur xref)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1427 (with-current-buffer buf
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1428 (erase-buffer)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1429 (set-buffer nntp-server-buffer)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1430 (goto-char (point-min))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1431 (mapc
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1432 (lambda (article)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1433 (when (or (looking-at (number-to-string article))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1434 (nnheader-find-nov-line article))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1435 (setq cur (nnheader-parse-nov))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1436 (when corr
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1437 (setq article (+ (mail-header-number cur) numc))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1438 (mail-header-set-number cur article))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1439 (setq xref (mail-header-xref cur))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1440 (when (and (stringp xref)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1441 (string-match (format "[ \t]%s:[0-9]+" backendgroup) xref))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1442 (setq xref (replace-match (format " %s:%d" mairixgroup article) t nil xref))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1443 (mail-header-set-xref cur xref))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1444 (set-buffer buf)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1445 (nnheader-insert-nov cur)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1446 (set-buffer nntp-server-buffer)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1447 (when (not (eobp))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1448 (forward-line 1))))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1449 articles)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1450 (kill-buffer nntp-server-buffer)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1451 (set-buffer buf)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1452 (rename-buffer name)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1453 (setq nntp-server-buffer buf))))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1454 ((and (eq type 'headers)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1455 (not (zerop numc)))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1456 (with-current-buffer nntp-server-buffer
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1457 (save-excursion
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1458 (goto-char (point-min))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1459 (while (re-search-forward "^[23][0-9]+ \\([0-9]+\\)" nil t)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1460 (replace-match (number-to-string
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1461 (+ (string-to-number (match-string 1)) numc))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1462 t t nil 1))))))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1463 (nnheader-message 7 "nnmairix: Rewriting headers... done"))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1464
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1465 (defun nnmairix-backend-to-server (server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1466 "Return nnmairix server most probably responsible for back end SERVER.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1467 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
1468 parameter 'indexed-servers of corresponding default search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1469 group."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1470 (let ((allservers (nnmairix-get-nnmairix-servers))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1471 mairixserver found defaultgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1472 (if (> (length allservers) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1473 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1474 ;; 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
1475 (while (and allservers (not found))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1476 (setq mairixserver (gnus-server-to-method (car (pop allservers))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1477 ;; 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
1478 (setq found (and (eq (cadr (assoc 'nnmairix-backend mairixserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1479 (car server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1480 (string= (cadr (assoc 'nnmairix-backend-server mairixserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1481 (nth 1 server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1482 ;; 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
1483 ;; variable in default search group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1484 (when (not found)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1485 (setq defaultgroup (cadr (assoc 'nnmairix-default-group mairixserver)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1486 (setq found (member (gnus-method-to-server server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1487 (gnus-group-get-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1488 (gnus-group-prefixed-name defaultgroup
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1489 mairixserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1490 'indexed-servers t)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1491 ;; If still not found, we ask user
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1492 (when (not found)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1493 (setq mairixserver
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1494 (gnus-server-to-method
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1495 (completing-read
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1496 (format "Cannot determine which nnmairix server indexes %s. Please specify: "
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1497 (gnus-method-to-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1498 (nnmairix-get-nnmairix-servers) nil nil "nnmairix:")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1499 ;; Save result in parameter of default search group so that
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1500 ;; we don't have to ask again
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1501 (setq defaultgroup (gnus-group-prefixed-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1502 (cadr (assoc 'nnmairix-default-group mairixserver)) mairixserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1503 (gnus-group-set-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1504 defaultgroup
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1505 'indexed-servers
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1506 (append (gnus-group-get-parameter defaultgroup 'indexed-servers t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1507 (list (gnus-method-to-server server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1508 mairixserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1509 ;; If there is just one (or none) nnmairix server:
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1510 (gnus-server-to-method (caar allservers)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1511
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1512
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1513 (defun nnmairix-delete-recreate-group (group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1514 "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
1515 (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
1516 (let ((folder (gnus-group-get-parameter group 'folder)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1517 (if (string-match nnmairix-group-regexp folder)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1518 (progn
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1519 (nnmairix-call-backend "open-server"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1520 nnmairix-backend-server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1521 (nnmairix-call-backend "request-delete-group"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1522 folder t nnmairix-backend-server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1523 (nnmairix-call-backend "request-create-group"
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1524 folder nnmairix-backend-server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1525 (error "`nnmairix-delete-recreate-group' called on \
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1526 non-mairix group. Check folder parameter")))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1527
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1528 (defun nnmairix-update-and-clear-marks (group &optional method)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1529 "Update group and clear all marks from GROUP using METHOD."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1530 (let ((method (or method
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1531 (gnus-find-method-for-group group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1532 (corr (gnus-group-get-parameter group 'numcorr t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1533 info)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1534 (unless (or (gnus-group-prefixed-p group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1535 (not method))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1536 (setq group (gnus-group-prefixed-name group method)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1537 (if (eq (nth 0 method) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1538 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1539 (nnmairix-open-server (nth 1 method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1540 (set-buffer gnus-group-buffer)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1541 ;; (gnus-group-set-parameter group 'propmarks nil)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1542 (setq info (gnus-get-info group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1543 ;; Clear active and info
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1544 (gnus-set-active group nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1545 (gnus-info-clear-data info)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1546 ;; Delete and re-create group if needed
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1547 (nnmairix-delete-recreate-group group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1548 ;; 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
1549 (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
1550 (when corr
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1551 (setcar corr t)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1552 (gnus-group-set-parameter group 'numcorr corr)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1553 (gnus-group-jump-to-group group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1554 (gnus-group-get-new-news-this-group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1555 (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
1556
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1557 (defun nnmairix-sentinel-mairix-update-finished (proc status)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1558 "Sentinel for mairix update process PROC with STATUS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1559 (if (equal status "finished\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1560 (nnheader-message 7 "Updating mairix database for %s... done" proc)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1561 (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
1562 See %s for details" proc nnmairix-mairix-output-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1563
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1564 (defun nnmairix-create-message-line-for-search ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1565 "Create message line for interactive query in minibuffer."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1566 (mapconcat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1567 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1568 (lambda (cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1569 (format "%c=%s" (car cur) (nth 3 cur))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1570 nnmairix-interactive-query-parameters ","))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1571
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1572 (defun nnmairix-replace-illegal-chars (header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1573 "Replace illegal characters in HEADER for mairix query."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1574 (when header
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1575 (if (> emacs-major-version 20)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1576 (while (string-match "[^-.@/,& [:alnum:]]" header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1577 (setq header (replace-match "" t t header)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1578 (while (string-match "[[]{}:<>]" header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1579 (setq header (replace-match "" t t header))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1580 (while (string-match "[-& ]" header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1581 (setq header (replace-match "," t t header)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1582 header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1583
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1584 (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
1585 "Toggle on GROUP a certain PARAMETER.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1586 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
1587 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
1588 set to t and to nil otherwise."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1589 (let* ((method (gnus-find-method-for-group group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1590 (par (or par
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1591 (not (gnus-group-get-parameter group parameter)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1592 (if (eq (car method) 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1593 (progn
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1594 (when (numberp par)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1595 (setq par (> par 0)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1596 (gnus-group-set-parameter group parameter par)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1597 (if par
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1598 (message "%s activated for group %s" description group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1599 (message "%s deactivated for group %s" description group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1600 t)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1601 (error "This is no nnmairix group")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1602 nil)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1603
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1604 ;; Search for original article helper functions
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1605
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1606 (defun nnmairix-goto-original-article (&optional no-registry)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1607 "Jump to the original group and display article.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1608 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
1609 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
1610 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
1611 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
1612 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
1613 search in raw mode."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1614 (interactive "P")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1615 (when (not (eq (car gnus-current-select-method) 'nnmairix))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1616 (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
1617 (if (eq (car method) 'nnmairix)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1618 (nnmairix-open-server (nth 1 method))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1619 (error "Not in a nnmairix group"))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1620 (when (not (gnus-buffer-live-p gnus-article-buffer))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1621 (error "No article buffer available"))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1622 (let ((server (nth 1 gnus-current-select-method))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1623 mid rval group allgroups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1624 ;; get message id
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
1625 (with-current-buffer gnus-article-buffer
96024
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))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
1681 (with-current-buffer nnmairix-mairix-output-buffer
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1682 (goto-char (point-min))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1683 (while (re-search-forward "^/.*$" nil t)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1684 (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
1685 allgroups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1686 (forward-line 1)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1687 (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
1688 nnmairix-mairix-output-buffer))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1689 allgroups))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1690
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1691 (defun nnmairix-get-group-from-file-path (file)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1692 "Get group by parsing the message location FILE."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1693 (let (path filename serverbase group maildirflag allgroups)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1694 (string-match "^\\(.*\\)/\\(.*?\\)$" file)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1695 (setq path (expand-file-name (match-string 1 file)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1696 (setq filename (match-string 2 file))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1697 ;; 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
1698 (setq maildirflag (string-match ".+\\..+\\..+" filename))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1699 (when maildirflag
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1700 (setq path
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1701 (replace-regexp-in-string
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1702 ".*\\(/cur\\|/new\\|/tmp\\)$" "" path t t 1)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1703 ;; we first check nnml and nnmaildir servers
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1704 (setq
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1705 group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1706 (catch 'found
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1707 (dolist (cur gnus-opened-servers)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1708 (when (or (and (not maildirflag)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1709 (eq (caar cur) 'nnml))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1710 (and maildirflag
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1711 (eq (caar cur) 'nnmaildir)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1712 ;; get base path from server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1713 (if maildirflag
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1714 (setq serverbase (cadr (assoc 'directory (car cur))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1715 (setq serverbase (cadr (assoc 'nnml-directory (car cur))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1716 (unless serverbase
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1717 (setq serverbase nnml-directory)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1718 (setq serverbase (file-name-as-directory
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1719 (expand-file-name serverbase)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1720 (when (string-match (concat serverbase "\\(.*\\)") path)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1721 ;; 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
1722 (setq group (match-string 1 path))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1723 (when (string-match "/$" group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1724 (setq group (replace-match "" t t group)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1725 (unless maildirflag
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1726 ;; for nnml: convert slashes to dots
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1727 (while (string-match "/" group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1728 (setq group (replace-match "." t t group))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1729 (setq group (gnus-group-prefixed-name group (car cur)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1730 ;; check whether this group actually exists
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1731 (when (gnus-group-entry group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1732 (throw 'found group)))))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1733 (unless group
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1734 ;; 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
1735 ;; 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
1736 ;; 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
1737 ;; ways...
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1738 (string-match "^.*/\\.?\\(.*\\)$" path)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1739 (setq group (match-string 1 path))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1740 ;; convert dots to slashes (nested group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1741 (while (string-match "\\." group)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1742 (setq group (replace-match "/" t t group)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1743 (dolist (cur gnus-opened-servers)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1744 (when (eq (caar cur) 'nnimap)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1745 (when (gnus-group-entry
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1746 (gnus-group-prefixed-name group (car cur)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1747 (push
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1748 (gnus-group-prefixed-name group (car cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1749 allgroups))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1750 (if (> (length allgroups) 1)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1751 (setq group (completing-read
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1752 "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
1753 allgroups nil t))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1754 (setq group (car allgroups))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1755 group))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1756
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1757 (defun nnmairix-show-original-article (group mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1758 "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
1759 (unless (string-match "^<" mid)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1760 (set mid (concat "<" mid)))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1761 (unless (string-match ">$" mid)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1762 (set mid (concat mid ">")))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1763 (when (string-match "Summary" (buffer-name (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1764 (gnus-summary-exit))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1765 (pop-to-buffer gnus-group-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1766 (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
1767 (gnus-summary-read-group group 1 t)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1768 (gnus-summary-refer-article mid)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1769 (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
1770 (gnus-summary-select-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1771 ;; Force redisplay
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1772 (gnus-summary-show-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1773 (nnheader-message 5 "Switched to group %s." group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1774
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1775 (defun nnmairix-map-range (func range)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1776 "Map function FUNC on all members of RANGE."
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1777 (cond
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1778 ((numberp range)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1779 (funcall func range))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1780 (t
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1781 (mapcar (lambda (cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1782 (cond
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1783 ((listp cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1784 (cons
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1785 (funcall func (car cur))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1786 (funcall func (cdr cur))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1787 ((numberp cur)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1788 (funcall func cur))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1789 range))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1790
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1791 (defun nnmairix-check-mairix-version (version &optional server)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1792 "Check mairix VERSION on SERVER.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1793 If VERSION is a number: specifies the minimum version.
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1794 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
1795 (unless server
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1796 (setq server nnmairix-current-server))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1797 (let ((versionstring (cadr (assoc server nnmairix-version-output))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1798 (unless versionstring
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1799 ;; call "mairix -V" to get the version string
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1800 (with-temp-buffer
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1801 (setq versionstring
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1802 (let* ((commandsplit (split-string nnmairix-mairix-command))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1803 (args (append (list (car commandsplit))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1804 `(nil t nil) (cdr commandsplit) '("-V"))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1805 (apply 'call-process args)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1806 (goto-char (point-min))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1807 (re-search-forward "mairix.*")
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1808 (match-string 0))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1809 ;; save version string for current session
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1810 (setq nnmairix-version-output
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1811 (append nnmairix-version-output
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1812 (list (list server versionstring)))))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1813 (cond
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1814 ((stringp version)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1815 (string-match version versionstring))
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1816 ((numberp version)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1817 (<= version (string-to-number
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1818 (progn
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1819 (string-match "mairix \\([0-9\\.]+\\)" versionstring)
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
1820 (match-string 1 versionstring))))))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1821
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1822 ;; ==== Widget stuff
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1823
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1824 (defvar nnmairix-widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1825 (defvar nnmairix-widgets-values nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1826
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1827 (defun nnmairix-widget-search-from-this-article ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1828 "Create mairix query based on current article using graphical widgets."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1829 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1830 (nnmairix-widget-search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1831 (nnmairix-widget-get-values)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1832
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1833 (defun nnmairix-widget-get-values ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1834 "Create values for editable fields from current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1835 (if (not (gnus-buffer-live-p gnus-article-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1836 (error "No article buffer available")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1837 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1838 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1839 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1840 (mapcar
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1841 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1842 (lambda (field)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1843 (list (car (cddr field))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1844 (if (car field)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1845 (nnmairix-replace-illegal-chars
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1846 (gnus-fetch-field (car field)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1847 nil))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1848 nnmairix-widget-fields-list))))
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1849
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1850
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1851 (defun nnmairix-widget-search (&optional mvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1852 "Create mairix query interactively using graphical widgets.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1853 MVALUES may contain values from current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1854 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1855 ;; Select window for mairix customization
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1856 (funcall nnmairix-widget-select-window-function)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1857 ;; generate widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1858 (nnmairix-widget-create-query mvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1859 ;; generate Buttons
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1860 (widget-create 'push-button
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1861 :notify
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1862 (if mvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1863 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1864 (nnmairix-widget-send-query nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1865 t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1866 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1867 (nnmairix-widget-send-query nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1868 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1869 "Send Query")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1870 (widget-insert " ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1871 (widget-create 'push-button
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1872 :notify
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1873 (if mvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1874 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1875 (nnmairix-widget-create-group nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1876 t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1877 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1878 (nnmairix-widget-create-group nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1879 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1880 "Create permanent group")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1881 (widget-insert " ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1882 (widget-create 'push-button
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1883 :notify (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1884 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1885 "Cancel")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1886 (use-local-map widget-keymap)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1887 (widget-setup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1888 (goto-char (point-min)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1889
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1890 (defun nnmairix-widget-send-query (widgets &optional withvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1891 "Send query from WIDGETS to mairix binary.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1892 If WITHVALUES is t, query is based on current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1893 (nnmairix-search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1894 (nnmairix-widget-make-query-from-widgets widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1895 (if withvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1896 (gnus-method-to-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1897 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1898 (car (nnmairix-get-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1899 (if (widget-value (cadr (assoc "Threads" widgets)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1900 t
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1901 -1))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1902 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1903
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1904 (defun nnmairix-widget-create-group (widgets &optional withvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1905 "Create nnmairix group based on current widget values WIDGETS.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1906 If WITHVALUES is t, query is based on current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1907 (let ((group (read-string "Name of the group: ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1908 (when (not (zerop (length group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1909 (nnmairix-create-search-group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1910 (if withvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1911 (gnus-method-to-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1912 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1913 (car (nnmairix-get-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1914 group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1915 (nnmairix-widget-make-query-from-widgets widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1916 (widget-value (cadr (assoc "Threads" widgets))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1917 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1918
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 (defun nnmairix-widget-make-query-from-widgets (widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1921 "Create mairix query from widget values WIDGETS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1922 (let (query temp flag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1923 ;; first we do the editable fields
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1924 (dolist (cur nnmairix-widget-fields-list)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1925 ;; See if checkbox is checked
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1926 (when (widget-value
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1927 (cadr (assoc (concat "c" (car (cddr cur))) widgets)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1928 ;; create query for the field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1929 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1930 (concat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1931 (nth 1 cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1932 ":"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1933 (nnmairix-replace-illegal-chars
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1934 (widget-value
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1935 (cadr (assoc (concat "e" (car (cddr cur))) widgets)))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1936 query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1937 ;; Flags
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1938 (when (member 'flags nnmairix-widget-other)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1939 (setq flag
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1940 (mapconcat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1941 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1942 (lambda (flag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1943 (setq temp
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1944 (widget-value (cadr (assoc (car flag) nnmairix-widgets))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1945 (if (string= "yes" temp)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1946 (cadr flag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1947 (if (string= "no" temp)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1948 (concat "-" (cadr flag))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1949 '(("seen" "s") ("replied" "r") ("flagged" "f")) ""))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1950 (when (not (zerop (length flag)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1951 (push (concat "F:" flag) query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1952 ;; return query string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1953 (mapconcat 'identity query " ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1954
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 (defun nnmairix-widget-create-query (&optional values)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1957 "Create widgets for creating mairix queries.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1958 Fill in VALUES if based on an article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1959 (let (allwidgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1960 (when (get-buffer nnmairix-customize-query-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1961 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1962 (switch-to-buffer nnmairix-customize-query-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1963 (kill-all-local-variables)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1964 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1965 (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
1966 (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
1967 ; (make-local-variable 'nnmairix-widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1968 (setq nnmairix-widgets (nnmairix-widget-build-editable-fields values))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1969 (when (member 'flags nnmairix-widget-other)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1970 (widget-insert "\nFlags:\n Seen: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1971 (nnmairix-widget-add "seen"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1972 'menu-choice
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1973 :value "ignore"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1974 '(item "yes") '(item "no") '(item "ignore"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1975 (widget-insert " Replied: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1976 (nnmairix-widget-add "replied"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1977 'menu-choice
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1978 :value "ignore"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1979 '(item "yes") '(item "no") '(item "ignore"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1980 (widget-insert " Ticked: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1981 (nnmairix-widget-add "flagged"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1982 'menu-choice
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1983 :value "ignore"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1984 '(item "yes") '(item "no") '(item "ignore")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1985 (when (member 'threads nnmairix-widget-other)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1986 (widget-insert "\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1987 (nnmairix-widget-add "Threads" 'checkbox nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1988 (widget-insert " Show full threads\n\n")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1989
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1990 (defun nnmairix-widget-build-editable-fields (values)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1991 "Build editable field widgets in `nnmairix-widget-fields-list'.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1992 VALUES may contain values for editable fields from current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1993 ;; how can this be done less ugly?
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1994 (let ((ret))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1995 (mapc
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1996 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1997 (lambda (field)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1998 (setq field (car (cddr field)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1999 (setq ret
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2000 (nconc
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2001 (list
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 (concat "c" field)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2004 (widget-create 'checkbox
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2005 :tag field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2006 :notify (lambda (widget &rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2007 (nnmairix-widget-toggle-activate widget))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2008 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2009 (list
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 (concat "e" field)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2012 (widget-create 'editable-field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2013 :size 60
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2014 :format (concat " " field ":"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2015 (make-string (- 11 (length field)) ?\ )
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2016 "%v")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2017 :value (or (cadr (assoc field values)) ""))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2018 ret))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2019 (widget-insert "\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2020 ;; Deactivate editable field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2021 (widget-apply (cadr (nth 1 ret)) :deactivate)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2022 nnmairix-widget-fields-list)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2023 ret))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2024
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2025 (defun nnmairix-widget-add (name &rest args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2026 "Add a widget NAME with optional ARGS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2027 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2028 (list name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2029 (apply 'widget-create args))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2030 nnmairix-widgets))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2031
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2032 (defun nnmairix-widget-toggle-activate (widget)
96024
be43dd7afc91 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95617
diff changeset
2033 "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
2034 (let ((field (widget-get widget :tag)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2035 (if (widget-value widget)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2036 (widget-apply
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2037 (cadr (assoc (concat "e" field) nnmairix-widgets))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2038 :activate)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2039 (widget-apply
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2040 (cadr (assoc (concat "e" field) nnmairix-widgets))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2041 :deactivate)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2042 (widget-setup))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2043
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2044 (provide 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2045
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2046 ;;; nnmairix.el ends here