annotate lisp/gnus/nntp.el @ 22:8fc7fe29b841 r19-15b94

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