annotate lisp/gnus/nntp.el @ 30:ec9a17fef872 r19-15b98

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