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