Mercurial > emacs
annotate lisp/gnus/nntp.el @ 54268:7716e9c7a9ef
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 04 Mar 2004 17:16:56 +0000 |
parents | 695cf19ef79e |
children | fede5cef1a1e 375f2633d815 |
rev | line source |
---|---|
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1 ;;; nntp.el --- nntp access for Gnus |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
2 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
3 ;; Copyright (C) 1987, 1988, 1989, 1990, 1992, 1993, 1994, 1995, 1996, |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
4 ;; 1997, 1998, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. |
17493 | 5 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 7 ;; Keywords: news |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;;; Code: | |
28 | |
29 (require 'nnheader) | |
30 (require 'nnoo) | |
31 (require 'gnus-util) | |
32 | |
33 (nnoo-declare nntp) | |
34 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
35 (eval-when-compile (require 'cl)) |
17493 | 36 |
37 (defvoo nntp-address nil | |
38 "Address of the physical nntp server.") | |
39 | |
40 (defvoo nntp-port-number "nntp" | |
41 "Port number on the physical nntp server.") | |
42 | |
43 (defvoo nntp-server-opened-hook '(nntp-send-mode-reader) | |
44 "*Hook used for sending commands to the server at startup. | |
45 The default value is `nntp-send-mode-reader', which makes an innd | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
46 server spawn an nnrpd server.") |
17493 | 47 |
48 (defvoo nntp-authinfo-function 'nntp-send-authinfo | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
49 "Function used to send AUTHINFO to the server. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
50 It is called with no parameters.") |
17493 | 51 |
52 (defvoo nntp-server-action-alist | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
53 '(("nntpd 1\\.5\\.11t" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
54 (remove-hook 'nntp-server-opened-hook 'nntp-send-mode-reader)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
55 ("NNRP server Netscape" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
56 (setq nntp-server-list-active-group nil))) |
17493 | 57 "Alist of regexps to match on server types and actions to be taken. |
58 For instance, if you want Gnus to beep every time you connect | |
59 to innd, you could say something like: | |
60 | |
61 \(setq nntp-server-action-alist | |
62 '((\"innd\" (ding)))) | |
63 | |
64 You probably don't want to do that, though.") | |
65 | |
66 (defvoo nntp-open-connection-function 'nntp-open-network-stream | |
67 "*Function used for connecting to a remote system. | |
68 It will be called with the buffer to output in. | |
69 | |
70 Two pre-made functions are `nntp-open-network-stream', which is the | |
71 default, and simply connects to some port or other on the remote | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
72 system (see nntp-port-number). The other are `nntp-open-rlogin', |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
73 which does an rlogin on the remote system, and then does a telnet to |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
74 the NNTP server available there (see nntp-rlogin-parameters) and |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
75 `nntp-open-telnet' which telnets to a remote system, logs in and does |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
76 the same.") |
17493 | 77 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
78 (defvoo nntp-rlogin-program "rsh" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
79 "*Program used to log in on remote machines. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
80 The default is \"rsh\", but \"ssh\" is a popular alternative.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
81 |
17493 | 82 (defvoo nntp-rlogin-parameters '("telnet" "-8" "${NNTPSERVER:=news}" "nntp") |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
83 "*Parameters to `nntp-open-rlogin'. |
17493 | 84 That function may be used as `nntp-open-connection-function'. In that |
85 case, this list will be used as the parameter list given to rsh.") | |
86 | |
87 (defvoo nntp-rlogin-user-name nil | |
88 "*User name on remote system when using the rlogin connect method.") | |
89 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
90 (defvoo nntp-telnet-parameters |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
91 '("exec" "telnet" "-8" "${NNTPSERVER:=news}" "nntp") |
17493 | 92 "*Parameters to `nntp-open-telnet'. |
93 That function may be used as `nntp-open-connection-function'. In that | |
94 case, this list will be executed as a command after logging in | |
95 via telnet.") | |
96 | |
97 (defvoo nntp-telnet-user-name nil | |
98 "User name to log in via telnet with.") | |
99 | |
100 (defvoo nntp-telnet-passwd nil | |
101 "Password to use to log in via telnet with.") | |
102 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
103 (defvoo nntp-open-telnet-envuser nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
104 "*If non-nil, telnet session (client and server both) will support the ENVIRON option and not prompt for login name.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
105 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
106 (defvoo nntp-telnet-shell-prompt "bash\\|\$ *\r?$\\|> *\r?" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
107 "*Regular expression to match the shell prompt on the remote machine.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
108 |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
109 (defvoo nntp-telnet-command "telnet" |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
110 "Command used to start telnet.") |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
111 |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
112 (defvoo nntp-telnet-switches '("-8") |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
113 "Switches given to the telnet command.") |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
114 |
17493 | 115 (defvoo nntp-end-of-line "\r\n" |
116 "String to use on the end of lines when talking to the NNTP server. | |
117 This is \"\\r\\n\" by default, but should be \"\\n\" when | |
118 using rlogin or telnet to communicate with the server.") | |
119 | |
120 (defvoo nntp-large-newsgroup 50 | |
121 "*The number of the articles which indicates a large newsgroup. | |
122 If the number of the articles is greater than the value, verbose | |
123 messages will be shown to indicate the current status.") | |
124 | |
125 (defvoo nntp-maximum-request 400 | |
126 "*The maximum number of the requests sent to the NNTP server at one time. | |
127 If Emacs hangs up while retrieving headers, set the variable to a | |
128 lower value.") | |
129 | |
130 (defvoo nntp-nov-is-evil nil | |
131 "*If non-nil, nntp will never attempt to use XOVER when talking to the server.") | |
132 | |
133 (defvoo nntp-xover-commands '("XOVER" "XOVERVIEW") | |
134 "*List of strings that are used as commands to fetch NOV lines from a server. | |
135 The strings are tried in turn until a positive response is gotten. If | |
136 none of the commands are successful, nntp will just grab headers one | |
137 by one.") | |
138 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
139 (defvoo nntp-nov-gap 5 |
17493 | 140 "*Maximum allowed gap between two articles. |
141 If the gap between two consecutive articles is bigger than this | |
142 variable, split the XOVER request into two requests.") | |
143 | |
144 (defvoo nntp-prepare-server-hook nil | |
145 "*Hook run before a server is opened. | |
146 If can be used to set up a server remotely, for instance. Say you | |
147 have an account at the machine \"other.machine\". This machine has | |
148 access to an NNTP server that you can't access locally. You could | |
149 then use this hook to rsh to the remote machine and start a proxy NNTP | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
150 server there that you can connect to. See also |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
151 `nntp-open-connection-function'") |
17493 | 152 |
153 (defvoo nntp-warn-about-losing-connection t | |
154 "*If non-nil, beep when a server closes connection.") | |
155 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
156 (defvoo nntp-coding-system-for-read 'binary |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
157 "*Coding system to read from NNTP.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
158 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
159 (defvoo nntp-coding-system-for-write 'binary |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
160 "*Coding system to write to NNTP.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
161 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
162 (defcustom nntp-authinfo-file "~/.authinfo" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
163 ".netrc-like file that holds nntp authinfo passwords." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
164 :type |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
165 '(choice file |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
166 (repeat :tag "Entries" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
167 :menu-tag "Inline" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
168 (list :format "%v" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
169 :value ("" ("login" . "") ("password" . "")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
170 (string :tag "Host") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
171 (checklist :inline t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
172 (cons :format "%v" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
173 (const :format "" "login") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
174 (string :format "Login: %v")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
175 (cons :format "%v" |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
176 (const :format "" "password") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
177 (string :format "Password: %v"))))))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
178 |
17493 | 179 |
180 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
181 (defvoo nntp-connection-timeout nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
182 "*Number of seconds to wait before an nntp connection times out. |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
183 If this variable is nil, which is the default, no timers are set. |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
184 NOTE: This variable is never seen to work in Emacs 20 and XEmacs 21.") |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
185 |
17493 | 186 ;;; Internal variables. |
187 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
188 (defvar nntp-record-commands nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
189 "*If non-nil, nntp will record all commands in the \"*nntp-log*\" buffer.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
190 |
17493 | 191 (defvar nntp-have-messaged nil) |
192 | |
193 (defvar nntp-process-wait-for nil) | |
194 (defvar nntp-process-to-buffer nil) | |
195 (defvar nntp-process-callback nil) | |
196 (defvar nntp-process-decode nil) | |
197 (defvar nntp-process-start-point nil) | |
198 (defvar nntp-inside-change-function nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
199 (defvoo nntp-last-command-time nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
200 (defvoo nntp-last-command nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
201 (defvoo nntp-authinfo-password nil) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
202 (defvoo nntp-authinfo-user nil) |
17493 | 203 |
204 (defvar nntp-connection-list nil) | |
205 | |
206 (defvoo nntp-server-type nil) | |
207 (defvoo nntp-connection-alist nil) | |
208 (defvoo nntp-status-string "") | |
209 (defconst nntp-version "nntp 5.0") | |
210 (defvoo nntp-inhibit-erase nil) | |
211 (defvoo nntp-inhibit-output nil) | |
212 | |
213 (defvoo nntp-server-xover 'try) | |
214 (defvoo nntp-server-list-active-group 'try) | |
215 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
216 (defvar nntp-async-needs-kluge |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
217 (string-match "^GNU Emacs 20\\.3\\." (emacs-version)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
218 "*When non-nil, nntp will poll asynchronous connections |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
219 once a second. By default, this is turned on only for Emacs |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
220 20.3, which has a bug that breaks nntp's normal method of |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
221 noticing asynchronous data.") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
222 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
223 (defvar nntp-async-timer nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
224 (defvar nntp-async-process-list nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
225 |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
226 (defvar nntp-ssl-program |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
227 "openssl s_client -quiet -ssl3 -connect %s:%p" |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
228 "A string containing commands for SSL connections. |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
229 Within a string, %s is replaced with the server address and %p with |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
230 port number on server. The program should accept IMAP commands on |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
231 stdin and return responses to stdout.") |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
232 |
17493 | 233 (eval-and-compile |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
234 (autoload 'mail-source-read-passwd "mail-source")) |
17493 | 235 |
236 | |
237 | |
238 ;;; Internal functions. | |
239 | |
240 (defsubst nntp-send-string (process string) | |
241 "Send STRING to PROCESS." | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
242 ;; We need to store the time to provide timeouts, and |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
243 ;; to store the command so the we can replay the command |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
244 ;; if the server gives us an AUTHINFO challenge. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
245 (setq nntp-last-command-time (current-time) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
246 nntp-last-command string) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
247 (when nntp-record-commands |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
248 (nntp-record-command string)) |
17493 | 249 (process-send-string process (concat string nntp-end-of-line))) |
250 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
251 (defun nntp-record-command (string) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
252 "Record the command STRING." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
253 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
254 (set-buffer (get-buffer-create "*nntp-log*")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
255 (goto-char (point-max)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
256 (let ((time (current-time))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
257 (insert (format-time-string "%Y%m%dT%H%M%S" time) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
258 "." (format "%03d" (/ (nth 2 time) 1000)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
259 " " nntp-address " " string "\n")))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
260 |
17493 | 261 (defsubst nntp-wait-for (process wait-for buffer &optional decode discard) |
262 "Wait for WAIT-FOR to arrive from PROCESS." | |
263 (save-excursion | |
264 (set-buffer (process-buffer process)) | |
265 (goto-char (point-min)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
266 (while (and (or (not (memq (char-after (point)) '(?2 ?3 ?4 ?5))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
267 (looking-at "480")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
268 (memq (process-status process) '(open run))) |
17493 | 269 (when (looking-at "480") |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
270 (nntp-handle-authinfo process)) |
17493 | 271 (nntp-accept-process-output process) |
272 (goto-char (point-min))) | |
273 (prog1 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
274 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
275 ((looking-at "[45]") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
276 (progn |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
277 (nntp-snarf-error-message) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
278 nil)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
279 ((not (memq (process-status process) '(open run))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
280 (nnheader-report 'nntp "Server closed connection")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
281 (t |
17493 | 282 (goto-char (point-max)) |
283 (let ((limit (point-min))) | |
284 (while (not (re-search-backward wait-for limit t)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
285 (nntp-accept-process-output process) |
17493 | 286 ;; We assume that whatever we wait for is less than 1000 |
287 ;; characters long. | |
288 (setq limit (max (- (point-max) 1000) (point-min))) | |
289 (goto-char (point-max)))) | |
290 (nntp-decode-text (not decode)) | |
291 (unless discard | |
292 (save-excursion | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
293 (set-buffer buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
294 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
295 (insert-buffer-substring (process-buffer process)) |
17493 | 296 ;; Nix out "nntp reading...." message. |
297 (when nntp-have-messaged | |
298 (setq nntp-have-messaged nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
299 (nnheader-message 5 "")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
300 t)))) |
17493 | 301 (unless discard |
302 (erase-buffer))))) | |
303 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
304 (defun nntp-kill-buffer (buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
305 (when (buffer-name buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
306 (kill-buffer buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
307 (nnheader-init-server-buffer))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
308 |
17493 | 309 (defsubst nntp-find-connection (buffer) |
310 "Find the connection delivering to BUFFER." | |
311 (let ((alist nntp-connection-alist) | |
312 (buffer (if (stringp buffer) (get-buffer buffer) buffer)) | |
313 process entry) | |
314 (while (setq entry (pop alist)) | |
315 (when (eq buffer (cadr entry)) | |
316 (setq process (car entry) | |
317 alist nil))) | |
318 (when process | |
319 (if (memq (process-status process) '(open run)) | |
320 process | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
321 (nntp-kill-buffer (process-buffer process)) |
17493 | 322 (setq nntp-connection-alist (delq entry nntp-connection-alist)) |
323 nil)))) | |
324 | |
325 (defsubst nntp-find-connection-entry (buffer) | |
326 "Return the entry for the connection to BUFFER." | |
327 (assq (nntp-find-connection buffer) nntp-connection-alist)) | |
328 | |
329 (defun nntp-find-connection-buffer (buffer) | |
330 "Return the process connection buffer tied to BUFFER." | |
331 (let ((process (nntp-find-connection buffer))) | |
332 (when process | |
333 (process-buffer process)))) | |
334 | |
335 (defsubst nntp-retrieve-data (command address port buffer | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
336 &optional wait-for callback decode) |
17493 | 337 "Use COMMAND to retrieve data into BUFFER from PORT on ADDRESS." |
338 (let ((process (or (nntp-find-connection buffer) | |
339 (nntp-open-connection buffer)))) | |
340 (if (not process) | |
341 (nnheader-report 'nntp "Couldn't open connection to %s" address) | |
342 (unless (or nntp-inhibit-erase nnheader-callback-function) | |
343 (save-excursion | |
344 (set-buffer (process-buffer process)) | |
345 (erase-buffer))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
346 (condition-case err |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
347 (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
348 (when command |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
349 (nntp-send-string process command)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
350 (cond |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
351 ((eq callback 'ignore) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
352 t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
353 ((and callback wait-for) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
354 (nntp-async-wait process wait-for buffer decode callback) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
355 t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
356 (wait-for |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
357 (nntp-wait-for process wait-for buffer decode)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
358 (t t))) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42628
diff
changeset
|
359 (error |
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42628
diff
changeset
|
360 (nnheader-report 'nntp "Couldn't open connection to %s: %s" |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
361 address err)) |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
362 (quit |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
363 (message "Quit retrieving data from nntp") |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
364 (signal 'quit nil) |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
365 nil))))) |
17493 | 366 |
367 (defsubst nntp-send-command (wait-for &rest strings) | |
368 "Send STRINGS to server and wait until WAIT-FOR returns." | |
369 (when (and (not nnheader-callback-function) | |
370 (not nntp-inhibit-output)) | |
371 (save-excursion | |
372 (set-buffer nntp-server-buffer) | |
373 (erase-buffer))) | |
374 (nntp-retrieve-data | |
375 (mapconcat 'identity strings " ") | |
376 nntp-address nntp-port-number nntp-server-buffer | |
377 wait-for nnheader-callback-function)) | |
378 | |
379 (defun nntp-send-command-nodelete (wait-for &rest strings) | |
380 "Send STRINGS to server and wait until WAIT-FOR returns." | |
381 (nntp-retrieve-data | |
382 (mapconcat 'identity strings " ") | |
383 nntp-address nntp-port-number nntp-server-buffer | |
384 wait-for nnheader-callback-function)) | |
385 | |
386 (defun nntp-send-command-and-decode (wait-for &rest strings) | |
387 "Send STRINGS to server and wait until WAIT-FOR returns." | |
388 (when (and (not nnheader-callback-function) | |
389 (not nntp-inhibit-output)) | |
390 (save-excursion | |
391 (set-buffer nntp-server-buffer) | |
392 (erase-buffer))) | |
393 (nntp-retrieve-data | |
394 (mapconcat 'identity strings " ") | |
395 nntp-address nntp-port-number nntp-server-buffer | |
396 wait-for nnheader-callback-function t)) | |
397 | |
398 (defun nntp-send-buffer (wait-for) | |
399 "Send the current buffer to server and wait until WAIT-FOR returns." | |
400 (when (and (not nnheader-callback-function) | |
401 (not nntp-inhibit-output)) | |
402 (save-excursion | |
403 (set-buffer (nntp-find-connection-buffer nntp-server-buffer)) | |
404 (erase-buffer))) | |
405 (nntp-encode-text) | |
42500
9b68dff3d385
* mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38525
diff
changeset
|
406 (mm-with-unibyte-current-buffer |
9b68dff3d385
* mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38525
diff
changeset
|
407 ;; Some encoded unicode text contains character 0x80-0x9f e.g. Euro. |
9b68dff3d385
* mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38525
diff
changeset
|
408 (process-send-region (nntp-find-connection nntp-server-buffer) |
9b68dff3d385
* mm-util.el (mm-use-find-coding-systems-region): New variable.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38525
diff
changeset
|
409 (point-min) (point-max))) |
17493 | 410 (nntp-retrieve-data |
411 nil nntp-address nntp-port-number nntp-server-buffer | |
412 wait-for nnheader-callback-function)) | |
413 | |
414 | |
415 | |
416 ;;; Interface functions. | |
417 | |
418 (nnoo-define-basics nntp) | |
419 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
420 (defsubst nntp-next-result-arrived-p () |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
421 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
422 ;; A result that starts with a 2xx code is terminated by |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
423 ;; a line with only a "." on it. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
424 ((eq (char-after) ?2) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
425 (if (re-search-forward "\n\\.\r?\n" nil t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
426 t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
427 nil)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
428 ;; A result that starts with a 3xx or 4xx code is terminated |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
429 ;; by a newline. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
430 ((looking-at "[34]") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
431 (if (search-forward "\n" nil t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
432 t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
433 nil)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
434 ;; No result here. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
435 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
436 nil))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
437 |
17493 | 438 (deffoo nntp-retrieve-headers (articles &optional group server fetch-old) |
439 "Retrieve the headers of ARTICLES." | |
440 (nntp-possibly-change-group group server) | |
441 (save-excursion | |
442 (set-buffer (nntp-find-connection-buffer nntp-server-buffer)) | |
443 (erase-buffer) | |
444 (if (and (not gnus-nov-is-evil) | |
445 (not nntp-nov-is-evil) | |
446 (nntp-retrieve-headers-with-xover articles fetch-old)) | |
447 ;; We successfully retrieved the headers via XOVER. | |
448 'nov | |
449 ;; XOVER didn't work, so we do it the hard, slow and inefficient | |
450 ;; way. | |
451 (let ((number (length articles)) | |
452 (count 0) | |
453 (received 0) | |
454 (last-point (point-min)) | |
455 (buf (nntp-find-connection-buffer nntp-server-buffer)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
456 (nntp-inhibit-erase t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
457 article) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
458 ;; Send HEAD commands. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
459 (while (setq article (pop articles)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
460 (nntp-send-command |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
461 nil |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
462 "HEAD" (if (numberp article) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
463 (int-to-string article) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
464 ;; `articles' is either a list of article numbers |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
465 ;; or a list of article IDs. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
466 article)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
467 (incf count) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
468 ;; Every 400 requests we have to read the stream in |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
469 ;; order to avoid deadlocks. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
470 (when (or (null articles) ;All requests have been sent. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
471 (zerop (% count nntp-maximum-request))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
472 (nntp-accept-response) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
473 (while (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
474 (set-buffer buf) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
475 (goto-char last-point) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
476 ;; Count replies. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
477 (while (nntp-next-result-arrived-p) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
478 (setq last-point (point)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
479 (incf received)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
480 (< received count)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
481 ;; If number of headers is greater than 100, give |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
482 ;; informative messages. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
483 (and (numberp nntp-large-newsgroup) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
484 (> number nntp-large-newsgroup) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
485 (zerop (% received 20)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
486 (nnheader-message 6 "NNTP: Receiving headers... %d%%" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
487 (/ (* received 100) number))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
488 (nntp-accept-response)))) |
17493 | 489 (and (numberp nntp-large-newsgroup) |
490 (> number nntp-large-newsgroup) | |
491 (nnheader-message 6 "NNTP: Receiving headers...done")) | |
492 | |
493 ;; Now all of replies are received. Fold continuation lines. | |
494 (nnheader-fold-continuation-lines) | |
495 ;; Remove all "\r"'s. | |
496 (nnheader-strip-cr) | |
497 (copy-to-buffer nntp-server-buffer (point-min) (point-max)) | |
498 'headers)))) | |
499 | |
500 (deffoo nntp-retrieve-groups (groups &optional server) | |
501 "Retrieve group info on GROUPS." | |
502 (nntp-possibly-change-group nil server) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
503 (when (nntp-find-connection-buffer nntp-server-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
504 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
505 ;; Erase nntp-server-buffer before nntp-inhibit-erase. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
506 (set-buffer nntp-server-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
507 (erase-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
508 (set-buffer (nntp-find-connection-buffer nntp-server-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
509 ;; The first time this is run, this variable is `try'. So we |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
510 ;; try. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
511 (when (eq nntp-server-list-active-group 'try) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
512 (nntp-try-list-active (car groups))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
513 (erase-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
514 (let ((count 0) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
515 (received 0) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
516 (last-point (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
517 (nntp-inhibit-erase t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
518 (buf (nntp-find-connection-buffer nntp-server-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
519 (command (if nntp-server-list-active-group "LIST ACTIVE" "GROUP"))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
520 (while groups |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
521 ;; Send the command to the server. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
522 (nntp-send-command nil command (pop groups)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
523 (incf count) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
524 ;; Every 400 requests we have to read the stream in |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
525 ;; order to avoid deadlocks. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
526 (when (or (null groups) ;All requests have been sent. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
527 (zerop (% count nntp-maximum-request))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
528 (nntp-accept-response) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
529 (while (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
530 ;; Search `blue moon' in this file for the |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
531 ;; reason why set-buffer here. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
532 (set-buffer buf) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
533 (goto-char last-point) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
534 ;; Count replies. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
535 (while (re-search-forward "^[0-9]" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
536 (incf received)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
537 (setq last-point (point)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
538 (< received count)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
539 (nntp-accept-response)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
540 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
541 ;; Wait for the reply from the final command. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
542 (set-buffer buf) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
543 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
544 (re-search-backward "^[0-9]" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
545 (when (looking-at "^[23]") |
17493 | 546 (while (progn |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
547 (set-buffer buf) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
548 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
549 (if (not nntp-server-list-active-group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
550 (not (re-search-backward "\r?\n" (- (point) 3) t)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
551 (not (re-search-backward "^\\.\r?\n" (- (point) 4) t)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
552 (nntp-accept-response))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
553 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
554 ;; Now all replies are received. We remove CRs. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
555 (set-buffer buf) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
556 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
557 (while (search-forward "\r" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
558 (replace-match "" t t)) |
17493 | 559 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
560 (if (not nntp-server-list-active-group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
561 (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
562 (copy-to-buffer nntp-server-buffer (point-min) (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
563 'group) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
564 ;; We have read active entries, so we just delete the |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
565 ;; superfluous gunk. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
566 (goto-char (point-min)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
567 (while (re-search-forward "^[.2-5]" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
568 (delete-region (match-beginning 0) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
569 (progn (forward-line 1) (point)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
570 (copy-to-buffer nntp-server-buffer (point-min) (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
571 'active))))) |
17493 | 572 |
573 (deffoo nntp-retrieve-articles (articles &optional group server) | |
574 (nntp-possibly-change-group group server) | |
575 (save-excursion | |
576 (let ((number (length articles)) | |
577 (count 0) | |
578 (received 0) | |
579 (last-point (point-min)) | |
580 (buf (nntp-find-connection-buffer nntp-server-buffer)) | |
581 (nntp-inhibit-erase t) | |
582 (map (apply 'vector articles)) | |
583 (point 1) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
584 article) |
17493 | 585 (set-buffer buf) |
586 (erase-buffer) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
587 ;; Send ARTICLE command. |
17493 | 588 (while (setq article (pop articles)) |
589 (nntp-send-command | |
590 nil | |
591 "ARTICLE" (if (numberp article) | |
592 (int-to-string article) | |
593 ;; `articles' is either a list of article numbers | |
594 ;; or a list of article IDs. | |
595 article)) | |
596 (incf count) | |
597 ;; Every 400 requests we have to read the stream in | |
598 ;; order to avoid deadlocks. | |
599 (when (or (null articles) ;All requests have been sent. | |
600 (zerop (% count nntp-maximum-request))) | |
601 (nntp-accept-response) | |
602 (while (progn | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
603 (set-buffer buf) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
604 (goto-char last-point) |
17493 | 605 ;; Count replies. |
606 (while (nntp-next-result-arrived-p) | |
607 (aset map received (cons (aref map received) (point))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
608 (setq last-point (point)) |
17493 | 609 (incf received)) |
610 (< received count)) | |
611 ;; If number of headers is greater than 100, give | |
612 ;; informative messages. | |
613 (and (numberp nntp-large-newsgroup) | |
614 (> number nntp-large-newsgroup) | |
615 (zerop (% received 20)) | |
616 (nnheader-message 6 "NNTP: Receiving articles... %d%%" | |
617 (/ (* received 100) number))) | |
618 (nntp-accept-response)))) | |
619 (and (numberp nntp-large-newsgroup) | |
620 (> number nntp-large-newsgroup) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
621 (nnheader-message 6 "NNTP: Receiving articles...done")) |
17493 | 622 |
623 ;; Now we have all the responses. We go through the results, | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
624 ;; wash it and copy it over to the server buffer. |
17493 | 625 (set-buffer nntp-server-buffer) |
626 (erase-buffer) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
627 (setq last-point (point-min)) |
17493 | 628 (mapcar |
629 (lambda (entry) | |
630 (narrow-to-region | |
631 (setq point (goto-char (point-max))) | |
632 (progn | |
633 (insert-buffer-substring buf last-point (cdr entry)) | |
634 (point-max))) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
635 (setq last-point (cdr entry)) |
17493 | 636 (nntp-decode-text) |
637 (widen) | |
638 (cons (car entry) point)) | |
639 map)))) | |
640 | |
641 (defun nntp-try-list-active (group) | |
642 (nntp-list-active-group group) | |
643 (save-excursion | |
644 (set-buffer nntp-server-buffer) | |
645 (goto-char (point-min)) | |
646 (cond ((or (eobp) | |
647 (looking-at "5[0-9]+")) | |
648 (setq nntp-server-list-active-group nil)) | |
649 (t | |
650 (setq nntp-server-list-active-group t))))) | |
651 | |
652 (deffoo nntp-list-active-group (group &optional server) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
653 "Return the active info on GROUP (which can be a regexp)." |
17493 | 654 (nntp-possibly-change-group nil server) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
655 (nntp-send-command "^\\.*\r?\n" "LIST ACTIVE" group)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
656 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
657 (deffoo nntp-request-group-articles (group &optional server) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
658 "Return the list of existing articles in GROUP." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
659 (nntp-possibly-change-group nil server) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
660 (nntp-send-command "^\\.*\r?\n" "LISTGROUP" group)) |
17493 | 661 |
662 (deffoo nntp-request-article (article &optional group server buffer command) | |
663 (nntp-possibly-change-group group server) | |
664 (when (nntp-send-command-and-decode | |
665 "\r?\n\\.\r?\n" "ARTICLE" | |
666 (if (numberp article) (int-to-string article) article)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
667 (if (and buffer |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
668 (not (equal buffer nntp-server-buffer))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
669 (save-excursion |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
670 (set-buffer nntp-server-buffer) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
671 (copy-to-buffer buffer (point-min) (point-max)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
672 (nntp-find-group-and-number)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
673 (nntp-find-group-and-number)))) |
17493 | 674 |
675 (deffoo nntp-request-head (article &optional group server) | |
676 (nntp-possibly-change-group group server) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
677 (when (nntp-send-command |
17493 | 678 "\r?\n\\.\r?\n" "HEAD" |
679 (if (numberp article) (int-to-string article) article)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
680 (prog1 |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
681 (nntp-find-group-and-number) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
682 (nntp-decode-text)))) |
17493 | 683 |
684 (deffoo nntp-request-body (article &optional group server) | |
685 (nntp-possibly-change-group group server) | |
686 (nntp-send-command-and-decode | |
687 "\r?\n\\.\r?\n" "BODY" | |
688 (if (numberp article) (int-to-string article) article))) | |
689 | |
690 (deffoo nntp-request-group (group &optional server dont-check) | |
691 (nntp-possibly-change-group nil server) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
692 (when (nntp-send-command "^[245].*\n" "GROUP" group) |
17493 | 693 (let ((entry (nntp-find-connection-entry nntp-server-buffer))) |
694 (setcar (cddr entry) group)))) | |
695 | |
696 (deffoo nntp-close-group (group &optional server) | |
697 t) | |
698 | |
699 (deffoo nntp-server-opened (&optional server) | |
700 "Say whether a connection to SERVER has been opened." | |
701 (and (nnoo-current-server-p 'nntp server) | |
702 nntp-server-buffer | |
703 (gnus-buffer-live-p nntp-server-buffer) | |
704 (nntp-find-connection nntp-server-buffer))) | |
705 | |
706 (deffoo nntp-open-server (server &optional defs connectionless) | |
707 (nnheader-init-server-buffer) | |
708 (if (nntp-server-opened server) | |
709 t | |
710 (when (or (stringp (car defs)) | |
711 (numberp (car defs))) | |
712 (setq defs (cons (list 'nntp-port-number (car defs)) (cdr defs)))) | |
713 (unless (assq 'nntp-address defs) | |
714 (setq defs (append defs (list (list 'nntp-address server))))) | |
715 (nnoo-change-server 'nntp server defs) | |
716 (unless connectionless | |
717 (or (nntp-find-connection nntp-server-buffer) | |
718 (nntp-open-connection nntp-server-buffer))))) | |
719 | |
720 (deffoo nntp-close-server (&optional server) | |
721 (nntp-possibly-change-group nil server t) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
722 (let ((process (nntp-find-connection nntp-server-buffer))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
723 (while process |
17493 | 724 (when (memq (process-status process) '(open run)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
725 (ignore-errors |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
726 (nntp-send-string process "QUIT") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
727 (unless (eq nntp-open-connection-function 'nntp-open-network-stream) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
728 ;; Ok, this is evil, but when using telnet and stuff |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
729 ;; as the connection method, it's important that the |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
730 ;; QUIT command actually is sent out before we kill |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
731 ;; the process. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
732 (sleep-for 1)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
733 (nntp-kill-buffer (process-buffer process)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
734 (setq process (car (pop nntp-connection-alist)))) |
17493 | 735 (nnoo-close-server 'nntp))) |
736 | |
737 (deffoo nntp-request-close () | |
738 (let (process) | |
739 (while (setq process (pop nntp-connection-list)) | |
740 (when (memq (process-status process) '(open run)) | |
741 (ignore-errors | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
742 (nntp-send-string process "QUIT") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
743 (unless (eq nntp-open-connection-function 'nntp-open-network-stream) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
744 ;; Ok, this is evil, but when using telnet and stuff |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
745 ;; as the connection method, it's important that the |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
746 ;; QUIT command actually is sent out before we kill |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
747 ;; the process. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
748 (sleep-for 1)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
749 (nntp-kill-buffer (process-buffer process))))) |
17493 | 750 |
751 (deffoo nntp-request-list (&optional server) | |
752 (nntp-possibly-change-group nil server) | |
753 (nntp-send-command-and-decode "\r?\n\\.\r?\n" "LIST")) | |
754 | |
755 (deffoo nntp-request-list-newsgroups (&optional server) | |
756 (nntp-possibly-change-group nil server) | |
757 (nntp-send-command "\r?\n\\.\r?\n" "LIST NEWSGROUPS")) | |
758 | |
759 (deffoo nntp-request-newgroups (date &optional server) | |
760 (nntp-possibly-change-group nil server) | |
761 (save-excursion | |
762 (set-buffer nntp-server-buffer) | |
38525
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
763 (let* ((time (date-to-time date)) |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
764 (ls (- (cadr time) (nth 8 (decode-time time))))) |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
765 (cond ((< ls 0) |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
766 (setcar time (1- (car time))) |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
767 (setcar (cdr time) (+ ls 65536))) |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
768 ((>= ls 65536) |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
769 (setcar time (1+ (car time))) |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
770 (setcar (cdr time) (- ls 65536))) |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
771 (t |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
772 (setcar (cdr time) ls))) |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
773 (prog1 |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
774 (nntp-send-command |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
775 "^\\.\r?\n" "NEWGROUPS" |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
776 (format-time-string "%y%m%d %H%M%S" time) |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
777 "GMT") |
f5c857b7ecf8
(nntp-request-newgroups): Use UTC date for NEWGROUPS
Gerd Moellmann <gerd@gnu.org>
parents:
33575
diff
changeset
|
778 (nntp-decode-text))))) |
17493 | 779 |
780 (deffoo nntp-request-post (&optional server) | |
781 (nntp-possibly-change-group nil server) | |
782 (when (nntp-send-command "^[23].*\r?\n" "POST") | |
783 (nntp-send-buffer "^[23].*\n"))) | |
784 | |
785 (deffoo nntp-request-type (group article) | |
786 'news) | |
787 | |
788 (deffoo nntp-asynchronous-p () | |
789 t) | |
790 | |
791 ;;; Hooky functions. | |
792 | |
793 (defun nntp-send-mode-reader () | |
794 "Send the MODE READER command to the nntp server. | |
795 This function is supposed to be called from `nntp-server-opened-hook'. | |
796 It will make innd servers spawn an nnrpd process to allow actual article | |
797 reading." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
798 (nntp-send-command "^.*\n" "MODE READER")) |
17493 | 799 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
800 (defun nntp-send-authinfo (&optional send-if-force) |
17493 | 801 "Send the AUTHINFO to the nntp server. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
802 It will look in the \"~/.authinfo\" file for matching entries. If |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
803 nothing suitable is found there, it will prompt for a user name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
804 and a password. |
17493 | 805 |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
806 If SEND-IF-FORCE, only send authinfo to the server if the |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
807 .authinfo file has the FORCE token." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
808 (let* ((list (gnus-parse-netrc nntp-authinfo-file)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
809 (alist (gnus-netrc-machine list nntp-address "nntp")) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
810 (force (gnus-netrc-get alist "force")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
811 (user (or (gnus-netrc-get alist "login") nntp-authinfo-user)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
812 (passwd (gnus-netrc-get alist "password"))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
813 (when (or (not send-if-force) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
814 force) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
815 (unless user |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
816 (setq user (read-string (format "NNTP (%s) user name: " nntp-address)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
817 nntp-authinfo-user user)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
818 (unless (member user '(nil "")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
819 (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" user) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
820 (when t ;???Should check if AUTHINFO succeeded |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
821 (nntp-send-command |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
822 "^2.*\r?\n" "AUTHINFO PASS" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
823 (or passwd |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
824 nntp-authinfo-password |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
825 (setq nntp-authinfo-password |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
826 (mail-source-read-passwd |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
827 (format "NNTP (%s@%s) password: " |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
828 user nntp-address)))))))))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
829 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
830 (defun nntp-send-nosy-authinfo () |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
831 "Send the AUTHINFO to the nntp server." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
832 (let ((user (read-string (format "NNTP (%s) user name: " nntp-address)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
833 (unless (member user '(nil "")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
834 (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" user) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
835 (when t ;???Should check if AUTHINFO succeeded |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
836 (nntp-send-command "^2.*\r?\n" "AUTHINFO PASS" |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
837 (mail-source-read-passwd "NNTP (%s@%s) password: " |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
838 user nntp-address)))))) |
17493 | 839 |
840 (defun nntp-send-authinfo-from-file () | |
841 "Send the AUTHINFO to the nntp server. | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
842 |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
843 The authinfo login name is taken from the user's login name and the |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
844 password contained in '~/.nntp-authinfo'." |
17493 | 845 (when (file-exists-p "~/.nntp-authinfo") |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
846 (with-temp-buffer |
17493 | 847 (insert-file-contents "~/.nntp-authinfo") |
848 (goto-char (point-min)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
849 (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" (user-login-name)) |
17493 | 850 (nntp-send-command |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
851 "^2.*\r?\n" "AUTHINFO PASS" |
17493 | 852 (buffer-substring (point) (progn (end-of-line) (point))))))) |
853 | |
854 ;;; Internal functions. | |
855 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
856 (defun nntp-handle-authinfo (process) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
857 "Take care of an authinfo response from the server." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
858 (let ((last nntp-last-command)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
859 (funcall nntp-authinfo-function) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
860 ;; We have to re-send the function that was interrupted by |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
861 ;; the authinfo request. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
862 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
863 (set-buffer nntp-server-buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
864 (erase-buffer)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
865 (nntp-send-string process last))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
866 |
17493 | 867 (defun nntp-make-process-buffer (buffer) |
868 "Create a new, fresh buffer usable for nntp process connections." | |
869 (save-excursion | |
870 (set-buffer | |
871 (generate-new-buffer | |
872 (format " *server %s %s %s*" | |
873 nntp-address nntp-port-number | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
874 (gnus-buffer-exists-p buffer)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
875 (mm-enable-multibyte) |
17493 | 876 (set (make-local-variable 'after-change-functions) nil) |
877 (set (make-local-variable 'nntp-process-wait-for) nil) | |
878 (set (make-local-variable 'nntp-process-callback) nil) | |
879 (set (make-local-variable 'nntp-process-to-buffer) nil) | |
880 (set (make-local-variable 'nntp-process-start-point) nil) | |
881 (set (make-local-variable 'nntp-process-decode) nil) | |
882 (current-buffer))) | |
883 | |
884 (defun nntp-open-connection (buffer) | |
885 "Open a connection to PORT on ADDRESS delivering output to BUFFER." | |
886 (run-hooks 'nntp-prepare-server-hook) | |
887 (let* ((pbuffer (nntp-make-process-buffer buffer)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
888 (timer |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
889 (and nntp-connection-timeout |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
890 (nnheader-run-at-time |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
891 nntp-connection-timeout nil |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
892 `(lambda () |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
893 (nntp-kill-buffer ,pbuffer))))) |
17493 | 894 (process |
895 (condition-case () | |
19992
36e81448237d
(nntp-coding-system-for-write): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
896 (let ((coding-system-for-read nntp-coding-system-for-read) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
897 (coding-system-for-write nntp-coding-system-for-write)) |
19598
611e0de24d43
(nntp-coding-system-for-read): New variable.
Kenichi Handa <handa@m17n.org>
parents:
17493
diff
changeset
|
898 (funcall nntp-open-connection-function pbuffer)) |
17493 | 899 (error nil) |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
900 (quit |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
901 (message "Quit opening connection") |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
902 (nntp-kill-buffer pbuffer) |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
903 (signal 'quit nil) |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
904 nil)))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
905 (when timer |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
906 (nnheader-cancel-timer timer)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
907 (when (and (buffer-name pbuffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
908 process) |
17493 | 909 (process-kill-without-query process) |
910 (nntp-wait-for process "^.*\n" buffer nil t) | |
911 (if (memq (process-status process) '(open run)) | |
912 (prog1 | |
913 (caar (push (list process buffer nil) nntp-connection-alist)) | |
914 (push process nntp-connection-list) | |
915 (save-excursion | |
916 (set-buffer pbuffer) | |
917 (nntp-read-server-type) | |
918 (erase-buffer) | |
919 (set-buffer nntp-server-buffer) | |
920 (let ((nnheader-callback-function nil)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
921 (run-hooks 'nntp-server-opened-hook) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
922 (nntp-send-authinfo t)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
923 (nntp-kill-buffer (process-buffer process)) |
17493 | 924 nil)))) |
925 | |
926 (defun nntp-open-network-stream (buffer) | |
927 (open-network-stream "nntpd" buffer nntp-address nntp-port-number)) | |
928 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
929 (defun nntp-open-ssl-stream (buffer) |
49993
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
930 (let* ((process-connection-type nil) |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
931 (proc (start-process "nntpd" buffer |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
932 shell-file-name |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
933 shell-command-switch |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
934 (format-spec nntp-ssl-program |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
935 (format-spec-make |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
936 ?s nntp-address |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
937 ?p nntp-port-number))))) |
a40d0a292281
* nnfolder.el (nnfolder-request-accept-article): Don't use
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
49725
diff
changeset
|
938 (process-kill-without-query proc) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
939 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
940 (set-buffer buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
941 (nntp-wait-for-string "^\r*20[01]") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
942 (beginning-of-line) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
943 (delete-region (point-min) (point)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
944 proc))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
945 |
17493 | 946 (defun nntp-read-server-type () |
947 "Find out what the name of the server we have connected to is." | |
948 ;; Wait for the status string to arrive. | |
949 (setq nntp-server-type (buffer-string)) | |
950 (let ((alist nntp-server-action-alist) | |
951 (case-fold-search t) | |
952 entry) | |
953 ;; Run server-specific commands. | |
954 (while alist | |
955 (setq entry (pop alist)) | |
956 (when (string-match (car entry) nntp-server-type) | |
957 (if (and (listp (cadr entry)) | |
958 (not (eq 'lambda (caadr entry)))) | |
959 (eval (cadr entry)) | |
960 (funcall (cadr entry))))))) | |
961 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
962 (defun nntp-async-wait (process wait-for buffer decode callback) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
963 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
964 (set-buffer (process-buffer process)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
965 (unless nntp-inside-change-function |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
966 (erase-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
967 (setq nntp-process-wait-for wait-for |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
968 nntp-process-to-buffer buffer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
969 nntp-process-decode decode |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
970 nntp-process-callback callback |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
971 nntp-process-start-point (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
972 (setq after-change-functions '(nntp-after-change-function)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
973 (if nntp-async-needs-kluge |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
974 (nntp-async-kluge process)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
975 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
976 (defun nntp-async-kluge (process) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
977 ;; emacs 20.3 bug: process output with encoding 'binary |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
978 ;; doesn't trigger after-change-functions. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
979 (unless nntp-async-timer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
980 (setq nntp-async-timer |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
981 (nnheader-run-at-time 1 1 'nntp-async-timer-handler))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
982 (add-to-list 'nntp-async-process-list process)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
983 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
984 (defun nntp-async-timer-handler () |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
985 (mapcar |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
986 (lambda (proc) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
987 (if (memq (process-status proc) '(open run)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
988 (nntp-async-trigger proc) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
989 (nntp-async-stop proc))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
990 nntp-async-process-list)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
991 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
992 (defun nntp-async-stop (proc) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
993 (setq nntp-async-process-list (delq proc nntp-async-process-list)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
994 (when (and nntp-async-timer (not nntp-async-process-list)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
995 (nnheader-cancel-timer nntp-async-timer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
996 (setq nntp-async-timer nil))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
997 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
998 (defun nntp-after-change-function (beg end len) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
999 (unwind-protect |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1000 ;; we only care about insertions at eob |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1001 (when (and (eq 0 len) (eq (point-max) end)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1002 (save-match-data |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1003 (let ((proc (get-buffer-process (current-buffer)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1004 (when proc |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1005 (nntp-async-trigger proc))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1006 ;; any throw from after-change-functions will leave it |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1007 ;; set to nil. so we reset it here, if necessary. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1008 (when quit-flag |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1009 (setq after-change-functions '(nntp-after-change-function))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1010 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1011 (defun nntp-async-trigger (process) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1012 (save-excursion |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1013 (set-buffer (process-buffer process)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1014 (when nntp-process-callback |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1015 ;; do we have an error message? |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1016 (goto-char nntp-process-start-point) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1017 (if (memq (following-char) '(?4 ?5)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1018 ;; wants credentials? |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1019 (if (looking-at "480") |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1020 (nntp-handle-authinfo process) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1021 ;; report error message. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1022 (nntp-snarf-error-message) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1023 (nntp-do-callback nil)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1024 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1025 ;; got what we expect? |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1026 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1027 (when (re-search-backward |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1028 nntp-process-wait-for nntp-process-start-point t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1029 (nntp-async-stop process) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1030 ;; convert it. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1031 (when (gnus-buffer-exists-p nntp-process-to-buffer) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1032 (let ((buf (current-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1033 (start nntp-process-start-point) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1034 (decode nntp-process-decode)) |
17493 | 1035 (save-excursion |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1036 (set-buffer nntp-process-to-buffer) |
17493 | 1037 (goto-char (point-max)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1038 (save-restriction |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1039 (narrow-to-region (point) (point)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1040 (insert-buffer-substring buf start) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1041 (when decode |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1042 (nntp-decode-text)))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1043 ;; report it. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1044 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1045 (nntp-do-callback |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1046 (buffer-name (get-buffer nntp-process-to-buffer)))))))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1047 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1048 (defun nntp-do-callback (arg) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1049 (let ((callback nntp-process-callback) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1050 (nntp-inside-change-function t)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1051 (setq nntp-process-callback nil) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1052 (funcall callback arg))) |
17493 | 1053 |
1054 (defun nntp-snarf-error-message () | |
1055 "Save the error message in the current buffer." | |
1056 (let ((message (buffer-string))) | |
1057 (while (string-match "[\r\n]+" message) | |
1058 (setq message (replace-match " " t t message))) | |
1059 (nnheader-report 'nntp message) | |
1060 message)) | |
1061 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1062 (defun nntp-accept-process-output (process &optional timeout) |
17493 | 1063 "Wait for output from PROCESS and message some dots." |
1064 (save-excursion | |
1065 (set-buffer (or (nntp-find-connection-buffer nntp-server-buffer) | |
1066 nntp-server-buffer)) | |
49725
f13275d94b11
(nntp-accept-process-output): Don't use point-max to get the buffer's size.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
49598
diff
changeset
|
1067 (let ((len (/ (buffer-size) 1024)) |
17493 | 1068 message-log-max) |
1069 (unless (< len 10) | |
1070 (setq nntp-have-messaged t) | |
1071 (nnheader-message 7 "nntp read: %dk" len))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1072 (accept-process-output process (or timeout 1)))) |
17493 | 1073 |
1074 (defun nntp-accept-response () | |
1075 "Wait for output from the process that outputs to BUFFER." | |
1076 (nntp-accept-process-output (nntp-find-connection nntp-server-buffer))) | |
1077 | |
1078 (defun nntp-possibly-change-group (group server &optional connectionless) | |
1079 (let ((nnheader-callback-function nil)) | |
1080 (when server | |
1081 (or (nntp-server-opened server) | |
1082 (nntp-open-server server nil connectionless))) | |
1083 | |
1084 (unless connectionless | |
1085 (or (nntp-find-connection nntp-server-buffer) | |
1086 (nntp-open-connection nntp-server-buffer)))) | |
1087 | |
1088 (when group | |
1089 (let ((entry (nntp-find-connection-entry nntp-server-buffer))) | |
1090 (when (not (equal group (caddr entry))) | |
1091 (save-excursion | |
1092 (set-buffer (process-buffer (car entry))) | |
1093 (erase-buffer) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1094 (nntp-send-command "^[245].*\n" "GROUP" group) |
17493 | 1095 (setcar (cddr entry) group) |
1096 (erase-buffer)))))) | |
1097 | |
1098 (defun nntp-decode-text (&optional cr-only) | |
1099 "Decode the text in the current buffer." | |
1100 (goto-char (point-min)) | |
1101 (while (search-forward "\r" nil t) | |
1102 (delete-char -1)) | |
1103 (unless cr-only | |
1104 ;; Remove trailing ".\n" end-of-transfer marker. | |
1105 (goto-char (point-max)) | |
1106 (forward-line -1) | |
1107 (when (looking-at ".\n") | |
1108 (delete-char 2)) | |
1109 ;; Delete status line. | |
1110 (goto-char (point-min)) | |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1111 (while (looking-at "[1-5][0-9][0-9] .*\n") |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1112 ;; For some unknown reason, there is more than one status line. |
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1113 (delete-region (point) (progn (forward-line 1) (point)))) |
17493 | 1114 ;; Remove "." -> ".." encoding. |
1115 (while (search-forward "\n.." nil t) | |
1116 (delete-char -1)))) | |
1117 | |
1118 (defun nntp-encode-text () | |
1119 "Encode the text in the current buffer." | |
1120 (save-excursion | |
1121 ;; Replace "." at beginning of line with "..". | |
1122 (goto-char (point-min)) | |
1123 (while (re-search-forward "^\\." nil t) | |
1124 (insert ".")) | |
1125 (goto-char (point-max)) | |
1126 ;; Insert newline at the end of the buffer. | |
1127 (unless (bolp) | |
1128 (insert "\n")) | |
1129 ;; Insert `.' at end of buffer (end of text mark). | |
1130 (goto-char (point-max)) | |
23010
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1131 (insert ".\n") |
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1132 (goto-char (point-min)) |
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1133 (while (not (eobp)) |
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1134 (end-of-line) |
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1135 (delete-char 1) |
196f32d1873f
(nntp-encode-text): Properly encode outgoing text by
Richard M. Stallman <rms@gnu.org>
parents:
20236
diff
changeset
|
1136 (insert nntp-end-of-line)))) |
17493 | 1137 |
1138 (defun nntp-retrieve-headers-with-xover (articles &optional fetch-old) | |
1139 (set-buffer nntp-server-buffer) | |
1140 (erase-buffer) | |
1141 (cond | |
1142 | |
1143 ;; This server does not talk NOV. | |
1144 ((not nntp-server-xover) | |
1145 nil) | |
1146 | |
1147 ;; We don't care about gaps. | |
1148 ((or (not nntp-nov-gap) | |
1149 fetch-old) | |
1150 (nntp-send-xover-command | |
1151 (if fetch-old | |
1152 (if (numberp fetch-old) | |
1153 (max 1 (- (car articles) fetch-old)) | |
1154 1) | |
1155 (car articles)) | |
1156 (car (last articles)) 'wait) | |
1157 | |
1158 (goto-char (point-min)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1159 (when (looking-at "[1-5][0-9][0-9] .*\n") |
17493 | 1160 (delete-region (point) (progn (forward-line 1) (point)))) |
1161 (while (search-forward "\r" nil t) | |
1162 (replace-match "" t t)) | |
1163 (goto-char (point-max)) | |
1164 (forward-line -1) | |
1165 (when (looking-at "\\.") | |
1166 (delete-region (point) (progn (forward-line 1) (point))))) | |
1167 | |
1168 ;; We do it the hard way. For each gap, an XOVER command is sent | |
1169 ;; to the server. We do not wait for a reply from the server, we | |
1170 ;; just send them off as fast as we can. That means that we have | |
1171 ;; to count the number of responses we get back to find out when we | |
1172 ;; have gotten all we asked for. | |
1173 ((numberp nntp-nov-gap) | |
1174 (let ((count 0) | |
1175 (received 0) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1176 last-point |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1177 in-process-buffer-p |
17493 | 1178 (buf nntp-server-buffer) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1179 (process-buffer (nntp-find-connection-buffer nntp-server-buffer)) |
17493 | 1180 first) |
1181 ;; We have to check `nntp-server-xover'. If it gets set to nil, | |
1182 ;; that means that the server does not understand XOVER, but we | |
1183 ;; won't know that until we try. | |
1184 (while (and nntp-server-xover articles) | |
1185 (setq first (car articles)) | |
1186 ;; Search forward until we find a gap, or until we run out of | |
1187 ;; articles. | |
1188 (while (and (cdr articles) | |
1189 (< (- (nth 1 articles) (car articles)) nntp-nov-gap)) | |
1190 (setq articles (cdr articles))) | |
1191 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1192 (setq in-process-buffer-p (stringp nntp-server-xover)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1193 (nntp-send-xover-command first (car articles)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1194 (setq articles (cdr articles)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42628
diff
changeset
|
1195 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1196 (when (and nntp-server-xover in-process-buffer-p) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1197 ;; Don't count tried request. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1198 (setq count (1+ count)) |
49598
0d8b17d428b5
Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
42628
diff
changeset
|
1199 |
17493 | 1200 ;; Every 400 requests we have to read the stream in |
1201 ;; order to avoid deadlocks. | |
1202 (when (or (null articles) ;All requests have been sent. | |
1203 (zerop (% count nntp-maximum-request))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1204 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1205 (nntp-accept-response) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1206 ;; On some Emacs versions the preceding function has a |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1207 ;; tendency to change the buffer. Perhaps. It's quite |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1208 ;; difficult to reproduce, because it only seems to happen |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1209 ;; once in a blue moon. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1210 (set-buffer process-buffer) |
17493 | 1211 (while (progn |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1212 (goto-char (or last-point (point-min))) |
17493 | 1213 ;; Count replies. |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1214 (while (re-search-forward "^[0-9][0-9][0-9] .*\n" nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1215 (incf received)) |
17493 | 1216 (setq last-point (point)) |
1217 (< received count)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1218 (nntp-accept-response) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1219 (set-buffer process-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1220 (set-buffer buf)))) |
17493 | 1221 |
1222 (when nntp-server-xover | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1223 (when in-process-buffer-p |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1224 (set-buffer process-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1225 ;; Wait for the reply from the final command. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1226 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1227 (while (not (re-search-backward "^[0-9][0-9][0-9] " nil t)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1228 (nntp-accept-response) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1229 (set-buffer process-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1230 (goto-char (point-max))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1231 (when (looking-at "^[23]") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1232 (while (progn |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1233 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1234 (forward-line -1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1235 (not (looking-at "^\\.\r?\n"))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1236 (nntp-accept-response) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1237 (set-buffer process-buffer))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1238 (set-buffer buf) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1239 (goto-char (point-max)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1240 (insert-buffer-substring process-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1241 (set-buffer process-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1242 (erase-buffer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1243 (set-buffer buf)) |
17493 | 1244 |
1245 ;; We remove any "." lines and status lines. | |
1246 (goto-char (point-min)) | |
1247 (while (search-forward "\r" nil t) | |
1248 (delete-char -1)) | |
1249 (goto-char (point-min)) | |
1250 (delete-matching-lines "^\\.$\\|^[1-5][0-9][0-9] ") | |
1251 t)))) | |
1252 | |
1253 nntp-server-xover) | |
1254 | |
1255 (defun nntp-send-xover-command (beg end &optional wait-for-reply) | |
1256 "Send the XOVER command to the server." | |
1257 (let ((range (format "%d-%d" beg end)) | |
1258 (nntp-inhibit-erase t)) | |
1259 (if (stringp nntp-server-xover) | |
1260 ;; If `nntp-server-xover' is a string, then we just send this | |
1261 ;; command. | |
1262 (if wait-for-reply | |
1263 (nntp-send-command-nodelete | |
1264 "\r?\n\\.\r?\n" nntp-server-xover range) | |
1265 ;; We do not wait for the reply. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1266 (nntp-send-command-nodelete nil nntp-server-xover range)) |
17493 | 1267 (let ((commands nntp-xover-commands)) |
1268 ;; `nntp-xover-commands' is a list of possible XOVER commands. | |
1269 ;; We try them all until we get at positive response. | |
1270 (while (and commands (eq nntp-server-xover 'try)) | |
1271 (nntp-send-command-nodelete "\r?\n\\.\r?\n" (car commands) range) | |
1272 (save-excursion | |
1273 (set-buffer nntp-server-buffer) | |
1274 (goto-char (point-min)) | |
1275 (and (looking-at "[23]") ; No error message. | |
1276 ;; We also have to look at the lines. Some buggy | |
1277 ;; servers give back simple lines with just the | |
1278 ;; article number. How... helpful. | |
1279 (progn | |
1280 (forward-line 1) | |
1281 (looking-at "[0-9]+\t...")) ; More text after number. | |
1282 (setq nntp-server-xover (car commands)))) | |
1283 (setq commands (cdr commands))) | |
1284 ;; If none of the commands worked, we disable XOVER. | |
1285 (when (eq nntp-server-xover 'try) | |
1286 (save-excursion | |
1287 (set-buffer nntp-server-buffer) | |
1288 (erase-buffer) | |
1289 (setq nntp-server-xover nil))) | |
1290 nntp-server-xover)))) | |
1291 | |
1292 ;;; Alternative connection methods. | |
1293 | |
1294 (defun nntp-wait-for-string (regexp) | |
1295 "Wait until string arrives in the buffer." | |
1296 (let ((buf (current-buffer))) | |
1297 (goto-char (point-min)) | |
1298 (while (not (re-search-forward regexp nil t)) | |
1299 (accept-process-output (nntp-find-connection nntp-server-buffer)) | |
1300 (set-buffer buf) | |
1301 (goto-char (point-min))))) | |
1302 | |
1303 (defun nntp-open-telnet (buffer) | |
1304 (save-excursion | |
1305 (set-buffer buffer) | |
1306 (erase-buffer) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
1307 (let ((proc (apply |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
1308 'start-process |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19598
diff
changeset
|
1309 "nntpd" buffer nntp-telnet-command nntp-telnet-switches)) |
17493 | 1310 (case-fold-search t)) |
1311 (when (memq (process-status proc) '(open run)) | |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1312 (nntp-wait-for-string "^r?telnet") |
17493 | 1313 (process-send-string proc "set escape \^X\n") |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1314 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1315 ((and nntp-open-telnet-envuser nntp-telnet-user-name) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1316 (process-send-string proc (concat "open " "-l" nntp-telnet-user-name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1317 nntp-address "\n"))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1318 (t |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1319 (process-send-string proc (concat "open " nntp-address "\n")))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1320 (cond |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1321 ((not nntp-open-telnet-envuser) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1322 (nntp-wait-for-string "^\r*.?login:") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1323 (process-send-string |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1324 proc (concat |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1325 (or nntp-telnet-user-name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1326 (setq nntp-telnet-user-name (read-string "login: "))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1327 "\n")))) |
17493 | 1328 (nntp-wait-for-string "^\r*.?password:") |
1329 (process-send-string | |
1330 proc (concat | |
1331 (or nntp-telnet-passwd | |
1332 (setq nntp-telnet-passwd | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1333 (mail-source-read-passwd "Password: "))) |
17493 | 1334 "\n")) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1335 (nntp-wait-for-string nntp-telnet-shell-prompt) |
17493 | 1336 (process-send-string |
1337 proc (concat (mapconcat 'identity nntp-telnet-parameters " ") "\n")) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1338 (nntp-wait-for-string "^\r*20[01]") |
17493 | 1339 (beginning-of-line) |
1340 (delete-region (point-min) (point)) | |
1341 (process-send-string proc "\^]") | |
33575
93288a69f66f
2000-11-17 Katsumi Yamaoka <yamaoka@jpl.org>
Dave Love <fx@gnu.org>
parents:
31716
diff
changeset
|
1342 (nntp-wait-for-string "^r?telnet") |
17493 | 1343 (process-send-string proc "mode character\n") |
1344 (accept-process-output proc 1) | |
1345 (sit-for 1) | |
1346 (goto-char (point-min)) | |
1347 (forward-line 1) | |
1348 (delete-region (point) (point-max))) | |
1349 proc))) | |
1350 | |
1351 (defun nntp-open-rlogin (buffer) | |
1352 "Open a connection to SERVER using rsh." | |
1353 (let ((proc (if nntp-rlogin-user-name | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1354 (apply 'start-process |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1355 "nntpd" buffer nntp-rlogin-program |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1356 nntp-address "-l" nntp-rlogin-user-name |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1357 nntp-rlogin-parameters) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1358 (apply 'start-process |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1359 "nntpd" buffer nntp-rlogin-program nntp-address |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1360 nntp-rlogin-parameters)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1361 (save-excursion |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1362 (set-buffer buffer) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1363 (nntp-wait-for-string "^\r*20[01]") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1364 (beginning-of-line) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1365 (delete-region (point-min) (point)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
23870
diff
changeset
|
1366 proc))) |
17493 | 1367 |
1368 (defun nntp-find-group-and-number () | |
1369 (save-excursion | |
1370 (save-restriction | |
1371 (set-buffer nntp-server-buffer) | |
1372 (narrow-to-region (goto-char (point-min)) | |
1373 (or (search-forward "\n\n" nil t) (point-max))) | |
1374 (goto-char (point-min)) | |
1375 ;; We first find the number by looking at the status line. | |
1376 (let ((number (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ") | |
1377 (string-to-int | |
1378 (buffer-substring (match-beginning 1) | |
1379 (match-end 1))))) | |
1380 group newsgroups xref) | |
1381 (and number (zerop number) (setq number nil)) | |
1382 ;; Then we find the group name. | |
1383 (setq group | |
1384 (cond | |
1385 ;; If there is only one group in the Newsgroups header, | |
1386 ;; then it seems quite likely that this article comes | |
1387 ;; from that group, I'd say. | |
1388 ((and (setq newsgroups (mail-fetch-field "newsgroups")) | |
1389 (not (string-match "," newsgroups))) | |
1390 newsgroups) | |
1391 ;; If there is more than one group in the Newsgroups | |
1392 ;; header, then the Xref header should be filled out. | |
1393 ;; We hazard a guess that the group that has this | |
1394 ;; article number in the Xref header is the one we are | |
1395 ;; looking for. This might very well be wrong if this | |
1396 ;; article happens to have the same number in several | |
1397 ;; groups, but that's life. | |
1398 ((and (setq xref (mail-fetch-field "xref")) | |
1399 number | |
1400 (string-match (format "\\([^ :]+\\):%d" number) xref)) | |
1401 (substring xref (match-beginning 1) (match-end 1))) | |
1402 (t ""))) | |
1403 (when (string-match "\r" group) | |
1404 (setq group (substring group 0 (match-beginning 0)))) | |
1405 (cons group number))))) | |
1406 | |
1407 (provide 'nntp) | |
1408 | |
52401 | 1409 ;;; arch-tag: 8655466a-b1b5-4929-9c45-7b1b2e767271 |
17493 | 1410 ;;; nntp.el ends here |