annotate lisp/gnus/nntp.el @ 144:318232e2a3f0 r20-2b6

Import from CVS: tag r20-2b6
author cvs
date Mon, 13 Aug 2007 09:34:14 +0200
parents 585fb297b004
children 3bb7ccffb0c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; nntp.el --- nntp access for Gnus
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
2 ;;; Copyright (C) 1987,88,89,90,92,93,94,95,96,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: news
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
21 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (require 'nnheader)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (require 'nnoo)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
29 (require 'gnus-util)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (nnoo-declare nntp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (eval-and-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (unless (fboundp 'open-network-stream)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (require 'tcp)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (eval-when-compile (require 'cl))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
39 (defvoo nntp-address nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
40 "Address of the physical nntp server.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
42 (defvoo nntp-port-number "nntp"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
43 "Port number on the physical nntp server.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defvoo nntp-server-opened-hook '(nntp-send-mode-reader)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
46 "*Hook used for sending commands to the server at startup.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 The default value is `nntp-send-mode-reader', which makes an innd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 server spawn an nnrpd server. Another useful function to put in this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 hook might be `nntp-send-authinfo', which will prompt for a password
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 to allow posting from the server. Note that this is only necessary to
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
51 do on servers that use strict access control.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
52
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
53 (defvoo nntp-authinfo-function 'nntp-send-authinfo
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
54 "Function used to send AUTHINFO to the server.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
56 (defvoo nntp-server-action-alist
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
57 '(("nntpd 1\\.5\\.11t"
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
58 (remove-hook 'nntp-server-opened-hook 'nntp-send-mode-reader))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
59 ("NNRP server Netscape"
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
60 (setq nntp-server-list-active-group nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "Alist of regexps to match on server types and actions to be taken.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 For instance, if you want Gnus to beep every time you connect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 to innd, you could say something like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 \(setq nntp-server-action-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 '((\"innd\" (ding))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 You probably don't want to do that, though.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
70 (defvoo nntp-open-connection-function 'nntp-open-network-stream
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 "*Function used for connecting to a remote system.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
72 It will be called with the buffer to output in.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 Two pre-made functions are `nntp-open-network-stream', which is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 default, and simply connects to some port or other on the remote
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
76 system (see nntp-port-number). The other are `nntp-open-rlogin', which
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 does an rlogin on the remote system, and then does a telnet to the
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
78 NNTP server available there (see nntp-rlogin-parameters) and `nntp-open-telnet' which
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
79 telnets to a remote system, logs in and does the same")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
81 (defvoo nntp-rlogin-parameters '("telnet" "-8" "${NNTPSERVER:=news}" "nntp")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
82 "*Parameters to `nntp-open-login'.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
83 That function may be used as `nntp-open-connection-function'. In that
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 case, this list will be used as the parameter list given to rsh.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defvoo nntp-rlogin-user-name nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "*User name on remote system when using the rlogin connect method.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
89 (defvoo nntp-telnet-parameters '("exec" "telnet" "-8" "${NNTPSERVER:=news}" "nntp")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
90 "*Parameters to `nntp-open-telnet'.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
91 That function may be used as `nntp-open-connection-function'. In that
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
92 case, this list will be executed as a command after logging in
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
93 via telnet.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
94
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
95 (defvoo nntp-telnet-user-name nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
96 "User name to log in via telnet with.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
97
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
98 (defvoo nntp-telnet-passwd nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
99 "Password to use to log in via telnet with.")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
100
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 110
diff changeset
101 (defvoo nntp-telnet-command "telnet"
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 110
diff changeset
102 "Command used to start telnet.")
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 110
diff changeset
103
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 110
diff changeset
104 (defvoo nntp-telnet-switches '("-8")
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 110
diff changeset
105 "Switches given to the telnet command.")
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 110
diff changeset
106
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defvoo nntp-end-of-line "\r\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 "String to use on the end of lines when talking to the NNTP server.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 This is \"\\r\\n\" by default, but should be \"\\n\" when
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
110 using rlogin or telnet to communicate with the server.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defvoo nntp-large-newsgroup 50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 "*The number of the articles which indicates a large newsgroup.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 If the number of the articles is greater than the value, verbose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 messages will be shown to indicate the current status.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (defvoo nntp-maximum-request 400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 "*The maximum number of the requests sent to the NNTP server at one time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 If Emacs hangs up while retrieving headers, set the variable to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 lower value.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defvoo nntp-nov-is-evil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 "*If non-nil, nntp will never attempt to use XOVER when talking to the server.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defvoo nntp-xover-commands '("XOVER" "XOVERVIEW")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 "*List of strings that are used as commands to fetch NOV lines from a server.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
127 The strings are tried in turn until a positive response is gotten. If
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 none of the commands are successful, nntp will just grab headers one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 by one.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defvoo nntp-nov-gap 20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 "*Maximum allowed gap between two articles.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 If the gap between two consecutive articles is bigger than this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 variable, split the XOVER request into two requests.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (defvoo nntp-connection-timeout nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 "*Number of seconds to wait before an nntp connection times out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 If this variable is nil, which is the default, no timers are set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (defvoo nntp-prepare-server-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 "*Hook run before a server is opened.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 If can be used to set up a server remotely, for instance. Say you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 have an account at the machine \"other.machine\". This machine has
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 access to an NNTP server that you can't access locally. You could
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 then use this hook to rsh to the remote machine and start a proxy NNTP
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
146 server there that you can connect to. See also `nntp-open-connection-function'")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defvoo nntp-warn-about-losing-connection t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 "*If non-nil, beep when a server closes connection.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
153 ;;; Internal variables.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
155 (defvar nntp-have-messaged nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
157 (defvar nntp-process-wait-for nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
158 (defvar nntp-process-to-buffer nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
159 (defvar nntp-process-callback nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
160 (defvar nntp-process-decode nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
161 (defvar nntp-process-start-point nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
162 (defvar nntp-inside-change-function nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
164 (defvar nntp-connection-list nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
166 (defvoo nntp-server-type nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
167 (defvoo nntp-connection-alist nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
168 (defvoo nntp-status-string "")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
169 (defconst nntp-version "nntp 5.0")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
170 (defvoo nntp-inhibit-erase nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
171 (defvoo nntp-inhibit-output nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (defvoo nntp-server-xover 'try)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (defvoo nntp-server-list-active-group 'try)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
176 (eval-and-compile
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
177 (autoload 'nnmail-read-passwd "nnmail"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
180
110
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
181 ;;; Internal functions.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
182
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
183 (defsubst nntp-send-string (process string)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
184 "Send STRING to PROCESS."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
185 (process-send-string process (concat string nntp-end-of-line)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
186
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
187 (defsubst nntp-wait-for (process wait-for buffer &optional decode discard)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
188 "Wait for WAIT-FOR to arrive from PROCESS."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
189 (save-excursion
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
190 (set-buffer (process-buffer process))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
191 (goto-char (point-min))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
192 (while (or (not (memq (following-char) '(?2 ?3 ?4 ?5)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
193 (looking-at "480"))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
194 (when (looking-at "480")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
195 (erase-buffer)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
196 (funcall nntp-authinfo-function))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
197 (nntp-accept-process-output process)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
198 (goto-char (point-min)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
199 (prog1
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
200 (if (looking-at "[45]")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
201 (progn
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
202 (nntp-snarf-error-message)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
203 nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
204 (goto-char (point-max))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
205 (let ((limit (point-min)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
206 (while (not (re-search-backward wait-for limit t))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
207 ;; We assume that whatever we wait for is less than 1000
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
208 ;; characters long.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
209 (setq limit (max (- (point-max) 1000) (point-min)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
210 (nntp-accept-process-output process)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
211 (goto-char (point-max))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
212 (nntp-decode-text (not decode))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
213 (unless discard
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
214 (save-excursion
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
215 (set-buffer buffer)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
216 (goto-char (point-max))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
217 (insert-buffer-substring (process-buffer process))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
218 ;; Nix out "nntp reading...." message.
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
219 (when nntp-have-messaged
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
220 (setq nntp-have-messaged nil)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
221 (message ""))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
222 t)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
223 (unless discard
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
224 (erase-buffer)))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
225
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
226 (defsubst nntp-find-connection (buffer)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
227 "Find the connection delivering to BUFFER."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
228 (let ((alist nntp-connection-alist)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
229 (buffer (if (stringp buffer) (get-buffer buffer) buffer))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
230 process entry)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
231 (while (setq entry (pop alist))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
232 (when (eq buffer (cadr entry))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
233 (setq process (car entry)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
234 alist nil)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
235 (when process
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
236 (if (memq (process-status process) '(open run))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
237 process
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
238 (when (buffer-name (process-buffer process))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
239 (kill-buffer (process-buffer process)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
240 (setq nntp-connection-alist (delq entry nntp-connection-alist))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
241 nil))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
242
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
243 (defsubst nntp-find-connection-entry (buffer)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
244 "Return the entry for the connection to BUFFER."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
245 (assq (nntp-find-connection buffer) nntp-connection-alist))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
246
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
247 (defun nntp-find-connection-buffer (buffer)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
248 "Return the process connection buffer tied to BUFFER."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
249 (let ((process (nntp-find-connection buffer)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
250 (when process
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
251 (process-buffer process))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
252
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
253 (defsubst nntp-retrieve-data (command address port buffer
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
254 &optional wait-for callback decode)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
255 "Use COMMAND to retrieve data into BUFFER from PORT on ADDRESS."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
256 (let ((process (or (nntp-find-connection buffer)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
257 (nntp-open-connection buffer))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
258 (if (not process)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
259 (nnheader-report 'nntp "Couldn't open connection to %s" address)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
260 (unless (or nntp-inhibit-erase nnheader-callback-function)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
261 (save-excursion
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
262 (set-buffer (process-buffer process))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
263 (erase-buffer)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
264 (when command
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
265 (nntp-send-string process command))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
266 (cond
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
267 ((eq callback 'ignore)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
268 t)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
269 ((and callback wait-for)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
270 (save-excursion
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
271 (set-buffer (process-buffer process))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
272 (unless nntp-inside-change-function
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
273 (erase-buffer))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
274 (setq nntp-process-decode decode
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
275 nntp-process-to-buffer buffer
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
276 nntp-process-wait-for wait-for
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
277 nntp-process-callback callback
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
278 nntp-process-start-point (point-max)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
279 after-change-functions
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
280 (list 'nntp-after-change-function-callback)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
281 t)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
282 (wait-for
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
283 (nntp-wait-for process wait-for buffer decode))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
284 (t t)))))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
285
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
286 (defsubst nntp-send-command (wait-for &rest strings)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
287 "Send STRINGS to server and wait until WAIT-FOR returns."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
288 (when (and (not nnheader-callback-function)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
289 (not nntp-inhibit-output))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
290 (save-excursion
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
291 (set-buffer nntp-server-buffer)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
292 (erase-buffer)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
293 (nntp-retrieve-data
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
294 (mapconcat 'identity strings " ")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
295 nntp-address nntp-port-number nntp-server-buffer
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
296 wait-for nnheader-callback-function))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
297
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
298 (defun nntp-send-command-nodelete (wait-for &rest strings)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
299 "Send STRINGS to server and wait until WAIT-FOR returns."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
300 (nntp-retrieve-data
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
301 (mapconcat 'identity strings " ")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
302 nntp-address nntp-port-number nntp-server-buffer
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
303 wait-for nnheader-callback-function))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
304
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
305 (defun nntp-send-command-and-decode (wait-for &rest strings)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
306 "Send STRINGS to server and wait until WAIT-FOR returns."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
307 (when (and (not nnheader-callback-function)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
308 (not nntp-inhibit-output))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
309 (save-excursion
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
310 (set-buffer nntp-server-buffer)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
311 (erase-buffer)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
312 (nntp-retrieve-data
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
313 (mapconcat 'identity strings " ")
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
314 nntp-address nntp-port-number nntp-server-buffer
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
315 wait-for nnheader-callback-function t))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
316
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
317 (defun nntp-send-buffer (wait-for)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
318 "Send the current buffer to server and wait until WAIT-FOR returns."
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
319 (when (and (not nnheader-callback-function)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
320 (not nntp-inhibit-output))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
321 (save-excursion
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
322 (set-buffer (nntp-find-connection-buffer nntp-server-buffer))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
323 (erase-buffer)))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
324 (nntp-encode-text)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
325 (process-send-region (nntp-find-connection nntp-server-buffer)
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
326 (point-min) (point-max))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
327 (nntp-retrieve-data
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
328 nil nntp-address nntp-port-number nntp-server-buffer
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
329 wait-for nnheader-callback-function))
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
330
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
331
fe104dbd9147 Import from CVS: tag r20-1b7
cvs
parents: 108
diff changeset
332
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;;; Interface functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (nnoo-define-basics nntp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (deffoo nntp-retrieve-headers (articles &optional group server fetch-old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 "Retrieve the headers of ARTICLES."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
339 (nntp-possibly-change-group group server)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (save-excursion
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
341 (set-buffer (nntp-find-connection-buffer nntp-server-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (erase-buffer)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
343 (if (and (not gnus-nov-is-evil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (not nntp-nov-is-evil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (nntp-retrieve-headers-with-xover articles fetch-old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; We successfully retrieved the headers via XOVER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 'nov
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;; XOVER didn't work, so we do it the hard, slow and inefficient
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
349 ;; way.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (let ((number (length articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (received 0)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
353 (last-point (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
354 (buf (nntp-find-connection-buffer nntp-server-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
355 (nntp-inhibit-erase t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 ;; Send HEAD command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (while articles
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
358 (nntp-send-command
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
359 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
360 "HEAD" (if (numberp (car articles))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (int-to-string (car articles))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ;; `articles' is either a list of article numbers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;; or a list of article IDs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (car articles)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (setq articles (cdr articles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 count (1+ count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 ;; Every 400 header requests we have to read the stream in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 ;; order to avoid deadlocks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (when (or (null articles) ;All requests have been sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (zerop (% count nntp-maximum-request)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (nntp-accept-response)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (while (progn
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
373 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
374 (set-buffer buf)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
375 (goto-char last-point))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 ;; Count replies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (while (re-search-forward "^[0-9]" nil t)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
378 (incf received))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (setq last-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (< received count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ;; If number of headers is greater than 100, give
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;; informative messages.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (and (numberp nntp-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (> number nntp-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (zerop (% received 20))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
386 (nnheader-message 6 "NNTP: Receiving headers... %d%%"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (/ (* received 100) number)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (nntp-accept-response))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 ;; Wait for text of last command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (re-search-backward "^[0-9]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (when (looking-at "^[23]")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (while (progn
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 98
diff changeset
394 (goto-char (point-max))
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 98
diff changeset
395 (forward-line -1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (not (looking-at "^\\.\r?\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (nntp-accept-response)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (and (numberp nntp-large-newsgroup)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (> number nntp-large-newsgroup)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
400 (nnheader-message 6 "NNTP: Receiving headers...done"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 ;; Now all of replies are received. Fold continuation lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (nnheader-fold-continuation-lines)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;; Remove all "\r"'s.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
405 (nnheader-strip-cr)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
406 (copy-to-buffer nntp-server-buffer (point-min) (point-max))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 'headers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (deffoo nntp-retrieve-groups (groups &optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 "Retrieve group info on GROUPS."
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
411 (nntp-possibly-change-group nil server)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (save-excursion
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
413 (set-buffer (nntp-find-connection-buffer nntp-server-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;; The first time this is run, this variable is `try'. So we
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
415 ;; try.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (when (eq nntp-server-list-active-group 'try)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (nntp-try-list-active (car groups)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (let ((count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (received 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (last-point (point-min))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
422 (nntp-inhibit-erase t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (command (if nntp-server-list-active-group "LIST ACTIVE" "GROUP")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (while groups
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ;; Send the command to the server.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
426 (nntp-send-command nil command (pop groups))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
427 (incf count)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 ;; Every 400 requests we have to read the stream in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 ;; order to avoid deadlocks.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (when (or (null groups) ;All requests have been sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (zerop (% count nntp-maximum-request)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (nntp-accept-response)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (while (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (goto-char last-point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;; Count replies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (while (re-search-forward "^[0-9]" nil t)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
437 (incf received))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq last-point (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (< received count))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (nntp-accept-response))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ;; Wait for the reply from the final command.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
443 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
444 (re-search-backward "^[0-9]" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
445 (when (looking-at "^[23]")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
446 (while (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
447 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
448 (if (not nntp-server-list-active-group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
449 (not (re-search-backward "\r?\n" (- (point) 3) t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
450 (not (re-search-backward "^\\.\r?\n" (- (point) 4) t))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
451 (nntp-accept-response)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
453 ;; Now all replies are received. We remove CRs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (while (search-forward "\r" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (replace-match "" t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (if (not nntp-server-list-active-group)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
459 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
460 (copy-to-buffer nntp-server-buffer (point-min) (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
461 'group)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ;; We have read active entries, so we just delete the
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
463 ;; superfluous gunk.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (while (re-search-forward "^[.2-5]" nil t)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
466 (delete-region (match-beginning 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (progn (forward-line 1) (point))))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
468 (copy-to-buffer nntp-server-buffer (point-min) (point-max))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 'active))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
471 (deffoo nntp-retrieve-articles (articles &optional group server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
472 (nntp-possibly-change-group group server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
473 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
474 (let ((number (length articles))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
475 (count 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
476 (received 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
477 (last-point (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
478 (buf (nntp-find-connection-buffer nntp-server-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
479 (nntp-inhibit-erase t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
480 (map (apply 'vector articles))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
481 (point 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
482 article alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
483 (set-buffer buf)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
484 (erase-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
485 ;; Send HEAD command.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
486 (while (setq article (pop articles))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
487 (nntp-send-command
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
488 nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
489 "ARTICLE" (if (numberp article)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
490 (int-to-string article)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
491 ;; `articles' is either a list of article numbers
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
492 ;; or a list of article IDs.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
493 article))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
494 (incf count)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
495 ;; Every 400 requests we have to read the stream in
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
496 ;; order to avoid deadlocks.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
497 (when (or (null articles) ;All requests have been sent.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
498 (zerop (% count nntp-maximum-request)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
499 (nntp-accept-response)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
500 (while (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
501 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
502 (set-buffer buf)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
503 (goto-char last-point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
504 ;; Count replies.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
505 (while (nntp-next-result-arrived-p)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
506 (aset map received (cons (aref map received) (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
507 (incf received))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
508 (setq last-point (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
509 (< received count))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
510 ;; If number of headers is greater than 100, give
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
511 ;; informative messages.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
512 (and (numberp nntp-large-newsgroup)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
513 (> number nntp-large-newsgroup)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
514 (zerop (% received 20))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
515 (nnheader-message 6 "NNTP: Receiving articles... %d%%"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
516 (/ (* received 100) number)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
517 (nntp-accept-response))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
518 (and (numberp nntp-large-newsgroup)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
519 (> number nntp-large-newsgroup)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
520 (nnheader-message 6 "NNTP: Receiving headers...done"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
522 ;; Now we have all the responses. We go through the results,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
523 ;; washes it and copies it over to the server buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
524 (set-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
525 (erase-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
526 (mapcar
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
527 (lambda (entry)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
528 (narrow-to-region
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
529 (setq point (goto-char (point-max)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
530 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
531 (insert-buffer-substring buf last-point (cdr entry))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
532 (point-max)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
533 (nntp-decode-text)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
534 (widen)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
535 (cons (car entry) point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
536 map))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
537
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
538 (defun nntp-next-result-arrived-p ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
539 (let ((point (point)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
540 (cond
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
541 ((looking-at "2")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
542 (if (re-search-forward "\n.\r?\n" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
543 t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
544 (goto-char point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
545 nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
546 ((looking-at "[34]")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
547 (forward-line 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
548 t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
549 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
550 nil))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
552 (defun nntp-try-list-active (group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
553 (nntp-list-active-group group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
554 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
555 (set-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
556 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
557 (cond ((or (eobp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
558 (looking-at "5[0-9]+"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
559 (setq nntp-server-list-active-group nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
560 (t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
561 (setq nntp-server-list-active-group t)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
562
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
563 (deffoo nntp-list-active-group (group &optional server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
564 "Return the active info on GROUP (which can be a regexp."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
565 (nntp-possibly-change-group nil server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
566 (nntp-send-command "^.*\r?\n" "LIST ACTIVE" group))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
567
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
568 (deffoo nntp-request-article (article &optional group server buffer command)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
569 (nntp-possibly-change-group group server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
570 (when (nntp-send-command-and-decode
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
571 "\r?\n\\.\r?\n" "ARTICLE"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
572 (if (numberp article) (int-to-string article) article))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
573 (when (and buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
574 (not (equal buffer nntp-server-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
575 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
576 (set-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
577 (copy-to-buffer buffer (point-min) (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
578 (nntp-find-group-and-number)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
579 (nntp-find-group-and-number)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
580
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
581 (deffoo nntp-request-head (article &optional group server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
582 (nntp-possibly-change-group group server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
583 (when (nntp-send-command-and-decode
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
584 "\r?\n\\.\r?\n" "HEAD"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
585 (if (numberp article) (int-to-string article) article))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
586 (nntp-find-group-and-number)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
587
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
588 (deffoo nntp-request-body (article &optional group server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
589 (nntp-possibly-change-group group server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
590 (nntp-send-command-and-decode
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
591 "\r?\n\\.\r?\n" "BODY"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
592 (if (numberp article) (int-to-string article) article)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
593
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
594 (deffoo nntp-request-group (group &optional server dont-check)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
595 (nntp-possibly-change-group nil server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
596 (when (nntp-send-command "^2.*\n" "GROUP" group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
597 (let ((entry (nntp-find-connection-entry nntp-server-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
598 (setcar (cddr entry) group))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
599
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
600 (deffoo nntp-close-group (group &optional server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
601 t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (deffoo nntp-server-opened (&optional server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 "Say whether a connection to SERVER has been opened."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (and (nnoo-current-server-p 'nntp server)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 nntp-server-buffer
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
607 (gnus-buffer-live-p nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
608 (nntp-find-connection nntp-server-buffer)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
610 (deffoo nntp-open-server (server &optional defs connectionless)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
611 (nnheader-init-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
612 (if (nntp-server-opened server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
613 t
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
614 (when (or (stringp (car defs))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
615 (numberp (car defs)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
616 (setq defs (cons (list 'nntp-port-number (car defs)) (cdr defs))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
617 (unless (assq 'nntp-address defs)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
618 (setq defs (append defs (list (list 'nntp-address server)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
619 (nnoo-change-server 'nntp server defs)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
620 (unless connectionless
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
621 (or (nntp-find-connection nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
622 (nntp-open-connection nntp-server-buffer)))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
623
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
624 (deffoo nntp-close-server (&optional server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
625 (nntp-possibly-change-group nil server t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
626 (let (process)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
627 (while (setq process (car (pop nntp-connection-alist)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
628 (when (memq (process-status process) '(open run))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
629 (set-process-sentinel process nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
630 (nntp-send-string process "QUIT"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
631 (when (buffer-name (process-buffer process))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
632 (kill-buffer (process-buffer process))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
633 (nnoo-close-server 'nntp)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
635 (deffoo nntp-request-close ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
636 (let (process)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
637 (while (setq process (pop nntp-connection-list))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
638 (when (memq (process-status process) '(open run))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
639 (set-process-sentinel process nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
640 (ignore-errors
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
641 (nntp-send-string process "QUIT")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
642 (when (buffer-name (process-buffer process))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
643 (kill-buffer (process-buffer process))))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
644
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
645 (deffoo nntp-request-list (&optional server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
646 (nntp-possibly-change-group nil server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
647 (nntp-send-command-and-decode "\r?\n\\.\r?\n" "LIST"))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
648
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
649 (deffoo nntp-request-list-newsgroups (&optional server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
650 (nntp-possibly-change-group nil server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
651 (nntp-send-command "\r?\n\\.\r?\n" "LIST NEWSGROUPS"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
653 (deffoo nntp-request-newgroups (date &optional server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
654 (nntp-possibly-change-group nil server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
655 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
656 (set-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
657 (let* ((date (timezone-parse-date date))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
658 (time-string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
659 (format "%s%02d%02d %s%s%s"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
660 (substring (aref date 0) 2) (string-to-int (aref date 1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
661 (string-to-int (aref date 2)) (substring (aref date 3) 0 2)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
662 (substring
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
663 (aref date 3) 3 5) (substring (aref date 3) 6 8))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
664 (prog1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
665 (nntp-send-command "^\\.\r?\n" "NEWGROUPS" time-string)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
666 (nntp-decode-text)))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
667
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
668 (deffoo nntp-request-post (&optional server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
669 (nntp-possibly-change-group nil server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
670 (when (nntp-send-command "^[23].*\r?\n" "POST")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
671 (nntp-send-buffer "^[23].*\n")))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
672
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
673 (deffoo nntp-request-type (group article)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
674 'news)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
675
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
676 (deffoo nntp-asynchronous-p ()
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
677 t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
679 ;;; Hooky functions.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (defun nntp-send-mode-reader ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 "Send the MODE READER command to the nntp server.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 This function is supposed to be called from `nntp-server-opened-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 It will make innd servers spawn an nnrpd process to allow actual article
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 reading."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (nntp-send-command "^.*\r?\n" "MODE READER"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (defun nntp-send-nosy-authinfo ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 "Send the AUTHINFO to the nntp server.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 This function is supposed to be called from `nntp-server-opened-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 It will prompt for a password."
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
692 (nntp-send-command
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
693 "^.*\r?\n" "AUTHINFO USER"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
694 (read-string (format "NNTP (%s) user name: " nntp-address)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
695 (nntp-send-command
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
696 "^.*\r?\n" "AUTHINFO PASS"
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
697 (nnmail-read-passwd "NNTP (%s) password: " nntp-address)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (defun nntp-send-authinfo ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 "Send the AUTHINFO to the nntp server.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 This function is supposed to be called from `nntp-server-opened-hook'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 It will prompt for a password."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (nntp-send-command "^.*\r?\n" "AUTHINFO USER" (user-login-name))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
704 (nntp-send-command
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
705 "^.*\r?\n" "AUTHINFO PASS"
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
706 (nnmail-read-passwd (format "NNTP (%s) password: " nntp-address))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (defun nntp-send-authinfo-from-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 "Send the AUTHINFO to the nntp server.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
710 This function is supposed to be called from `nntp-server-opened-hook'."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (when (file-exists-p "~/.nntp-authinfo")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
712 (nnheader-temp-write nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (insert-file-contents "~/.nntp-authinfo")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (nntp-send-command "^.*\r?\n" "AUTHINFO USER" (user-login-name))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
716 (nntp-send-command
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
717 "^.*\r?\n" "AUTHINFO PASS"
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
718 (buffer-substring (point) (progn (end-of-line) (point)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
719
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
720 ;;; Internal functions.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
721
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
722 (defun nntp-make-process-buffer (buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
723 "Create a new, fresh buffer usable for nntp process connections."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
724 (save-excursion
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
725 (set-buffer
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
726 (generate-new-buffer
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
727 (format " *server %s %s %s*"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
728 nntp-address nntp-port-number
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
729 (buffer-name (get-buffer buffer)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
730 (buffer-disable-undo (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
731 (set (make-local-variable 'after-change-functions) nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
732 (set (make-local-variable 'nntp-process-wait-for) nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
733 (set (make-local-variable 'nntp-process-callback) nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
734 (set (make-local-variable 'nntp-process-to-buffer) nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
735 (set (make-local-variable 'nntp-process-start-point) nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
736 (set (make-local-variable 'nntp-process-decode) nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
737 (current-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
738
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
739 (defun nntp-open-connection (buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
740 "Open a connection to PORT on ADDRESS delivering output to BUFFER."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
741 (run-hooks 'nntp-prepare-server-hook)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
742 (let* ((pbuffer (nntp-make-process-buffer buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
743 (process
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
744 (condition-case ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
745 (funcall nntp-open-connection-function pbuffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
746 (error nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
747 (quit nil))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
748 (when process
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
749 (process-kill-without-query process)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
750 (nntp-wait-for process "^.*\n" buffer nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
751 (if (memq (process-status process) '(open run))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
752 (prog1
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
753 (caar (push (list process buffer nil) nntp-connection-alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
754 (push process nntp-connection-list)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
755 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
756 (set-buffer pbuffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
757 (nntp-read-server-type)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
758 (erase-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
759 (set-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
760 (let ((nnheader-callback-function nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
761 (run-hooks 'nntp-server-opened-hook))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
762 (when (buffer-name (process-buffer process))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
763 (kill-buffer (process-buffer process)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
764 nil))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
765
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
766 (defun nntp-open-network-stream (buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
767 (open-network-stream "nntpd" buffer nntp-address nntp-port-number))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
768
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
769 (defun nntp-read-server-type ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
770 "Find out what the name of the server we have connected to is."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
771 ;; Wait for the status string to arrive.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
772 (setq nntp-server-type (buffer-string))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
773 (let ((alist nntp-server-action-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
774 (case-fold-search t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
775 entry)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
776 ;; Run server-specific commands.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
777 (while alist
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
778 (setq entry (pop alist))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
779 (when (string-match (car entry) nntp-server-type)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
780 (if (and (listp (cadr entry))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
781 (not (eq 'lambda (caadr entry))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
782 (eval (cadr entry))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
783 (funcall (cadr entry)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
785 (defun nntp-after-change-function-callback (beg end len)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
786 (when nntp-process-callback
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
787 (save-match-data
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
788 (if (and (= beg (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
789 (memq (char-after beg) '(?4 ?5)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
790 ;; Report back error messages.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
791 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
792 (goto-char beg)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
793 (if (looking-at "480")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
794 (funcall nntp-authinfo-function)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
795 (nntp-snarf-error-message)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
796 (funcall nntp-process-callback nil)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
797 (goto-char end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
798 (when (and (> (point) nntp-process-start-point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
799 (re-search-backward nntp-process-wait-for
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
800 nntp-process-start-point t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
801 (when (buffer-name (get-buffer nntp-process-to-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
802 (let ((cur (current-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
803 (start nntp-process-start-point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
804 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
805 (set-buffer (get-buffer nntp-process-to-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
806 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
807 (let ((b (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
808 (insert-buffer-substring cur start)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
809 (narrow-to-region b (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
810 (nntp-decode-text)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
811 (widen)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
812 (goto-char end)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
813 (let ((callback nntp-process-callback)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
814 (nntp-inside-change-function t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
815 (setq nntp-process-callback nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
816 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
817 (funcall callback (buffer-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
818 (get-buffer nntp-process-to-buffer))))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
820 (defun nntp-snarf-error-message ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
821 "Save the error message in the current buffer."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
822 (let ((message (buffer-string)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
823 (while (string-match "[\r\n]+" message)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
824 (setq message (replace-match " " t t message)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
825 (nnheader-report 'nntp message)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
826 message))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
827
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
828 (defun nntp-accept-process-output (process)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
829 "Wait for output from PROCESS and message some dots."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
830 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
831 (set-buffer (or (nntp-find-connection-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
832 nntp-server-buffer))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
833 (let ((len (/ (point-max) 1024))
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
834 message-log-max)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
835 (unless (< len 10)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
836 (setq nntp-have-messaged t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
837 (nnheader-message 7 "nntp read: %dk" len)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
838 (accept-process-output process 1)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
839
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
840 (defun nntp-accept-response ()
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
841 "Wait for output from the process that outputs to BUFFER."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
842 (nntp-accept-process-output (nntp-find-connection nntp-server-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
843
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
844 (defun nntp-possibly-change-group (group server &optional connectionless)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
845 (let ((nnheader-callback-function nil))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
846 (when server
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
847 (or (nntp-server-opened server)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
848 (nntp-open-server server nil connectionless)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
849
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
850 (unless connectionless
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
851 (or (nntp-find-connection nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
852 (nntp-open-connection nntp-server-buffer))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
853
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
854 (when group
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
855 (let ((entry (nntp-find-connection-entry nntp-server-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
856 (when (not (equal group (caddr entry)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
857 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
858 (set-buffer (process-buffer (car entry)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
859 (erase-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
860 (nntp-send-string (car entry) (concat "GROUP " group))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
861 (nntp-wait-for-string "^2.*\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
862 (setcar (cddr entry) group)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
863 (erase-buffer))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
864
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
865 (defun nntp-decode-text (&optional cr-only)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
866 "Decode the text in the current buffer."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
867 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
868 (while (search-forward "\r" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
869 (delete-char -1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
870 (unless cr-only
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
871 ;; Remove trailing ".\n" end-of-transfer marker.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (forward-line -1)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
874 (when (looking-at ".\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
875 (delete-char 2))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
876 ;; Delete status line.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (goto-char (point-min))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
878 (delete-region (point) (progn (forward-line 1) (point)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
879 ;; Remove "." -> ".." encoding.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (while (search-forward "\n.." nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (delete-char -1))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (defun nntp-encode-text ()
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
884 "Encode the text in the current buffer."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (save-excursion
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
886 ;; Replace "." at beginning of line with "..".
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (goto-char (point-min))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
888 (while (re-search-forward "^\\." nil t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (insert "."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (goto-char (point-max))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
891 ;; Insert newline at the end of the buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
892 (unless (bolp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
893 (insert "\n"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 ;; Insert `.' at end of buffer (end of text mark).
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
895 (goto-char (point-max))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (insert "." nntp-end-of-line)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
898 (defun nntp-retrieve-headers-with-xover (articles &optional fetch-old)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
899 (set-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
900 (erase-buffer)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
901 (cond
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
902
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
903 ;; This server does not talk NOV.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
904 ((not nntp-server-xover)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
905 nil)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
906
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
907 ;; We don't care about gaps.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
908 ((or (not nntp-nov-gap)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
909 fetch-old)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
910 (nntp-send-xover-command
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
911 (if fetch-old
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
912 (if (numberp fetch-old)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
913 (max 1 (- (car articles) fetch-old))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
914 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
915 (car articles))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
916 (car (last articles)) 'wait)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
917
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
918 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
919 (when (looking-at "[1-5][0-9][0-9] ")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
920 (delete-region (point) (progn (forward-line 1) (point))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
921 (while (search-forward "\r" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
922 (replace-match "" t t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
923 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
924 (forward-line -1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
925 (when (looking-at "\\.")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
926 (delete-region (point) (progn (forward-line 1) (point)))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
927
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
928 ;; We do it the hard way. For each gap, an XOVER command is sent
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
929 ;; to the server. We do not wait for a reply from the server, we
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
930 ;; just send them off as fast as we can. That means that we have
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
931 ;; to count the number of responses we get back to find out when we
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
932 ;; have gotten all we asked for.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
933 ((numberp nntp-nov-gap)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
934 (let ((count 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
935 (received 0)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
936 (last-point (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
937 (buf nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
938 ;;(process-buffer (nntp-find-connection (current-buffer))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
939 first)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
940 ;; We have to check `nntp-server-xover'. If it gets set to nil,
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
941 ;; that means that the server does not understand XOVER, but we
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
942 ;; won't know that until we try.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
943 (while (and nntp-server-xover articles)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
944 (setq first (car articles))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
945 ;; Search forward until we find a gap, or until we run out of
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
946 ;; articles.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
947 (while (and (cdr articles)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
948 (< (- (nth 1 articles) (car articles)) nntp-nov-gap))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
949 (setq articles (cdr articles)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
950
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
951 (when (nntp-send-xover-command first (car articles))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
952 (setq articles (cdr articles)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
953 count (1+ count))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
954
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
955 ;; Every 400 requests we have to read the stream in
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
956 ;; order to avoid deadlocks.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
957 (when (or (null articles) ;All requests have been sent.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
958 (zerop (% count nntp-maximum-request)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
959 (accept-process-output)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
960 ;; On some Emacs versions the preceding function has
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
961 ;; a tendency to change the buffer. Perhaps. It's
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
962 ;; quite difficult to reproduce, because it only
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
963 ;; seems to happen once in a blue moon.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
964 (set-buffer buf)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
965 (while (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
966 (goto-char last-point)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
967 ;; Count replies.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
968 (while (re-search-forward "^[0-9][0-9][0-9] " nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
969 (setq received (1+ received)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
970 (setq last-point (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
971 (< received count))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
972 (accept-process-output)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
973 (set-buffer buf)))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
974
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
975 (when nntp-server-xover
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
976 ;; Wait for the reply from the final command.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
977 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
978 (re-search-backward "^[0-9][0-9][0-9] " nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
979 (when (looking-at "^[23]")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
980 (while (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
981 (goto-char (point-max))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
982 (forward-line -1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
983 (not (looking-at "^\\.\r?\n")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
984 (nntp-accept-response)))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
985
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
986 ;; We remove any "." lines and status lines.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
987 (goto-char (point-min))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
988 (while (search-forward "\r" nil t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
989 (delete-char -1))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
990 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
991 (delete-matching-lines "^\\.$\\|^[1-5][0-9][0-9] ")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
992 ;;(copy-to-buffer nntp-server-buffer (point-min) (point-max))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
993 t))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
994
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
995 nntp-server-xover)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
996
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
997 (defun nntp-send-xover-command (beg end &optional wait-for-reply)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
998 "Send the XOVER command to the server."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
999 (let ((range (format "%d-%d" beg end))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1000 (nntp-inhibit-erase t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1001 (if (stringp nntp-server-xover)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1002 ;; If `nntp-server-xover' is a string, then we just send this
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1003 ;; command.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1004 (if wait-for-reply
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
1005 (nntp-send-command-nodelete
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1006 "\r?\n\\.\r?\n" nntp-server-xover range)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1007 ;; We do not wait for the reply.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1008 (nntp-send-command-nodelete "\r?\n\\.\r?\n" nntp-server-xover range))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1009 (let ((commands nntp-xover-commands))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1010 ;; `nntp-xover-commands' is a list of possible XOVER commands.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
1011 ;; We try them all until we get at positive response.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1012 (while (and commands (eq nntp-server-xover 'try))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1013 (nntp-send-command-nodelete "\r?\n\\.\r?\n" (car commands) range)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1014 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1015 (set-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1016 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1017 (and (looking-at "[23]") ; No error message.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1018 ;; We also have to look at the lines. Some buggy
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1019 ;; servers give back simple lines with just the
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1020 ;; article number. How... helpful.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1021 (progn
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1022 (forward-line 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1023 (looking-at "[0-9]+\t...")) ; More text after number.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1024 (setq nntp-server-xover (car commands))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1025 (setq commands (cdr commands)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1026 ;; If none of the commands worked, we disable XOVER.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1027 (when (eq nntp-server-xover 'try)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1028 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1029 (set-buffer nntp-server-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1030 (erase-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1031 (setq nntp-server-xover nil)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1032 nntp-server-xover))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1033
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1034 ;;; Alternative connection methods.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1035
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1036 (defun nntp-wait-for-string (regexp)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1037 "Wait until string arrives in the buffer."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1038 (let ((buf (current-buffer)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1039 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1040 (while (not (re-search-forward regexp nil t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1041 (accept-process-output (nntp-find-connection nntp-server-buffer))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1042 (set-buffer buf)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1043 (goto-char (point-min)))))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1044
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1045 (defun nntp-open-telnet (buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1046 (save-excursion
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1047 (set-buffer buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1048 (erase-buffer)
140
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 110
diff changeset
1049 (let ((proc (apply
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 110
diff changeset
1050 'start-process
585fb297b004 Import from CVS: tag r20-2b4
cvs
parents: 110
diff changeset
1051 "nntpd" buffer nntp-telnet-command nntp-telnet-switches))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1052 (case-fold-search t))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1053 (when (memq (process-status proc) '(open run))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1054 (process-send-string proc "set escape \^X\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1055 (process-send-string proc (concat "open " nntp-address "\n"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1056 (nntp-wait-for-string "^\r*.?login:")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1057 (process-send-string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1058 proc (concat
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1059 (or nntp-telnet-user-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1060 (setq nntp-telnet-user-name (read-string "login: ")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1061 "\n"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1062 (nntp-wait-for-string "^\r*.?password:")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1063 (process-send-string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1064 proc (concat
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1065 (or nntp-telnet-passwd
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1066 (setq nntp-telnet-passwd
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1067 (nnmail-read-passwd "Password: ")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1068 "\n"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1069 (erase-buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1070 (nntp-wait-for-string "bash\\|\$ *\r?$\\|> *\r?")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1071 (process-send-string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1072 proc (concat (mapconcat 'identity nntp-telnet-parameters " ") "\n"))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1073 (nntp-wait-for-string "^\r*200")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1074 (beginning-of-line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1075 (delete-region (point-min) (point))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1076 (process-send-string proc "\^]")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1077 (nntp-wait-for-string "^telnet")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1078 (process-send-string proc "mode character\n")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1079 (accept-process-output proc 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1080 (sit-for 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1081 (goto-char (point-min))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1082 (forward-line 1)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1083 (delete-region (point) (point-max)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1084 proc)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1085
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1086 (defun nntp-open-rlogin (buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1087 "Open a connection to SERVER using rsh."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1088 (let ((proc (if nntp-rlogin-user-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1089 (start-process
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1090 "nntpd" buffer "rsh"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1091 nntp-address "-l" nntp-rlogin-user-name
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1092 (mapconcat 'identity
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1093 nntp-rlogin-parameters " "))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1094 (start-process
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1095 "nntpd" buffer "rsh" nntp-address
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1096 (mapconcat 'identity
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1097 nntp-rlogin-parameters " ")))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1098 (set-buffer buffer)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1099 (nntp-wait-for-string "^\r*200")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1100 (beginning-of-line)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1101 (delete-region (point-min) (point))
104
cf808b4c4290 Import from CVS: tag r20-1b4
cvs
parents: 98
diff changeset
1102 proc))
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1103
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1104 (defun nntp-find-group-and-number ()
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1105 (save-excursion
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1106 (save-restriction
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1107 (set-buffer nntp-server-buffer)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1108 (narrow-to-region (goto-char (point-min))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1109 (or (search-forward "\n\n" nil t) (point-max)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1110 (goto-char (point-min))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1111 ;; We first find the number by looking at the status line.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1112 (let ((number (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ")
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1113 (string-to-int
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1114 (buffer-substring (match-beginning 1)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1115 (match-end 1)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1116 group newsgroups xref)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1117 (and number (zerop number) (setq number nil))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1118 ;; Then we find the group name.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1119 (setq group
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
1120 (cond
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1121 ;; If there is only one group in the Newsgroups header,
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1122 ;; then it seems quite likely that this article comes
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1123 ;; from that group, I'd say.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1124 ((and (setq newsgroups (mail-fetch-field "newsgroups"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1125 (not (string-match "," newsgroups)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1126 newsgroups)
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1127 ;; If there is more than one group in the Newsgroups
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1128 ;; header, then the Xref header should be filled out.
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1129 ;; We hazard a guess that the group that has this
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1130 ;; article number in the Xref header is the one we are
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1131 ;; looking for. This might very well be wrong if this
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1132 ;; article happens to have the same number in several
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 104
diff changeset
1133 ;; groups, but that's life.
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1134 ((and (setq xref (mail-fetch-field "xref"))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1135 number
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1136 (string-match (format "\\([^ :]+\\):%d" number) xref))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1137 (substring xref (match-beginning 1) (match-end 1)))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1138 (t "")))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
1139 (when (string-match "\r" group)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1140 (setq group (substring group 0 (match-beginning 0))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1141 (cons group number)))))
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 44
diff changeset
1142
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (provide 'nntp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 ;;; nntp.el ends here