annotate lisp/gnus/nnmairix.el @ 92599:f90cefa62737

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