*** empty log message ***
[gnus] / lisp / nntp.el
1 ;;; nntp.el --- nntp access for Gnus
2 ;; Copyright (C) 1987,88,89,90,92,93,94,95 Free Software Foundation, Inc.
3
4 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
5 ;;      Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (require 'rnews)
29 (require 'sendmail)
30 (require 'nnheader)
31
32 (eval-when-compile (require 'cl))
33
34 (eval-and-compile
35   (autoload 'news-setup "rnewspost")
36   (autoload 'news-reply-mode "rnewspost")
37   (autoload 'cancel-timer "timer")
38   (autoload 'telnet "telnet" nil t)
39   (autoload 'telnet-send-input "telnet" nil t)
40   (autoload 'timezone-parse-date "timezone"))
41
42 (defvar nntp-server-hook nil
43   "*Hooks for the NNTP server.
44 If the kanji code of the NNTP server is different from the local kanji
45 code, the correct kanji code of the buffer associated with the NNTP
46 server must be specified as follows:
47
48 \(setq nntp-server-hook
49       (function
50        (lambda ()
51          ;; Server's Kanji code is EUC (NEmacs hack).
52          (make-local-variable 'kanji-fileio-code)
53          (setq kanji-fileio-code 0))))
54
55 If you'd like to change something depending on the server in this
56 hook, use the variable `nntp-address'.")
57
58 (defvar nntp-server-opened-hook nil
59   "*Hook used for sending commands to the server at startup.  
60 The default value is `nntp-send-mode-reader', which makes an innd
61 server spawn an nnrpd server.  Another useful function to put in this
62 hook might be `nntp-send-authinfo', which will prompt for a password
63 to allow posting from the server.  Note that this is only necessary to
64 do on servers that use strict access control.")  
65 (add-hook 'nntp-server-opened-hook 'nntp-send-mode-reader)
66
67 (defvar nntp-open-server-function 'nntp-open-network-stream
68   "*Function used for connecting to a remote system.
69 It will be called with the address of the remote system.
70
71 Two pre-made functions are `nntp-open-network-stream', which is the
72 default, and simply connects to some port or other on the remote
73 system (see nntp-port-number).  The other is `nntp-open-rlogin', which
74 does an rlogin on the remote system, and then does a telnet to the
75 NNTP server available there (see nntp-rlogin-parameters).")
76
77 (defvar nntp-rlogin-parameters '("telnet" "${NNTPSERVER:=localhost}" "nntp")
78   "*Parameters to `nntp-open-login'.
79 That function may be used as `nntp-open-server-function'.  In that
80 case, this list will be used as the parameter list given to rsh.")
81
82 (defvar nntp-rlogin-user-name nil
83   "*User name on remote system when using the rlogin connect method.")
84
85 (defvar nntp-address nil
86   "*The name of the NNTP server.")
87
88 (defvar nntp-port-number "nntp"
89   "*Port number to connect to.")
90
91 (defvar nntp-large-newsgroup 50
92   "*The number of the articles which indicates a large newsgroup.
93 If the number of the articles is greater than the value, verbose
94 messages will be shown to indicate the current status.")
95
96 (defvar nntp-buggy-select (memq system-type '(fujitsu-uts))
97   "*t if your select routine is buggy.
98 If the select routine signals error or fall into infinite loop while
99 waiting for the server response, the variable must be set to t.  In
100 case of Fujitsu UTS, it is set to T since `accept-process-output'
101 doesn't work properly.")
102
103 (defvar nntp-maximum-request 400
104   "*The maximum number of the requests sent to the NNTP server at one time.
105 If Emacs hangs up while retrieving headers, set the variable to a
106 lower value.")
107
108 (defvar nntp-debug-read 10000
109   "*Display '...' every 10Kbytes of a message being received if it is non-nil.
110 If it is a number, dots are displayed per the number.")
111
112 (defvar nntp-nov-is-evil nil
113   "*If non-nil, nntp will never attempt to use XOVER when talking to the server.")
114
115 (defvar nntp-xover-commands '("XOVER" "XOVERVIEW")
116   "*List of strings that are used as commands to fetch NOV lines from a server.
117 The strings are tried in turn until a positive response is gotten. If
118 none of the commands are successful, nntp will just grab headers one
119 by one.")
120
121 (defvar nntp-nov-gap 20
122   "*Maximum allowed gap between two articles.
123 If the gap between two consecutive articles is bigger than this
124 variable, split the XOVER request into two requests.")
125
126 (defvar nntp-connection-timeout nil
127   "*Number of seconds to wait before an nntp connection times out.
128 If this variable is nil, which is the default, no timers are set.")
129
130 (defvar nntp-news-default-headers nil
131   "*If non-nil, override `mail-default-headers' when posting news.")
132
133 (defvar nntp-prepare-server-hook nil
134   "*Hook run before a server is opened.
135 If can be used to set up a server remotely, for instance.  Say you
136 have an account at the machine \"other.machine\".  This machine has
137 access to an NNTP server that you can't access locally.  You could
138 then use this hook to rsh to the remote machine and start a proxy NNTP
139 server there that you can connect to.")
140
141 (defvar nntp-async-number 5
142   "*How many articles should be prefetched when in asynchronous mode.")
143
144 (defvar nntp-warn-about-losing-connection t
145   "*If non-nil, beep when a server closes connection.")
146
147 \f
148
149 (defconst nntp-version "nntp 4.0"
150   "Version numbers of this version of NNTP.")
151
152 (defvar nntp-server-buffer nil
153   "Buffer associated with the NNTP server process.")
154
155 (defvar nntp-server-process nil
156   "The NNTP server process.
157 You'd better not use this variable in NNTP front-end program, but
158 instead use `nntp-server-buffer'.")
159
160 (defvar nntp-status-string nil
161   "Save the server response message.
162 You'd better not use this variable in NNTP front-end program but
163 instead call function `nntp-status-message' to get status message.")
164
165 (defvar nntp-opened-connections nil
166   "All (possibly) opened connections.")
167
168 (defvar nntp-server-xover 'try)
169 (defvar nntp-server-list-active-group 'try)
170 (defvar nntp-current-group "")
171
172 (defvar nntp-async-process nil)
173 (defvar nntp-async-buffer nil)
174 (defvar nntp-async-articles nil)
175 (defvar nntp-async-fetched nil)
176 (defvar nntp-async-group-alist nil)
177
178
179 \f
180 (defvar nntp-current-server nil)
181 (defvar nntp-server-alist nil)
182 (defvar nntp-server-variables 
183   `((nntp-server-hook ,nntp-server-hook)
184     (nntp-server-opened-hook ,nntp-server-opened-hook)
185     (nntp-port-number ,nntp-port-number)
186     (nntp-address ,nntp-address)
187     (nntp-large-newsgroup ,nntp-large-newsgroup)
188     (nntp-buggy-select ,nntp-buggy-select)
189     (nntp-maximum-request ,nntp-maximum-request)
190     (nntp-debug-read ,nntp-debug-read)
191     (nntp-nov-is-evil ,nntp-nov-is-evil)
192     (nntp-xover-commands ,nntp-xover-commands)
193     (nntp-connection-timeout ,nntp-connection-timeout)
194     (nntp-news-default-headers ,nntp-news-default-headers)
195     (nntp-prepare-server-hook ,nntp-prepare-server-hook) 
196     (nntp-async-number ,nntp-async-number)
197     (nntp-async-process nil)
198     (nntp-async-buffer nil)
199     (nntp-async-articles nil)
200     (nntp-async-fetched nil)
201     (nntp-async-group-alist nil)
202     (nntp-server-process nil)
203     (nntp-status-string nil)
204     (nntp-server-xover try)
205     (nntp-server-list-active-group try)
206     (nntp-current-group "")))
207
208 \f
209 ;;; Interface functions.
210
211 (defun nntp-retrieve-headers (articles &optional group server fetch-old)
212   "Retrieve the headers of ARTICLES."
213   (nntp-possibly-change-server group server)
214   (save-excursion
215     (set-buffer nntp-server-buffer)
216     (erase-buffer)
217     (if (and (not gnus-nov-is-evil) 
218              (not nntp-nov-is-evil)
219              (nntp-retrieve-headers-with-xover articles fetch-old))
220         ;; We successfully retrieved the headers via XOVER.
221         'nov
222       ;; XOVER didn't work, so we do it the hard, slow and inefficient
223       ;; way.  
224       (let ((number (length articles))
225             (count 0)
226             (received 0)
227             (last-point (point-min)))
228         ;; Send HEAD command.
229         (while articles
230           (nntp-send-strings-to-server 
231            "HEAD" (if (numberp (car articles)) 
232                       (int-to-string (car articles))
233                     ;; `articles' is either a list of article numbers
234                     ;; or a list of article IDs.
235                     (car articles)))
236           (setq articles (cdr articles)
237                 count (1+ count))
238           ;; Every 400 header requests we have to read the stream in
239           ;; order to avoid deadlocks.
240           (when (or (null articles)     ;All requests have been sent.
241                     (zerop (% count nntp-maximum-request)))
242             (nntp-accept-response)
243             (while (progn
244                      (goto-char last-point)
245                      ;; Count replies.
246                      (while (re-search-forward "^[0-9]" nil t)
247                        (setq received (1+ received)))
248                      (setq last-point (point))
249                      (< received count))
250               ;; If number of headers is greater than 100, give
251               ;;  informative messages.
252               (and (numberp nntp-large-newsgroup)
253                    (> number nntp-large-newsgroup)
254                    (zerop (% received 20))
255                    (message "NNTP: Receiving headers... %d%%"
256                             (/ (* received 100) number)))
257               (nntp-accept-response))))
258         ;; Wait for text of last command.
259         (goto-char (point-max))
260         (re-search-backward "^[0-9]" nil t)
261         (when (looking-at "^[23]")
262           (while (progn
263                    (goto-char (- (point-max) 3))
264                    (not (looking-at "^\\.\r?\n")))
265             (nntp-accept-response)))
266         (and (numberp nntp-large-newsgroup)
267              (> number nntp-large-newsgroup)
268              (message "NNTP: Receiving headers...done"))
269
270         ;; Now all of replies are received.  Fold continuation lines.
271         (goto-char (point-min))
272         (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
273           (replace-match " " t t))
274         ;; Remove all "\r"'s.
275         (goto-char (point-min))
276         (while (search-forward "\r" nil t)
277           (replace-match "" t t))
278         'headers))))
279
280
281 (defun nntp-retrieve-groups (groups &optional server)
282   "Retrieve group info on GROUPS."
283   (nntp-possibly-change-server nil server)
284   (save-excursion
285     (set-buffer nntp-server-buffer)
286     ;; The first time this is run, this variable is `try'.  So we
287     ;; try.   
288     (when (eq nntp-server-list-active-group 'try)
289       (nntp-try-list-active (car groups)))
290     (erase-buffer)
291     (let ((count 0)
292           (received 0)
293           (last-point (point-min))
294           (command (if nntp-server-list-active-group "LIST ACTIVE" "GROUP")))
295       (while groups
296         ;; Send the command to the server.
297         (nntp-send-strings-to-server command (car groups))
298         (setq groups (cdr groups))
299         (setq count (1+ count))
300         ;; Every 400 requests we have to read the stream in
301         ;; order to avoid deadlocks.
302         (when (or (null groups)         ;All requests have been sent.
303                   (zerop (% count nntp-maximum-request)))
304           (nntp-accept-response)
305           (while (progn
306                    (goto-char last-point)
307                    ;; Count replies.
308                    (while (re-search-forward "^[0-9]" nil t)
309                      (setq received (1+ received)))
310                    (setq last-point (point))
311                    (< received count))
312             (nntp-accept-response))))
313
314       ;; Wait for the reply from the final command.
315       (when nntp-server-list-active-group
316         (goto-char (point-max))
317         (re-search-backward "^[0-9]" nil t)
318         (when (looking-at "^[23]")
319           (while (progn
320                    (goto-char (- (point-max) 3))
321                    (not (looking-at "^\\.\r?\n")))
322             (nntp-accept-response))))
323
324       ;; Now all replies are received. We remove CRs.
325       (goto-char (point-min))
326       (while (search-forward "\r" nil t)
327         (replace-match "" t t))
328
329       (if (not nntp-server-list-active-group)
330           'group
331         ;; We have read active entries, so we just delete the
332         ;; superfluos gunk.
333         (goto-char (point-min))
334         (while (re-search-forward "^[.2-5]" nil t)
335           (delete-region (match-beginning 0) 
336                          (progn (forward-line 1) (point))))
337         'active))))
338
339 (defun nntp-open-server (server &optional defs connectionless)
340   "Open the virtual server SERVER.
341 If CONNECTIONLESS is non-nil, don't attempt to connect to any physical
342 servers."
343   (nnheader-init-server-buffer)
344   (if (nntp-server-opened server)
345       t
346     (if (or (stringp (car defs))
347             (numberp (car defs)))
348         (setq defs (cons (list 'nntp-port-number (car defs)) (cdr defs))))
349     (or (assq 'nntp-address defs)
350         (setq defs (append defs (list (list 'nntp-address server)))))
351     (if (and nntp-current-server
352              (not (equal server nntp-current-server)))
353         (setq nntp-server-alist 
354               (cons (list nntp-current-server
355                           (nnheader-save-variables nntp-server-variables))
356                     nntp-server-alist)))
357     (let ((state (assoc server nntp-server-alist)))
358       (if state 
359           (progn
360             (nnheader-restore-variables (nth 1 state))
361             (setq nntp-server-alist (delq state nntp-server-alist)))
362         (nnheader-set-init-variables nntp-server-variables defs)))
363     (setq nntp-current-server server)
364     (or (nntp-server-opened server)
365         connectionless
366         (progn
367           (run-hooks 'nntp-prepare-server-hook)
368           (nntp-open-server-semi-internal nntp-address nntp-port-number)))))
369
370 (defun nntp-close-server (&optional server)
371   "Close connection to SERVER."
372   (nntp-possibly-change-server nil server t)
373   (unwind-protect
374       (progn
375         ;; Un-set default sentinel function before closing connection.
376         (and nntp-server-process
377              (eq 'nntp-default-sentinel
378                  (process-sentinel nntp-server-process))
379              (set-process-sentinel nntp-server-process nil))
380         ;; We cannot send QUIT command unless the process is running.
381         (if (nntp-server-opened)
382             (nntp-send-command nil "QUIT")))
383     (nntp-close-server-internal server)))
384
385 (defalias 'nntp-request-quit (symbol-function 'nntp-close-server))
386
387 (defun nntp-request-close ()
388   "Close all server connections."
389   (let (proc)
390      (while nntp-opened-connections
391        (when (setq proc (pop nntp-opened-connections))
392          (condition-case ()
393              (process-send-string proc "QUIT\n")
394            (error nil))
395          (delete-process proc)))
396      (and nntp-async-buffer
397           (get-buffer nntp-async-buffer)
398           (kill-buffer nntp-async-buffer))
399     (while nntp-server-alist
400       (and (setq proc (nth 1 (assq 'nntp-async-buffer
401                                    (car nntp-server-alist))))
402            (buffer-name proc)
403            (kill-buffer proc))
404       (setq nntp-server-alist (cdr nntp-server-alist)))
405     (setq nntp-current-server nil
406           nntp-async-group-alist nil)))
407
408 (defun nntp-server-opened (&optional server)
409   "Say whether a connection to SERVER has been opened."
410   (and (equal server nntp-current-server)
411        nntp-server-buffer
412        (buffer-name nntp-server-buffer)
413        nntp-server-process
414        (memq (process-status nntp-server-process) '(open run))))
415
416 (defun nntp-status-message (&optional server)
417   "Return server status as a string."
418   (if (and nntp-status-string
419            ;; NNN MESSAGE
420            (string-match "[0-9][0-9][0-9][ \t]+\\([^\r]*\\).*$"
421                          nntp-status-string))
422       (substring nntp-status-string (match-beginning 1) (match-end 1))
423     ;; Empty message if nothing.
424     (or nntp-status-string "")))
425
426 (defun nntp-request-article (id &optional group server buffer)
427   "Request article ID (Message-ID or number)."
428   (nntp-possibly-change-server group server)
429
430   (let (found)
431
432     ;; First we see whether we can get the article from the async buffer. 
433     (when (and (numberp id)
434                nntp-async-articles
435                (memq id nntp-async-fetched))
436       (save-excursion
437         (set-buffer nntp-async-buffer)
438         (let ((opoint (point))
439               (art (if (numberp id) (int-to-string id) id))
440               beg end)
441           (when (and (or (re-search-forward (concat "^2.. +" art) nil t)
442                          (progn
443                            (goto-char (point-min))
444                            (re-search-forward (concat "^2.. +" art) opoint t)))
445                      (progn
446                        (beginning-of-line)
447                        (setq beg (point)
448                              end (re-search-forward "^\\.\r?\n" nil t))))
449             (setq found t)
450             (save-excursion
451               (set-buffer (or buffer nntp-server-buffer))
452               (erase-buffer)
453               (insert-buffer-substring nntp-async-buffer beg end)
454               (let ((nntp-server-buffer (current-buffer)))
455                 (nntp-decode-text)))
456             (delete-region beg end)
457             (when nntp-async-articles
458               (nntp-async-fetch-articles id))))))
459
460     (if found 
461         id
462       ;; The article was not in the async buffer, so we fetch it now.
463       (unwind-protect
464           (progn
465             (if buffer (set-process-buffer nntp-server-process buffer))
466             (let ((nntp-server-buffer (or buffer nntp-server-buffer))
467                   (art (or (and (numberp id) (int-to-string id)) id)))
468               (prog1
469                   (and (nntp-send-command "^\\.\r?\n" "ARTICLE" art)
470                        (if (numberp id) 
471                            (cons nntp-current-group id)
472                          ;; We find out what the article number was.
473                          (nntp-find-group-and-number)))
474                 (nntp-decode-text)
475                 (and nntp-async-articles (nntp-async-fetch-articles id)))))
476         (when buffer 
477           (set-process-buffer nntp-server-process nntp-server-buffer))))))
478
479 (defun nntp-request-body (id &optional group server)
480   "Request body of article ID (Message-ID or number)."
481   (nntp-possibly-change-server group server)
482   (prog1
483       ;; If NEmacs, end of message may look like: "\256\215" (".^M")
484       (nntp-send-command
485        "^\\.\r?\n" "BODY" (or (and (numberp id) (int-to-string id)) id))
486     (nntp-decode-text)))
487
488 (defun nntp-request-head (id &optional group server)
489   "Request head of article ID (Message-ID or number)."
490   (nntp-possibly-change-server group server)
491   (prog1
492       (and (nntp-send-command 
493             "^\\.\r?\n" "HEAD" (if (numberp id) (int-to-string id) id))
494            (if (numberp id) id
495              ;; We find out what the article number was.
496              (nntp-find-group-and-number)))
497     (nntp-decode-text)))
498
499 (defun nntp-request-stat (id &optional group server)
500   "Request STAT of article ID (Message-ID or number)."
501   (nntp-possibly-change-server group server)
502   (nntp-send-command 
503    "^[23].*\r?\n" "STAT" (or (and (numberp id) (int-to-string id)) id)))
504
505 (defun nntp-request-group (group &optional server dont-check)
506   "Select GROUP."
507   (setq nntp-current-group
508         (when (nntp-send-command "^2.*\r?\n" "GROUP" group)
509           group)))
510
511 (defun nntp-request-asynchronous (group &optional server articles)
512   "Enable pre-fetch in GROUP."
513   (when nntp-async-articles
514     (nntp-async-request-group group))
515   (when nntp-async-number
516     (if (not (or (nntp-async-server-opened)
517                  (nntp-async-open-server)))
518         ;; Couldn't open the second connection
519         (progn
520           (message "Can't open second connection to %s" nntp-address)
521           (ding)
522           (setq nntp-async-articles nil)
523           (sit-for 2))
524       ;; We opened the second connection (or it was opened already).  
525       (setq nntp-async-articles articles)
526       (setq nntp-async-fetched nil)
527       ;; Clear any old data.
528       (save-excursion
529         (set-buffer nntp-async-buffer)
530         (erase-buffer))
531       ;; Select the correct current group on this server.
532       (nntp-async-send-strings "GROUP" group)
533       t)))
534
535 (defun nntp-list-active-group (group &optional server)
536   "Return the active info on GROUP (which can be a regexp."
537   (nntp-possibly-change-server group server)
538   (nntp-send-command "^.*\r?\n" "LIST ACTIVE" group))
539
540 (defun nntp-request-group-description (group &optional server)
541   "Get the description of GROUP."
542   (nntp-possibly-change-server nil server)
543   (prog1
544       (nntp-send-command "^.*\r?\n" "XGTITLE" group)
545     (nntp-decode-text)))
546
547 (defun nntp-close-group (group &optional server)
548   "Close GROUP."
549   (setq nntp-current-group nil)
550   t)
551
552 (defun nntp-request-list (&optional server)
553   "List all active groups."
554   (nntp-possibly-change-server nil server)
555   (prog1
556       (nntp-send-command "^\\.\r?\n" "LIST")
557     (nntp-decode-text)))
558
559 (defun nntp-request-list-newsgroups (&optional server)
560   "Get descriptions on all groups on SERVER."
561   (nntp-possibly-change-server nil server)
562   (prog1
563       (nntp-send-command "^\\.\r?\n" "LIST NEWSGROUPS")
564     (nntp-decode-text)))
565
566 (defun nntp-request-newgroups (date &optional server)
567   "List groups that have arrived since DATE."
568   (nntp-possibly-change-server nil server)
569   (let* ((date (timezone-parse-date date))
570          (time-string
571           (format "%s%02d%02d %s%s%s"
572                   (substring (aref date 0) 2) (string-to-int (aref date 1)) 
573                   (string-to-int (aref date 2)) (substring (aref date 3) 0 2)
574                   (substring 
575                    (aref date 3) 3 5) (substring (aref date 3) 6 8))))
576     (prog1
577         (nntp-send-command "^\\.\r?\n" "NEWGROUPS" time-string)
578       (nntp-decode-text))))
579
580 (defun nntp-request-list-distributions (&optional server)
581   "List distributions."
582   (nntp-possibly-change-server nil server)
583   (prog1
584       (nntp-send-command "^\\.\r?\n" "LIST DISTRIBUTIONS")
585     (nntp-decode-text)))
586
587 (defun nntp-request-last (&optional group server)
588   "Decrease the current article pointer."
589   (nntp-possibly-change-server group server)
590   (nntp-send-command "^[23].*\r?\n" "LAST"))
591
592 (defun nntp-request-next (&optional group server)
593   "Advance the current article pointer."
594   (nntp-possibly-change-server group server)
595   (nntp-send-command "^[23].*\r?\n" "NEXT"))
596
597 (defun nntp-request-post (&optional server)
598   "Post the current buffer."
599   (nntp-possibly-change-server nil server)
600   (when (nntp-send-command "^[23].*\r?\n" "POST")
601     (nntp-encode-text)
602     (nntp-send-region-to-server (point-min) (point-max))
603     ;; 1.2a NNTP's post command is buggy. "^M" (\r) is not
604     ;;  appended to end of the status message.
605     (nntp-wait-for-response "^[23].*\n")))
606
607 ;;; Internal functions.
608
609 (defun nntp-send-mode-reader ()
610   "Send the MODE READER command to the nntp server.
611 This function is supposed to be called from `nntp-server-opened-hook'.
612 It will make innd servers spawn an nnrpd process to allow actual article
613 reading."
614   (nntp-send-command "^.*\r?\n" "MODE READER"))
615
616 (defun nntp-send-nosy-authinfo ()
617   "Send the AUTHINFO to the nntp server.
618 This function is supposed to be called from `nntp-server-opened-hook'.
619 It will prompt for a password."
620   (nntp-send-command "^.*\r?\n" "AUTHINFO USER"
621                      (read-string "NNTP user name: "))
622   (nntp-send-command "^.*\r?\n" "AUTHINFO PASS" 
623                      (read-string "NNTP password: ")))
624
625 (defun nntp-send-authinfo ()
626   "Send the AUTHINFO to the nntp server.
627 This function is supposed to be called from `nntp-server-opened-hook'.
628 It will prompt for a password."
629   (nntp-send-command "^.*\r?\n" "AUTHINFO USER" (user-login-name))
630   (nntp-send-command "^.*\r?\n" "AUTHINFO PASS" 
631                      (read-string "NNTP password: ")))
632
633 (defun nntp-send-authinfo-from-file ()
634   "Send the AUTHINFO to the nntp server.
635 This function is supposed to be called from `nntp-server-opened-hook'.
636 It will prompt for a password."
637   (when (file-exists-p "~/.nntp-authinfo")
638     (save-excursion
639       (set-buffer (get-buffer-create " *authinfo*"))
640       (buffer-disable-undo (current-buffer))
641       (erase-buffer)
642       (insert-file-contents "~/.nntp-authinfo")
643       (goto-char (point-min))
644       (nntp-send-command "^.*\r?\n" "AUTHINFO USER" (user-login-name))
645       (nntp-send-command 
646        "^.*\r?\n" "AUTHINFO PASS" 
647        (buffer-substring (point) (progn (end-of-line) (point))))
648       (kill-buffer (current-buffer)))))
649
650 (defun nntp-default-sentinel (proc status)
651   "Default sentinel function for NNTP server process."
652   (let ((servers nntp-server-alist)
653         server)
654     ;; Go through the alist of server names and find the name of the
655     ;; server that the process that sent the signal is connected to.
656     ;; If you get my drift.
657     (if (equal proc nntp-server-process)
658         (setq server nntp-address)
659       (while (and servers 
660                   (not (equal proc (nth 1 (assq 'nntp-server-process
661                                                 (car servers))))))
662         (setq servers (cdr servers)))
663       (setq server (car (car servers))))
664     (when (and server
665                nntp-warn-about-losing-connection)
666       (message "nntp: Connection closed to server %s" server)
667       (ding))))
668
669 (defun nntp-kill-connection (server)
670   "Choke the connection to SERVER."
671   (let ((proc (nth 1 (assq 'nntp-server-process 
672                            (assoc server nntp-server-alist)))))
673     (when proc 
674       (delete-process (process-name proc)))
675     (nntp-close-server server)
676     (setq nntp-status-string 
677           (message "Connection timed out to server %s." server))
678     (ding)
679     (sit-for 1)))
680
681 ;; Encoding and decoding of NNTP text.
682
683 (defun nntp-decode-text ()
684   "Decode text transmitted by NNTP.
685 0. Delete status line.
686 1. Delete `^M' at end of line.
687 2. Delete `.' at end of buffer (end of text mark).
688 3. Delete `.' at beginning of line."
689   (save-excursion
690     (set-buffer nntp-server-buffer)
691     ;; Insert newline at end of buffer.
692     (goto-char (point-max))
693     (or (bolp) (insert "\n"))
694     ;; Delete status line.
695     (delete-region (goto-char (point-min)) (progn (forward-line 1) (point)))
696     ;; Delete `^M's.
697     (while (search-forward "\r" nil t)
698       (replace-match "" t t))
699     ;; Delete `.' at end of the buffer (end of text mark).
700     (goto-char (point-max))
701     (forward-line -1)
702     (when (looking-at "^\\.\n")
703       (delete-region (point) (progn (forward-line 1) (point))))
704     ;; Replace `..' at beginning of line with `.'.
705     (goto-char (point-min))
706     ;; (replace-regexp "^\\.\\." ".")
707     (while (search-forward "\n.." nil t)
708       (delete-char -1))))
709
710 (defun nntp-encode-text ()
711   "Encode text in current buffer for NNTP transmission.
712 1. Insert `.' at beginning of line.
713 2. Insert `.' at end of buffer (end of text mark)."
714   (save-excursion
715     ;; Replace `.' at beginning of line with `..'.
716     (goto-char (point-min))
717     (while (search-forward "\n." nil t)
718       (insert "."))
719     (goto-char (point-max))
720     ;; Insert newline at end of buffer.
721     (or (bolp) (insert "\n"))
722     ;; Insert `.' at end of buffer (end of text mark).
723     (insert ".\r\n")))
724
725 \f
726 ;;;
727 ;;; Synchronous Communication with NNTP servers.
728 ;;;
729
730 (defun nntp-send-command (response cmd &rest args)
731   "Wait for server RESPONSE after sending CMD and optional ARGS to server."
732   (save-excursion
733     ;; Clear communication buffer.
734     (set-buffer nntp-server-buffer)
735     (erase-buffer)
736     (apply 'nntp-send-strings-to-server cmd args)
737     (if response
738         (nntp-wait-for-response response)
739       t)))
740
741 (defun nntp-wait-for-response (regexp &optional slow)
742   "Wait for server response which matches REGEXP."
743   (save-excursion
744     (let ((status t)
745           (wait t)
746           (dotnum 0)                    ;Number of "." being displayed.
747           (dotsize                      ;How often "." displayed.
748            (if (numberp nntp-debug-read) nntp-debug-read 10000)))
749       (set-buffer nntp-server-buffer)
750       ;; Wait for status response (RFC977).
751       ;; 1xx - Informative message.
752       ;; 2xx - Command ok.
753       ;; 3xx - Command ok so far, send the rest of it.
754       ;; 4xx - Command was correct, but couldn't be performed for some
755       ;;       reason.
756       ;; 5xx - Command unimplemented, or incorrect, or a serious
757       ;;       program error occurred.
758       (nntp-accept-response)
759       (while wait
760         (goto-char (point-min))
761         (if slow
762             (progn
763               (cond ((re-search-forward "^[23][0-9][0-9]" nil t)
764                      (setq wait nil))
765                     ((re-search-forward "^[45][0-9][0-9]" nil t)
766                      (setq status nil)
767                      (setq wait nil))
768                     (t (nntp-accept-response)))
769               (if (not wait) (delete-region (point-min) 
770                                             (progn (beginning-of-line)
771                                                    (point)))))
772           (cond ((looking-at "[23]")
773                  (setq wait nil))
774                 ((looking-at "[45]")
775                  (setq status nil)
776                  (setq wait nil))
777                 (t (nntp-accept-response)))))
778       ;; Save status message.
779       (end-of-line)
780       (setq nntp-status-string
781             (buffer-substring (point-min) (point)))
782       (when status
783         (setq wait t)
784         (while wait
785           (goto-char (point-max))
786           (forward-line -1)
787           (if (looking-at regexp)
788               (setq wait nil)
789             (when nntp-debug-read
790               (let ((newnum (/ (buffer-size) dotsize)))
791                 (if (not (= dotnum newnum))
792                     (progn
793                       (setq dotnum newnum)
794                       (message "NNTP: Reading %s"
795                                (make-string dotnum ?.))))))
796             (nntp-accept-response)))
797         ;; Remove "...".
798         (when (and nntp-debug-read (> dotnum 0))
799           (message ""))
800         ;; Successfully received server response.
801         t))))
802
803 \f
804
805 ;;;
806 ;;; Low-Level Interface to NNTP Server.
807 ;;; 
808
809 (defun nntp-find-group-and-number ()
810   (save-excursion
811     (save-restriction
812       (set-buffer nntp-server-buffer)
813       (narrow-to-region (goto-char (point-min))
814                         (or (search-forward "\n\n" nil t) (point-max)))
815       (goto-char (point-min))
816       ;; We first find the number by looking at the status line.
817       (let ((number (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ")
818                          (string-to-int
819                           (buffer-substring (match-beginning 1)
820                                             (match-end 1)))))
821             group newsgroups xref)
822         (and number (zerop number) (setq number nil))
823         ;; Then we find the group name.
824         (setq group
825               (cond 
826                ;; If there is only one group in the Newsgroups header,
827                ;; then it seems quite likely that this article comes
828                ;; from that group, I'd say.
829                ((and (setq newsgroups (mail-fetch-field "newsgroups"))
830                      (not (string-match "," newsgroups)))
831                 newsgroups)
832                ;; If there is more than one group in the Newsgroups
833                ;; header, then the Xref header should be filled out.
834                ;; We hazard a guess that the group that has this
835                ;; article number in the Xref header is the one we are
836                ;; looking for.  This might very well be wrong if this
837                ;; article happens to have the same number in several
838                ;; groups, but that's life. 
839                ((and (setq xref (mail-fetch-field "xref"))
840                      number
841                      (string-match (format "\\([^ :]+\\):%d" number) xref))
842                 (substring xref (match-beginning 1) (match-end 1)))
843                (t "")))
844         (when (string-match "\r" group) 
845           (setq group (substring group 0 (match-beginning 0))))
846         (cons group number)))))
847
848 (defun nntp-retrieve-headers-with-xover (articles &optional fetch-old)
849   (erase-buffer)
850   (cond 
851
852    ;; This server does not talk NOV.
853    ((not nntp-server-xover)
854     nil)
855
856    ;; We don't care about gaps.
857    ((or (not nntp-nov-gap)
858         fetch-old)
859     (nntp-send-xover-command 
860      (if fetch-old
861          (if (numberp fetch-old) 
862              (max 1 (- (car articles) fetch-old)) 
863            1)
864        (car articles))
865      (nntp-last-element articles) 'wait)
866
867     (goto-char (point-min))
868     (when (looking-at "[1-5][0-9][0-9] ")
869       (delete-region (point) (progn (forward-line 1) (point))))
870     (while (search-forward "\r" nil t)
871       (replace-match "" t t))
872     (goto-char (point-max))
873     (forward-line -1)
874     (when (looking-at "\\.")
875       (delete-region (point) (progn (forward-line 1) (point)))))
876
877    ;; We do it the hard way.  For each gap, an XOVER command is sent
878    ;; to the server.  We do not wait for a reply from the server, we
879    ;; just send them off as fast as we can.  That means that we have
880    ;; to count the number of responses we get back to find out when we
881    ;; have gotten all we asked for.
882    ((numberp nntp-nov-gap)
883     (let ((count 0)
884           (received 0)
885           (last-point (point-min))
886           (buf (current-buffer))
887           first)
888       ;; We have to check `nntp-server-xover'.  If it gets set to nil,
889       ;; that means that the server does not understand XOVER, but we
890       ;; won't know that until we try.
891       (while (and nntp-server-xover articles)
892         (setq first (car articles))
893         ;; Search forward until we find a gap, or until we run out of
894         ;; articles. 
895         (while (and (cdr articles) 
896                     (< (- (nth 1 articles) (car articles)) nntp-nov-gap))
897           (setq articles (cdr articles)))
898
899         (when (nntp-send-xover-command first (car articles))
900           (setq articles (cdr articles)
901                 count (1+ count))
902
903           ;; Every 400 requests we have to read the stream in
904           ;; order to avoid deadlocks.
905           (when (or (null articles)     ;All requests have been sent.
906                     (zerop (% count nntp-maximum-request)))
907             (accept-process-output)
908             ;; On some Emacs versions the preceding function has
909             ;; a tendency to change the buffer. Perhaps. It's
910             ;; quite difficult to reporduce, because it only
911             ;; seems to happen once in a blue moon. 
912             (set-buffer buf) 
913             (while (progn
914                      (goto-char last-point)
915                      ;; Count replies.
916                      (while (re-search-forward "^[0-9][0-9][0-9] " nil t)
917                        (setq received (1+ received)))
918                      (setq last-point (point))
919                      (< received count))
920               (accept-process-output)
921               (set-buffer buf)))))
922
923       (when nntp-server-xover
924         ;; Wait for the reply from the final command.
925         (goto-char (point-max))
926         (re-search-backward "^[0-9][0-9][0-9] " nil t)
927         (when (looking-at "^[23]")
928           (while (progn
929                    (goto-char (point-max))
930                    (forward-line -1)
931                    (not (looking-at "^\\.\r?\n")))
932             (nntp-accept-response)))
933         
934         ;; We remove any "." lines and status lines.
935         (goto-char (point-min))
936         (while (search-forward "\r" nil t)
937           (delete-char -1))
938         (goto-char (point-min))
939         (delete-matching-lines "^\\.$\\|^[1-5][0-9][0-9] ")))))
940
941   nntp-server-xover)
942
943 (defun nntp-send-xover-command (beg end &optional wait-for-reply)
944   "Send the XOVER command to the server."
945   (let ((range (format "%d-%d" beg end)))
946     (if (stringp nntp-server-xover)
947         ;; If `nntp-server-xover' is a string, then we just send this
948         ;; command.
949         (if wait-for-reply
950             (nntp-send-command "^\\.\r?\n" nntp-server-xover range)
951           ;; We do not wait for the reply.
952           (nntp-send-strings-to-server nntp-server-xover range))
953       (let ((commands nntp-xover-commands))
954         ;; `nntp-xover-commands' is a list of possible XOVER commands.
955         ;; We try them all until we get at positive response. 
956         (while (and commands (eq nntp-server-xover 'try))
957           (nntp-send-command "^\\.\r?\n" (car commands) range)
958           (save-excursion
959             (set-buffer nntp-server-buffer)
960             (goto-char (point-min))
961             (and (looking-at "[23]") ; No error message.
962                  ;; We also have to look at the lines.  Some buggy
963                  ;; servers give back simple lines with just the
964                  ;; article number.  How... helpful.
965                  (progn
966                    (forward-line 1)
967                    (looking-at "[0-9]+\t...")) ; More text after number.
968                  (setq nntp-server-xover (car commands))))
969           (setq commands (cdr commands)))
970         ;; If none of the commands worked, we disable XOVER.
971         (when (eq nntp-server-xover 'try)
972           (save-excursion
973             (set-buffer nntp-server-buffer)
974             (erase-buffer)
975             (setq nntp-server-xover nil)))
976         nntp-server-xover))))
977
978 (defun nntp-send-strings-to-server (&rest strings)
979   "Send STRINGS to the server."
980   (let ((cmd (concat (mapconcat 'identity strings " ") "\r\n")))
981     ;; We open the nntp server if it is down.
982     (or (nntp-server-opened nntp-current-server)
983         (nntp-open-server nntp-current-server)
984         (error (nntp-status-message)))
985     ;; Send the strings.
986     (process-send-string nntp-server-process cmd)
987     t))
988
989 (defun nntp-send-region-to-server (begin end)
990   "Send the current buffer region (from BEGIN to END) to the server."
991   (save-excursion
992     ;; If we're not the the nntp server buffer, we copy the region
993     ;; over to that buffer.  
994     (if (eq (get-buffer nntp-server-buffer) (current-buffer))
995         (let ((orig (current-buffer)))
996           (set-buffer nntp-server-buffer)
997           (erase-buffer)
998           (insert-buffer-substring orig begin end))
999       ;; We are in the nntp buffer, so we just narrow it.
1000       (narrow-to-region begin end))
1001     ;; `process-send-region' does not work if the text to be sent is very
1002     ;; large, so we send it piecemeal.
1003     (let ((last (point-min))
1004           (size 100))                   ;Size of text sent at once.
1005       (while (/= last (point-max))
1006         (process-send-region 
1007          nntp-server-process last (setq last (min (+ last size) (point-max))))
1008         ;; Read any output from the server.  May be unnecessary.
1009         (accept-process-output)))
1010     ;; Delete the area we sent.
1011     (delete-region (point-min) (point-max))
1012     (widen)))
1013
1014 (defun nntp-open-server-semi-internal (server &optional service)
1015   "Open SERVER.
1016 If SERVER is nil, use value of environment variable `NNTPSERVER'.
1017 If SERVICE, this this as the port number."
1018   (let ((server (or server (getenv "NNTPSERVER")))
1019         (status nil)
1020         (timer 
1021          (and nntp-connection-timeout 
1022               (cond
1023                ((fboundp 'run-at-time)
1024                 (run-at-time nntp-connection-timeout
1025                              nil 'nntp-kill-connection server))
1026                ((fboundp 'start-itimer)
1027                 ;; Not sure if this will work or not, only one way to
1028                 ;; find out
1029                 (eval '(start-itimer "nntp-timeout"
1030                                      (lambda ()
1031                                        (nntp-kill-connection server))
1032                                      nntp-connection-timeout nil)))))))
1033     (save-excursion
1034       (set-buffer nntp-server-buffer)
1035       (setq nntp-status-string "")
1036       (message "nntp: Connecting to server on %s..." server)
1037       (cond ((and server (nntp-open-server-internal server service))
1038              (setq nntp-address server)
1039              (setq status
1040                    (condition-case nil
1041                        (nntp-wait-for-response "^[23].*\r?\n" 'slow)
1042                      (error nil)
1043                      (quit nil)))
1044              (or status (nntp-close-server-internal server))
1045              (and nntp-server-process
1046                   (progn
1047                     (set-process-sentinel 
1048                      nntp-server-process 'nntp-default-sentinel)
1049                     ;; You can send commands at startup like AUTHINFO here.
1050                     ;; Added by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>
1051                     (run-hooks 'nntp-server-opened-hook))))
1052             ((null server)
1053              (setq nntp-status-string "NNTP server is not specified."))
1054             (t                          ; We couldn't open the server.
1055              (setq nntp-status-string 
1056                    (buffer-substring (point-min) (point-max)))))
1057       (and timer (cancel-timer timer))
1058       (message "")
1059       (or status
1060           (setq nntp-current-server nil
1061                 nntp-async-number nil))
1062       status)))
1063
1064 (defun nntp-open-server-internal (server &optional service)
1065   "Open connection to news server on SERVER by SERVICE (default is nntp)."
1066   (let (proc)
1067     (save-excursion
1068       ;; Use TCP/IP stream emulation package if needed.
1069       (or (fboundp 'open-network-stream)
1070           (require 'tcp))
1071       ;; Initialize communication buffer.
1072       (nnheader-init-server-buffer)
1073       (set-buffer nntp-server-buffer)
1074       (if (setq proc
1075                 (condition-case nil
1076                     (funcall nntp-open-server-function server)
1077                   (error nil)))
1078           (progn
1079             (setq nntp-server-process proc)
1080             ;; Suggested by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
1081             (process-kill-without-query proc)
1082             (setq nntp-address server)
1083             ;; It is possible to change kanji-fileio-code in this hook.
1084             (run-hooks 'nntp-server-hook)
1085             (push proc nntp-opened-connections)
1086             nntp-server-process)
1087         (setq nntp-status-string (format "Couldn't open server %s" server))
1088         nil))))
1089
1090 (defun nntp-open-network-stream (server)
1091   (open-network-stream 
1092    "nntpd" nntp-server-buffer server nntp-port-number))
1093
1094 (defun nntp-open-rlogin (server)
1095   (let ((proc (start-process "nntpd" nntp-server-buffer "rsh" server)))
1096     (process-send-string proc (mapconcat 'identity nntp-rlogin-parameters
1097                                          " "))
1098     (process-send-string proc "\n")))
1099
1100 (defun nntp-telnet-to-machine ()
1101   (let (b)
1102     (telnet "localhost")
1103     (goto-char (point-min))
1104     (while (not (re-search-forward "^login: *" nil t))
1105       (sit-for 1)
1106       (goto-char (point-min)))
1107     (goto-char (point-max))
1108     (insert "larsi")
1109     (telnet-send-input)
1110     (setq b (point))
1111     (while (not (re-search-forward ">" nil t))
1112       (sit-for 1)
1113       (goto-char b))
1114     (goto-char (point-max))
1115     (insert "ls")
1116     (telnet-send-input)))
1117
1118 (defun nntp-close-server-internal (&optional server)
1119   "Close connection to news server."
1120   (nntp-possibly-change-server nil server)
1121   (if nntp-server-process
1122       (delete-process nntp-server-process))
1123   (setq nntp-server-process nil)
1124   (setq nntp-address ""))
1125
1126 (defun nntp-accept-response ()
1127   "Read response of server.
1128 It is well-known that the communication speed will be much improved by
1129 defining this function as macro."
1130   ;; To deal with server process exiting before
1131   ;;  accept-process-output is called.
1132   ;; Suggested by Jason Venner <jason@violet.berkeley.edu>.
1133   ;; This is a copy of `nntp-default-sentinel'.
1134   (let ((buf (current-buffer)))
1135     (prog1
1136         (if (or (not nntp-server-process)
1137                 (not (memq (process-status nntp-server-process) '(open run))))
1138             (error "nntp: Process connection closed; %s" (nntp-status-message))
1139           (if nntp-buggy-select
1140               (progn
1141                 ;; We cannot use `accept-process-output'.
1142                 ;; Fujitsu UTS requires messages during sleep-for.
1143                 ;; I don't know why.
1144                 (message "NNTP: Reading...")
1145                 (sleep-for 1)
1146                 (message ""))
1147             (condition-case errorcode
1148                 (accept-process-output nntp-server-process)
1149               (error
1150                (cond ((string-equal "select error: Invalid argument" 
1151                                     (nth 1 errorcode))
1152                       ;; Ignore select error.
1153                       nil)
1154                      (t
1155                       (signal (car errorcode) (cdr errorcode))))))))
1156       (set-buffer buf))))
1157
1158 (defun nntp-last-element (list)
1159   "Return last element of LIST."
1160   (while (cdr list)
1161     (setq list (cdr list)))
1162   (car list))
1163
1164 (defun nntp-possibly-change-server (newsgroup server &optional connectionless)
1165   "Check whether the virtual server needs changing."
1166   (if (and server
1167            (not (nntp-server-opened server)))
1168       ;; This virtual server isn't open, so we (re)open it here.
1169       (nntp-open-server server nil t))
1170   (if (and newsgroup 
1171            (not (equal newsgroup nntp-current-group)))
1172       ;; Set the proper current group.
1173       (nntp-request-group newsgroup server)))
1174  
1175 (defun nntp-try-list-active (group)
1176   (nntp-list-active-group group)
1177   (save-excursion
1178     (set-buffer nntp-server-buffer)
1179     (goto-char (point-min))
1180     (cond ((looking-at "5[0-9]+")
1181            (setq nntp-server-list-active-group nil))
1182           (t
1183            (setq nntp-server-list-active-group t)))))
1184
1185 (defun nntp-async-server-opened ()
1186   (and nntp-async-process
1187        (memq (process-status nntp-async-process) '(open run))))
1188
1189 (defun nntp-async-open-server ()
1190   (save-excursion
1191     (set-buffer (generate-new-buffer " *async-nntp*"))
1192     (setq nntp-async-buffer (current-buffer))
1193     (buffer-disable-undo (current-buffer)))
1194   (let ((nntp-server-process nil)
1195         (nntp-server-buffer nntp-async-buffer))
1196     (nntp-open-server-semi-internal nntp-address nntp-port-number)
1197     (if (not (setq nntp-async-process nntp-server-process))
1198         (progn
1199           (setq nntp-async-number nil))
1200       (set-process-buffer nntp-async-process nntp-async-buffer))))
1201
1202 (defun nntp-async-fetch-articles (article)
1203   (if (stringp article)
1204       ()
1205     (let ((articles (cdr (memq (assq article nntp-async-articles)
1206                                nntp-async-articles)))
1207           (max (cond ((numberp nntp-async-number)
1208                       nntp-async-number) 
1209                      ((eq nntp-async-number t)
1210                       (length nntp-async-articles))
1211                      (t 0)))
1212           nart)
1213       (while (and (>= (setq max (1- max)) 0)
1214                   articles)
1215         (or (memq (setq nart (car (car articles))) nntp-async-fetched)
1216             (progn
1217               (nntp-async-send-strings "ARTICLE " (int-to-string nart))
1218               (setq nntp-async-fetched (cons nart nntp-async-fetched))))
1219         (setq articles (cdr articles))))))
1220
1221 (defun nntp-async-send-strings (&rest strings)
1222   (let ((cmd (concat (mapconcat 'identity strings " ") "\r\n")))
1223     (or (nntp-async-server-opened)
1224         (nntp-async-open-server)
1225         (error (nntp-status-message)))
1226     (process-send-string nntp-async-process cmd)))
1227
1228 (defun nntp-async-request-group (group)
1229   (if (equal group nntp-current-group)
1230       ()
1231     (let ((asyncs (assoc group nntp-async-group-alist)))
1232       ;; A new group has been selected, so we push the current state
1233       ;; of async articles on an alist, and pull the old state off.
1234       (setq nntp-async-group-alist 
1235             (cons (list nntp-current-group
1236                         nntp-async-articles nntp-async-fetched
1237                         nntp-async-process)
1238                   (delq asyncs nntp-async-group-alist)))
1239       (and asyncs
1240            (progn
1241              (setq nntp-async-articles (nth 1 asyncs))
1242              (setq nntp-async-fetched (nth 2 asyncs))
1243              (setq nntp-async-process (nth 3 asyncs)))))))
1244
1245 (provide 'nntp)
1246
1247 ;;; nntp.el ends here