annotate lisp/gnus/nnimap.el @ 112401:e80422318be4

gnus-art.el (gnus-mime-display-single): Use mm-display-inline rather than mm-insert-inline.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Fri, 21 Jan 2011 23:33:46 +0000
parents 700b890dcfb5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1 ;;; nnimap.el --- IMAP interface for Gnus
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
2
112045
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111994
diff changeset
3 ;; Copyright (C) 2010, 2011 Free Software Foundation, Inc.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
6 ;; Simon Josefsson <simon@josefsson.org>
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93820
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93820
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93820
diff changeset
13 ;; (at your option) any later version.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93820
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93820
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;;; Commentary:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
25 ;; nnimap interfaces Gnus with IMAP servers.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;;; Code:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
110918
236342431786 nnimap.el (gnutls-negotiate): Silence the byte compiler.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110917
diff changeset
29 ;; For Emacs <22.2 and XEmacs.
236342431786 nnimap.el (gnutls-negotiate): Silence the byte compiler.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110917
diff changeset
30 (eval-and-compile
236342431786 nnimap.el (gnutls-negotiate): Silence the byte compiler.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110917
diff changeset
31 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
236342431786 nnimap.el (gnutls-negotiate): Silence the byte compiler.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110917
diff changeset
32
107427
ecbe0edc4f69 Stop message.el from loading about 40 libraries it doesn't always need.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
33 (eval-and-compile
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
34 (require 'nnheader))
107427
ecbe0edc4f69 Stop message.el from loading about 40 libraries it doesn't always need.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
35
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
36 (eval-when-compile
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
37 (require 'cl))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38
110419
bde55f3d7125 * nnimap.el: Require nnoo and other files necessary.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 110410
diff changeset
39 (require 'nnheader)
bde55f3d7125 * nnimap.el: Require nnoo and other files necessary.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 110410
diff changeset
40 (require 'gnus-util)
bde55f3d7125 * nnimap.el: Require nnoo and other files necessary.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 110410
diff changeset
41 (require 'gnus)
bde55f3d7125 * nnimap.el: Require nnoo and other files necessary.
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents: 110410
diff changeset
42 (require 'nnoo)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
43 (require 'netrc)
110605
5bd3c6bdbcb0 nnimap.el (utf7): Required.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110604
diff changeset
44 (require 'utf7)
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
45 (require 'tls)
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
46 (require 'parse-time)
111283
c6f71b33c8ee Silence nnimap.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
47 (require 'nnmail)
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
48 (require 'proto-stream)
111283
c6f71b33c8ee Silence nnimap.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
49
110633
b1c50a3d738a nnimap.el (auth-source-forget-user-or-password, auth-source-user-or-password): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110615
diff changeset
50 (autoload 'auth-source-forget-user-or-password "auth-source")
b1c50a3d738a nnimap.el (auth-source-forget-user-or-password, auth-source-user-or-password): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110615
diff changeset
51 (autoload 'auth-source-user-or-password "auth-source")
b1c50a3d738a nnimap.el (auth-source-forget-user-or-password, auth-source-user-or-password): Autoload.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110615
diff changeset
52
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 (nnoo-declare nnimap)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 (defvoo nnimap-address nil
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
56 "The address of the IMAP server.")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 (defvoo nnimap-server-port nil
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
59 "The IMAP port used.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
60 If nnimap-stream is `ssl', this will default to `imaps'. If not,
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
61 it will default to `imap'.")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
63 (defvoo nnimap-stream 'undecided
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
64 "How nnimap will talk to the IMAP server.
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
65 Values are `ssl', `network', `starttls' or `shell'.
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
66 The default is to try `ssl' first, and then `network'.")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
68 (defvoo nnimap-shell-program (if (boundp 'imap-shell-program)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
69 (if (listp imap-shell-program)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
70 (car imap-shell-program)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
71 imap-shell-program)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
72 "ssh %s imapd"))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
74 (defvoo nnimap-inbox nil
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
75 "The mail box where incoming mail arrives and should be split out of.")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
77 (defvoo nnimap-split-methods nil
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
78 "How mail is split.
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
79 Uses the same syntax as nnmail-split-methods")
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
80
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
81 (defvoo nnimap-split-fancy nil
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
82 "Uses the same syntax as nnmail-split-fancy.")
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
83
111240
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
84 (defvoo nnimap-unsplittable-articles '(%Deleted %Seen)
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
85 "Articles with the flags in the list will not be considered when splitting.")
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
86
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
87 (make-obsolete-variable 'nnimap-split-rule "see `nnimap-split-methods'"
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
88 "Emacs 24.1")
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
89
110433
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
90 (defvoo nnimap-authenticator nil
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
91 "How nnimap authenticate itself to the server.
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
92 Possible choices are nil (use default methods) or `anonymous'.")
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
93
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
94 (defvoo nnimap-expunge t
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
95 "If non-nil, expunge articles after deleting them.
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
96 This is always done if the server supports UID EXPUNGE, but it's
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
97 not done by default on servers that doesn't support that command.")
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
98
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
99 (defvoo nnimap-streaming t
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
100 "If non-nil, try to use streaming commands with IMAP servers.
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
101 Switching this off will make nnimap slower, but it helps with
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
102 some servers.")
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
103
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
104 (defvoo nnimap-connection-alist nil)
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
105
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
106 (defvoo nnimap-current-infos nil)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
107
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
108 (defvoo nnimap-fetch-partial-articles nil
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
109 "If non-nil, Gnus will fetch partial articles.
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
110 If t, nnimap will fetch only the first part. If a string, it
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
111 will fetch all parts that have types that match that string. A
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
112 likely value would be \"text/\" to automatically fetch all
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
113 textual parts.")
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
114
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
115 (defvar nnimap-process nil)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 56280
diff changeset
116
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
117 (defvar nnimap-status-string "")
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 56280
diff changeset
118
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 56280
diff changeset
119 (defvar nnimap-split-download-body-default nil
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 56280
diff changeset
120 "Internal variable with default value for `nnimap-split-download-body'.")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 56280
diff changeset
121
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
122 (defvar nnimap-keepalive-timer nil)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
123 (defvar nnimap-process-buffers nil)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
124
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
125 (defstruct nnimap
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
126 group process commands capabilities select-result newlinep server
111660
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
127 last-command-time greeting examined)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 56280
diff changeset
128
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
129 (defvar nnimap-object nil)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
131 (defvar nnimap-mark-alist
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
132 '((read "\\Seen" %Seen)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
133 (tick "\\Flagged" %Flagged)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
134 (reply "\\Answered" %Answered)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
135 (expire "gnus-expire")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
136 (dormant "gnus-dormant")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
137 (score "gnus-score")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
138 (save "gnus-save")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
139 (download "gnus-download")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
140 (forward "gnus-forward")))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
142 (defvar nnimap-quirks
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
143 '(("QRESYNC" "Zimbra" "QRESYNC ")))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
144
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
145 (defun nnimap-buffer ()
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
146 (nnimap-find-process-buffer nntp-server-buffer))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147
111168
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
148 (defun nnimap-header-parameters ()
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
149 (format "(UID RFC822.SIZE BODYSTRUCTURE %s)"
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
150 (format
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
151 (if (nnimap-ver4-p)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
152 "BODY.PEEK[HEADER.FIELDS %s]"
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
153 "RFC822.HEADER.LINES %s")
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
154 (append '(Subject From Date Message-Id
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
155 References In-Reply-To Xref)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
156 nnmail-extra-headers))))
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
157
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
158 (deffoo nnimap-retrieve-headers (articles &optional group server fetch-old)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
159 (with-current-buffer nntp-server-buffer
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
160 (erase-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
161 (when (nnimap-possibly-change-group group server)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
162 (with-current-buffer (nnimap-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
163 (erase-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
164 (nnimap-wait-for-response
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
165 (nnimap-send-command
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
166 "UID FETCH %s %s"
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
167 (nnimap-article-ranges (gnus-compress-sequence articles))
111168
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
168 (nnimap-header-parameters))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
169 t)
111994
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111988
diff changeset
170 (nnimap-transform-headers)
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111988
diff changeset
171 (nnheader-remove-cr-followed-by-lf))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
172 (insert-buffer-substring
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
173 (nnimap-find-process-buffer (current-buffer))))
110516
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110502
diff changeset
174 'headers))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
176 (defun nnimap-transform-headers ()
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
177 (goto-char (point-min))
110516
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110502
diff changeset
178 (let (article bytes lines size string)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
179 (block nil
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
180 (while (not (eobp))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
181 (while (not (looking-at "^\\* [0-9]+ FETCH.*UID \\([0-9]+\\)"))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
182 (delete-region (point) (progn (forward-line 1) (point)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
183 (when (eobp)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
184 (return)))
110516
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110502
diff changeset
185 (setq article (match-string 1))
111717
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
186 ;; Unfold quoted {number} strings.
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
187 (while (re-search-forward "[^]][ (]{\\([0-9]+\\)}\r?\n"
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
188 (1+ (line-end-position)) t)
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
189 (setq size (string-to-number (match-string 1)))
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
190 (delete-region (+ (match-beginning 0) 2) (point))
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
191 (setq string (buffer-substring (point) (+ (point) size)))
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
192 (delete-region (point) (+ (point) size))
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
193 (insert (format "%S" string)))
110516
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110502
diff changeset
194 (setq bytes (nnimap-get-length)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
195 lines nil)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
196 (beginning-of-line)
110451
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
197 (setq size
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
198 (and (re-search-forward "RFC822.SIZE \\([0-9]+\\)"
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
199 (line-end-position)
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
200 t)
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
201 (match-string 1)))
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
202 (beginning-of-line)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
203 (when (search-forward "BODYSTRUCTURE" (line-end-position) t)
110516
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110502
diff changeset
204 (let ((structure (ignore-errors
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110502
diff changeset
205 (read (current-buffer)))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
206 (while (and (consp structure)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
207 (not (stringp (car structure))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
208 (setq structure (car structure)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
209 (setq lines (nth 7 structure))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
210 (delete-region (line-beginning-position) (line-end-position))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
211 (insert (format "211 %s Article retrieved." article))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
212 (forward-line 1)
110451
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
213 (when size
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
214 (insert (format "Chars: %s\n" size)))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
215 (when lines
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
216 (insert (format "Lines: %s\n" lines)))
111168
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
217 (unless (re-search-forward "^\r$" nil t)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
218 (goto-char (point-max)))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
219 (delete-region (line-beginning-position) (line-end-position))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
220 (insert ".")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
221 (forward-line 1)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222
111715
d00ba7ce3ef0 nnimap.el (nnimap-unfold-quoted-lines): Refactor out.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111705
diff changeset
223 (defun nnimap-unfold-quoted-lines ()
d00ba7ce3ef0 nnimap.el (nnimap-unfold-quoted-lines): Refactor out.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111705
diff changeset
224 ;; Unfold quoted {number} strings.
111717
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
225 (let (size string)
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
226 (while (re-search-forward " {\\([0-9]+\\)}\r?\n" nil t)
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
227 (setq size (string-to-number (match-string 1)))
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
228 (delete-region (1+ (match-beginning 0)) (point))
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
229 (setq string (buffer-substring (point) (+ (point) size)))
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
230 (delete-region (point) (+ (point) size))
5b0bb82d5f67 nnimap.el (nnimap-last-response-string): Fix last unfolding fix.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111715
diff changeset
231 (insert (format "%S" string)))))
111715
d00ba7ce3ef0 nnimap.el (nnimap-unfold-quoted-lines): Refactor out.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111705
diff changeset
232
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
233 (defun nnimap-get-length ()
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
234 (and (re-search-forward "{\\([0-9]+\\)}" (line-end-position) t)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
235 (string-to-number (match-string 1))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
237 (defun nnimap-article-ranges (ranges)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
238 (let (result)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
239 (cond
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
240 ((numberp ranges)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
241 (number-to-string ranges))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
242 ((numberp (cdr ranges))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
243 (format "%d:%d" (car ranges) (cdr ranges)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
244 (t
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
245 (dolist (elem ranges)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
246 (push
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
247 (if (consp elem)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
248 (format "%d:%d" (car elem) (cdr elem))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
249 (number-to-string elem))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
250 result))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
251 (mapconcat #'identity (nreverse result) ",")))))
107427
ecbe0edc4f69 Stop message.el from loading about 40 libraries it doesn't always need.
Glenn Morris <rgm@gnu.org>
parents: 106815
diff changeset
252
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
253 (deffoo nnimap-open-server (server &optional defs)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 (if (nnimap-server-opened server)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 t
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (unless (assq 'nnimap-address defs)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
257 (setq defs (append defs (list (list 'nnimap-address server)))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 (nnoo-change-server 'nnimap server defs)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
259 (or (nnimap-find-connection nntp-server-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
260 (nnimap-open-connection nntp-server-buffer))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
262 (defun nnimap-make-process-buffer (buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
263 (with-current-buffer
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
264 (generate-new-buffer (format "*nnimap %s %s %s*"
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
265 nnimap-address nnimap-server-port
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
266 (gnus-buffer-exists-p buffer)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
267 (mm-disable-multibyte)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
268 (buffer-disable-undo)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
269 (gnus-add-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
270 (set (make-local-variable 'after-change-functions) nil)
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
271 (set (make-local-variable 'nnimap-object)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
272 (make-nnimap :server (nnoo-current-server 'nnimap)))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
273 (push (list buffer (current-buffer)) nnimap-connection-alist)
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
274 (push (current-buffer) nnimap-process-buffers)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
275 (current-buffer)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276
110587
e474d7d76259 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110583
diff changeset
277 (defun nnimap-credentials (address ports &optional inhibit-create)
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
278 (let (port credentials)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
279 ;; Request the credentials from all ports, but only query on the
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
280 ;; last port if all the previous ones have failed.
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
281 (while (and (null credentials)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
282 (setq port (pop ports)))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
283 (setq credentials
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
284 (auth-source-user-or-password
110587
e474d7d76259 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110583
diff changeset
285 '("login" "password") address port nil
e474d7d76259 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110583
diff changeset
286 (if inhibit-create
e474d7d76259 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110583
diff changeset
287 nil
e474d7d76259 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110583
diff changeset
288 (null ports)))))
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
289 credentials))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
290
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
291 (defun nnimap-keepalive ()
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
292 (let ((now (current-time)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
293 (dolist (buffer nnimap-process-buffers)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
294 (when (buffer-name buffer)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
295 (with-current-buffer buffer
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
296 (when (and nnimap-object
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
297 (nnimap-last-command-time nnimap-object)
111283
c6f71b33c8ee Silence nnimap.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111269
diff changeset
298 (> (gnus-float-time
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
299 (time-subtract
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
300 now
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
301 (nnimap-last-command-time nnimap-object)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
302 ;; More than five minutes since the last command.
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
303 (* 5 60)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
304 (nnimap-send-command "NOOP")))))))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
305
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
306 (defun nnimap-open-connection (buffer)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
307 ;; Be backwards-compatible -- the earlier value of nnimap-stream was
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
308 ;; `ssl' when nnimap-server-port was nil. Sort of.
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
309 (when (and nnimap-server-port
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
310 (eq nnimap-stream 'undecided))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
311 (setq nnimap-stream 'ssl))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
312 (let ((stream
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
313 (if (eq nnimap-stream 'undecided)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
314 (loop for type in '(ssl network)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
315 for stream = (let ((nnimap-stream type))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
316 (nnimap-open-connection-1 buffer))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
317 while (eq stream 'no-connect)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
318 finally (return stream))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
319 (nnimap-open-connection-1 buffer))))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
320 (if (eq stream 'no-connect)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
321 nil
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
322 stream)))
110918
236342431786 nnimap.el (gnutls-negotiate): Silence the byte compiler.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110917
diff changeset
323
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
324 (defun nnimap-open-connection-1 (buffer)
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
325 (unless nnimap-keepalive-timer
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
326 (setq nnimap-keepalive-timer (run-at-time (* 60 15) (* 60 15)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
327 'nnimap-keepalive)))
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
328 (with-current-buffer (nnimap-make-process-buffer buffer)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
329 (let* ((coding-system-for-read 'binary)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
330 (coding-system-for-write 'binary)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
331 (port nil)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
332 (ports
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
333 (cond
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
334 ((or (eq nnimap-stream 'network)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
335 (eq nnimap-stream 'starttls))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
336 (nnheader-message 7 "Opening connection to %s..."
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
337 nnimap-address)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
338 '("143" "imap"))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
339 ((eq nnimap-stream 'shell)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
340 (nnheader-message 7 "Opening connection to %s via shell..."
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
341 nnimap-address)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
342 '("imap"))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
343 ((memq nnimap-stream '(ssl tls))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
344 (nnheader-message 7 "Opening connection to %s via tls..."
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
345 nnimap-address)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
346 '("143" "993" "imap" "imaps"))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
347 (t
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
348 (error "Unknown stream type: %s" nnimap-stream))))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
349 (proto-stream-always-use-starttls t)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
350 login-result credentials)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
351 (when nnimap-server-port
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
352 (setq ports (append ports (list nnimap-server-port))))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
353 (destructuring-bind (stream greeting capabilities)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
354 (open-protocol-stream
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
355 "*nnimap*" (current-buffer) nnimap-address (car (last ports))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
356 :type nnimap-stream
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
357 :shell-command nnimap-shell-program
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
358 :capability-command "1 CAPABILITY\r\n"
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
359 :success " OK "
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
360 :starttls-function
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
361 (lambda (capabilities)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
362 (when (gnus-string-match-p "STARTTLS" capabilities)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
363 "1 STARTTLS\r\n")))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
364 (setf (nnimap-process nnimap-object) stream)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
365 (if (not stream)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
366 (progn
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
367 (nnheader-report 'nnimap "Unable to contact %s:%s via %s"
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
368 nnimap-address port nnimap-stream)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
369 'no-connect)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
370 (gnus-set-process-query-on-exit-flag stream nil)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
371 (if (not (gnus-string-match-p "[*.] \\(OK\\|PREAUTH\\)" greeting))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
372 (nnheader-report 'nnimap "%s" greeting)
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
373 ;; Store the greeting (for debugging purposes).
111789
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
374 (setf (nnimap-greeting nnimap-object) greeting)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
375 (setf (nnimap-capabilities nnimap-object)
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
376 (mapcar #'upcase
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
377 (split-string capabilities)))
f97704487fb3 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111731
diff changeset
378 (unless (gnus-string-match-p "[*.] PREAUTH" greeting)
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
379 (if (not (setq credentials
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
380 (if (eq nnimap-authenticator 'anonymous)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
381 (list "anonymous"
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
382 (message-make-address))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
383 (or
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
384 ;; First look for the credentials based
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
385 ;; on the virtual server name.
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
386 (nnimap-credentials
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
387 (nnoo-current-server 'nnimap) ports t)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
388 ;; Then look them up based on the
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
389 ;; physical address.
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
390 (nnimap-credentials nnimap-address ports)))))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
391 (setq nnimap-object nil)
111240
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
392 (setq login-result
112101
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
393 (nnimap-login (car credentials) (cadr credentials)))
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
394 (unless (car login-result)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
395 ;; If the login failed, then forget the credentials
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
396 ;; that are now possibly cached.
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
397 (dolist (host (list (nnoo-current-server 'nnimap)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
398 nnimap-address))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
399 (dolist (port ports)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
400 (dolist (element '("login" "password"))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
401 (auth-source-forget-user-or-password
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
402 element host port))))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
403 (delete-process (nnimap-process nnimap-object))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
404 (setq nnimap-object nil))))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
405 (when nnimap-object
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
406 (when (nnimap-capability "QRESYNC")
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
407 (nnimap-command "ENABLE QRESYNC"))
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
408 (nnimap-process nnimap-object))))))))
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
409
112101
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
410 (autoload 'rfc2104-hash "rfc2104")
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
411
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
412 (defun nnimap-login (user password)
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
413 (cond
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
414 ((nnimap-capability "AUTH=CRAM-MD5")
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
415 (erase-buffer)
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
416 (let ((sequence (nnimap-send-command "AUTHENTICATE CRAM-MD5"))
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
417 (challenge (nnimap-wait-for-line "^\\+\\(.*\\)\n")))
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
418 (process-send-string
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
419 (get-buffer-process (current-buffer))
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
420 (concat
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
421 (base64-encode-string
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
422 (concat user " "
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
423 (rfc2104-hash 'md5 64 16 password
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
424 (base64-decode-string challenge))))
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
425 "\r\n"))
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
426 (nnimap-wait-for-response sequence)))
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
427 ((not (nnimap-capability "LOGINDISABLED"))
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
428 (nnimap-command "LOGIN %S %S" user password))
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
429 ((nnimap-capability "AUTH=PLAIN")
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
430 (nnimap-command
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
431 "AUTHENTICATE PLAIN %s"
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
432 (base64-encode-string
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
433 (format "\000%s\000%s"
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
434 (nnimap-quote-specials user)
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
435 (nnimap-quote-specials password)))))))
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
436
111240
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
437 (defun nnimap-quote-specials (string)
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
438 (with-temp-buffer
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
439 (insert string)
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
440 (goto-char (point-min))
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
441 (while (re-search-forward "[\\\"]" nil t)
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
442 (forward-char -1)
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
443 (insert "\\")
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
444 (forward-char 1))
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
445 (buffer-string)))
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
446
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
447 (defun nnimap-find-parameter (parameter elems)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
448 (let (result)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
449 (dolist (elem elems)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
450 (cond
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
451 ((equal (car elem) parameter)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
452 (setq result (cdr elem)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
453 ((and (equal (car elem) "OK")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
454 (consp (cadr elem))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
455 (equal (caadr elem) parameter))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
456 (setq result (cdr (cadr elem))))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
457 result))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
459 (deffoo nnimap-close-server (&optional server)
110763
0fe64d68a522 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110689
diff changeset
460 (when (nnoo-change-server 'nnimap server nil)
0fe64d68a522 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110689
diff changeset
461 (ignore-errors
0fe64d68a522 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110689
diff changeset
462 (delete-process (get-buffer-process (nnimap-buffer))))
110970
029adaffe445 nnimap.el (nnimap-close-server): Forget the nnimap data on close.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110968
diff changeset
463 (nnoo-close-server 'nnimap server)
110763
0fe64d68a522 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110689
diff changeset
464 t))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
466 (deffoo nnimap-request-close ()
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
467 t)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
469 (deffoo nnimap-server-opened (&optional server)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
470 (and (nnoo-current-server-p 'nnimap server)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
471 nntp-server-buffer
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
472 (gnus-buffer-live-p nntp-server-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
473 (nnimap-find-connection nntp-server-buffer)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
475 (deffoo nnimap-status-message (&optional server)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
476 nnimap-status-string)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
478 (deffoo nnimap-request-article (article &optional group server to-buffer)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
479 (with-current-buffer nntp-server-buffer
110433
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
480 (let ((result (nnimap-possibly-change-group group server))
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
481 parts structure)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
482 (when (stringp article)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
483 (setq article (nnimap-find-article-by-message-id group article)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
484 (when (and result
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
485 article)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
486 (erase-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
487 (with-current-buffer (nnimap-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
488 (erase-buffer)
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
489 (when nnimap-fetch-partial-articles
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
490 (nnimap-command "UID FETCH %d (BODYSTRUCTURE)" article)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
491 (goto-char (point-min))
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
492 (when (re-search-forward "FETCH.*BODYSTRUCTURE" nil t)
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
493 (setq structure (ignore-errors
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
494 (let ((start (point)))
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
495 (forward-sexp 1)
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
496 (downcase-region start (point))
111065
106c6aef1933 nnimap.el (nnimap-request-article): Fix BODYSTRUCTURE retrieval.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111031
diff changeset
497 (goto-char start)
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
498 (read (current-buffer))))
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
499 parts (nnimap-find-wanted-parts structure))))
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
500 (when (if parts
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
501 (nnimap-get-partial-article article parts structure)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
502 (nnimap-get-whole-article article))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
503 (let ((buffer (current-buffer)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
504 (with-current-buffer (or to-buffer nntp-server-buffer)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
505 (erase-buffer)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
506 (insert-buffer-substring buffer)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
507 (nnheader-ms-strip-cr)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
508 (cons group article)))))))))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
509
111168
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
510 (deffoo nnimap-request-head (article &optional group server to-buffer)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
511 (when (nnimap-possibly-change-group group server)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
512 (with-current-buffer (nnimap-buffer)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
513 (when (stringp article)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
514 (setq article (nnimap-find-article-by-message-id group article)))
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
515 (nnimap-get-whole-article
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
516 article (format "UID FETCH %%d %s"
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
517 (nnimap-header-parameters)))
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
518 (let ((buffer (current-buffer)))
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
519 (with-current-buffer (or to-buffer nntp-server-buffer)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
520 (erase-buffer)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
521 (insert-buffer-substring buffer)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
522 (nnheader-ms-strip-cr)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
523 (cons group article))))))
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
524
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
525 (defun nnimap-get-whole-article (article &optional command)
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
526 (let ((result
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
527 (nnimap-command
111168
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
528 (or command
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
529 (if (nnimap-ver4-p)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
530 "UID FETCH %d BODY.PEEK[]"
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
531 "UID FETCH %d RFC822.PEEK"))
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
532 article)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
533 ;; Check that we really got an article.
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
534 (goto-char (point-min))
110596
415e87a42437 mail-source.el (mail-source-value): Revert previous patch.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110587
diff changeset
535 (unless (re-search-forward "\\* [0-9]+ FETCH" nil t)
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
536 (setq result nil))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
537 (when result
110596
415e87a42437 mail-source.el (mail-source-value): Revert previous patch.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110587
diff changeset
538 ;; Remove any data that may have arrived before the FETCH data.
415e87a42437 mail-source.el (mail-source-value): Revert previous patch.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110587
diff changeset
539 (beginning-of-line)
415e87a42437 mail-source.el (mail-source-value): Revert previous patch.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110587
diff changeset
540 (unless (bobp)
415e87a42437 mail-source.el (mail-source-value): Revert previous patch.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110587
diff changeset
541 (delete-region (point-min) (point)))
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
542 (let ((bytes (nnimap-get-length)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
543 (delete-region (line-beginning-position)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
544 (progn (forward-line 1) (point)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
545 (goto-char (+ (point) bytes))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
546 (delete-region (point) (point-max)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
547 t)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
548
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
549 (defun nnimap-capability (capability)
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
550 (member capability (nnimap-capabilities nnimap-object)))
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
551
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
552 (defun nnimap-ver4-p ()
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
553 (nnimap-capability "IMAP4REV1"))
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
554
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
555 (defun nnimap-get-partial-article (article parts structure)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
556 (let ((result
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
557 (nnimap-command
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
558 "UID FETCH %d (%s %s)"
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
559 article
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
560 (if (nnimap-ver4-p)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
561 "BODY.PEEK[HEADER]"
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
562 "RFC822.HEADER")
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
563 (if (nnimap-ver4-p)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
564 (mapconcat (lambda (part)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
565 (format "BODY.PEEK[%s]" part))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
566 parts " ")
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
567 (mapconcat (lambda (part)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
568 (format "RFC822.PEEK[%s]" part))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
569 parts " ")))))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
570 (when result
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
571 (nnimap-convert-partial-article structure))))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
572
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
573 (defun nnimap-convert-partial-article (structure)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
574 ;; First just skip past the headers.
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
575 (goto-char (point-min))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
576 (let ((bytes (nnimap-get-length))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
577 id parts)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
578 ;; Delete "FETCH" line.
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
579 (delete-region (line-beginning-position)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
580 (progn (forward-line 1) (point)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
581 (goto-char (+ (point) bytes))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
582 ;; Collect all the body parts.
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
583 (while (looking-at ".*BODY\\[\\([.0-9]+\\)\\]")
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
584 (setq id (match-string 1)
112193
700b890dcfb5 proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112101
diff changeset
585 bytes (or (nnimap-get-length) 0))
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
586 (beginning-of-line)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
587 (delete-region (point) (progn (forward-line 1) (point)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
588 (push (list id (buffer-substring (point) (+ (point) bytes)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
589 parts)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
590 (delete-region (point) (+ (point) bytes)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
591 ;; Delete trailing junk.
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
592 (delete-region (point) (point-max))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
593 ;; Now insert all the parts again where they fit in the structure.
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
594 (nnimap-insert-partial-structure structure parts)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
595 t))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
596
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
597 (defun nnimap-insert-partial-structure (structure parts &optional subp)
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
598 (let (type boundary)
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
599 (let ((bstruc structure))
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
600 (while (consp (car bstruc))
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
601 (pop bstruc))
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
602 (setq type (car bstruc))
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
603 (setq bstruc (car (cdr bstruc)))
111067
e36c65ac23bf Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111065
diff changeset
604 (let ((has-boundary (member "boundary" bstruc)))
e36c65ac23bf Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111065
diff changeset
605 (when has-boundary
e36c65ac23bf Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111065
diff changeset
606 (setq boundary (cadr has-boundary)))))
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
607 (when subp
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
608 (insert (format "Content-type: multipart/%s; boundary=%S\n\n"
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
609 (downcase type) boundary)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
610 (while (not (stringp (car structure)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
611 (insert "\n--" boundary "\n")
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
612 (if (consp (caar structure))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
613 (nnimap-insert-partial-structure (pop structure) parts t)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
614 (let ((bit (pop structure)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
615 (insert (format "Content-type: %s/%s"
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
616 (downcase (nth 0 bit))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
617 (downcase (nth 1 bit))))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
618 (if (member "CHARSET" (nth 2 bit))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
619 (insert (format
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
620 "; charset=%S\n" (cadr (member "CHARSET" (nth 2 bit)))))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
621 (insert "\n"))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
622 (insert (format "Content-transfer-encoding: %s\n"
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
623 (nth 5 bit)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
624 (insert "\n")
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
625 (when (assoc (nth 9 bit) parts)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
626 (insert (cadr (assoc (nth 9 bit) parts)))))))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
627 (insert "\n--" boundary "--\n")))
110433
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
628
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
629 (defun nnimap-find-wanted-parts (structure)
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
630 (message-flatten-list (nnimap-find-wanted-parts-1 structure "")))
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
631
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
632 (defun nnimap-find-wanted-parts-1 (structure prefix)
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
633 (let ((num 1)
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
634 parts)
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
635 (while (consp (car structure))
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
636 (let ((sub (pop structure)))
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
637 (if (consp (car sub))
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
638 (push (nnimap-find-wanted-parts-1
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
639 sub (if (string= prefix "")
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
640 (number-to-string num)
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
641 (format "%s.%s" prefix num)))
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
642 parts)
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
643 (let ((type (format "%s/%s" (nth 0 sub) (nth 1 sub)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
644 (id (if (string= prefix "")
110433
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
645 (number-to-string num)
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
646 (format "%s.%s" prefix num))))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
647 (setcar (nthcdr 9 sub) id)
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
648 (when (if (eq nnimap-fetch-partial-articles t)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
649 (equal id "1")
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
650 (string-match nnimap-fetch-partial-articles type))
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
651 (push id parts))))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
652 (incf num)))
110433
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
653 (nreverse parts)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
655 (deffoo nnimap-request-group (group &optional server dont-check info)
111029
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
656 (let ((result (nnimap-possibly-change-group
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
657 ;; Don't SELECT the group if we're going to select it
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
658 ;; later, anyway.
112045
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111994
diff changeset
659 (if (and (not dont-check)
111312
0c7c9736f766 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111299
diff changeset
660 (assoc group nnimap-current-infos))
111029
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
661 nil
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
662 group)
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
663 server))
110451
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
664 articles active marks high low)
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
665 (with-current-buffer nntp-server-buffer
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
666 (when result
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
667 (if (and dont-check
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
668 (setq active (nth 2 (assoc group nnimap-current-infos))))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
669 (insert (format "211 %d %d %d %S\n"
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
670 (- (cdr active) (car active))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
671 (car active)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
672 (cdr active)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
673 group))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
674 (with-current-buffer (nnimap-buffer)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
675 (erase-buffer)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
676 (let ((group-sequence
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
677 (nnimap-send-command "SELECT %S" (utf7-encode group t)))
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
678 (flag-sequence
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
679 (nnimap-send-command "UID FETCH 1:* FLAGS")))
111029
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
680 (setf (nnimap-group nnimap-object) group)
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
681 (nnimap-wait-for-response flag-sequence)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
682 (setq marks
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
683 (nnimap-flags-to-marks
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
684 (nnimap-parse-flags
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
685 (list (list group-sequence flag-sequence
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
686 1 group "SELECT")))))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
687 (when (and info
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
688 marks)
111312
0c7c9736f766 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111299
diff changeset
689 (nnimap-update-infos marks (list info))
0c7c9736f766 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111299
diff changeset
690 (nnimap-store-info info (gnus-active (gnus-info-group info))))
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
691 (goto-char (point-max))
110516
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110502
diff changeset
692 (let ((uidnext (nth 5 (car marks))))
110689
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
693 (setq high (or (if uidnext
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
694 (1- uidnext)
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
695 (nth 3 (car marks)))
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
696 0)
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
697 low (or (nth 4 (car marks)) uidnext 1)))))
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
698 (erase-buffer)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
699 (insert
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
700 (format
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
701 "211 %d %d %d %S\n" (1+ (- high low)) low high group)))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
702 t))))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
703
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
704 (deffoo nnimap-request-create-group (group &optional server args)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
705 (when (nnimap-possibly-change-group nil server)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
706 (with-current-buffer (nnimap-buffer)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
707 (car (nnimap-command "CREATE %S" (utf7-encode group t))))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
708
110451
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
709 (deffoo nnimap-request-delete-group (group &optional force server)
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
710 (when (nnimap-possibly-change-group nil server)
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
711 (with-current-buffer (nnimap-buffer)
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
712 (car (nnimap-command "DELETE %S" (utf7-encode group t))))))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
713
110804
30fed27e97bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110790
diff changeset
714 (deffoo nnimap-request-rename-group (group new-name &optional server)
30fed27e97bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110790
diff changeset
715 (when (nnimap-possibly-change-group nil server)
30fed27e97bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110790
diff changeset
716 (with-current-buffer (nnimap-buffer)
111660
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
717 (nnimap-unselect-group)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
718 (car (nnimap-command "RENAME %S %S"
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
719 (utf7-encode group t) (utf7-encode new-name t))))))
110804
30fed27e97bc Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110790
diff changeset
720
111660
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
721 (defun nnimap-unselect-group ()
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
722 ;; Make sure we don't have this group open read/write by asking
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
723 ;; to examine a mailbox that doesn't exist. This seems to be
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
724 ;; the only way that allows us to reliably go back to unselected
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
725 ;; state on Courier.
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
726 (nnimap-command "EXAMINE DOES.NOT.EXIST"))
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
727
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
728 (deffoo nnimap-request-expunge-group (group &optional server)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
729 (when (nnimap-possibly-change-group group server)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
730 (with-current-buffer (nnimap-buffer)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
731 (car (nnimap-command "EXPUNGE")))))
110451
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
732
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
733 (defun nnimap-get-flags (spec)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
734 (let ((articles nil)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
735 elems end)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
736 (with-current-buffer (nnimap-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
737 (erase-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
738 (nnimap-wait-for-response (nnimap-send-command
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
739 "UID FETCH %s FLAGS" spec))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
740 (setq end (point))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
741 (subst-char-in-region (point-min) (point-max)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
742 ?\\ ?% t)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
743 (goto-char (point-min))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
744 (while (search-forward " FETCH " end t)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
745 (setq elems (read (current-buffer)))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
746 (push (cons (cadr (memq 'UID elems))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
747 (cadr (memq 'FLAGS elems)))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
748 articles)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
749 (nreverse articles)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 56280
diff changeset
750
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
751 (deffoo nnimap-close-group (group &optional server)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
752 t)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
753
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
754 (deffoo nnimap-request-move-article (article group server accept-form
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
755 &optional last internal-move-group)
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
756 (with-temp-buffer
111031
4bed37ddc92b * lisp/gnus/nnimap.el (nnimap-request-move-article, nnimap-parse-line)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111029
diff changeset
757 (mm-disable-multibyte)
111168
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
758 (when (funcall (if internal-move-group
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
759 'nnimap-request-head
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
760 'nnimap-request-article)
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
761 article group server (current-buffer))
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
762 ;; If the move is internal (on the same server), just do it the easy
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
763 ;; way.
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
764 (let ((message-id (message-field-value "message-id")))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
765 (if internal-move-group
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
766 (let ((result
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
767 (with-current-buffer (nnimap-buffer)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
768 (nnimap-command "UID COPY %d %S"
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
769 article
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
770 (utf7-encode internal-move-group t)))))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
771 (when (car result)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
772 (nnimap-delete-article article)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
773 (cons internal-move-group
111719
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
774 (or (nnimap-find-uid-response "COPYUID" (cadr result))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
775 (nnimap-find-article-by-message-id
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
776 internal-move-group message-id)))))
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
777 ;; Move the article to a different method.
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
778 (let ((result (eval accept-form)))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
779 (when result
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
780 (nnimap-delete-article article)
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
781 result)))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
782
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
783 (deffoo nnimap-request-expire-articles (articles group &optional server force)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
784 (cond
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
785 ((null articles)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
786 nil)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
787 ((not (nnimap-possibly-change-group group server))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
788 articles)
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
789 ((and force
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
790 (eq nnmail-expiry-target 'delete))
110596
415e87a42437 mail-source.el (mail-source-value): Revert previous patch.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110587
diff changeset
791 (unless (nnimap-delete-article (gnus-compress-sequence articles))
111014
c6a7ac5bcef4 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110999
diff changeset
792 (nnheader-message 7 "Article marked for deletion, but not expunged."))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
793 nil)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
794 (t
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
795 (let ((deletable-articles
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
796 (if (or force
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
797 (eq nnmail-expiry-wait 'immediate))
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
798 articles
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
799 (gnus-sorted-intersection
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
800 articles
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
801 (nnimap-find-expired-articles group)))))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
802 (if (null deletable-articles)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
803 articles
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
804 (if (eq nnmail-expiry-target 'delete)
110596
415e87a42437 mail-source.el (mail-source-value): Revert previous patch.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110587
diff changeset
805 (nnimap-delete-article (gnus-compress-sequence deletable-articles))
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
806 (setq deletable-articles
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
807 (nnimap-process-expiry-targets
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
808 deletable-articles group server)))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
809 ;; Return the articles we didn't delete.
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
810 (gnus-sorted-complement articles deletable-articles))))))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
811
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
812 (defun nnimap-process-expiry-targets (articles group server)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
813 (let ((deleted-articles nil))
111830
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
814 (cond
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
815 ;; shortcut further processing if we're going to delete the articles
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
816 ((eq nnmail-expiry-target 'delete)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
817 (setq deleted-articles articles)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
818 t)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
819 ;; or just move them to another folder on the same IMAP server
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
820 ((and (not (functionp nnmail-expiry-target))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
821 (gnus-server-equal (gnus-group-method nnmail-expiry-target)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
822 (gnus-server-to-method
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
823 (format "nnimap:%s" server))))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
824 (and (nnimap-possibly-change-group group server)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
825 (with-current-buffer (nnimap-buffer)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
826 (nnheader-message 7 "Expiring articles from %s: %s" group articles)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
827 (nnimap-command
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
828 "UID COPY %s %S"
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
829 (nnimap-article-ranges (gnus-compress-sequence articles))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
830 (utf7-encode (gnus-group-real-name nnmail-expiry-target) t))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
831 (setq deleted-articles articles)))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
832 t)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
833 (t
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
834 (dolist (article articles)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
835 (let ((target nnmail-expiry-target))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
836 (with-temp-buffer
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
837 (mm-disable-multibyte)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
838 (when (nnimap-request-article article group server (current-buffer))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
839 (nnheader-message 7 "Expiring article %s:%d" group article)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
840 (when (functionp target)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
841 (setq target (funcall target group)))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
842 (when (and target
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
843 (not (eq target 'delete)))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
844 (if (or (gnus-request-group target t)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
845 (gnus-request-create-group target))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
846 (nnmail-expiry-target-group target group)
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
847 (setq target nil)))
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
848 (when target
79219ca01c7b Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111789
diff changeset
849 (push article deleted-articles))))))))
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
850 ;; Change back to the current group again.
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
851 (nnimap-possibly-change-group group server)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
852 (setq deleted-articles (nreverse deleted-articles))
110596
415e87a42437 mail-source.el (mail-source-value): Revert previous patch.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110587
diff changeset
853 (nnimap-delete-article (gnus-compress-sequence deleted-articles))
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
854 deleted-articles))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
855
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
856 (defun nnimap-find-expired-articles (group)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
857 (let ((cutoff (nnmail-expired-article-p group nil nil)))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
858 (with-current-buffer (nnimap-buffer)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
859 (let ((result
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
860 (nnimap-command
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
861 "UID SEARCH SENTBEFORE %s"
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
862 (format-time-string
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
863 (format "%%d-%s-%%Y"
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
864 (upcase
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
865 (car (rassoc (nth 4 (decode-time cutoff))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
866 parse-time-months))))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
867 cutoff))))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
868 (and (car result)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
869 (delete 0 (mapcar #'string-to-number
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
870 (cdr (assoc "SEARCH" (cdr result))))))))))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
871
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
872
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
873 (defun nnimap-find-article-by-message-id (group message-id)
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
874 (with-current-buffer (nnimap-buffer)
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
875 (erase-buffer)
111401
733acab855e4 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111312
diff changeset
876 (unless (equal group (nnimap-group nnimap-object))
733acab855e4 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111312
diff changeset
877 (setf (nnimap-group nnimap-object) nil)
111660
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
878 (setf (nnimap-examined nnimap-object) group)
111401
733acab855e4 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111312
diff changeset
879 (nnimap-send-command "EXAMINE %S" (utf7-encode group t)))
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
880 (let ((sequence
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
881 (nnimap-send-command "UID SEARCH HEADER Message-Id %S" message-id))
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
882 article result)
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
883 (setq result (nnimap-wait-for-response sequence))
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
884 (when (and result
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
885 (car (setq result (nnimap-parse-response))))
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
886 ;; Select the last instance of the message in the group.
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
887 (and (setq article
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
888 (car (last (assoc "SEARCH" (cdr result)))))
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
889 (string-to-number article))))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
890
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
891 (defun nnimap-delete-article (articles)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
892 (with-current-buffer (nnimap-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
893 (nnimap-command "UID STORE %s +FLAGS.SILENT (\\Deleted)"
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
894 (nnimap-article-ranges articles))
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
895 (cond
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
896 ((nnimap-capability "UIDPLUS")
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
897 (nnimap-command "UID EXPUNGE %s"
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
898 (nnimap-article-ranges articles))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
899 t)
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
900 (nnimap-expunge
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
901 (nnimap-command "EXPUNGE")
110479
437c7aaf08fd nnimap.el (nnimap-delete-article): Tell user if expunge won't happen.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110465
diff changeset
902 t)
437c7aaf08fd nnimap.el (nnimap-delete-article): Tell user if expunge won't happen.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110465
diff changeset
903 (t (gnus-message 7 (concat "nnimap: nnimap-expunge is not set and the "
437c7aaf08fd nnimap.el (nnimap-delete-article): Tell user if expunge won't happen.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110465
diff changeset
904 "server doesn't support UIDPLUS, so we won't "
437c7aaf08fd nnimap.el (nnimap-delete-article): Tell user if expunge won't happen.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110465
diff changeset
905 "delete this article now"))))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
906
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
907 (deffoo nnimap-request-scan (&optional group server)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
908 (when (and (nnimap-possibly-change-group nil server)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
909 nnimap-inbox
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
910 nnimap-split-methods)
111014
c6a7ac5bcef4 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110999
diff changeset
911 (nnheader-message 7 "nnimap %s splitting mail..." server)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
912 (nnimap-split-incoming-mail)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
913
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
914 (defun nnimap-marks-to-flags (marks)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
915 (let (flags flag)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
916 (dolist (mark marks)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
917 (when (setq flag (cadr (assq mark nnimap-mark-alist)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
918 (push flag flags)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
919 flags))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
920
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
921 (deffoo nnimap-request-update-group-status (group status &optional server)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
922 (when (nnimap-possibly-change-group nil server)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
923 (let ((command (assoc
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
924 status
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
925 '((subscribe "SUBSCRIBE")
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
926 (unsubscribe "UNSUBSCRIBE")))))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
927 (when command
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
928 (with-current-buffer (nnimap-buffer)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
929 (nnimap-command "%s %S" (cadr command) (utf7-encode group t)))))))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
930
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
931 (deffoo nnimap-request-set-mark (group actions &optional server)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
932 (when (nnimap-possibly-change-group group server)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
933 (let (sequence)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
934 (with-current-buffer (nnimap-buffer)
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
935 (erase-buffer)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
936 ;; Just send all the STORE commands without waiting for
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
937 ;; response. If they're successful, they're successful.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
938 (dolist (action actions)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
939 (destructuring-bind (range action marks) action
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
940 (let ((flags (nnimap-marks-to-flags marks)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
941 (when flags
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
942 (setq sequence (nnimap-send-command
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
943 "UID STORE %s %sFLAGS.SILENT (%s)"
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
944 (nnimap-article-ranges range)
111721
7bb815042e61 nnml.el, nnfolder.el, nntp.el (*-request-set-mark): Extend syntax with 'set.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111720
diff changeset
945 (cond
7bb815042e61 nnml.el, nnfolder.el, nntp.el (*-request-set-mark): Extend syntax with 'set.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111720
diff changeset
946 ((eq action 'del) "-")
111722
c0bbb7dd9600 nnimap.el (nnimap-request-set-mark): Add is "+", not "-".
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111721
diff changeset
947 ((eq action 'add) "+")
111721
7bb815042e61 nnml.el, nnfolder.el, nntp.el (*-request-set-mark): Extend syntax with 'set.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111720
diff changeset
948 ((eq action 'set) ""))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
949 (mapconcat #'identity flags " ")))))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
950 ;; Wait for the last command to complete to avoid later
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
951 ;; syncronisation problems with the stream.
110451
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
952 (when sequence
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
953 (nnimap-wait-for-response sequence))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
954
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
955 (deffoo nnimap-request-accept-article (group &optional server last)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
956 (when (nnimap-possibly-change-group nil server)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
957 (nnmail-check-syntax)
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
958 (let ((message-id (message-field-value "message-id"))
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
959 sequence message)
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
960 (nnimap-add-cr)
111070
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
961 (setq message (buffer-substring-no-properties (point-min) (point-max)))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
962 (with-current-buffer (nnimap-buffer)
111660
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
963 ;; If we have this group open read-only, then unselect it
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
964 ;; before appending to it.
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
965 (when (equal (nnimap-examined nnimap-object) group)
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
966 (nnimap-unselect-group))
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
967 (erase-buffer)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
968 (setq sequence (nnimap-send-command
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
969 "APPEND %S {%d}" (utf7-encode group t)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
970 (length message)))
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
971 (unless nnimap-streaming
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
972 (nnimap-wait-for-connection "^[+]"))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
973 (process-send-string (get-buffer-process (current-buffer)) message)
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
974 (process-send-string (get-buffer-process (current-buffer))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
975 (if (nnimap-newlinep nnimap-object)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
976 "\n"
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
977 "\r\n"))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
978 (let ((result (nnimap-get-response sequence)))
110604
71a0913fcc8c gnus-html.el (gnus-html-wash-tags): Decode URL entities to avoid handing broken links to browse-url.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110596
diff changeset
979 (if (not (car result))
71a0913fcc8c gnus-html.el (gnus-html-wash-tags): Decode URL entities to avoid handing broken links to browse-url.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110596
diff changeset
980 (progn
111014
c6a7ac5bcef4 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110999
diff changeset
981 (nnheader-message 7 "%s" (nnheader-get-report-string 'nnimap))
110604
71a0913fcc8c gnus-html.el (gnus-html-wash-tags): Decode URL entities to avoid handing broken links to browse-url.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110596
diff changeset
982 nil)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
983 (cons group
111719
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
984 (or (nnimap-find-uid-response "APPENDUID" (car result))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
985 (nnimap-find-article-by-message-id
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
986 group message-id)))))))))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
987
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
988 (defun nnimap-find-uid-response (name list)
111720
cb1fa19c3f33 nnimap.el (nnimap-find-uid-response): The UID is the last element in the list.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111719
diff changeset
989 (let ((result (car (last (nnimap-find-response-element name list)))))
111719
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
990 (and result
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
991 (string-to-number result))))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
992
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
993 (defun nnimap-find-response-element (name list)
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
994 (let (result)
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
995 (dolist (elem list)
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
996 (when (and (consp elem)
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
997 (equal name (car elem)))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
998 (setq result elem)))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
999 result))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1000
111070
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1001 (deffoo nnimap-request-replace-article (article group buffer)
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1002 (let (group-art)
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1003 (when (and (nnimap-possibly-change-group group nil)
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1004 ;; Put the article into the group.
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1005 (with-current-buffer buffer
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1006 (setq group-art
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1007 (nnimap-request-accept-article group nil t))))
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1008 (nnimap-delete-article (list article))
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1009 ;; Return the new article number.
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1010 (cdr group-art))))
25ddbcf2f2ea Allow nnimap article editing (sort of).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111067
diff changeset
1011
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1012 (defun nnimap-add-cr ()
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1013 (goto-char (point-min))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1014 (while (re-search-forward "\r?\n" nil t)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1015 (replace-match "\r\n" t t)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1016
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1017 (defun nnimap-get-groups ()
111719
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1018 (erase-buffer)
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1019 (let ((sequence (nnimap-send-command "LIST \"\" \"*\""))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1020 groups)
111719
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1021 (nnimap-wait-for-response sequence)
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1022 (subst-char-in-region (point-min) (point-max)
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1023 ?\\ ?% t)
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1024 (goto-char (point-min))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1025 (nnimap-unfold-quoted-lines)
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1026 (goto-char (point-min))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1027 (while (search-forward "* LIST " nil t)
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1028 (let ((flags (read (current-buffer)))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1029 (separator (read (current-buffer)))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1030 (group (read (current-buffer))))
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1031 (unless (member '%NoSelect flags)
111731
8071f778f77e nnimap.el (nnimap-request-set-mark): Remove left over.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111722
diff changeset
1032 (push (if (stringp group)
8071f778f77e nnimap.el (nnimap-request-set-mark): Remove left over.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111722
diff changeset
1033 group
8071f778f77e nnimap.el (nnimap-request-set-mark): Remove left over.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111722
diff changeset
1034 (format "%s" group))
8071f778f77e nnimap.el (nnimap-request-set-mark): Remove left over.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111722
diff changeset
1035 groups))))
111719
2ec43a7063b3 nnimap.el: Use the UID returned when copying and accepting articles, instead of searching for the ID (on the servers that support it).
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111718
diff changeset
1036 (nreverse groups)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 56280
diff changeset
1037
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1038 (deffoo nnimap-request-list (&optional server)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1039 (nnimap-possibly-change-group nil server)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1040 (with-current-buffer nntp-server-buffer
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1041 (erase-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1042 (let ((groups
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1043 (with-current-buffer (nnimap-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1044 (nnimap-get-groups)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1045 sequences responses)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1046 (when groups
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1047 (with-current-buffer (nnimap-buffer)
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1048 (setf (nnimap-group nnimap-object) nil)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 56280
diff changeset
1049 (dolist (group groups)
111660
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
1050 (setf (nnimap-examined nnimap-object) group)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1051 (push (list (nnimap-send-command "EXAMINE %S" (utf7-encode group t))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1052 group)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1053 sequences))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1054 (nnimap-wait-for-response (caar sequences))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1055 (setq responses
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1056 (nnimap-get-responses (mapcar #'car sequences))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1057 (dolist (response responses)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1058 (let* ((sequence (car response))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1059 (response (cadr response))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1060 (group (cadr (assoc sequence sequences))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1061 (when (and group
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1062 (equal (caar response) "OK"))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1063 (let ((uidnext (nnimap-find-parameter "UIDNEXT" response))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1064 highest exists)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1065 (dolist (elem response)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1066 (when (equal (cadr elem) "EXISTS")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1067 (setq exists (string-to-number (car elem)))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1068 (when uidnext
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1069 (setq highest (1- (string-to-number (car uidnext)))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1070 (cond
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1071 ((null highest)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1072 (insert (format "%S 0 1 y\n" (utf7-decode group t))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1073 ((zerop exists)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1074 ;; Empty group.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1075 (insert (format "%S %d %d y\n"
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1076 (utf7-decode group t) highest (1+ highest))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1077 (t
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1078 ;; Return the widest possible range.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1079 (insert (format "%S %d 1 y\n" (utf7-decode group t)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1080 (or highest exists)))))))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1081 t))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1082
110689
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
1083 (deffoo nnimap-request-newgroups (date &optional server)
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
1084 (nnimap-possibly-change-group nil server)
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
1085 (with-current-buffer nntp-server-buffer
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
1086 (erase-buffer)
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
1087 (dolist (group (with-current-buffer (nnimap-buffer)
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
1088 (nnimap-get-groups)))
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
1089 (unless (assoc group nnimap-current-infos)
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
1090 ;; Insert dummy numbers here -- they don't matter.
110777
895607aec71e Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
1091 (insert (format "%S 0 1 y\n" group))))
895607aec71e Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110763
diff changeset
1092 t))
110689
42815c76b976 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110679
diff changeset
1093
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1094 (deffoo nnimap-retrieve-group-data-early (server infos)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1095 (when (nnimap-possibly-change-group nil server)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1096 (with-current-buffer (nnimap-buffer)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1097 (erase-buffer)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1098 (setf (nnimap-group nnimap-object) nil)
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
1099 (let ((qresyncp (nnimap-capability "QRESYNC"))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1100 params groups sequences active uidvalidity modseq group)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1101 ;; Go through the infos and gather the data needed to know
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1102 ;; what and how to request the data.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1103 (dolist (info infos)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1104 (setq params (gnus-info-params info)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1105 group (gnus-group-real-name (gnus-info-group info))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1106 active (cdr (assq 'active params))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1107 uidvalidity (cdr (assq 'uidvalidity params))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1108 modseq (cdr (assq 'modseq params)))
111660
42b6f450ae22 nnimap.el (nnimap-unselect-group): Made into its own function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111479
diff changeset
1109 (setf (nnimap-examined nnimap-object) group)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1110 (if (and qresyncp
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1111 uidvalidity
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1112 modseq)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1113 (push
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1114 (list (nnimap-send-command "EXAMINE %S (%s (%s %s))"
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1115 (utf7-encode group t)
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1116 (nnimap-quirk "QRESYNC")
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1117 uidvalidity modseq)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1118 'qresync
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1119 nil group 'qresync)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1120 sequences)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1121 (let ((start
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1122 (if (and active uidvalidity)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1123 ;; Fetch the last 100 flags.
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1124 (max 1 (- (cdr active) 100))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1125 1))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1126 (command
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1127 (if uidvalidity
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1128 "EXAMINE"
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1129 ;; If we don't have a UIDVALIDITY, then this is
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1130 ;; the first time we've seen the group, so we
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1131 ;; have to do a SELECT (which is slower than an
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1132 ;; examine), but will tell us whether the group
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1133 ;; is read-only or not.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1134 "SELECT")))
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1135 (push (list (nnimap-send-command "%s %S" command
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1136 (utf7-encode group t))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1137 (nnimap-send-command "UID FETCH %d:* FLAGS" start)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1138 start group command)
111168
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
1139 sequences))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1140 sequences))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1141
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1142 (defun nnimap-quirk (command)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1143 (let ((quirk (assoc command nnimap-quirks)))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1144 ;; If this server is of a type that matches a quirk, then return
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1145 ;; the "quirked" command instead of the proper one.
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1146 (if (or (null quirk)
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1147 (not (string-match (nth 1 quirk) (nnimap-greeting nnimap-object))))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1148 command
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1149 (nth 2 quirk))))
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1150
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1151 (deffoo nnimap-finish-retrieve-group-infos (server infos sequences)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1152 (when (and sequences
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1153 (nnimap-possibly-change-group nil server))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1154 (with-current-buffer (nnimap-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1155 ;; Wait for the final data to trickle in.
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1156 (when (nnimap-wait-for-response (if (eq (cadar sequences) 'qresync)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1157 (caar sequences)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1158 (cadar sequences))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1159 t)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1160 ;; Now we should have most of the data we need, no matter
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1161 ;; whether we're QRESYNCING, fetching all the flags from
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1162 ;; scratch, or just fetching the last 100 flags per group.
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1163 (nnimap-update-infos (nnimap-flags-to-marks
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1164 (nnimap-parse-flags
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1165 (nreverse sequences)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1166 infos)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1167 ;; Finally, just return something resembling an active file in
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1168 ;; the nntp buffer, so that the agent can save the info, too.
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1169 (with-current-buffer nntp-server-buffer
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1170 (erase-buffer)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1171 (dolist (info infos)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1172 (let* ((group (gnus-info-group info))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1173 (active (gnus-active group)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1174 (when active
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1175 (insert (format "%S %d %d y\n"
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1176 (gnus-group-real-name group)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1177 (cdr active)
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1178 (car active)))))))))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1179
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1180 (defun nnimap-update-infos (flags infos)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1181 (dolist (info infos)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1182 (let* ((group (gnus-group-real-name (gnus-info-group info)))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1183 (marks (cdr (assoc group flags))))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1184 (when marks
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1185 (nnimap-update-info info marks)))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49274
diff changeset
1186
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1187 (defun nnimap-update-info (info marks)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1188 (destructuring-bind (existing flags high low uidnext start-article
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1189 permanent-flags uidvalidity
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1190 vanished highestmodseq) marks
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1191 (cond
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1192 ;; Ignore groups with no UIDNEXT/marks. This happens for
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1193 ;; completely empty groups.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1194 ((and (not existing)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1195 (not uidnext))
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1196 (let ((active (cdr (assq 'active (gnus-info-params info)))))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1197 (when active
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1198 (gnus-set-active (gnus-info-group info) active))))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1199 ;; We have a mismatch between the old and new UIDVALIDITY
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1200 ;; identifiers, so we have to re-request the group info (the next
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1201 ;; time). This virtually never happens.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1202 ((let ((old-uidvalidity
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1203 (cdr (assq 'uidvalidity (gnus-info-params info)))))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1204 (and old-uidvalidity
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1205 (not (equal old-uidvalidity uidvalidity))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1206 (> start-article 1)))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1207 (gnus-group-remove-parameter info 'uidvalidity)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1208 (gnus-group-remove-parameter info 'modseq))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1209 ;; We have the data needed to update.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1210 (t
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1211 (let* ((group (gnus-info-group info))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1212 (completep (and start-article
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1213 (= start-article 1)))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1214 (active (or (gnus-active group)
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1215 (cdr (assq 'active (gnus-info-params info))))))
110516
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110502
diff changeset
1216 (when uidnext
4d2f8b81bb01 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110502
diff changeset
1217 (setq high (1- uidnext)))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1218 ;; First set the active ranges based on high/low.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1219 (if (or completep
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1220 (not (gnus-active group)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1221 (gnus-set-active group
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1222 (cond
111479
244f248736b4 nnimap.el (nnimap-update-info): Fix problem with `g' chopping of low-numbered articles.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111430
diff changeset
1223 (active
244f248736b4 nnimap.el (nnimap-update-info): Fix problem with `g' chopping of low-numbered articles.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111430
diff changeset
1224 (cons (min (or low (car active))
244f248736b4 nnimap.el (nnimap-update-info): Fix problem with `g' chopping of low-numbered articles.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111430
diff changeset
1225 (car active))
244f248736b4 nnimap.el (nnimap-update-info): Fix problem with `g' chopping of low-numbered articles.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111430
diff changeset
1226 (max (or high (cdr active))
244f248736b4 nnimap.el (nnimap-update-info): Fix problem with `g' chopping of low-numbered articles.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111430
diff changeset
1227 (cdr active))))
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1228 ((and low high)
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1229 (cons low high))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1230 (uidnext
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1231 ;; No articles in this group.
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1232 (cons uidnext (1- uidnext)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1233 (start-article
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1234 (cons start-article (1- start-article)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1235 (t
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1236 ;; No articles and no uidnext.
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1237 nil)))
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
1238 (gnus-set-active
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
1239 group
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1240 (cons (car active)
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
1241 (or high (1- uidnext)))))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1242 ;; See whether this is a read-only group.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1243 (unless (eq permanent-flags 'not-scanned)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1244 (gnus-group-set-parameter
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1245 info 'permanent-flags
111029
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1246 (and (or (memq '%* permanent-flags)
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1247 (memq '%Seen permanent-flags))
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1248 permanent-flags)))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1249 ;; Update marks and read articles if this isn't a
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1250 ;; read-only IMAP group.
111029
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1251 (when (setq permanent-flags
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1252 (cdr (assq 'permanent-flags (gnus-info-params info))))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1253 (if (and highestmodseq
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1254 (not start-article))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1255 ;; We've gotten the data by QRESYNCing.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1256 (nnimap-update-qresync-info
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1257 info existing (nnimap-imap-ranges-to-gnus-ranges vanished) flags)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1258 ;; Do normal non-QRESYNC flag updates.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1259 ;; Update the list of read articles.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1260 (let* ((unread
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1261 (gnus-compress-sequence
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1262 (gnus-set-difference
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1263 (gnus-set-difference
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1264 existing
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1265 (cdr (assoc '%Seen flags)))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1266 (cdr (assoc '%Flagged flags)))))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1267 (read (gnus-range-difference
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1268 (cons start-article high) unread)))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1269 (when (> start-article 1)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1270 (setq read
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1271 (gnus-range-nconcat
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1272 (if (> start-article 1)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1273 (gnus-sorted-range-intersection
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1274 (cons 1 (1- start-article))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1275 (gnus-info-read info))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1276 (gnus-info-read info))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1277 read)))
111029
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1278 (when (or (not (listp permanent-flags))
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1279 (memq '%Seen permanent-flags))
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1280 (gnus-info-set-read info read))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1281 ;; Update the marks.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1282 (setq marks (gnus-info-marks info))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1283 (dolist (type (cdr nnimap-mark-alist))
111029
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1284 (when (or (not (listp permanent-flags))
111242
4ec0d0a0569f nnimap.el (nnimap-update-info): Allow 'ticked and other flags to be set on groups that don't have \* permanentflags.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111240
diff changeset
1285 (memq (car (assoc (caddr type) flags))
4ec0d0a0569f nnimap.el (nnimap-update-info): Allow 'ticked and other flags to be set on groups that don't have \* permanentflags.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111240
diff changeset
1286 permanent-flags)
111029
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1287 (memq '%* permanent-flags))
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1288 (let ((old-marks (assoc (car type) marks))
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1289 (new-marks
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1290 (gnus-compress-sequence
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1291 (cdr (or (assoc (caddr type) flags) ; %Flagged
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1292 (assoc (intern (cadr type) obarray) flags)
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1293 (assoc (cadr type) flags)))))) ; "\Flagged"
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1294 (setq marks (delq old-marks marks))
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1295 (pop old-marks)
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1296 (when (and old-marks
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1297 (> start-article 1))
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1298 (setq old-marks (gnus-range-difference
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1299 old-marks
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1300 (cons start-article high)))
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1301 (setq new-marks (gnus-range-nconcat old-marks new-marks)))
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1302 (when new-marks
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1303 (push (cons (car type) new-marks) marks)))))
fc6dc700cc9f Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111014
diff changeset
1304 (gnus-info-set-marks info marks t))))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1305 ;; Note the active level for the next run-through.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1306 (gnus-group-set-parameter info 'active (gnus-active group))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1307 (gnus-group-set-parameter info 'uidvalidity uidvalidity)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1308 (gnus-group-set-parameter info 'modseq highestmodseq)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1309 (nnimap-store-info info (gnus-active group)))))))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1310
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1311 (defun nnimap-update-qresync-info (info existing vanished flags)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1312 ;; Add all the vanished articles to the list of read articles.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1313 (gnus-info-set-read
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1314 info
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1315 (gnus-add-to-range
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1316 (gnus-add-to-range
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1317 (gnus-range-add (gnus-info-read info)
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1318 vanished)
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1319 (cdr (assq '%Flagged flags)))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1320 (cdr (assq '%Seen flags))))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1321 (let ((marks (gnus-info-marks info)))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1322 (dolist (type (cdr nnimap-mark-alist))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1323 (let ((ticks (assoc (car type) marks))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1324 (new-marks
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1325 (cdr (or (assoc (caddr type) flags) ; %Flagged
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1326 (assoc (intern (cadr type) obarray) flags)
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1327 (assoc (cadr type) flags))))) ; "\Flagged"
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1328 (setq marks (delq ticks marks))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1329 (pop ticks)
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1330 ;; Add the new marks we got.
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1331 (setq ticks (gnus-add-to-range ticks new-marks))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1332 ;; Remove the marks from messages that don't have them.
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1333 (setq ticks (gnus-remove-from-range
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1334 ticks
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1335 (gnus-compress-sequence
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1336 (gnus-sorted-complement existing new-marks))))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1337 (when ticks
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1338 (push (cons (car type) ticks) marks)))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1339 (gnus-info-set-marks info marks t))))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1340
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1341 (defun nnimap-imap-ranges-to-gnus-ranges (irange)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1342 (if (zerop (length irange))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1343 nil
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1344 (let ((result nil))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1345 (dolist (elem (split-string irange ","))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1346 (push
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1347 (if (string-match ":" elem)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1348 (let ((numbers (split-string elem ":")))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1349 (cons (string-to-number (car numbers))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1350 (string-to-number (cadr numbers))))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1351 (string-to-number elem))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1352 result))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1353 (nreverse result))))
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1354
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1355 (defun nnimap-store-info (info active)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1356 (let* ((group (gnus-group-real-name (gnus-info-group info)))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1357 (entry (assoc group nnimap-current-infos)))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1358 (if entry
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1359 (setcdr entry (list info active))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1360 (push (list group info active) nnimap-current-infos))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1361
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1362 (defun nnimap-flags-to-marks (groups)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1363 (let (data group totalp uidnext articles start-article mark permanent-flags
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1364 uidvalidity vanished highestmodseq)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1365 (dolist (elem groups)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1366 (setq group (car elem)
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1367 uidnext (nth 1 elem)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1368 start-article (nth 2 elem)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1369 permanent-flags (nth 3 elem)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1370 uidvalidity (nth 4 elem)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1371 vanished (nth 5 elem)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1372 highestmodseq (nth 6 elem)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1373 articles (nthcdr 7 elem))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1374 (let ((high (caar articles))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1375 marks low existing)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1376 (dolist (article articles)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1377 (setq low (car article))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1378 (push (car article) existing)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1379 (dolist (flag (cdr article))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1380 (setq mark (assoc flag marks))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1381 (if (not mark)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1382 (push (list flag (car article)) marks)
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1383 (setcdr mark (cons (car article) (cdr mark))))))
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1384 (push (list group existing marks high low uidnext start-article
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1385 permanent-flags uidvalidity vanished highestmodseq)
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1386 data)))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1387 data))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1388
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1389 (defun nnimap-parse-flags (sequences)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1390 (goto-char (point-min))
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1391 ;; Change \Delete etc to %Delete, so that the reader can read it.
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1392 (subst-char-in-region (point-min) (point-max)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1393 ?\\ ?% t)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1394 (let (start end articles groups uidnext elems permanent-flags
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1395 uidvalidity vanished highestmodseq)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1396 (dolist (elem sequences)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1397 (destructuring-bind (group-sequence flag-sequence totalp group command)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1398 elem
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1399 (setq start (point))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1400 (when (and
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1401 ;; The EXAMINE was successful.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1402 (search-forward (format "\n%d OK " group-sequence) nil t)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1403 (progn
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1404 (forward-line 1)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1405 (setq end (point))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1406 (goto-char start)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1407 (setq permanent-flags
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1408 (if (equal command "SELECT")
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1409 (and (search-forward "PERMANENTFLAGS "
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1410 (or end (point-min)) t)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1411 (read (current-buffer)))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1412 'not-scanned))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1413 (goto-char start)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1414 (setq uidnext
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1415 (and (search-forward "UIDNEXT "
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1416 (or end (point-min)) t)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1417 (read (current-buffer))))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1418 (goto-char start)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1419 (setq uidvalidity
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1420 (and (re-search-forward "UIDVALIDITY \\([0-9]+\\)"
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1421 (or end (point-min)) t)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1422 ;; Store UIDVALIDITY as a string, as it's
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1423 ;; too big for 32-bit Emacsen, usually.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1424 (match-string 1)))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1425 (goto-char start)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1426 (setq vanished
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1427 (and (eq flag-sequence 'qresync)
111846
076a5b56d8c9 shr.el (shr-tag-table-1): Use bg/gfcolor specs on tables.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111838
diff changeset
1428 (re-search-forward "^\\* VANISHED .* \\([0-9:,]+\\)"
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1429 (or end (point-min)) t)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1430 (match-string 1)))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1431 (goto-char start)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1432 (setq highestmodseq
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1433 (and (search-forward "HIGHESTMODSEQ "
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1434 (or end (point-min)) t)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1435 (read (current-buffer))))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1436 (goto-char end)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1437 (forward-line -1))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1438 ;; The UID FETCH FLAGS was successful.
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1439 (or (eq flag-sequence 'qresync)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1440 (search-forward (format "\n%d OK " flag-sequence) nil t)))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1441 (if (eq flag-sequence 'qresync)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1442 (progn
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1443 (goto-char start)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1444 (setq start end))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1445 (setq start (point))
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1446 (goto-char end))
110968
3958dbde1223 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110957
diff changeset
1447 (while (re-search-forward "^\\* [0-9]+ FETCH " start t)
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1448 (setq elems (read (current-buffer)))
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1449 (push (cons (cadr (memq 'UID elems))
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1450 (cadr (memq 'FLAGS elems)))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1451 articles))
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1452 (push (nconc (list group uidnext totalp permanent-flags uidvalidity
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1453 vanished highestmodseq)
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1454 articles)
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1455 groups)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1456 (goto-char end)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1457 (setq articles nil))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1458 groups))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1459
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1460 (defun nnimap-find-process-buffer (buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1461 (cadr (assoc buffer nnimap-connection-alist)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1462
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1463 (deffoo nnimap-request-post (&optional server)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1464 (setq nnimap-status-string "Read-only server")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1465 nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1466
111838
de6f9af48bfa Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111830
diff changeset
1467 (deffoo nnimap-request-thread (header)
de6f9af48bfa Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111830
diff changeset
1468 (let* ((id (mail-header-id header))
de6f9af48bfa Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111830
diff changeset
1469 (refs (split-string
de6f9af48bfa Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111830
diff changeset
1470 (or (mail-header-references header)
111430
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1471 "")))
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1472 (cmd (let ((value
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1473 (format
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1474 "(OR HEADER REFERENCES %s HEADER Message-Id %s)"
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1475 id id)))
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1476 (dolist (refid refs value)
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1477 (setq value (format
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1478 "(OR (OR HEADER Message-Id %s HEADER REFERENCES %s) %s)"
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1479 refid refid value)))))
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1480 (result (with-current-buffer (nnimap-buffer)
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1481 (nnimap-command "UID SEARCH %s" cmd))))
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1482 (gnus-fetch-headers
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1483 (and (car result) (delete 0 (mapcar #'string-to-number
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1484 (cdr (assoc "SEARCH" (cdr result))))))
b75e6634a171 gnus-int.el, nnimap.el, nnir.el: More improvements to thread-referral.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111401
diff changeset
1485 nil t)))
110999
9330a5183ae6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110995
diff changeset
1486
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1487 (defun nnimap-possibly-change-group (group server)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1488 (let ((open-result t))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1489 (when (and server
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1490 (not (nnimap-server-opened server)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1491 (setq open-result (nnimap-open-server server)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1492 (cond
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1493 ((not open-result)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1494 nil)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1495 ((not group)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1496 t)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1497 (t
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1498 (with-current-buffer (nnimap-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1499 (if (equal group (nnimap-group nnimap-object))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1500 t
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1501 (let ((result (nnimap-command "SELECT %S" (utf7-encode group t))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1502 (when (car result)
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1503 (setf (nnimap-group nnimap-object) group
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1504 (nnimap-select-result nnimap-object) result)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1505 result))))))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1506
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1507 (defun nnimap-find-connection (buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1508 "Find the connection delivering to BUFFER."
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1509 (let ((entry (assoc buffer nnimap-connection-alist)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1510 (when entry
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1511 (if (and (buffer-name (cadr entry))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1512 (get-buffer-process (cadr entry))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1513 (memq (process-status (get-buffer-process (cadr entry)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1514 '(open run)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1515 (get-buffer-process (cadr entry))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1516 (setq nnimap-connection-alist (delq entry nnimap-connection-alist))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1517 nil))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1518
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1519 (defvar nnimap-sequence 0)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1520
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1521 (defun nnimap-send-command (&rest args)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1522 (process-send-string
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1523 (get-buffer-process (current-buffer))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1524 (nnimap-log-command
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1525 (format "%d %s%s\n"
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1526 (incf nnimap-sequence)
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1527 (apply #'format args)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1528 (if (nnimap-newlinep nnimap-object)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1529 ""
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1530 "\r"))))
111168
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
1531 ;; Some servers apparently can't have many outstanding
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
1532 ;; commands, so throttle them.
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
1533 (unless nnimap-streaming
d1079095427d Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111070
diff changeset
1534 (nnimap-wait-for-response nnimap-sequence))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1535 nnimap-sequence)
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 49274
diff changeset
1536
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1537 (defun nnimap-log-command (command)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1538 (with-current-buffer (get-buffer-create "*imap log*")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1539 (goto-char (point-max))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1540 (insert (format-time-string "%H:%M:%S") " " command))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1541 command)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1542
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1543 (defun nnimap-command (&rest args)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1544 (erase-buffer)
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1545 (setf (nnimap-last-command-time nnimap-object) (current-time))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1546 (let* ((sequence (apply #'nnimap-send-command args))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1547 (response (nnimap-get-response sequence)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1548 (if (equal (caar response) "OK")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1549 (cons t response)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1550 (nnheader-report 'nnimap "%s"
110451
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
1551 (mapconcat (lambda (a)
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
1552 (format "%s" a))
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
1553 (car response) " "))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1554 nil)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1555
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1556 (defun nnimap-get-response (sequence)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1557 (nnimap-wait-for-response sequence)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1558 (nnimap-parse-response))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1559
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
1560 (defun nnimap-wait-for-connection (&optional regexp)
112101
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
1561 (nnimap-wait-for-line (or regexp "^[*.] .*\n") "[*.] \\([A-Z0-9]+\\)"))
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
1562
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
1563 (defun nnimap-wait-for-line (regexp &optional response-regexp)
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1564 (let ((process (get-buffer-process (current-buffer))))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1565 (goto-char (point-min))
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1566 (while (and (memq (process-status process)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1567 '(open run))
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
1568 (not (re-search-forward regexp nil t)))
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1569 (nnheader-accept-process-output process)
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1570 (goto-char (point-min)))
110433
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
1571 (forward-line -1)
112101
f17e96101723 nnimap.el (nnimap-login): Refactored out into own function, and implement CRAM-MD5.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 112045
diff changeset
1572 (and (looking-at (or response-regexp regexp))
110433
33cf78a271ef Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110428
diff changeset
1573 (match-string 1))))
110422
93e093c035a0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110419
diff changeset
1574
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1575 (defun nnimap-wait-for-response (sequence &optional messagep)
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1576 (let ((process (get-buffer-process (current-buffer)))
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1577 openp)
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1578 (condition-case nil
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1579 (progn
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1580 (goto-char (point-max))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1581 (while (and (setq openp (memq (process-status process)
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1582 '(open run)))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1583 (not (re-search-backward
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1584 (format "^%d .*\n" sequence)
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1585 (if nnimap-streaming
111986
faa4a1c986c6 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111972
diff changeset
1586 (max (point-min)
111988
edfb54ff984c nnimap.el (nnimap-wait-for-response): Fix the end-point calculation to really consider the last line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111986
diff changeset
1587 (min
edfb54ff984c nnimap.el (nnimap-wait-for-response): Fix the end-point calculation to really consider the last line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111986
diff changeset
1588 (- (point) 500)
edfb54ff984c nnimap.el (nnimap-wait-for-response): Fix the end-point calculation to really consider the last line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111986
diff changeset
1589 (save-excursion
111994
c92e0a5c96e9 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111988
diff changeset
1590 (forward-line -3)
111988
edfb54ff984c nnimap.el (nnimap-wait-for-response): Fix the end-point calculation to really consider the last line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111986
diff changeset
1591 (point))))
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1592 (point-min))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1593 t)))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1594 (when messagep
111014
c6a7ac5bcef4 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110999
diff changeset
1595 (nnheader-message 7 "nnimap read %dk" (/ (buffer-size) 1000)))
110908
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1596 (nnheader-accept-process-output process)
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1597 (goto-char (point-max)))
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1598 openp)
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1599 (quit
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1600 ;; The user hit C-g while we were waiting: kill the process, in case
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1601 ;; it's a gnutls-cli process that's stuck (tends to happen a lot behind
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1602 ;; NAT routers).
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1603 (delete-process process)
2a4bfc24abf0 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110898
diff changeset
1604 nil))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1605
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1606 (defun nnimap-parse-response ()
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1607 (let ((lines (split-string (nnimap-last-response-string) "\r\n" t))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1608 result)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1609 (dolist (line lines)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1610 (push (cdr (nnimap-parse-line line)) result))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1611 ;; Return the OK/error code first, and then all the "continuation
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1612 ;; lines" afterwards.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1613 (cons (pop result)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1614 (nreverse result))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1615
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1616 ;; Parse an IMAP response line lightly. They look like
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1617 ;; "* OK [UIDVALIDITY 1164213559] UIDs valid", typically, so parse
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1618 ;; the lines into a list of strings and lists of string.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1619 (defun nnimap-parse-line (line)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1620 (let (char result)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1621 (with-temp-buffer
111031
4bed37ddc92b * lisp/gnus/nnimap.el (nnimap-request-move-article, nnimap-parse-line)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111029
diff changeset
1622 (mm-disable-multibyte)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1623 (insert line)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1624 (goto-char (point-min))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1625 (while (not (eobp))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1626 (if (eql (setq char (following-char)) ? )
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1627 (forward-char 1)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1628 (push
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1629 (cond
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1630 ((eql char ?\[)
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1631 (split-string
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1632 (buffer-substring
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1633 (1+ (point))
111312
0c7c9736f766 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111299
diff changeset
1634 (if (search-forward "]" (line-end-position) 'move)
0c7c9736f766 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111299
diff changeset
1635 (1- (point))
0c7c9736f766 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111299
diff changeset
1636 (point)))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1637 ((eql char ?\()
110898
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1638 (split-string
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1639 (buffer-substring
069deed4cdec Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110810
diff changeset
1640 (1+ (point))
111312
0c7c9736f766 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111299
diff changeset
1641 (if (search-forward ")" (line-end-position) 'move)
0c7c9736f766 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111299
diff changeset
1642 (1- (point))
0c7c9736f766 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111299
diff changeset
1643 (point)))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1644 ((eql char ?\")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1645 (forward-char 1)
110615
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
1646 (buffer-substring
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
1647 (point)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
1648 (1- (or (search-forward "\"" (line-end-position) 'move)
84a76c5e1b1c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110605
diff changeset
1649 (point)))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1650 (t
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1651 (buffer-substring (point) (if (search-forward " " nil t)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1652 (1- (point))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1653 (goto-char (point-max))))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1654 result)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1655 (nreverse result))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1656
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1657 (defun nnimap-last-response-string ()
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1658 (save-excursion
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1659 (forward-line 1)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1660 (let ((end (point)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1661 (forward-line -1)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1662 (when (not (bobp))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1663 (forward-line -1)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1664 (while (and (not (bobp))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1665 (eql (following-char) ?*))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1666 (forward-line -1))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1667 (unless (eql (following-char) ?*)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1668 (forward-line 1)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1669 (buffer-substring (point) end))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1670
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1671 (defun nnimap-get-responses (sequences)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1672 (let (responses)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1673 (dolist (sequence sequences)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1674 (goto-char (point-min))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1675 (when (re-search-forward (format "^%d " sequence) nil t)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1676 (push (list sequence (nnimap-parse-response))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1677 responses)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1678 responses))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1679
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1680 (defvar nnimap-incoming-split-list nil)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 56280
diff changeset
1681
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1682 (defun nnimap-fetch-inbox (articles)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1683 (erase-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1684 (nnimap-wait-for-response
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1685 (nnimap-send-command
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1686 "UID FETCH %s %s"
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1687 (nnimap-article-ranges articles)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1688 (format "(UID %s%s)"
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1689 (format
110583
b6d2a63ad993 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110568
diff changeset
1690 (if (nnimap-ver4-p)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1691 "BODY.PEEK[HEADER] BODY.PEEK"
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1692 "RFC822.PEEK"))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1693 (if nnimap-split-download-body-default
110451
4b82113fd203 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110433
diff changeset
1694 "[]"
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1695 "[1]")))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1696 t))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1697
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1698 (defun nnimap-split-incoming-mail ()
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1699 (with-current-buffer (nnimap-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1700 (let ((nnimap-incoming-split-list nil)
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
1701 (nnmail-split-methods (if (eq nnimap-split-methods 'default)
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
1702 nnmail-split-methods
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
1703 nnimap-split-methods))
110666
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
1704 (nnmail-split-fancy (or nnimap-split-fancy
3b9bd3888ee9 nnimap.el (nnimap-request-accept-article): Get the Message-ID without the \r.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
1705 nnmail-split-fancy))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1706 (nnmail-inhibit-default-split-group t)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1707 (groups (nnimap-get-groups))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1708 new-articles)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1709 (erase-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1710 (nnimap-command "SELECT %S" nnimap-inbox)
111240
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
1711 (setf (nnimap-group nnimap-object) nnimap-inbox)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1712 (setq new-articles (nnimap-new-articles (nnimap-get-flags "1:*")))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1713 (when new-articles
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1714 (nnimap-fetch-inbox new-articles)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1715 (nnimap-transform-split-mail)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1716 (nnheader-ms-strip-cr)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1717 (nnmail-cache-open)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1718 (nnmail-split-incoming (current-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1719 #'nnimap-save-mail-spec
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1720 nil nil
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1721 #'nnimap-dummy-active-number
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1722 #'nnimap-save-mail-spec)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1723 (when nnimap-incoming-split-list
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1724 (let ((specs (nnimap-make-split-specs nnimap-incoming-split-list))
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1725 sequences junk-articles)
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1726 ;; Create any groups that doesn't already exist on the
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1727 ;; server first.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1728 (dolist (spec specs)
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1729 (when (and (not (member (car spec) groups))
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1730 (not (eq (car spec) 'junk)))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1731 (nnimap-command "CREATE %S" (utf7-encode (car spec) t))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1732 ;; Then copy over all the messages.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1733 (erase-buffer)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1734 (dolist (spec specs)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1735 (let ((group (car spec))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1736 (ranges (cdr spec)))
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1737 (if (eq group 'junk)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1738 (setq junk-articles ranges)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1739 (push (list (nnimap-send-command
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1740 "UID COPY %s %S"
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1741 (nnimap-article-ranges ranges)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1742 (utf7-encode group t))
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1743 ranges)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1744 sequences))))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1745 ;; Wait for the last COPY response...
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1746 (when sequences
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1747 (nnimap-wait-for-response (caar sequences))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1748 ;; And then mark the successful copy actions as deleted,
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1749 ;; and possibly expunge them.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1750 (nnimap-mark-and-expunge-incoming
110555
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1751 (nnimap-parse-copied-articles sequences)))
e07971bb896c Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110516
diff changeset
1752 (nnimap-mark-and-expunge-incoming junk-articles)))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1753
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1754 (defun nnimap-mark-and-expunge-incoming (range)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1755 (when range
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1756 (setq range (nnimap-article-ranges range))
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110633
diff changeset
1757 (erase-buffer)
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1758 (let ((sequence
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1759 (nnimap-send-command
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1760 "UID STORE %s +FLAGS.SILENT (\\Deleted)" range)))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1761 (cond
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1762 ;; If the server supports it, we now delete the message we have
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1763 ;; just copied over.
111269
3d7a1caabf14 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111242
diff changeset
1764 ((nnimap-capability "UIDPLUS")
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1765 (setq sequence (nnimap-send-command "UID EXPUNGE %s" range)))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1766 ;; If it doesn't support UID EXPUNGE, then we only expunge if the
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1767 ;; user has configured it.
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1768 (nnimap-expunge
110465
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1769 (setq sequence (nnimap-send-command "EXPUNGE"))))
b7b7e970d807 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110451
diff changeset
1770 (nnimap-wait-for-response sequence))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1771
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1772 (defun nnimap-parse-copied-articles (sequences)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1773 (let (sequence copied range)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1774 (goto-char (point-min))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1775 (while (re-search-forward "^\\([0-9]+\\) OK " nil t)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1776 (setq sequence (string-to-number (match-string 1)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1777 (when (setq range (cadr (assq sequence sequences)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1778 (push (gnus-uncompress-range range) copied)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1779 (gnus-compress-sequence (sort (apply #'nconc copied) #'<))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1780
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1781 (defun nnimap-new-articles (flags)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1782 (let (new)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1783 (dolist (elem flags)
111240
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
1784 (unless (gnus-list-memq-of-list nnimap-unsplittable-articles
ffb890b32d37 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111204
diff changeset
1785 (cdr elem))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1786 (push (car elem) new)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1787 (gnus-compress-sequence (nreverse new))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1788
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1789 (defun nnimap-make-split-specs (list)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1790 (let ((specs nil)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1791 entry)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1792 (dolist (elem list)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1793 (destructuring-bind (article spec) elem
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1794 (dolist (group (delete nil (mapcar #'car spec)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1795 (unless (setq entry (assoc group specs))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1796 (push (setq entry (list group)) specs))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1797 (setcdr entry (cons article (cdr entry))))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1798 (dolist (entry specs)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1799 (setcdr entry (gnus-compress-sequence (sort (cdr entry) #'<))))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1800 specs))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1801
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1802 (defun nnimap-transform-split-mail ()
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1803 (goto-char (point-min))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1804 (let (article bytes)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1805 (block nil
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1806 (while (not (eobp))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1807 (while (not (looking-at "^\\* [0-9]+ FETCH.*UID \\([0-9]+\\)"))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1808 (delete-region (point) (progn (forward-line 1) (point)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1809 (when (eobp)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1810 (return)))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1811 (setq article (match-string 1)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1812 bytes (nnimap-get-length))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1813 (delete-region (line-beginning-position) (line-end-position))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1814 ;; Insert MMDF separator, and a way to remember what this
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1815 ;; article UID is.
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1816 (insert (format "\^A\^A\^A\^A\n\nX-nnimap-article: %s" article))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1817 (forward-char (1+ bytes))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1818 (setq bytes (nnimap-get-length))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1819 (delete-region (line-beginning-position) (line-end-position))
110917
3243e7055d49 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
1820 ;; There's a body; skip past that.
3243e7055d49 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
1821 (when bytes
3243e7055d49 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
1822 (forward-char (1+ bytes))
3243e7055d49 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110908
diff changeset
1823 (delete-region (line-beginning-position) (line-end-position)))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1824
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1825 (defun nnimap-dummy-active-number (group &optional server)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1826 1)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1827
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1828 (defun nnimap-save-mail-spec (group-art &optional server full-nov)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1829 (let (article)
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1830 (goto-char (point-min))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1831 (if (not (re-search-forward "X-nnimap-article: \\([0-9]+\\)" nil t))
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1832 (error "Invalid nnimap mail")
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1833 (setq article (string-to-number (match-string 1))))
110486
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1834 (push (list article
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1835 (if (eq group-art 'junk)
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1836 (list (cons 'junk 1))
1ad1adb298a3 Merge Changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110479
diff changeset
1837 group-art))
110410
f2e111723c3a Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110219
diff changeset
1838 nnimap-incoming-split-list)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1839
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1840 (provide 'nnimap)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1841
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1842 ;;; nnimap.el ends here