1 ;;; nnimap.el --- imap backend for Gnus
2 ;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
4 ;; Author: Simon Josefsson <jas@pdc.kth.se>
5 ;; Jim Radford <radford@robby.caltech.edu>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; Todo, major things:
29 ;; o Fix Gnus to view correct number of unread/total articles in group buffer
30 ;; o Fix Gnus to handle leading '.' in group names (fixed?)
31 ;; o Finish disconnected mode (moving articles between mailboxes unplugged)
33 ;; o MIME (partial article fetches)
34 ;; o Split to other backends, different split rules for different
37 ;; Todo, minor things:
39 ;; o Don't require half of Gnus -- backends should be standalone
40 ;; o Verify that we don't use IMAP4rev1 specific things (RFC2060 App B)
41 ;; o Dont uid fetch 1,* in nnimap-retrive-groups (slow)
42 ;; o Split up big fetches (1,* header especially) in smaller chunks
43 ;; o What do I do with gnus-newsgroup-*?
44 ;; o Tell Gnus about new groups (how can we tell?)
45 ;; o Respooling (fix Gnus?) (unnecessery?)
46 ;; o Add support for the following: (if applicable)
47 ;; request-list-newsgroups, request-regenerate
49 ;; request-associate-buffer, request-restore-buffer,
50 ;; o Do The Right Thing when UIDVALIDITY changes (what's the right thing?)
51 ;; o Support RFC2221 (Login referrals)
52 ;; o IMAP2BIS compatibility? (RFC2061)
53 ;; o ACAP stuff (perhaps a different project, would be nice to ACAPify
55 ;; o What about Gnus's article editing, can we support it? NO!
56 ;; o Use \Draft to support the draft group??
57 ;; o Duplicate suppression
76 (defconst nnimap-version "nnimap 0.131")
78 (defvoo nnimap-address nil
79 "Address of physical IMAP server. If nil, use the virtual server's name.")
81 (defvoo nnimap-server-port nil
82 "Port number on physical IMAP server.
83 If nil, defaults to 993 for SSL connections and 143 otherwise.")
85 ;; Splitting variables
87 (defvar nnimap-split-crosspost t
88 "If non-nil, do crossposting if several split methods match the mail.
89 If nil, the first match found will be used.")
91 (defvar nnimap-split-inbox nil
92 "*Name of mailbox to split mail from.
94 Mail is read from this mailbox and split according to rules in
97 This can be a string or a list of strings.")
99 (defvar nnimap-split-rule nil
100 "*Mail will be split according to theese rules.
102 Mail is read from mailbox(es) specified in `nnimap-split-inbox'.
104 If you'd like, for instance, one mail group for mail from the
105 \"gnus-imap\" mailing list, one group for junk mail and leave
106 everything else in the incoming mailbox, you could do something like
109 (setq nnimap-split-rule '((\"INBOX.gnus-imap\" \"From:.*gnus-imap\")
110 (\"INBOX.junk\" \"Subject:.*buy\")))
112 As you can see, `nnimap-split-rule' is a list of lists, where the first
113 element in each \"rule\" is the name of the IMAP mailbox, and the
114 second is a regexp that nnimap will try to match on the header to find
117 The second element can also be a function. In that case, it will be
118 called narrowed to the headers with the first element of the rule as
119 the argument. It should return a non-nil value if it thinks that the
120 mail belongs in that group.
122 This variable can also have a function as its value, the function will
123 be called with the headers narrowed and should return a group where it
124 thinks the article should be splitted to. See `nnimap-split-fancy'.
126 To allow for different split rules on different virtual servers, and
127 even different split rules in different inboxes on the same server,
128 the syntax of this variable have been extended along the lines of:
130 (setq nnimap-split-rule
131 '((\"my1server\" (\".*\" ((\"ding\" \"ding@gnus.org\")
132 (\"junk\" \"From:.*Simon\")))
133 (\"my2server\" (\"INBOX\" nnimap-split-fancy))
134 (\"my[34]server\" (\".*\" ((\"private\" \"To:.*Simon\")
135 (\"junk\" my-junk-func)))))
137 The virtual server name is in fact a regexp, so that the same rules
138 may apply to several servers. In the example, the servers
139 \"my3server\" and \"my4server\" both use the same rules. Similarly,
140 the inbox string is also a regexp. The actual splitting rules are as
141 before, either a function, or a list with group/regexp or
142 group/function elements.")
144 (defvar nnimap-split-predicate "UNSEEN UNDELETED"
145 "The predicate used to find articles to split.
146 If you use another IMAP client to peek on articles but always would
147 like nnimap to split them once it's started, you could change this to
148 \"UNDELETED\". Other available predicates are available in
149 RFC2060 section 6.4.4.")
151 (defvar nnimap-split-fancy nil
152 "Like `nnmail-split-fancy', which see.")
154 ;; Authorization / Privacy variables
156 (defvoo nnimap-auth-method nil
159 (defvoo nnimap-stream nil
160 "How nnimap will connect to the server.
162 The default, nil, will try to use the \"best\" method the server can
167 1) you want to connect with SSL. The SSL integration with IMAP is
168 brain-dead so you'll have to tell it specifically.
170 2) your server is more capable than your environment -- i.e. your
171 server accept Kerberos login's but you haven't installed the
172 `imtest' program or your machine isn't configured for Kerberos.
174 Possible choices: kerberos4, ssl, network")
176 (defvoo nnimap-authenticator nil
177 "How nnimap authenticate itself to the server.
179 The default, nil, will try to use the \"best\" method the server can
182 There is only one reason for fiddling with this variable, and that is
183 if your server is more capable than your environment -- i.e. you
184 connect to a server that accept Kerberos login's but you haven't
185 installed the `imtest' program or your machine isn't configured for
188 Possible choices: kerberos4, cram-md5, login, anonymous.")
190 (defvoo nnimap-directory (nnheader-concat gnus-directory "overview/")
191 "Directory to keep NOV cache files for nnimap groups.
192 See also `nnimap-nov-file-name'.")
194 (defvoo nnimap-nov-file-name "nnimap."
195 "NOV cache base filename.
196 The group name and `nnimap-nov-file-name-suffix' will be appended. A
197 typical complete file name would be
198 ~/News/overview/nnimap.pdc.INBOX.ding.nov, or
199 ~/News/overview/nnimap/pdc/INBOX/ding/nov if
200 `nnmail-use-long-file-names' is nil")
202 (defvoo nnimap-nov-file-name-suffix ".novcache"
203 "Suffix for NOV cache base filename.")
205 (defvoo nnimap-nov-is-evil nil
206 "If non-nil, nnimap will never generate or use a local nov database for this backend.
207 Using nov databases will speed up header fetching considerably.
208 Unlike other backends, you do not need to take special care if you
209 flip this variable.")
211 (defvoo nnimap-expunge-on-close 'always ; 'ask, 'never
212 "Whether to expunge a group when it is closed.
213 When a IMAP group with articles marked for deletion is closed, this
214 variable determine if nnimap should actually remove the articles or
217 If always, nnimap always perform a expunge when closing the group.
218 If never, nnimap never expunges articles marked for deletion.
219 If ask, nnimap will ask you if you wish to expunge marked articles.
221 When setting this variable to `never', you can only expunge articles
222 by using `G x' (gnus-group-nnimap-expunge) from the Group buffer.")
224 (defvoo nnimap-list-pattern "*"
225 "A string LIMIT or list of strings with mailbox wildcards used to limit available groups.
226 See below for available wildcards.
228 The LIMIT string can be a cons cell (REFERENCE . LIMIT), where
229 REFERENCE will be passed as the first parameter to LIST/LSUB. The
230 semantics of this are server specific, on the University of Washington
231 server you can specify a directory.
234 '(\"INBOX\" \"mail/*\" (\"~friend/mail/\" . \"list/*\"))
236 There are two wildcards * and %. * matches everything, % matches
237 everything in the current hierarchy.")
239 (defvoo nnimap-news-groups nil
240 "IMAP support a news-like mode, also known as bulletin board mode, where replies is sent via IMAP instead of SMTP.
242 This variable should contain a regexp matching groups where you wish
243 replies to be stored to the mailbox directly.
246 '(\"^[^I][^N][^B][^O][^X].*$\")