annotate lisp/gnus/nnmairix.el @ 94994:29adfc9354e7

Switch to recommended form of GPLv3 permissions notice.
author Glenn Morris <rgm@gnu.org>
date Thu, 15 May 2008 03:25:15 +0000
parents f42ef85caf91
children 15ffd5c2dc17
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
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
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
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
7 ;; Version: 0.5
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 ;; * When using Maildir: path and filename of a mail can change due to
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
87 ;; reading/replying/etc. This can lead to dangling symlinks in
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
88 ;; nnmairix groups and it depends on the back end how well it deals
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
89 ;; with that (some IMAP servers out there may not be amused). Update the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
90 ;; database ('G b u') and the group to fix it.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
91 ;; * Mairix does only support us-ascii characters.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
92
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
93 ;; TODO/MISSING FEATURES:
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
94 ;; * Possibility to propagate flags like seen, replied, ticked
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
95 ;; to original message
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
96 ;; * Support of more back ends (nnmh, nnfolder, nnmbox...)?
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
97 ;; * Maybe use an active file instead of group parameters?
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
98 ;; * 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
99
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
100 ;;; Changelog:
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
101 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
102 ;; 02/06/2008 - version 0.5
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
103 ;;
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
104 ;; * New function: nnmairix-goto-original-article. Uses the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
105 ;; 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
106 ;;
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
107 ;; * Deal with empty Xref header
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
108 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
109 ;; * Changed summary mode keybindings since the old ones were
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
110 ;; already taken
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
111 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
112 ;; (Thanks to Tassilo Horn and Ted Zlatanov for their help)
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 ;; 01/07/2008 - version 0.4
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
115 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
116 ;; * New/fixed doc strings and code cleanup.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
117 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
118 ;; 18/11/2007 - version 0.3
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
119 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
120 ;; * Fixed bugs when dealing with nnml and native servers
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
121 ;;
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
122 ;; * Make variables customizable
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 ;; 10/10/2007 - version 0.2
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 ;; * Use nnml-directory/directory server variables for nnml and
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
127 ;; nnmaildir backends as path for search folders. This way it
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
128 ;; becomes independent of 'base' setting in .mairixirc (but not for
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
129 ;; nnimap).
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
130 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 ;; * 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
132 ;; is asked when more than one nnmairix server exists and we do not
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
133 ;; know which one is responsible for current backend.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
134 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
135 ;; * Rename files when using nnml backends so that there are no
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
136 ;; holes in article numbers. This should fix all problems regarding
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
137 ;; wrong article counts with nnml.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
138 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 ;; * More commands for creating queries (using widgets or the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
140 ;; minibuffer).
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
142 ;; * Fixed bug in nnmairix-create-search-group-from-message
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
143 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 ;; * Changed copyright to FSF
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
145 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
146 ;; (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
147 ;; ideas!)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
148 ;;
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
149 ;; 10/03/2007 - version 0.1 - first release
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
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
152 ;;; Code:
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 (require 'nnoo)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
155 (require 'gnus-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
156 (require 'gnus-sum)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
157 (require 'message)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
158 (require 'nnml)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
159 (require 'widget)
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 (nnoo-declare nnmairix)
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 ;;; === Keymaps
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
164
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
165 ;; Group mode
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
166 (defun nnmairix-group-mode-hook ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
167 "Nnmairix group mode keymap."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
168 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
169 (kbd "G b") (make-sparse-keymap))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
170 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
171 (kbd "G b g") 'nnmairix-create-search-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
172 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
173 (kbd "G b c") 'nnmairix-create-server-and-default-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
174 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
175 (kbd "G b q") 'nnmairix-group-change-query-this-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
176 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
177 (kbd "G b t") 'nnmairix-group-toggle-threads-this-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
178 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
179 (kbd "G b u") 'nnmairix-update-database)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
180 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
181 (kbd "G b s") 'nnmairix-search)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
182 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
183 (kbd "G b i") 'nnmairix-search-interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
184 (define-key gnus-group-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
185 (kbd "G b m") 'nnmairix-widget-search))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
186
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
187 ;; Summary mode
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
188 (defun nnmairix-summary-mode-hook ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
189 "Nnmairix summary mode keymap."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
190 (define-key gnus-summary-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
191 (kbd "$ t") 'nnmairix-search-thread-this-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
192 (define-key gnus-summary-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
193 (kbd "$ f") 'nnmairix-search-from-this-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
194 (define-key gnus-summary-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
195 (kbd "$ m") 'nnmairix-widget-search-from-this-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
196 (define-key gnus-summary-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
197 (kbd "$ g") 'nnmairix-create-search-group-from-message)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
198 (define-key gnus-summary-mode-map
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
199 (kbd "$ o") 'nnmairix-goto-original-article))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
200
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
201 (add-hook 'gnus-group-mode-hook 'nnmairix-group-mode-hook)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
202 (add-hook 'gnus-summary-mode-hook 'nnmairix-summary-mode-hook)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
203
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
204
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
205 ;; Customizable stuff
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
206
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
207 (defgroup nnmairix nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
208 "Backend for the Mairix mail search engine."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
209 :group 'gnus)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
210
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
211 (defcustom nnmairix-group-prefix "zz_mairix"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
212 "Prefix for mairix search groups on back end server.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
213 nnmairix will create these groups automatically on the back end
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
214 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
215 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
216 unused nnmairix groups on the back end using
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
217 `nnmairix-purge-old-groups'."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
218 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
219 :type 'string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
220 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
221
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
222 (defcustom nnmairix-mairix-output-buffer "*mairix output*"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
223 "Buffer used for mairix output."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
224 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
225 :type 'string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
226 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
227
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
228 (defcustom nnmairix-customize-query-buffer "*mairix query*"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
229 "Name of the buffer for customizing Mairix queries."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
230 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
231 :type 'string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
232 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
233
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
234 (defcustom nnmairix-mairix-update-options '("-F" "-Q")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
235 "Options when calling mairix for updating the database.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
236 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
237 should call mairix without these options from time to
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
238 time (e.g. via cron job)."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
239 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
240 :type '(repeat string)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
241 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
242
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
243 (defcustom nnmairix-mairix-synchronous-update nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
244 "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
245 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
246 :type 'boolean
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
247 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
248
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
249 (defcustom nnmairix-rename-files-for-nnml t
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
250 "Rename nnml mail files so that they are consecutively numbered.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
251 When using nnml as backend, mairix might produce holes in the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
252 article numbers which will produce wrong article counts by
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
253 Gnus. This option controls whether nnmairix should rename the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
254 files consecutively."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
255 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
256 :type 'boolean
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
257 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
258
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
259 (defcustom nnmairix-widget-fields-list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
260 '(("from" "f" "From") ("to" "t" "To") ("cc" "c" "Cc")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
261 ("subject" "s" "Subject") ("to" "tc" "To or Cc")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
262 ("from" "a" "Address") (nil "b" "Body") (nil "n" "Attachment")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
263 ("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
264 "Fields that should be editable during interactive query customization.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
265
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
266 Header, corresponding mairix command and description for editable
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
267 fields in interactive query customization. The header specifies
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
268 which header contents should be inserted into the editable field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
269 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
270 nil for disabling this)."
92257
d77d4d87d354 Switch license to GPLv3+.
Glenn Morris <rgm@gnu.org>
parents: 92255
diff changeset
271 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
272 :type '(repeat (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
273 (choice :tag "Field"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
274 (const :tag "none" nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
275 (const :tag "From" "from")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
276 (const :tag "To" "to")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
277 (const :tag "Cc" "cc")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
278 (const :tag "Subject" "subject")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
279 (const :tag "Message ID" "Message-ID"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
280 (string :tag "Command")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
281 (string :tag "Description")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
282 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
283
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
284 (defcustom nnmairix-widget-select-window-function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
285 (lambda () (select-window (get-largest-window)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
286 "Function for selecting the window for customizing the mairix query.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
287 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
288 :version "23.1"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
289 :type 'function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
290 :group 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
291
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
292 ;; ==== Other variables
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
293
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
294 (defvar nnmairix-widget-other
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
295 '(threads flags)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
296 "Other editable mairix commands when using customization widgets.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
297 Currently there are 'threads and 'flags.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
298
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
299 (defvar nnmairix-interactive-query-parameters
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
300 '((?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
301 (?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
302 (?d nil "d" "Date") (?n nil "n" "Attachment"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
303 "Things that should be editable during interactive query generation.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
304 Every list element consists of the following entries: Keystroke,
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
305 message field (if any), mairix command and description.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
306
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
307 (defvar nnmairix-delete-and-create-on-change '(nnimap nnmaildir nnml)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
308 "Controls on which backends groups should be deleted and re-created.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
309 This variable is a list of back ends where the search group should
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
310 be completely deleted and re-created when the query or thread
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
311 parameter changes. I know this is rather \"brute force\" and maybe
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
312 even dangerous (you have backups, right?), but it should be used at
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
313 least for nnimap since some IMAP servers are really not amused when
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
314 mailbox content changes behind their back. It usually also corrects
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
315 the problem of \"holes\" in the article numbers which often lead to a
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
316 wrong count of total articles shown by Gnus.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
317
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
318 ;;; === Server variables
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
319
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
320 (defvoo nnmairix-backend nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
321 "Backend where mairix stores its searches.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
322
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
323 (defvoo nnmairix-backend-server nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
324 "Name of the server where mairix stores its searches.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
325
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
326 (defvoo nnmairix-mairix-command "mairix"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
327 "Command to call mairix for this nnmairix server.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
328
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
329 (defvoo nnmairix-hidden-folders nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
330 "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
331 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
332
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
333 (defvoo nnmairix-default-group nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
334 "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
335 temporary searches, e.g. nnmairix-search.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
336
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
337 ;;; === Internal variables
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
338
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
339 (defconst nnmairix-group-regexp
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
340 (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
341 "Regexp for mairix groups on back end.")
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
342
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
343 (defconst nnmairix-valid-backends '(nnimap nnml nnmaildir)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
344 "Backends supported by nnmairix.
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
345 Other backends might or might not work.")
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
346
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
347 (defvar nnmairix-last-server nil
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
348 "Last chosen server.")
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
349
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
350 (defvar nnmairix-current-server nil
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
351 "Current server.")
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
352
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
353 ;;; === Gnus backend functions
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
354
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
355 (nnoo-define-basics nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
356
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
357 (gnus-declare-backend "nnmairix" 'mail 'address)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
358
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
359 (deffoo nnmairix-open-server (server &optional definitions)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
360 ;; just set server variables
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
361 (setq nnmairix-current-server server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
362 (nnoo-change-server 'nnmairix server definitions))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
363
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
364 (deffoo nnmairix-request-group (group &optional server fast)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
365 ;; Call mairix and request group on back end server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
366 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
367 (let* ((qualgroup (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
368 (gnus-group-prefixed-name group (list 'nnmairix server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
369 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
370 (query (gnus-group-get-parameter qualgroup 'query t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
371 (folder (gnus-group-get-parameter qualgroup 'folder))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
372 (threads (gnus-group-get-parameter qualgroup 'threads))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
373 (backendmethod (gnus-server-to-method
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
374 (format "%s:%s" (symbol-name nnmairix-backend)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
375 nnmairix-backend-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
376 rval mfolder folderpath)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
377 (cond
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
378 ((not folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
379 ;; No folder parameter -> error
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
380 (nnheader-report 'nnmairix "Check folder parameter for group %s" group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
381 nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
382 ((not query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
383 ;; No query -> return empty group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
384 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
385 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
386 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
387 (insert (concat "211 0 1 0 " group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
388 t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
389 (t
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
390 ;; For maildir++ folders: create a hidden directory (prepend dot)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
391 (setq mfolder (if (and nnmairix-hidden-folders
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
392 (not (string-match "^\\." folder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
393 (concat "." folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
394 folder))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
395 ;; For nnml and nnmaildir, precede mfolder with directory where mail
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
396 ;; 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
397 ;; in .mairixrc.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
398 (when (eq nnmairix-backend 'nnml)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
399 (setq folderpath (cadr (assoc 'nnml-directory backendmethod)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
400 ;; if nnml-directory is not explicitly set, use global value
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
401 (when (not folderpath)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
402 (setq folderpath nnml-directory)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
403 (when (eq nnmairix-backend 'nnmaildir)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
404 (setq folderpath
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
405 (cadr (assoc 'directory backendmethod))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
406 (when folderpath
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
407 (setq mfolder
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
408 (concat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
409 (file-name-as-directory
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
410 (expand-file-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
411 folderpath))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
412 mfolder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
413 ;; If (not fast), call Mairix binary
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
414 (setq rval
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
415 (if fast 0
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
416 (nnmairix-call-mairix-binary
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
417 (split-string nnmairix-mairix-command)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
418 mfolder query threads)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
419 ;; Check return value
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
420 (cond
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
421 ((zerop rval) ; call was succesful
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
422 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
423 "open-server" nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
424 ;; If we're dealing with nnml, rename files
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
425 ;; consecutively and make new active file for this
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
426 ;; group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
427 (when (eq nnmairix-backend 'nnml)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
428 (when nnmairix-rename-files-for-nnml
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
429 (nnmairix-rename-files-consecutively mfolder))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
430 (nnml-generate-nov-databases-directory mfolder))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
431 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
432 "request-scan" folder nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
433 (if fast
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
434 t
92359
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
435 (nnmairix-request-group-with-article-number-correction
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
436 folder qualgroup)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
437 ((and (= rval 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
438 (save-excursion (set-buffer nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
439 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
440 (looking-at "^Matched 0 messages")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
441 ;; No messages found -> return empty group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
442 (nnheader-message 5 "Mairix: No matches found.")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
443 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
444 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
445 (insert (concat "211 0 1 0 " group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
446 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
447 ;; Everything else is an error
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
448 (t
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
449 (nnheader-report
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
450 'nnmairix "Error running marix. See buffer %s for details"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
451 nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
452 nil))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
453
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
454
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
455 (deffoo nnmairix-request-create-group (group &optional server args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
456 (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
457 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
458 (exist t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
459 (count 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
460 groupname info)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
461 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
462 (gnus-group-add-parameter qualgroup '(query . nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
463 (gnus-group-add-parameter qualgroup '(threads . nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
464 (while exist
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
465 (setq count (1+ count))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
466 (setq groupname (format "%s-%s-%s" nnmairix-group-prefix group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
467 (number-to-string count)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
468 (setq exist (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
469 "request-group" groupname nnmairix-backend-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
470 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
471 "request-create-group" groupname nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
472 (gnus-group-add-parameter qualgroup '(folder . nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
473 (gnus-group-set-parameter qualgroup 'folder groupname))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
474 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
475
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
476
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
477 (deffoo nnmairix-retrieve-headers (articles group &optional server fetch-old)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
478 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
479 (let* ((folder (nnmairix-get-backend-folder group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
480 (corr (nnmairix-get-numcorr group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
481 (numcorr 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
482 rval)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
483 (when (and corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
484 (not (zerop (cadr corr)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
485 (numberp (car articles)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
486 (setq numcorr (cadr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
487 (setq articles
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
488 (mapcar
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
489 (lambda (arg) (- arg numcorr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
490 articles)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
491 (setq rval (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
492 "retrieve-headers" articles folder nnmairix-backend-server fetch-old))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
493 (when (eq rval 'nov)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
494 (nnmairix-replace-group-and-numbers articles folder group numcorr)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
495 rval)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
496
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
497 (deffoo nnmairix-request-article (article &optional group server to-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
498 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
499 (let ((folder (nnmairix-get-backend-folder group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
500 (corr (nnmairix-get-numcorr group server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
501 (when (and
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
502 (numberp article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
503 corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
504 (not (zerop (cadr corr))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
505 (setq article (- article (cadr corr))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
506 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
507 "request-article" article folder nnmairix-backend-server to-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
508 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
509
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
510 (deffoo nnmairix-close-group (group &optional server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
511 ;; Should we do something here?
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
512 nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
513
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
514
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
515 (deffoo nnmairix-request-list (&optional server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
516 (when server (nnmairix-open-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
517 (if (nnmairix-call-backend "request-list" nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
518 (let (cpoint cur qualgroup folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
519 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
520 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
521 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
522 (setq cpoint (point))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
523 (while (re-search-forward nnmairix-group-regexp (point-max) t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
524 (setq cur (match-string 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
525 qualgroup (gnus-group-prefixed-name cur
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
526 (list 'nnmairix server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
527 (if (and (gnus-group-entry qualgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
528 (string= (match-string 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
529 (gnus-group-get-parameter qualgroup 'folder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
530 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
531 (replace-match cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
532 (delete-region cpoint (point-at-bol))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
533 (forward-line)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
534 (setq cpoint (point)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
535 (forward-line)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
536 (delete-region cpoint (point-max)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
537 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
538 nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
539
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
540
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
541 (nnoo-define-skeleton nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
542
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
543
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
544 ;;; === Interactive functions
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
545
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
546 (defun nnmairix-create-search-group (server group query threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
547 "Create on SERVER nnmairix search group GROUP with QUERY.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
548 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
549 called interactively, user will be asked for parameters."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
550 (interactive
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
551 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
552 (gnus-server-to-method (car (nnmairix-get-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
553 (read-string "Group name: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
554 (read-string "Query: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
555 (y-or-n-p "Include threads? ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
556 (when (and (stringp query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
557 (string-match "\\s-" query))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
558 (setq query (split-string query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
559 (when (not (listp query))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
560 (setq query (list query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
561 (when (and server group query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
562 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
563 (let ((groupname (gnus-group-prefixed-name group server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
564 info)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
565 (set-buffer gnus-group-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
566 (gnus-group-make-group group server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
567 (gnus-group-set-parameter groupname 'query query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
568 (gnus-group-set-parameter groupname 'threads threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
569 (nnmairix-update-and-clear-marks groupname)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
570
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
571 (defun nnmairix-search-interactive ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
572 "Create mairix search interactively with the minibuffer."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
573 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
574 (let ((char-header nnmairix-interactive-query-parameters)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
575 header finished query achar)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
576 (while (not finished)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
577 (while (not achar)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
578 (message "Query (%s): " (nnmairix-create-message-line-for-search))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
579 (setq achar (read-char))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
580 (when (not (assoc achar char-header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
581 (setq achar nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
582 (setq header (read-string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
583 (concat "Match " (nth 3 (assoc achar char-header)) " on: ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
584 (push (concat (nth 2 (assoc achar char-header)) ":" header) query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
585 (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
586 achar nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
587 (nnmairix-search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
588 (mapconcat 'identity query " ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
589 (car (nnmairix-get-server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
590 (y-or-n-p "Include whole threads? "))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
591
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
592 (defun nnmairix-create-search-group-from-message ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
593 "Interactively create search group with query based on current message."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
594 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
595 (let ((char-header nnmairix-interactive-query-parameters)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
596 (server (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
597 query achar header finished group threads cq)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
598 (when (or (not (gnus-buffer-live-p gnus-article-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
599 (not (gnus-buffer-live-p gnus-summary-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
600 (error "No article or summary buffer"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
601 (when (not server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
602 (error "No nnmairix server found for back end %s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
603 (symbol-name (car gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
604 (nth 1 gnus-current-select-method)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
605 (while (not finished)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
606 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
607 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
608 (while (not achar)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
609 (message "Query (%s): " (nnmairix-create-message-line-for-search))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
610 (setq achar (read-char))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
611 (when (not (assoc achar char-header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
612 (setq achar nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
613 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
614 (setq header nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
615 (when (setq cq (nth 1 (assoc achar char-header)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
616 (setq header
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
617 (nnmairix-replace-illegal-chars
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
618 (gnus-fetch-field (nth 1 (assoc achar char-header))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
619 (setq header (read-string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
620 (concat "Match " (nth 3 (assoc achar char-header)) " on: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
621 header))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
622 (push (concat (nth 2 (assoc achar char-header)) ":" header) query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
623 (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
624 achar nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
625 (setq threads (y-or-n-p "Include whole threads? "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
626 (setq group (read-string "Group name: "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
627 (set-buffer gnus-summary-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
628 (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
629 (gnus-method-to-server server) (mapconcat 'identity query " "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
630 (nnmairix-create-search-group server group query threads)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
631
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
632 (defun nnmairix-create-server-and-default-group ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
633 "Interactively create new nnmairix server with default search group.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
634 All necessary information will be queried from the user."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
635 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
636 (let* ((name (read-string "Name of the mairix server: "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
637 (server (completing-read "Back end server (TAB for completion): "
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
638 (nnmairix-get-valid-servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
639 (mairix (read-string "Command to call mairix: " "mairix"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
640 (defaultgroup (read-string "Default search group: "))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
641 (backend (symbol-name (car (gnus-server-to-method server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
642 (servername (nth 1 (gnus-server-to-method server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
643 (hidden (and (string-match "^nn\\(imap\\|maildir\\)$" backend)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
644 (y-or-n-p
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
645 "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
646 create)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
647
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
648 (apply (intern (format "%s-%s" backend "open-server"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
649 (list servername))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
650
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
651 (when (and hidden
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
652 (string-match "^\\." defaultgroup))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
653 (setq defaultgroup (substring defaultgroup 1)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
654 ;; Create default search group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
655 (gnus-group-make-group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
656 defaultgroup (list 'nnmairix name (list 'nnmairix-backend (intern backend))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
657 (list 'nnmairix-backend-server servername)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
658 (list 'nnmairix-mairix-command mairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
659 (list 'nnmairix-hidden-folders hidden)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
660 (list 'nnmairix-default-group defaultgroup)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
661
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
662
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
663 (defun nnmairix-group-change-query-this-group (&optional query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
664 "Set QUERY for group under cursor."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
665 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
666 (let* ((group (gnus-group-group-name))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
667 (method (gnus-find-method-for-group group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
668 (oldquery (gnus-group-get-parameter group 'query t)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
669 (if (eq (car method) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
670 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
671 (when (listp oldquery)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
672 (setq oldquery (mapconcat 'identity oldquery " ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
673 (setq query (or query
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
674 (read-string "New query: " oldquery)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
675 (when (stringp query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
676 (setq query (split-string query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
677 (when query
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
678 (gnus-group-set-parameter group 'query query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
679 (nnmairix-update-and-clear-marks group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
680 (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
681
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
682
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
683 (defun nnmairix-group-toggle-threads-this-group (&optional threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
684 "Toggle threads parameter for this group.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
685 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
686 If THREADS is a negative number, set it to nil."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
687 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
688 (let* ((group (gnus-group-group-name))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
689 (method (gnus-find-method-for-group group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
690 (getthreads (or threads
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
691 (not (gnus-group-get-parameter group 'threads)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
692 (if (eq (car method) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
693 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
694 (when (numberp getthreads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
695 (setq getthreads (> getthreads 0)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
696 (gnus-group-set-parameter group 'threads getthreads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
697 (if getthreads
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
698 (message "Threads activated for group %s" group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
699 (message "Threads deacitavted for group %s" group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
700 (nnmairix-update-and-clear-marks group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
701 (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
702
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
703
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
704 (defun nnmairix-search (query &optional server threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
705 "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
706
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
707 Default search group is automatically entered and results are shown.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
708 If THREADS is t, enable threads.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
709 If THREADS is a negative number, disable threads.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
710 Otherwise, leave threads parameter as it is."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
711 (interactive (list (read-string "Query: ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
712 (when (not server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
713 (setq server (car (nnmairix-get-server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
714 (if (not server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
715 (error "No opened nnmairix server found")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
716 (setq server (gnus-server-to-method server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
717 (nnmairix-open-server (nth 1 server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
718 (let* ((qualgroup (gnus-group-prefixed-name nnmairix-default-group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
719 (list 'nnmairix (nth 1 server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
720 (set-buffer gnus-group-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
721 (when (stringp query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
722 (setq query (split-string query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
723 (gnus-group-set-parameter qualgroup 'query query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
724 (if (symbolp threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
725 (when (eq threads 't)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
726 (gnus-group-set-parameter qualgroup 'threads t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
727 (when (< threads 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
728 (gnus-group-set-parameter qualgroup 'threads nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
729 (nnmairix-update-and-clear-marks qualgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
730 (when (not (zerop (gnus-group-unread qualgroup)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
731 (gnus-group-read-group nil t qualgroup))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
732
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
733 (defun nnmairix-search-thread-this-article ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
734 "Search thread for the current article.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
735 This is effectively a shortcut for calling `nnmairix-search'
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
736 with m:msgid of the current article and enabled threads."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
737 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
738 (let* ((server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
739 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
740 mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
741 (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
742 (if (gnus-buffer-live-p gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
743 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
744 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
745 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
746 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
747 (setq mid (message-fetch-field "Message-ID")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
748 (while (string-match "[<>]" mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
749 (setq mid (replace-match "" t t mid)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
750 (nnmairix-search (concat "m:" mid) server t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
751 (message "No article buffer."))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
752 (error "No nnmairix server found for back end %s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
753 (symbol-name (car gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
754 (nth 1 gnus-current-select-method)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
755
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
756 (defun nnmairix-search-from-this-article ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
757 "Search messages from sender of the current article.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
758 This is effectively a shortcut for calling `nnmairix-search' with
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
759 f:current_from."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
760 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
761 (let* ((server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
762 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
763 from)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
764 (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
765 (if (gnus-buffer-live-p gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
766 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
767 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
768 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
769 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
770 (setq from (cadr (gnus-extract-address-components
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
771 (gnus-fetch-field "From"))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
772 (nnmairix-search (concat "f:" from) server -1)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
773 (message "No article buffer."))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
774 (error "No nnmairix server found for back end %s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
775 (symbol-name (car gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
776 (nth 1 gnus-current-select-method)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
777
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
778
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
779 (defun nnmairix-purge-old-groups (&optional dontask server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
780 "Delete mairix search groups which are no longer used.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
781
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
782 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
783 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
784 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
785 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
786 (let ((server (or server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
787 (gnus-server-to-method (car (nnmairix-get-server))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
788 (if (nnmairix-open-server (nth 1 server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
789 (when (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
790 "request-list" nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
791 (let (cur qualgroup folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
792 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
793 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
794 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
795 (while (re-search-forward nnmairix-group-regexp (point-max) t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
796 (setq cur (match-string 0)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
797 qualgroup (gnus-group-prefixed-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
798 (match-string 1) server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
799 (when (not (and (gnus-group-entry qualgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
800 (string= cur
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
801 (gnus-group-get-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
802 qualgroup 'folder))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
803 (when (or dontask
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
804 (y-or-n-p
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
805 (concat "Delete group " cur
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
806 " on server " nnmairix-backend-server "? ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
807 (nnmairix-call-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
808 "request-delete-group" cur t nnmairix-backend-server)))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
809 (message "Couldn't open server %s" (nth 1 server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
810
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
811
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
812 (defun nnmairix-update-database (&optional servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
813 "Call mairix for updating the database for SERVERS.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
814
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
815 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
816 will be called asynchronously unless
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
817 `nnmairix-mairix-synchronous-update' is t. Mairix will be called
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
818 with `nnmairix-mairix-update-options'."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
819 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
820 (let ((servers (or servers
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
821 (nnmairix-get-nnmairix-servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
822 args cur commandsplit)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
823 (while servers
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
824 (setq cur (car (pop servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
825 (nnmairix-open-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
826 (nth 1 (gnus-server-to-method cur)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
827 (setq commandsplit (split-string nnmairix-mairix-command))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
828 (nnheader-message 7 "Updating mairix database for %s..." cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
829 (if nnmairix-mairix-synchronous-update
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
830 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
831 (setq args (append (list (car commandsplit) nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
832 (get-buffer nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
833 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
834 (if (> (length commandsplit) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
835 (setq args (append args (cdr commandsplit) nnmairix-mairix-update-options))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
836 (setq args (append args nnmairix-mairix-update-options)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
837 (apply 'call-process args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
838 (nnheader-message 7 "Updating mairix database for %s... done" cur))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
839 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
840 (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
841 (car commandsplit))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
842 (if (> (length commandsplit) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
843 (setq args (append args (cdr commandsplit) nnmairix-mairix-update-options))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
844 (setq args (append args nnmairix-mairix-update-options)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
845 (set-process-sentinel (apply 'start-process args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
846 'nnmairix-sentinel-mairix-update-finished))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
847
92359
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
848 ;; Silence byte-compiler.
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
849 (eval-when-compile
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
850 (defvar gnus-registry-install)
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
851 (autoload 'gnus-registry-fetch-group "gnus-registry"))
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
852
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
853 (defun nnmairix-goto-original-article (&optional no-registry)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
854 "Jump to the original group and display article.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
855 The original group of the article is first determined with the
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
856 registry (if enabled). If the registry is not enabled or did not
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
857 find the article or the prefix NO-REGISTRY is non-nil, this
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
858 function will try to determine the original group form the path
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
859 of the mail file. The path is obtained through another mairix
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
860 search in raw mode."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
861 (interactive "P")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
862 (when (not (eq (car gnus-current-select-method) 'nnmairix))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
863 (let ((method (gnus-find-method-for-group gnus-newsgroup-name)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
864 (if (eq (car method) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
865 (nnmairix-open-server (nth 1 method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
866 (error "Not in a nnmairix group"))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
867 (when (not (gnus-buffer-live-p gnus-article-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
868 (error "No article buffer available"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
869 (let ((server (nth 1 gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
870 mid rval group allgroups)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
871 ;; get message id
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
872 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
873 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
874 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
875 (setq mid (message-fetch-field "Message-ID"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
876 ;; first check the registry (if available)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
877 (when (and (boundp 'gnus-registry-install)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
878 gnus-registry-install
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
879 (not no-registry))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
880 (setq group (gnus-registry-fetch-group mid)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
881 (while (string-match "[<>]" mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
882 (setq mid (replace-match "" t t mid)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
883 (unless group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
884 ;; registry was not available or did not find article
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
885 ;; so we search again with mairix in raw mode to get filename
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
886 (nnmairix-open-server server)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
887 (setq rval
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
888 (nnmairix-call-mairix-binary-raw
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
889 (split-string nnmairix-mairix-command)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
890 (list (concat "m:" mid))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
891 (if (zerop rval)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
892 ;; determine original group(s) from filename
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
893 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
894 (set-buffer nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
895 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
896 (while (looking-at "/")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
897 (push (nnmairix-determine-original-group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
898 allgroups)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
899 (forward-line 1))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
900 (if (> (length allgroups) 1)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
901 (setq group
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
902 (completing-read
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
903 "Message exists in more than one group. Choose: "
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
904 allgroups nil t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
905 (setq group (car allgroups))))
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
906 (error "Mairix could not find original article. See buffer %s for details"
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
907 nnmairix-mairix-output-buffer))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
908 (if group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
909 ;; show article in summary buffer
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
910 (nnmairix-show-original-article group mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
911 (message "Couldn't find original article"))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
912
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
913 (defun nnmairix-determine-original-group ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
914 "Try to determine to original group from the file path."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
915 (let (path filename serverbase group maildirflag allgroups)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
916 (re-search-forward "^\\(.*\\)/\\(.*?\\)$")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
917 (setq path (expand-file-name (match-string 1)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
918 (setq filename (match-string 2))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
919 ;; when we deal with maildir, remove cur/new/tmp from path
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
920 (setq maildirflag (string-match ".+\\..+\\..+" filename))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
921 (when maildirflag
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
922 (setq path
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
923 (replace-regexp-in-string
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
924 ".*\\(/cur\\|/new\\|/tmp\\)$" "" path t t 1)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
925 ;; we first check nnml and nnmaildir servers
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
926 (setq
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
927 group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
928 (catch 'found
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
929 (dolist (cur gnus-opened-servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
930 (when (or (and (not maildirflag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
931 (eq (caar cur) 'nnml))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
932 (and maildirflag
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
933 (eq (caar cur) 'nnmaildir)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
934 ;; get base path from server
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
935 (if maildirflag
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
936 (setq serverbase (cadr (assoc 'directory (car cur))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
937 (setq serverbase (cadr (assoc 'nnml-directory (car cur))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
938 (when (not serverbase)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
939 (setq serverbase nnml-directory)))
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
940 (setq serverbase (file-name-as-directory
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
941 (expand-file-name serverbase)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
942 (when (string-match (concat serverbase "\\(.*\\)") path)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
943 ;; looks good - rest of the path should be the group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
944 (setq group (match-string 1 path))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
945 (when (string-match "/$" group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
946 (setq group (replace-match "" t t group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
947 (when (not maildirflag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
948 ;; for nnml: convert slashes to dots
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
949 (while (string-match "/" group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
950 (setq group (replace-match "." t t group))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
951 (setq group (gnus-group-prefixed-name group (car cur)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
952 ;; check whether this group actually exists
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
953 (when (gnus-group-entry group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
954 (throw 'found group)))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
955 (unless group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
956 ;; we haven't found it yet --> look for nnimap groups
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
957 ;; assume last element of the path is the group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
958 (string-match "^.*/\\.?\\(.*\\)$" path)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
959 (setq group (match-string 1 path))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
960 ;; convert dots to slashes (nested group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
961 (while (string-match "\\." group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
962 (setq group (replace-match "/" t t group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
963 (dolist (cur gnus-opened-servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
964 (when (eq (caar cur) 'nnimap)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
965 (when (gnus-group-entry
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
966 (gnus-group-prefixed-name group (car cur)))
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
967 (push
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
968 (gnus-group-prefixed-name group (car cur))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
969 allgroups))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
970 (if (> (length allgroups) 1)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
971 (setq group (completing-read
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
972 "Group %s exists on more than one IMAP server. Choose: "
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
973 allgroups nil t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
974 (setq group (car allgroups))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
975 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
976
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
977
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
978 ;;; ==== Helper functions
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
979
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
980 (defun nnmairix-request-group-with-article-number-correction (folder qualgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
981 "Request FOLDER on backend for nnmairix QUALGROUP and article number correction."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
982 (save-excursion
92359
1af6d6eab2e9 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 92260
diff changeset
983 (nnmairix-call-backend "request-group" folder nnmairix-backend-server)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
984 (set-buffer nnmairix-mairix-output-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
985 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
986 (re-search-forward "^Matched.*messages")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
987 (nnheader-message 7 (match-string 0))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
988 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
989 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
990 (let ((status (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
991 (total (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
992 (low (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
993 (high (read (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
994 (corr (gnus-group-get-parameter qualgroup 'numcorr t)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
995 (if (= status 211)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
996 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
997 ;; Article number correction
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
998 (if (and corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
999 (> (+ (car (cddr corr)) high) 0))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1000 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1001 (when (car corr) ;Group has changed
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1002 (setq corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1003 (list nil
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1004 (car (cddr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1005 (+ (car (cddr corr)) high)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1006 (gnus-group-set-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1007 qualgroup 'numcorr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1008 (setq low (+ low (cadr corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1009 high (+ high (cadr corr))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1010 (when (member nnmairix-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1011 nnmairix-delete-and-create-on-change)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1012 (gnus-group-set-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1013 qualgroup 'numcorr (list nil 0 high))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1014 (erase-buffer)
92260
261f98568bde (nnmairix-request-group): Bind nnmairix-fast and nnmairix-group around
Glenn Morris <rgm@gnu.org>
parents: 92259
diff changeset
1015 (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
1016 (gnus-group-real-name qualgroup)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1017 t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1018 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1019 (nnheader-report
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1020 'nnmairix "Error calling back end on group %s" folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1021 nil)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1022
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1023 (defun nnmairix-call-mairix-binary (command folder query threads)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1024 "Call mairix binary with COMMAND, using FOLDER and QUERY.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1025 If THREADS is non-nil, enable full threads."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1026 (let ((args (cons (car command) '(nil t nil))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1027 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1028 (set-buffer
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1029 (get-buffer-create nnmairix-mairix-output-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1030 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1031 (when (> (length command) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1032 (setq args (append args (cdr command))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1033 (when threads
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1034 (setq args (append args '("-t"))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1035 (apply 'call-process
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1036 (append args (list "-o" folder) query)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1037
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1038 (defun nnmairix-call-mairix-binary-raw (command query)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1039 "Call mairix binary with COMMAND and QUERY in raw mode."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1040 (let ((args (cons (car command) '(nil t nil))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1041 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1042 (set-buffer
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1043 (get-buffer-create nnmairix-mairix-output-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1044 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1045 (when (> (length command) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1046 (setq args (append args (cdr command))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1047 (setq args (append args '("-r")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1048 (apply 'call-process
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1049 (append args query)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1050
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1051 (defun nnmairix-get-server ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1052 "If there exists just one nnmairix server, return its value.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1053 Otherwise, ask user for server."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1054 (let ((openedserver (nnmairix-get-nnmairix-servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1055 (when (not openedserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1056 (error "No opened nnmairix server found"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1057 (if (> (length openedserver) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1058 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1059 (while
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1060 (equal '("")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1061 (setq nnmairix-last-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1062 (list (completing-read "Server: " openedserver nil 1
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1063 (or nnmairix-last-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1064 "nnmairix:"))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1065 nnmairix-last-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1066 (car openedserver))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1067
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1068 (defun nnmairix-get-nnmairix-servers (&optional all)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1069 "Return available nnmairix servers.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1070 If ALL is t, return also the unopened/failed ones."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1071 (let ((alist gnus-opened-servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1072 server openedserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1073 (while alist
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1074 (setq server (pop alist))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1075 (when (and server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1076 (or all
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1077 (eq (cadr server) 'ok))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1078 (eq (caar server) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1079 (not (member (car server) gnus-ephemeral-servers)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1080 (setq server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1081 (concat (symbol-name (caar server)) ":" (nth 1 (car server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1082 (push (list server) openedserver)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1083 openedserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1084
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1085
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1086 (defun nnmairix-get-valid-servers ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1087 "Return list of valid backend servers for nnmairix groups."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1088 (let ((alist gnus-opened-servers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1089 (mairixservers (nnmairix-get-nnmairix-servers t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1090 server mserver openedserver occ cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1091 ;; 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
1092 ;; already occupied)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1093 (dolist (cur mairixservers)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1094 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1095 (concat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1096 (symbol-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1097 (cadr (assoc 'nnmairix-backend
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1098 (gnus-server-to-method (car cur)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1099 ":"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1100 (cadr (assoc 'nnmairix-backend-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1101 (gnus-server-to-method (car cur)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1102 occ))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1103 (while alist
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1104 (setq server (pop alist))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1105 (setq mserver (gnus-method-to-server (car server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1106 ;; 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
1107 ;; name to avoid confusion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1108 (when (string= mserver "native")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1109 (setq mserver (format "%s:%s"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1110 (caar server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1111 (nth 1 (car server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1112 (when (and server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1113 (eq (cadr server) 'ok)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1114 (member (caar server) nnmairix-valid-backends)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1115 (not (member (car server) gnus-ephemeral-servers))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1116 (not (member (gnus-method-to-server (car server)) occ)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1117 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1118 (list mserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1119 openedserver)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1120 openedserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1121
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1122 (defun nnmairix-call-backend (func &rest args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1123 "Call a function FUNC on backend with ARGS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1124 (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
1125
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1126 (defun nnmairix-get-backend-folder (group &optional server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1127 "Return back end GROUP from nnmairix group on SERVER."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1128 (let* ((qualgroup (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1129 (gnus-group-prefixed-name group (list 'nnmairix server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1130 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1131 (folder (gnus-group-get-parameter qualgroup 'folder)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1132 folder))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1133
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1134 (defun nnmairix-get-numcorr (group &optional server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1135 "Return values for article number correction nnmairix GROUP on SERVER."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1136 (let* ((qualgroup (if server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1137 (gnus-group-prefixed-name group (list 'nnmairix server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1138 group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1139 (corr (gnus-group-get-parameter qualgroup 'numcorr t)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1140 corr))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1141
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1142
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1143 (defun nnmairix-rename-files-consecutively (path)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1144 "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
1145 This should correct problems of wrong article counts when using
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1146 nnmairix with nnml backends."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1147 (let* ((files
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1148 (sort
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1149 (mapcar 'string-to-number
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1150 (directory-files path nil "[0-9]+" t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1151 '<))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1152 (lastplusone (car files))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1153 (path (file-name-as-directory path)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1154 (dolist (cur files)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1155 (when (not (= cur lastplusone))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1156 (rename-file (concat path
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1157 (number-to-string cur))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1158 (concat path
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1159 (number-to-string lastplusone)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1160 (setq cur lastplusone))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1161 (setq lastplusone (1+ cur)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1162
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1163 (defun nnmairix-replace-group-and-numbers (articles backendgroup mairixgroup numc)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1164 "Replace folder names in Xref header and correct article numbers.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1165 Do this for all ARTICLES on BACKENDGROUP. Replace using
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1166 MAIRIXGROUP. NUMC contains values for article number correction."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1167 (let ((buf (get-buffer-create " *nnmairix buffer*"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1168 (corr (not (zerop numc)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1169 (name (buffer-name nntp-server-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1170 header cur xref)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1171 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1172 (set-buffer buf)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1173 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1174 (set-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1175 (goto-char (point-min))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1176 (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
1177 (mapc
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1178 (lambda (article)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1179 (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
1180 (nnheader-find-nov-line article))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1181 (setq cur (nnheader-parse-nov))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1182 (when corr
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1183 (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
1184 (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
1185 (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
1186 (when (and (stringp xref)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1187 (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
1188 (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
1189 (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
1190 (set-buffer buf)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1191 (nnheader-insert-nov cur)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1192 (set-buffer nntp-server-buffer)
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1193 (when (not (eobp))
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1194 (forward-line 1))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1195 articles)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1196 (nnheader-message 7 "nnmairix: Rewriting headers... done")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1197 (kill-buffer nntp-server-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1198 (set-buffer buf)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1199 (rename-buffer name)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1200 (setq nntp-server-buffer buf))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1201
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1202 (defun nnmairix-backend-to-server (server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1203 "Return nnmairix server most probably responsible for back end SERVER.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1204 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
1205 parameter 'indexed-servers of corresponding default search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1206 group."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1207 (let ((allservers (nnmairix-get-nnmairix-servers))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1208 mairixserver found defaultgroup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1209 (if (> (length allservers) 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1210 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1211 ;; 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
1212 (while (and allservers (not found))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1213 (setq mairixserver (gnus-server-to-method (car (pop allservers))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1214 ;; 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
1215 (setq found (and (eq (cadr (assoc 'nnmairix-backend mairixserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1216 (car server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1217 (string= (cadr (assoc 'nnmairix-backend-server mairixserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1218 (nth 1 server))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1219 ;; 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
1220 ;; variable in default search group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1221 (when (not found)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1222 (setq defaultgroup (cadr (assoc 'nnmairix-default-group mairixserver)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1223 (setq found (member (gnus-method-to-server server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1224 (gnus-group-get-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1225 (gnus-group-prefixed-name defaultgroup
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1226 mairixserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1227 'indexed-servers t)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1228 ;; If still not found, we ask user
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1229 (when (not found)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1230 (setq mairixserver
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1231 (gnus-server-to-method
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1232 (completing-read
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1233 (format "Cannot determine which nnmairix server indexes %s. Please specify: "
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1234 (gnus-method-to-server server))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1235 (nnmairix-get-nnmairix-servers) nil nil "nnmairix:")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1236 ;; Save result in parameter of default search group so that
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1237 ;; we don't have to ask again
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1238 (setq defaultgroup (gnus-group-prefixed-name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1239 (cadr (assoc 'nnmairix-default-group mairixserver)) mairixserver))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1240 (gnus-group-set-parameter
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1241 defaultgroup
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1242 'indexed-servers
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1243 (append (gnus-group-get-parameter defaultgroup 'indexed-servers t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1244 (list (gnus-method-to-server server)))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1245 mairixserver)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1246 ;; If there is just one (or none) nnmairix server:
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1247 (gnus-server-to-method (caar allservers)))))
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 (defun nnmairix-update-and-clear-marks (group &optional method)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1250 "Update group and clear all marks from GROUP using METHOD."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1251 (when method
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1252 (setq group (gnus-group-prefixed-name group method)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1253 (let ((method (or method
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1254 (gnus-find-method-for-group group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1255 (folder (gnus-group-get-parameter group 'folder))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1256 (corr (gnus-group-get-parameter group 'numcorr t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1257 info)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1258 (if (eq (nth 0 method) 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1259 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1260 (nnmairix-open-server (nth 1 method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1261 (set-buffer gnus-group-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1262 (setq info (gnus-get-info group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1263 ;; Clear active and info
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1264 (gnus-set-active group nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1265 (gnus-info-clear-data info)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1266 ;; Delete and re-create group if needed
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1267 (when (member nnmairix-backend nnmairix-delete-and-create-on-change)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1268 (if (string-match nnmairix-group-regexp folder)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1269 (progn
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1270 (nnmairix-call-backend "open-server"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1271 nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1272 (nnmairix-call-backend "request-delete-group"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1273 folder t nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1274 (nnmairix-call-backend "request-create-group"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1275 folder nnmairix-backend-server)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1276 ;; set flag that group has changed for article number correction
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1277 (when corr
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1278 (setcar corr t)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1279 (gnus-group-set-parameter group 'numcorr corr)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1280 (error "Nnmairix-update-and-clear-marks - delete/create with\
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1281 non-mairix group!! - check folder parameter")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1282 (when (gnus-group-jump-to-group group)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1283 (gnus-group-get-new-news-this-group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1284 (error "Nnmairix-update-and-clear-marks - Called with non-nnmairix group"))))
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1285
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1286
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1287 (defun nnmairix-sentinel-mairix-update-finished (proc status)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1288 "Sentinel for mairix update process PROC with STATUS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1289 (if (equal status "finished\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1290 (nnheader-message 7 "Updating mairix database for %s... done" proc)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1291 (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
1292 See %s for details" proc nnmairix-mairix-output-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1293
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1294 (defun nnmairix-create-message-line-for-search ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1295 "Create message line for interactive query in minibuffer."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1296 (mapconcat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1297 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1298 (lambda (cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1299 (format "%c=%s" (car cur) (nth 3 cur))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1300 nnmairix-interactive-query-parameters ","))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1301
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1302 (defun nnmairix-replace-illegal-chars (header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1303 "Replace illegal characters in HEADER for mairix query."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1304 (when header
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1305 (if (> emacs-major-version 20)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1306 (while (string-match "[^-.@/,& [:alnum:]]" header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1307 (setq header (replace-match "" t t header)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1308 (while (string-match "[[]{}:<>]" header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1309 (setq header (replace-match "" t t header))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1310 (while (string-match "[-& ]" header)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1311 (setq header (replace-match "," t t header)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1312 header))
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-show-original-article (group mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1315 "Switch to GROUP and display Article with message-id MID."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1316 (when (string-match "Summary" (buffer-name (current-buffer)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1317 (gnus-summary-exit))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1318 (pop-to-buffer gnus-group-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1319 (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
1320 (gnus-summary-read-group group 1 t)
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1321 (gnus-summary-refer-article mid)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1322 (gnus-summary-limit-to-headers (format "message-id: <%s>" mid))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1323 (gnus-summary-select-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1324 ;; Force redisplay
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1325 (gnus-summary-show-article)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1326 (nnheader-message 5 "Switched to group %s." group))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1327
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1328
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1329 ;; ==== Widget stuff
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1330
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1331 (defvar nnmairix-widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1332 (defvar nnmairix-widgets-values nil)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1333
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1334 (defun nnmairix-widget-search-from-this-article ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1335 "Create mairix query based on current article using graphical widgets."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1336 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1337 (nnmairix-widget-search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1338 (nnmairix-widget-get-values)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1339
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1340
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1341 (defun nnmairix-widget-get-values ()
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1342 "Create values for editable fields from current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1343 (if (not (gnus-buffer-live-p gnus-article-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1344 (error "No article buffer available")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1345 (save-excursion
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1346 (gnus-summary-toggle-header 1)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1347 (set-buffer gnus-article-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1348 (mapcar
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1349 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1350 (lambda (field)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1351 (list (car (cddr field))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1352 (if (car field)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1353 (nnmairix-replace-illegal-chars
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1354 (gnus-fetch-field (car field)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1355 nil))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1356 nnmairix-widget-fields-list))))
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1357
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1358
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1359 (defun nnmairix-widget-search (&optional mvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1360 "Create mairix query interactively using graphical widgets.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1361 MVALUES may contain values from current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1362 (interactive)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1363 ;; Select window for mairix customization
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1364 (funcall nnmairix-widget-select-window-function)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1365 ;; generate widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1366 (nnmairix-widget-create-query mvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1367 ;; generate Buttons
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1368 (widget-create 'push-button
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1369 :notify
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1370 (if mvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1371 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1372 (nnmairix-widget-send-query nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1373 t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1374 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1375 (nnmairix-widget-send-query nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1376 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1377 "Send Query")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1378 (widget-insert " ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1379 (widget-create 'push-button
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1380 :notify
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1381 (if mvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1382 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1383 (nnmairix-widget-create-group nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1384 t))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1385 (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1386 (nnmairix-widget-create-group nnmairix-widgets
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1387 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1388 "Create permanent group")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1389 (widget-insert " ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1390 (widget-create 'push-button
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1391 :notify (lambda (&rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1392 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1393 "Cancel")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1394 (use-local-map widget-keymap)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1395 (widget-setup)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1396 (goto-char (point-min)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1397
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1398 (defun nnmairix-widget-send-query (widgets &optional withvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1399 "Send query from WIDGETS to mairix binary.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1400 If WITHVALUES is t, query is based on current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1401 (nnmairix-search
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1402 (nnmairix-widget-make-query-from-widgets widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1403 (if withvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1404 (gnus-method-to-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1405 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1406 (car (nnmairix-get-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1407 (if (widget-value (cadr (assoc "Threads" widgets)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1408 t
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1409 -1))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1410 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1411
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1412 (defun nnmairix-widget-create-group (widgets &optional withvalues)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1413 "Create nnmairix group based on current widget values WIDGETS.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1414 If WITHVALUES is t, query is based on current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1415 (let ((group (read-string "Name of the group: ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1416 (when (not (zerop (length group)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1417 (nnmairix-create-search-group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1418 (if withvalues
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1419 (gnus-method-to-server
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1420 (nnmairix-backend-to-server gnus-current-select-method))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1421 (car (nnmairix-get-server)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1422 group
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1423 (nnmairix-widget-make-query-from-widgets widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1424 (widget-value (cadr (assoc "Threads" widgets))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1425 (kill-buffer nnmairix-customize-query-buffer))
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-widget-make-query-from-widgets (widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1429 "Create mairix query from widget values WIDGETS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1430 (let (query temp flag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1431 ;; first we do the editable fields
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1432 (dolist (cur nnmairix-widget-fields-list)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1433 ;; See if checkbox is checked
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1434 (when (widget-value
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1435 (cadr (assoc (concat "c" (car (cddr cur))) widgets)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1436 ;; create query for the field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1437 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1438 (concat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1439 (nth 1 cur)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1440 ":"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1441 (nnmairix-replace-illegal-chars
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1442 (widget-value
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1443 (cadr (assoc (concat "e" (car (cddr cur))) widgets)))))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1444 query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1445 ;; Flags
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1446 (when (member 'flags nnmairix-widget-other)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1447 (setq flag
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1448 (mapconcat
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1449 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1450 (lambda (flag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1451 (setq temp
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1452 (widget-value (cadr (assoc (car flag) nnmairix-widgets))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1453 (if (string= "yes" temp)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1454 (cadr flag)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1455 (if (string= "no" temp)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1456 (concat "-" (cadr flag))))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1457 '(("seen" "s") ("replied" "r") ("flagged" "f")) ""))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1458 (when (not (zerop (length flag)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1459 (push (concat "F:" flag) query)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1460 ;; return query string
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1461 (mapconcat 'identity query " ")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1462
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1463
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1464 (defun nnmairix-widget-create-query (&optional values)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1465 "Create widgets for creating mairix queries.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1466 Fill in VALUES if based on an article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1467 (let (allwidgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1468 (when (get-buffer nnmairix-customize-query-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1469 (kill-buffer nnmairix-customize-query-buffer))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1470 (switch-to-buffer nnmairix-customize-query-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1471 (kill-all-local-variables)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1472 (erase-buffer)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1473 (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
1474 (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
1475 ; (make-local-variable 'nnmairix-widgets)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1476 (setq nnmairix-widgets (nnmairix-widget-build-editable-fields values))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1477 (when (member 'flags nnmairix-widget-other)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1478 (widget-insert "\nFlags:\n Seen: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1479 (nnmairix-widget-add "seen"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1480 'menu-choice
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1481 :value "ignore"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1482 '(item "yes") '(item "no") '(item "ignore"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1483 (widget-insert " Replied: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1484 (nnmairix-widget-add "replied"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1485 'menu-choice
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1486 :value "ignore"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1487 '(item "yes") '(item "no") '(item "ignore"))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1488 (widget-insert " Ticked: ")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1489 (nnmairix-widget-add "flagged"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1490 'menu-choice
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1491 :value "ignore"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1492 '(item "yes") '(item "no") '(item "ignore")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1493 (when (member 'threads nnmairix-widget-other)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1494 (widget-insert "\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1495 (nnmairix-widget-add "Threads" 'checkbox nil))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1496 (widget-insert " Show full threads\n\n")))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1497
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1498
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1499 (defun nnmairix-widget-build-editable-fields (values)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1500 "Build editable field widgets in `nnmairix-widget-fields-list'.
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1501 VALUES may contain values for editable fields from current article."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1502 ;; how can this be done less ugly?
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1503 (let ((ret))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1504 (mapc
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1505 (function
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1506 (lambda (field)
92259
5f51e1a51413 (nnmairix-group-regexp, nnmairix-valid-backends): Convert from free
Glenn Morris <rgm@gnu.org>
parents: 92257
diff changeset
1507 (setq field (car (cddr field)))
92255
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1508 (setq ret
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1509 (nconc
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1510 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1511 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1512 (concat "c" field)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1513 (widget-create 'checkbox
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1514 :tag field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1515 :notify (lambda (widget &rest ignore)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1516 (nnmairix-widget-toggle-activate widget))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1517 nil)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1518 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1519 (list
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1520 (concat "e" field)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1521 (widget-create 'editable-field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1522 :size 60
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1523 :format (concat " " field ":"
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1524 (make-string (- 11 (length field)) ?\ )
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1525 "%v")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1526 :value (or (cadr (assoc field values)) ""))))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1527 ret))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1528 (widget-insert "\n")
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1529 ;; Deactivate editable field
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1530 (widget-apply (cadr (nth 1 ret)) :deactivate)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1531 nnmairix-widget-fields-list)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1532 ret))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1533
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1534 (defun nnmairix-widget-add (name &rest args)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1535 "Add a widget NAME with optional ARGS."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1536 (push
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1537 (list name
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1538 (apply 'widget-create args))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1539 nnmairix-widgets))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1540
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1541 (defun nnmairix-widget-toggle-activate (widget)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1542 "Toggle activation status of WIDGET dependent on corresponding checkbox value."
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1543 (let ((field (widget-get widget :tag)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1544 (if (widget-value widget)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1545 (widget-apply
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1546 (cadr (assoc (concat "e" field) nnmairix-widgets))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1547 :activate)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1548 (widget-apply
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1549 (cadr (assoc (concat "e" field) nnmairix-widgets))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1550 :deactivate)))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1551 (widget-setup))
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1552
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1553 (provide 'nnmairix)
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1554
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1555 ;; arch-tag: bb187498-b229-4a55-8c07-6d3f80713e94
5602f2f74fe4 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1556 ;;; nnmairix.el ends here