annotate lisp/gnus/nnmairix.el @ 101453:bd842f836b89

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