;;; nntp.el --- nntp access for Gnus
-;;; Copyright (C) 1987-90,92-99 Free Software Foundation, Inc.
+;; Copyright (C) 1987, 1988, 1989, 1990, 1992, 1993, 1994, 1995, 1996,
+;; 1997, 1998, 2000
+;; Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Katsumi Yamaoka <yamaoka@jpl.org>
(defvoo nntp-port-number "nntp"
"Port number on the physical nntp server.")
+(defvoo nntp-list-options nil
+ "List of newsgroup name used for a option of the LIST command to
+restrict the listing output to only the specified newsgroups.
+Each newsgroup name can be a shell-style wildcard, for instance,
+\"fj.*\", \"japan.*\", etc. Fortunately, if the server can accept
+such a option, it will probably make gnus run faster. You may
+use it as a server variable as follows:
+
+\(setq gnus-select-method
+ '(nntp \"news.somewhere.edu\"
+ (nntp-list-options (\"fj.*\" \"japan.*\"))))")
+
+(defvoo nntp-options-subscribe nil
+ "Regexp matching the newsgroup names which will be subscribed
+unconditionally. It may be effective as well as `nntp-list-options'
+even though the server could not accept a shell-style wildcard as a
+option of the LIST command. You may use it as a server variable as
+follows:
+
+\(setq gnus-select-method
+ '(nntp \"news.somewhere.edu\"
+ (nntp-options-subscribe \"^fj\\\\.\\\\|^japan\\\\.\")))")
+
+(defvoo nntp-options-not-subscribe nil
+ "Regexp matching the newsgroup names which will not be subscribed
+unconditionally. It may be effective as well as `nntp-list-options'
+even though the server could not accept a shell-style wildcard as a
+option of the LIST command. You may use it as a server variable as
+follows:
+
+\(setq gnus-select-method
+ '(nntp \"news.somewhere.edu\"
+ (nntp-options-not-subscribe \"\\\\.binaries\\\\.\")))")
+
(defvoo nntp-server-opened-hook '(nntp-send-mode-reader)
"*Hook used for sending commands to the server at startup.
The default value is `nntp-send-mode-reader', which makes an innd
(save-excursion
(set-buffer (process-buffer process))
(erase-buffer)))
- (when command
- (nntp-send-string process command))
- (cond
- ((eq callback 'ignore)
- t)
- ((and callback wait-for)
- (nntp-async-wait process wait-for buffer decode callback)
- t)
- (wait-for
- (nntp-wait-for process wait-for buffer decode))
- (t t)))))
+ (condition-case err
+ (progn
+ (when command
+ (nntp-send-string process command))
+ (cond
+ ((eq callback 'ignore)
+ t)
+ ((and callback wait-for)
+ (nntp-async-wait process wait-for buffer decode callback)
+ t)
+ (wait-for
+ (nntp-wait-for process wait-for buffer decode))
+ (t t)))
+ (error
+ (nnheader-report 'nntp "Couldn't open connection to %s: %s"
+ address err))
+ (quit nil)))))
(defsubst nntp-send-command (wait-for &rest strings)
"Send STRINGS to server and wait until WAIT-FOR returns."
(nntp-kill-buffer (process-buffer process)))))
(deffoo nntp-request-list (&optional server)
+ "List active groups. If `nntp-list-options' is non-nil, the listing
+output from the server will be restricted to the specified newsgroups.
+If `nntp-options-subscribe' is non-nil, remove newsgroups that do not
+match the regexp. If `nntp-options-not-subscribe' is non-nil, remove
+newsgroups that match the regexp."
(nntp-possibly-change-group nil server)
- (nntp-send-command-and-decode "\r?\n\\.\r?\n" "LIST"))
+ (with-current-buffer nntp-server-buffer
+ (prog1
+ (if (not nntp-list-options)
+ (nntp-send-command-and-decode "\r?\n\\.\r?\n" "LIST")
+ (let ((options (if (consp nntp-list-options)
+ nntp-list-options
+ (list nntp-list-options)))
+ (ret t))
+ (erase-buffer)
+ (while options
+ (goto-char (point-max))
+ (narrow-to-region (point) (point))
+ (setq ret (and ret
+ (nntp-send-command-nodelete
+ "\r?\n\\.\r?\n"
+ (format "LIST ACTIVE %s" (car options))))
+ options (cdr options))
+ (nntp-decode-text))
+ (widen)
+ ret))
+ (when (and (stringp nntp-options-subscribe)
+ (not (string-equal "" nntp-options-subscribe)))
+ (goto-char (point-min))
+ (keep-lines nntp-options-subscribe))
+ (when (and (stringp nntp-options-not-subscribe)
+ (not (string-equal "" nntp-options-not-subscribe)))
+ (goto-char (point-min))
+ (flush-lines nntp-options-subscribe)))))
(deffoo nntp-request-list-newsgroups (&optional server)
(nntp-possibly-change-group nil server)
If SEND-IF-FORCE, only send authinfo to the server if the
.authinfo file has the FORCE token."
(let* ((list (gnus-parse-netrc nntp-authinfo-file))
- (alist (gnus-netrc-machine list nntp-address))
+ (alist (gnus-netrc-machine list nntp-address "nntp"))
(force (gnus-netrc-get alist "force"))
(user (or (gnus-netrc-get alist "login") nntp-authinfo-user))
(passwd (gnus-netrc-get alist "password")))
"nntpd" buffer nntp-telnet-command nntp-telnet-switches)))
(case-fold-search t))
(when (memq (process-status proc) '(open run))
+ (nntp-wait-for-string "^r?telnet")
(process-send-string proc "set escape \^X\n")
(cond
((and nntp-open-telnet-envuser nntp-telnet-user-name)
(beginning-of-line)
(delete-region (point-min) (point))
(process-send-string proc "\^]")
- (nntp-wait-for-string "^telnet")
+ (nntp-wait-for-string "^r?telnet")
(process-send-string proc "mode character\n")
(accept-process-output proc 1)
(sit-for 1)