texi/ChangeLog addition:
authorDidier Verna <didier@xemacs.org>
Wed, 4 Jul 2001 10:04:53 +0000 (10:04 +0000)
committerDidier Verna <didier@xemacs.org>
Wed, 4 Jul 2001 10:04:53 +0000 (10:04 +0000)
2001-07-04  Didier Verna  <didier@lrde.epita.fr>

* gnus.texi (Example Methods): use the new nntp-open-connection
methods in the examples.
* gnus.texi (NNTP): update for the new nntp-open-connection methods.
* gnus.texi (Direct Functions): new node.
* gnus.texi (Indirect Functions): new node.
* gnus.texi (Common Variables): new node.

lisp/ChangeLog addition:

2001-07-04  Didier Verna  <didier@lrde.epita.fr>

* nntp.el (nntp-open-connection-function): doc update.
* nntp.el (nntp-pre-command): New.
* nntp.el (nntp-via-rlogin-command): New.
* nntp.el (nntp-via-telnet-command): New.
* nntp.el (nntp-via-telnet-switches): New.
* nntp.el (nntp-via-user-name): New.
* nntp.el (nntp-via-user-password): New.
* nntp.el (nntp-via-address): New.
* nntp.el (nntp-via-envuser): New.
* nntp.el (nntp-via-shell-prompt): New.
* nntp.el (nntp-open-telnet-stream): New.
* nntp.el (nntp-open-via-rlogin-and-telnet): New.
* nntp.el (nntp-open-via-telnet-and-telnet): New.
* nntp.el (nntp-wait-for): check for possibly echo'ed commands.
* nntp.el (nntp-send-command): ditto.
* nntp.el (nntp-send-command-nodelete): ditto.
* nntp.el (nntp-send-command-and-decode): ditto.

lisp/ChangeLog
lisp/nntp.el
texi/ChangeLog
texi/gnus.texi

index 0bd82c3..676390f 100644 (file)
@@ -1,8 +1,28 @@
+2001-07-04  Didier Verna  <didier@lrde.epita.fr>
+
+       * nntp.el (nntp-open-connection-function): doc update.
+       * nntp.el (nntp-pre-command): New.
+       * nntp.el (nntp-via-rlogin-command): New.
+       * nntp.el (nntp-via-telnet-command): New.
+       * nntp.el (nntp-via-telnet-switches): New.
+       * nntp.el (nntp-via-user-name): New.
+       * nntp.el (nntp-via-user-password): New.
+       * nntp.el (nntp-via-address): New.
+       * nntp.el (nntp-via-envuser): New.
+       * nntp.el (nntp-via-shell-prompt): New.
+       * nntp.el (nntp-open-telnet-stream): New.
+       * nntp.el (nntp-open-via-rlogin-and-telnet): New.
+       * nntp.el (nntp-open-via-telnet-and-telnet): New.
+       * nntp.el (nntp-wait-for): check for possibly echo'ed commands.
+       * nntp.el (nntp-send-command): ditto.
+       * nntp.el (nntp-send-command-nodelete): ditto.
+       * nntp.el (nntp-send-command-and-decode): ditto.
+
 2001-06-30  YAGI Tatsuya  <yagi@is.titech.ac.jp>
 
        * gnus-start.el (gnus-check-first-time-used): Use `if' instead of
        `when'.
-       
+
 2001-07-03  Simon Josefsson  <jas@extundo.com>
        From Nuutti Kotivuori <nuutti.kotivuori@smarttrust.com>
 
@@ -22,7 +42,7 @@
        * mml2015.el (mml2015-format-error): New function.
        (mml2015-mailcrypt-decrypt, mml2015-mailcrypt-clear-decrypt)
        (mml2015-mailcrypt-verify, mml2015-gpg-clear-verify)
-       (mml2015-mailcrypt-clear-verify, mml2015-gpg-verify): Use it. 
+       (mml2015-mailcrypt-clear-verify, mml2015-gpg-verify): Use it.
 
 2001-06-26 22:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
@@ -38,7 +58,7 @@
 
        * nnrss.el (nnrss-save-server-data): Bind print-level and print-length.
        (nnrss-save-group-data): Ditto.
-       
+
        * gnus-agent.el (gnus-agent-save-alist): Ditto.
 
 2001-06-25  Katsumi Yamaoka  <yamaoka@jpl.org>
 
 2001-06-21 10:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
-       * message.el (message-make-date): Add week day. 
+       * message.el (message-make-date): Add week day.
        Suggested by Jason R. Mastaler <jason@mastaler.com>.
 
 2001-06-19  Simon Josefsson  <jas@extundo.com>
 
        * gnus.el (gnus-define-group-parameter): Don't quote the defcustom
        specs.
-       
+
 2001-06-13 15:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * gnus.el (gnus-email-address): Move it here.
 
 2001-06-12 11:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
-       * gnus-art.el (gnus-plain-save-name): Use file-relative-name. 
+       * gnus-art.el (gnus-plain-save-name): Use file-relative-name.
        From Marc Lefranc <Marc.Lefranc@univ-lille1.fr>.
-       
+
        * nnrss.el (nnrss-node-text): Node might be nil.
 
 2001-06-11 10:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * gnus-uu.el (gnus-uu-save-article): Use mml tag instead of
        part. From Katsumi Yamaoka <yamaoka@jpl.org>.
-       
+
        * nnrss.el (nnrss-group-alist): More items.
 
 2001-06-09 23:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
        * nnrss.el (nnrss-node-text): Use cddr instead xml-node-children.
 
 2001-06-03  Dale Hagglund  <rdh@best.com>
-       
+
        * gnus-mlspl.el (gnus-group-split-fancy): Fix generation of split
        restrict clauses.
 
 2001-06-07 16:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
-       
+
        From Benjamin Rutt <brutt+news@bloomington.in.us>
-       
+
        * message.el (message-wide-reply-confirm-recipients): New variable.
 
 2001-06-06  Mark Thomas  <mthomas@edrc.cmu.edu>
 
        * nnmail.el (nnmail-fix-eudora-headers): Change the In-Reply-To
        fix so it works with XEmacs.
-       
+
 2001-06-07 16:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * nnrss.el (nnrss-retrieve-headers): Support description as extra
 
 2001-06-02  Simon Josefsson  <simon@josefsson.org>
 
-       * imap.el (imap-kerberos4-open): 
+       * imap.el (imap-kerberos4-open):
        (imap-gssapi-open):
        (imap-ssl-open):
        (imap-network-open):
 2001-05-28  Kai Gro\e,A_\e(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
 
        From Jaap-Henk Hoepman (jhh@xs4all.nl).
-       
+
        * mm-decode.el (mm-keep-viewer-alive-types): New variable.
        (mm-keep-viewer-alive-p, mm-handle-set-external-undisplayer,
        mm-destroy-postponed-undisplay-list): New functions.
index 4a4b17b..9d7356a 100644 (file)
@@ -65,57 +65,70 @@ You probably don't want to do that, though.")
 
 (defvoo nntp-open-connection-function 'nntp-open-network-stream
   "*Function used for connecting to a remote system.
-It will be called with the buffer to output in.
+It will be called with the buffer to output in as argument.
 
-Two pre-made functions are `nntp-open-network-stream', which is the
-default, and simply connects to some port or other on the remote
-system (see nntp-port-number).  The other are `nntp-open-rlogin',
-which does an rlogin on the remote system, and then does a telnet to
-the NNTP server available there (see nntp-rlogin-parameters) and
-`nntp-open-telnet' which telnets to a remote system, logs in and does
-the same.")
+Currently, five such functions are provided (please refer to their
+respective doc string for more information), three of them establishing
+direct connections to the nntp server, and two of them using an indirect
+host.
 
-(defvoo nntp-rlogin-program "rsh"
-  "*Program used to log in on remote machines.
-The default is \"rsh\", but \"ssh\" is a popular alternative.")
+Direct connections:
+- `nntp-open-network-stream' (the default),
+- `nntp-open-ssl-stream',
+- `nntp-open-telnet-stream'.
 
-(defvoo nntp-rlogin-parameters '("telnet" "-8" "${NNTPSERVER:=news}" "nntp")
-  "*Parameters to `nntp-open-rlogin'.
-That function may be used as `nntp-open-connection-function'.  In that
-case, this list will be used as the parameter list given to rsh.")
+Indirect connections:
+- `nntp-open-via-rlogin-and-telnet',
+- `nntp-open-via-telnet-and-telnet'.")
 
-(defvoo nntp-rlogin-user-name nil
-  "*User name on remote system when using the rlogin connect method.")
+(defvoo nntp-pre-command nil
+  "*Pre-command to use with the various nntp-open-via-* methods.
+This is where you would put \"runsocks\" or stuff like that.")
 
-(defvoo nntp-telnet-parameters
-    '("exec" "telnet" "-8" "${NNTPSERVER:=news}" "nntp")
-  "*Parameters to `nntp-open-telnet'.
-That function may be used as `nntp-open-connection-function'.  In that
-case, this list will be executed as a command after logging in
-via telnet.")
+(defvoo nntp-telnet-command "telnet"
+  "*Telnet command used to connect to the nntp server.
+This command is used by the various nntp-open-via-* methods.")
 
-(defvoo nntp-telnet-user-name nil
-  "User name to log in via telnet with.")
+(defvoo nntp-telnet-switches '("-8")
+  "*Switches given to the telnet command `nntp-telnet-command'.")
 
-(defvoo nntp-telnet-passwd nil
-  "Password to use to log in via telnet with.")
+(defvoo nntp-end-of-line "\r\n"
+  "*String to use on the end of lines when talking to the NNTP server.
+This is \"\\r\\n\" by default, but should be \"\\n\" when
+using and indirect connection method (nntp-open-via-*).")
 
-(defvoo nntp-open-telnet-envuser nil
-  "*If non-nil, telnet session (client and server both) will support the ENVIRON option and not prompt for login name.")
+(defvoo nntp-via-rlogin-command "rsh"
+  "*Rlogin command used to connect to an intermediate host.
+This command is used by the `nntp-open-via-rlogin-and-telnet' method.
+The default is \"rsh\", but \"ssh\" is a popular alternative.")
 
-(defvoo nntp-telnet-shell-prompt "bash\\|\$ *\r?$\\|> *\r?"
-  "*Regular expression to match the shell prompt on the remote machine.")
+(defvoo nntp-via-telnet-command "telnet"
+  "*Telnet command used to connect to an intermediate host.
+This command is used by the `nntp-open-via-telnet-and-telnet' method.")
 
-(defvoo nntp-telnet-command "telnet"
-  "Command used to start telnet.")
+(defvoo nntp-via-telnet-switches '("-8")
+  "*Switches given to the telnet command `nntp-via-telnet-command'.")
 
-(defvoo nntp-telnet-switches '("-8")
-  "Switches given to the telnet command.")
+(defvoo nntp-via-user-name nil
+  "*User name to log in on an intermediate host with.
+This variable is used by the `nntp-open-via-telnet-and-telnet' method.")
 
-(defvoo nntp-end-of-line "\r\n"
-  "String to use on the end of lines when talking to the NNTP server.
-This is \"\\r\\n\" by default, but should be \"\\n\" when
-using rlogin or telnet to communicate with the server.")
+(defvoo nntp-via-user-password nil
+  "*Password to use to log in on an intermediate host with.
+This variable is used by the `nntp-open-via-telnet-and-telnet' method.")
+
+(defvoo nntp-via-address nil
+  "*Address of an intermediate host to connect to.
+This variable is used by the `nntp-open-via-rlogin-and-telnet' and
+`nntp-open-via-telnet-and-telnet' methods.")
+
+(defvoo nntp-via-envuser nil
+  "*Whether both telnet client and server support the ENVIRON option.
+If non-nil, there will be no prompt for a login name.")
+
+(defvoo nntp-via-shell-prompt "bash\\|\$ *\r?$\\|> *\r?"
+  "*Regular expression to match the shell prompt on an intermediate host.
+This variable is used by the `nntp-open-via-telnet-and-telnet' method.")
 
 (defvoo nntp-large-newsgroup 50
   "*The number of the articles which indicates a large newsgroup.
@@ -262,6 +275,8 @@ noticing asynchronous data.")
                (memq (process-status process) '(open run)))
       (when (looking-at "480")
        (nntp-handle-authinfo process))
+      (when (looking-at "^.*\n")
+       (delete-region (point) (progn (forward-line 1) (point))))
       (nntp-accept-process-output process)
       (goto-char (point-min)))
     (prog1
@@ -365,17 +380,43 @@ noticing asynchronous data.")
     (save-excursion
       (set-buffer nntp-server-buffer)
       (erase-buffer)))
-  (nntp-retrieve-data
-   (mapconcat 'identity strings " ")
-   nntp-address nntp-port-number nntp-server-buffer
-   wait-for nnheader-callback-function))
+  (let* ((command (mapconcat 'identity strings " "))
+        (buffer (process-buffer (nntp-find-connection nntp-server-buffer)))
+        (pos (point buffer)))
+    (prog1
+       (nntp-retrieve-data command
+                           nntp-address nntp-port-number nntp-server-buffer
+                           wait-for nnheader-callback-function)
+      ;; If nothing to wait for, still remove possibly echo'ed commands
+      (unless wait-for
+       (nntp-accept-response)
+       (save-excursion
+         (set-buffer buffer)
+         (goto-char pos)
+         (if (looking-at (regexp-quote command))
+             (delete-region pos (progn (forward-line 1) (point-at-bol))))
+         )))
+    ))
 
 (defun nntp-send-command-nodelete (wait-for &rest strings)
   "Send STRINGS to server and wait until WAIT-FOR returns."
-  (nntp-retrieve-data
-   (mapconcat 'identity strings " ")
-   nntp-address nntp-port-number nntp-server-buffer
-   wait-for nnheader-callback-function))
+  (let* ((command (mapconcat 'identity strings " "))
+        (buffer (process-buffer (nntp-find-connection nntp-server-buffer)))
+        (pos (point buffer)))
+    (prog1
+       (nntp-retrieve-data command
+                           nntp-address nntp-port-number nntp-server-buffer
+                           wait-for nnheader-callback-function)
+      ;; If nothing to wait for, still remove possibly echo'ed commands
+      (unless wait-for
+       (nntp-accept-response)
+       (save-excursion
+         (set-buffer buffer)
+         (goto-char pos)
+         (if (looking-at (regexp-quote command))
+             (delete-region pos (progn (forward-line 1) (point-at-bol))))
+         )))
+    ))
 
 (defun nntp-send-command-and-decode (wait-for &rest strings)
   "Send STRINGS to server and wait until WAIT-FOR returns."
@@ -384,10 +425,24 @@ noticing asynchronous data.")
     (save-excursion
       (set-buffer nntp-server-buffer)
       (erase-buffer)))
-  (nntp-retrieve-data
-   (mapconcat 'identity strings " ")
-   nntp-address nntp-port-number nntp-server-buffer
-   wait-for nnheader-callback-function t))
+  (let* ((command (mapconcat 'identity strings " "))
+        (buffer (process-buffer (nntp-find-connection nntp-server-buffer)))
+        (pos (point buffer)))
+    (prog1
+       (nntp-retrieve-data command
+                           nntp-address nntp-port-number nntp-server-buffer
+                           wait-for nnheader-callback-function t)
+      ;; If nothing to wait for, still remove possibly echo'ed commands
+      (unless wait-for
+       (nntp-accept-response)
+       (save-excursion
+         (set-buffer buffer)
+         (goto-char pos)
+         (if (looking-at (regexp-quote command))
+             (delete-region pos (progn (forward-line 1) (point-at-bol))))
+         )))
+    ))
+
 
 (defun nntp-send-buffer (wait-for)
   "Send the current buffer to server and wait until WAIT-FOR returns."
@@ -531,7 +586,7 @@ noticing asynchronous data.")
                            (setq last-point (point))
                            (< received count)))
                (nntp-accept-response))))
-         
+
          ;; Wait for the reply from the final command.
          (unless (gnus-buffer-live-p buf)
            (nnheader-report 'nntp "Connection to %s is closed." server)
@@ -549,7 +604,7 @@ noticing asynchronous data.")
                            (not (re-search-backward "^\\.\r?\n"
                                                     (- (point) 4) t)))))
              (nntp-accept-response)))
-         
+
          ;; Now all replies are received.  We remove CRs.
          (unless (gnus-buffer-live-p buf)
            (nnheader-report 'nntp "Connection to %s is closed." server)
@@ -558,7 +613,7 @@ noticing asynchronous data.")
          (goto-char (point-min))
          (while (search-forward "\r" nil t)
            (replace-match "" t t))
-         
+
          (if (not nntp-server-list-active-group)
              (progn
                (copy-to-buffer nntp-server-buffer (point-min) (point-max))
@@ -571,7 +626,7 @@ noticing asynchronous data.")
                             (progn (forward-line 1) (point))))
            (copy-to-buffer nntp-server-buffer (point-min) (point-max))
            'active))))))
-  
+
 (deffoo nntp-retrieve-articles (articles &optional group server)
   (nntp-possibly-change-group group server)
   (save-excursion
@@ -1174,11 +1229,11 @@ password contained in '~/.nntp-authinfo'."
        (while (and (cdr articles)
                    (< (- (nth 1 articles) (car articles)) nntp-nov-gap))
          (setq articles (cdr articles)))
-       
+
        (setq in-process-buffer-p (stringp nntp-server-xover))
        (nntp-send-xover-command first (car articles))
        (setq articles (cdr articles))
-       
+
        (when (and nntp-server-xover in-process-buffer-p)
          ;; Don't count tried request.
          (setq count (1+ count))
@@ -1275,7 +1330,44 @@ password contained in '~/.nntp-authinfo'."
            (setq nntp-server-xover nil)))
        nntp-server-xover))))
 
-;;; Alternative connection methods.
+(defun nntp-find-group-and-number ()
+  (save-excursion
+    (save-restriction
+      (set-buffer nntp-server-buffer)
+      (narrow-to-region (goto-char (point-min))
+                       (or (search-forward "\n\n" nil t) (point-max)))
+      (goto-char (point-min))
+      ;; We first find the number by looking at the status line.
+      (let ((number (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ")
+                        (string-to-int
+                         (buffer-substring (match-beginning 1)
+                                           (match-end 1)))))
+           group newsgroups xref)
+       (and number (zerop number) (setq number nil))
+       ;; Then we find the group name.
+       (setq group
+             (cond
+              ;; If there is only one group in the Newsgroups header,
+              ;; then it seems quite likely that this article comes
+              ;; from that group, I'd say.
+              ((and (setq newsgroups (mail-fetch-field "newsgroups"))
+                    (not (string-match "," newsgroups)))
+               newsgroups)
+              ;; If there is more than one group in the Newsgroups
+              ;; header, then the Xref header should be filled out.
+              ;; We hazard a guess that the group that has this
+              ;; article number in the Xref header is the one we are
+              ;; looking for.  This might very well be wrong if this
+              ;; article happens to have the same number in several
+              ;; groups, but that's life.
+              ((and (setq xref (mail-fetch-field "xref"))
+                    number
+                    (string-match (format "\\([^ :]+\\):%d" number) xref))
+               (substring xref (match-beginning 1) (match-end 1)))
+              (t "")))
+       (when (string-match "\r" group)
+         (setq group (substring group 0 (match-beginning 0))))
+       (cons group number)))))
 
 (defun nntp-wait-for-string (regexp)
   "Wait until string arrives in the buffer."
@@ -1286,6 +1378,42 @@ password contained in '~/.nntp-authinfo'."
       (set-buffer buf)
       (goto-char (point-min)))))
 
+
+;; ==========================================================================
+;; Obsolete nntp-open-* connection methods -- drv
+;; ==========================================================================
+
+(defvoo nntp-open-telnet-envuser nil
+  "*If non-nil, telnet session (client and server both) will support the ENVIRON option and not prompt for login name.")
+
+(defvoo nntp-telnet-shell-prompt "bash\\|\$ *\r?$\\|> *\r?"
+  "*Regular expression to match the shell prompt on the remote machine.")
+
+(defvoo nntp-rlogin-program "rsh"
+  "*Program used to log in on remote machines.
+The default is \"rsh\", but \"ssh\" is a popular alternative.")
+
+(defvoo nntp-rlogin-parameters '("telnet" "-8" "${NNTPSERVER:=news}" "nntp")
+  "*Parameters to `nntp-open-rlogin'.
+That function may be used as `nntp-open-connection-function'.  In that
+case, this list will be used as the parameter list given to rsh.")
+
+(defvoo nntp-rlogin-user-name nil
+  "*User name on remote system when using the rlogin connect method.")
+
+(defvoo nntp-telnet-parameters
+    '("exec" "telnet" "-8" "${NNTPSERVER:=news}" "nntp")
+  "*Parameters to `nntp-open-telnet'.
+That function may be used as `nntp-open-connection-function'.  In that
+case, this list will be executed as a command after logging in
+via telnet.")
+
+(defvoo nntp-telnet-user-name nil
+  "User name to log in via telnet with.")
+
+(defvoo nntp-telnet-passwd nil
+  "Password to use to log in via telnet with.")
+
 (defun nntp-open-telnet (buffer)
   (save-excursion
     (set-buffer buffer)
@@ -1351,44 +1479,143 @@ password contained in '~/.nntp-authinfo'."
       (delete-region (point-min) (point))
       proc)))
 
-(defun nntp-find-group-and-number ()
+
+;; ==========================================================================
+;; Replacements for the nntp-open-* functions -- drv
+;; ==========================================================================
+
+(defun nntp-open-telnet-stream (buffer)
+  "Open a nntp connection by telnet'ing the news server.
+
+Please refer to the following variables to customize the connection:
+- `nntp-pre-command',
+- `nntp-telnet-command',
+- `nntp-telnet-switches',
+- `nntp-address',
+- `nntp-port-number',
+- `nntp-end-of-line'."
+  (let ((command `(,nntp-telnet-command
+                  ,@nntp-telnet-switches
+                  ,nntp-address ,nntp-port-number))
+       proc)
+    (and nntp-pre-command
+        (push nntp-pre-command command))
+    (setq proc (apply 'start-process "nntpd" buffer command))
+    (save-excursion
+      (set-buffer buffer)
+      (nntp-wait-for-string "^\r*20[01]")
+      (beginning-of-line)
+      (delete-region (point-min) (point))
+      proc)))
+
+(defun nntp-open-via-rlogin-and-telnet (buffer)
+  "Open a connection to an nntp server through an intermediate host.
+First rlogin to the remote host, and then telnet the real news server
+from there.
+
+Please refer to the following variables to customize the connection:
+- `nntp-pre-command',
+- `nntp-via-rlogin-command',
+- `nntp-via-user-name',
+- `nntp-via-address',
+- `nntp-telnet-command',
+- `nntp-telnet-switches',
+- `nntp-address',
+- `nntp-port-number',
+- `nntp-end-of-line'."
+  (let ((command `(,nntp-via-address
+                  ,nntp-telnet-command
+                  ,@nntp-telnet-switches
+                  ,nntp-address ,nntp-port-number))
+       proc)
+    (and nntp-via-user-name
+        (setq command `("-l" ,nntp-via-user-name ,@command)))
+    (push nntp-via-rlogin-command command)
+    (and nntp-pre-command
+        (push nntp-pre-command command))
+    (setq proc (apply 'start-process "nntpd" buffer command))
+    (save-excursion
+      (set-buffer buffer)
+      (nntp-wait-for-string "^\r*20[01]")
+      (beginning-of-line)
+      (delete-region (point-min) (point))
+      proc)))
+
+(defun nntp-open-via-telnet-and-telnet (buffer)
+  "Open a connection to an nntp server through an intermediate host.
+First telnet the remote host, and then telnet the real news server
+from there.
+
+Please refer to the following variables to customize the connection:
+- `nntp-pre-command',
+- `nntp-via-telnet-command',
+- `nntp-via-telnet-switches',
+- `nntp-via-address',
+- `nntp-via-envuser',
+- `nntp-via-user-name',
+- `nntp-via-user-password',
+- `nntp-via-shell-prompt',
+- `nntp-telnet-command',
+- `nntp-telnet-switches',
+- `nntp-address',
+- `nntp-port-number',
+- `nntp-end-of-line'."
   (save-excursion
-    (save-restriction
-      (set-buffer nntp-server-buffer)
-      (narrow-to-region (goto-char (point-min))
-                       (or (search-forward "\n\n" nil t) (point-max)))
-      (goto-char (point-min))
-      ;; We first find the number by looking at the status line.
-      (let ((number (and (looking-at "2[0-9][0-9] +\\([0-9]+\\) ")
-                        (string-to-int
-                         (buffer-substring (match-beginning 1)
-                                           (match-end 1)))))
-           group newsgroups xref)
-       (and number (zerop number) (setq number nil))
-       ;; Then we find the group name.
-       (setq group
-             (cond
-              ;; If there is only one group in the Newsgroups header,
-              ;; then it seems quite likely that this article comes
-              ;; from that group, I'd say.
-              ((and (setq newsgroups (mail-fetch-field "newsgroups"))
-                    (not (string-match "," newsgroups)))
-               newsgroups)
-              ;; If there is more than one group in the Newsgroups
-              ;; header, then the Xref header should be filled out.
-              ;; We hazard a guess that the group that has this
-              ;; article number in the Xref header is the one we are
-              ;; looking for.  This might very well be wrong if this
-              ;; article happens to have the same number in several
-              ;; groups, but that's life.
-              ((and (setq xref (mail-fetch-field "xref"))
-                    number
-                    (string-match (format "\\([^ :]+\\):%d" number) xref))
-               (substring xref (match-beginning 1) (match-end 1)))
-              (t "")))
-       (when (string-match "\r" group)
-         (setq group (substring group 0 (match-beginning 0))))
-       (cons group number)))))
+    (set-buffer buffer)
+    (erase-buffer)
+    (let ((command `(,nntp-via-telnet-command ,@nntp-via-telnet-switches))
+         (case-fold-search t)
+         proc)
+      (and nntp-pre-command (push nntp-pre-command command))
+      (setq proc (apply 'start-process "nntpd" buffer command))
+      (when (memq (process-status proc) '(open run))
+       (nntp-wait-for-string "^r?telnet")
+       (process-send-string proc "set escape \^X\n")
+       (cond
+        ((and nntp-via-envuser nntp-via-user-name)
+         (process-send-string proc (concat "open " "-l" nntp-via-user-name
+                                           nntp-via-address "\n")))
+        (t
+         (process-send-string proc (concat "open " nntp-via-address
+                                           "\n"))))
+       (when (not nntp-via-envuser)
+         (nntp-wait-for-string "^\r*.?login:")
+         (process-send-string proc
+                              (concat
+                               (or nntp-via-user-name
+                                   (setq nntp-via-user-name
+                                         (read-string "login: ")))
+                               "\n")))
+       (nntp-wait-for-string "^\r*.?password:")
+       (process-send-string proc
+                            (concat
+                             (or nntp-via-user-password
+                                 (setq nntp-via-user-password
+                                       (mail-source-read-passwd
+                                        "Password: ")))
+                             "\n"))
+       (nntp-wait-for-string nntp-via-shell-prompt)
+       (let ((real-telnet-command `("exec"
+                                    ,nntp-telnet-command
+                                    ,@nntp-telnet-switches
+                                    ,nntp-address
+                                    ,nntp-port-number)))
+         (process-send-string proc
+                              (concat (mapconcat 'identity
+                                                 real-telnet-command " ")
+                                      "\n")))
+       (nntp-wait-for-string "^\r*20[01]")
+       (beginning-of-line)
+       (delete-region (point-min) (point))
+       (process-send-string proc "\^]")
+       (nntp-wait-for-string "^r?telnet")
+       (process-send-string proc "mode character\n")
+       (accept-process-output proc 1)
+       (sit-for 1)
+       (goto-char (point-min))
+       (forward-line 1)
+       (delete-region (point) (point-max)))
+      proc)))
 
 (provide 'nntp)
 
index ca8c3ae..93354d9 100644 (file)
@@ -1,3 +1,12 @@
+2001-07-04  Didier Verna  <didier@lrde.epita.fr>
+
+       * gnus.texi (Example Methods): use the new nntp-open-connection
+       methods in the examples.
+       * gnus.texi (NNTP): update for the new nntp-open-connection methods.
+       * gnus.texi (Direct Functions): new node.
+       * gnus.texi (Indirect Functions): new node.
+       * gnus.texi (Common Variables): new node.
+
 2001-06-27  Simon Josefsson  <jas@extundo.com>
        From Ralph Schleicher <rs@nunatak.allgaeu.org>
 
 2001-03-11  Kai Gro\e,A_\e(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
 
        * message.texi (Message Headers): Update doc for
-       `message-generate-headers-first'. 
+       `message-generate-headers-first'.
 
 2001-03-14 15:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
        From Nevin Kapur <nevin@jhu.edu>
 
        * gnus.texi (Posting Server): Fix, due to change of default value
        of `gnus-post-method' to `current'.
-       
+
 2001-02-23 08:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * gnus.texi: Remove double words. From Gerd Moellmann.
 
        * infohack.el (batch-makeinfo): New.
-       
+
        * Makefile.in (EMACSINFO): Use it.
 
 2001-02-17 13:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 2001-02-06 19:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * gnus.texi (Using GPG): Key binding.
-       
+
        * message.texi (Security): Ditto.
 
 2001-02-06 18:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
        * message.texi (message-ignored-news-headers): Add "X-Draft-From:".
        (message-ignored-mail-headers): Ditto.
-       
+
 2001-01-21  Raymond Scholz <ray-2001@zonix.de>
 
        * message.texi: Rename X-Mailer and X-Newsreader to User-Agent.
 
 2001-01-10 15:00:00  ShengHuo ZHU  <zsh@cs.rochester.edu>
 
-       * gnus.texi (Article Washing): makeinfo 1.69 doesn't grok `anchor'. 
+       * gnus.texi (Article Washing): makeinfo 1.69 doesn't grok `anchor'.
 
 2001-01-07 18:18:53  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 2001-01-03  Kai Gro\e,A_\e(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
 
        * gnus.texi (Article Washing): Mention `C-u g' as a sort of
-       anti-washing. 
+       anti-washing.
 
 2001-01-01 11:40:34  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
 
        * gnus.texi (Archived Messages): Explain what happens when group
        names mentioned in `gnus-message-archive-group' contain a select
-       method. 
+       method.
 
 2000-10-28  Kai Gro\e,A_\e(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
 
 
 2000-07-03 00:24:55  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
-       * gnus.texi (Splitting Mail): Mention gnus-summary-respool-trace. 
+       * gnus.texi (Splitting Mail): Mention gnus-summary-respool-trace.
        (Searching for Articles): Fix.
        (Newest Features): Fix.
 
 
 2000-04-26 02:30:06  Shenghuo ZHU  <zsh@cs.rochester.edu>
 
-       * gnus.texi (Posting Styles): Addition. 
+       * gnus.texi (Posting Styles): Addition.
 
 2000-04-24 17:09:17  Felix Natter  <f.natter@ndh.net>
 
@@ -1303,7 +1312,7 @@ Thu Feb 25 00:28:49 1999  Shenghuo ZHU  <zsh@cs.rochester.edu>
 1998-08-27 07:29:17  Lars Magne Ingebrigtsen  <larsi@gnus.org>
 
        * gnus.texi (Mail Folders): Addition.
-       
+
 ;; Local Variables:
 ;; coding: iso-2022-7bit
 ;; End:
index 890c35c..5c352ea 100644 (file)
 
 \thispagestyle{empty}
 
-Copyright \copyright{} 1995, 1996, 1997, 1998, 1999, 2000 
+Copyright \copyright{} 1995, 1996, 1997, 1998, 1999, 2000
 Free Software Foundation, Inc.
 
 
@@ -632,7 +632,7 @@ Getting News
 
 Getting Mail
 
-* Mail in a Newsreader::         Important introductory notes.  
+* Mail in a Newsreader::         Important introductory notes.
 * Getting Started Reading Mail:: A simple cookbook example.
 * Splitting Mail::               How to create mail groups.
 * Mail Sources::                 How to tell Gnus where to get mail from.
@@ -1195,7 +1195,7 @@ Kill all new groups.
 
 @item gnus-subscribe-topics
 @vindex gnus-subscribe-topics
-Put the groups into the topic that has a matching @code{subscribe} topic 
+Put the groups into the topic that has a matching @code{subscribe} topic
 parameter (@pxref{Topic Parameters}).  For instance, a @code{subscribe}
 topic parameter that looks like
 
@@ -1203,7 +1203,7 @@ topic parameter that looks like
 "nnslashdot"
 @end example
 
-will mean that all groups that match that regex will be subscribed under 
+will mean that all groups that match that regex will be subscribed under
 that topic.
 
 If no topics match the groups, the groups will be subscribed in the
@@ -1493,7 +1493,7 @@ performance, but if the server does not support the aforementioned
 @code{LIST ACTIVE group} command, this isn't very nice to the server.
 
 If you think that starting up Gnus takes too long, try all the three
-different values for this variable and see what works best for you. 
+different values for this variable and see what works best for you.
 
 In any case, if you use @code{some} or @code{nil}, you should definitely
 kill all groups that you aren't interested in to speed things up.
@@ -3321,7 +3321,7 @@ convention (@pxref{Process/Prefix}).
 @item T j
 @kindex T j (Topic)
 @findex gnus-topic-jump-to-topic
-Go to a topic (@code{gnus-topic-jump-to-topic}).  
+Go to a topic (@code{gnus-topic-jump-to-topic}).
 
 @item T c
 @kindex T c (Topic)
@@ -3567,10 +3567,10 @@ parameters:
 
 @table @code
 @item subscribe
-When subscribing new groups by topic (@pxref{Subscription Methods}), the 
-@code{subscribe} topic parameter says what groups go in what topic.  Its 
+When subscribing new groups by topic (@pxref{Subscription Methods}), the
+@code{subscribe} topic parameter says what groups go in what topic.  Its
 value should be a regexp to match the groups that should go in that
-topic. 
+topic.
 
 @end table
 
@@ -3686,7 +3686,7 @@ For example:
 
 @item gnus-group-name-charset-group-alist
 @vindex gnus-group-name-charset-group-alist
-An alist of regexp of group name and the charset for group names. 
+An alist of regexp of group name and the charset for group names.
 It is used to show non-ASCII group names.
 
 For example:
@@ -3981,7 +3981,7 @@ lines as a normal @code{format} string, with some extensions
 (@pxref{Formatting Variables}).
 
 There should always be a colon on the line; the cursor always moves to
-the colon after performing an operation. 
+the colon after performing an operation.
 
 The default string is @samp{%U%R%z%I%(%[%4L: %-20,20n%]%) %s\n}.
 
@@ -4548,8 +4548,8 @@ If given a numerical prefix, you can do semi-manual charset stuff.
 encoded in the @code{cn-gb-2312} charset.  If you have
 
 @lisp
-(setq gnus-summary-show-article-charset-alist 
-      '((1 . cn-gb-2312) 
+(setq gnus-summary-show-article-charset-alist
+      '((1 . cn-gb-2312)
         (2 . big5)))
 @end lisp
 
@@ -4797,7 +4797,7 @@ the process/prefix convention.
 @kindex S o p (Summary)
 @findex gnus-summary-post-forward
 Forward the current article to a newsgroup
-(@code{gnus-summary-post-forward}).  
+(@code{gnus-summary-post-forward}).
  If no prefix is given, the message is forwarded according to the value
 of (@code{message-forward-as-mime}) and
 (@code{message-forward-show-mml}); if the prefix is 1, decode the
@@ -6649,7 +6649,7 @@ a spool, you could
 
 @lisp
 (setq gnus-use-long-file-name '(not-save)) ; to get a hierarchy
-(setq gnus-default-article-saver 
+(setq gnus-default-article-saver
       'gnus-summary-save-in-file) ; no encoding
 @end lisp
 
@@ -7522,7 +7522,7 @@ when filling.
 
 @item W Q
 @kindex W Q (Summary)
-@findex gnus-article-fill-long-lines 
+@findex gnus-article-fill-long-lines
 Fill long lines (@code{gnus-article-fill-long-lines}).
 
 @item W C
@@ -7548,7 +7548,7 @@ non-ASCII (i. e., 8-bit) articles.  It typically makes strings like
 @samp{déjà vu} look like @samp{d=E9j=E0 vu}, which doesn't look very
 readable to me.  Note that the this is usually done automatically by
 Gnus if the message in question has a @code{Content-Transfer-Encoding}
-header that says that this encoding has been done. 
+header that says that this encoding has been done.
 If a prefix is given, a charset will be asked for.
 
 @item W 6
@@ -7572,7 +7572,7 @@ makes strings look like @samp{~@{<:Ky2;S@{#,NpJ)l6HK!#~@}}.
 @item W h
 @kindex W h (Summary)
 @findex gnus-article-wash-html
-Treat HTML (@code{gnus-article-wash-html}).  
+Treat HTML (@code{gnus-article-wash-html}).
 Note that the this is usually done automatically by Gnus if the message
 in question has a @code{Content-Type} header that says that this type
 has been done.
@@ -7629,8 +7629,8 @@ Add clickable buttons to the article headers
 @kindex W p (Summary)
 @findex gnus-article-verify-x-pgp-sig
 Verify a signed control message (@code{gnus-article-verify-x-pgp-sig}).
-Control messages such as @code{newgroup} and @code{checkgroups} are 
-usually signed by the hierarchy maintainer.  You need to add the PGP 
+Control messages such as @code{newgroup} and @code{checkgroups} are
+usually signed by the hierarchy maintainer.  You need to add the PGP
 public key of the maintainer to your keyring to verify the
 message.@footnote{PGP keys for many hierarchies are available at
 @uref{ftp://ftp.isc.org/pub/pgpcontrol/README.html}}
@@ -7933,7 +7933,7 @@ signature after all.
 @kindex A t (Summary)
 @findex gnus-article-babel
 Translate the article from one language to another
-(@code{gnus-article-babel}). 
+(@code{gnus-article-babel}).
 
 @end table
 
@@ -8675,7 +8675,7 @@ disk forever and ever, never to return again.'' Use with caution.
 @vindex gnus-preserve-marks
 Move the article from one mail group to another
 (@code{gnus-summary-move-article}).  Marks will be preserved if
-@var{gnus-preserve-marks} is non-@code{nil} (which is the default). 
+@var{gnus-preserve-marks} is non-@code{nil} (which is the default).
 
 @item B c
 @kindex B c (Summary)
@@ -9245,7 +9245,7 @@ Gnus is able to verify PGP or S/MIME signed messages or decrypt PGP
 encrypted messages.
 
 @enumerate
-@item 
+@item
 To verify or decrypt PGP messages, you have to install mailcrypt or
 gpg.el.
 
@@ -9443,7 +9443,7 @@ method (@code{gnus-mime-view-part}).
 @findex gnus-mime-view-part-as-type
 @item t (Article)
 View the @sc{mime} object as if it were a different @sc{mime} media type
-(@code{gnus-mime-view-part-as-type}). 
+(@code{gnus-mime-view-part-as-type}).
 
 @findex gnus-mime-view-part-as-charset
 @itemx C (Article)
@@ -9633,7 +9633,7 @@ You can, of course, write your own functions to be called from
 @code{gnus-part-display-hook}.  The functions are called narrowed to the
 part, and you can do anything you like, pretty much.  There is no
 information that you have to keep in the buffer---you can change
-everything.  
+everything.
 
 
 @node Article Keymap
@@ -10538,25 +10538,30 @@ should probably look something like this:
 
 @lisp
 (nntp "firewall"
-      (nntp-address "the.firewall.machine")
-      (nntp-open-connection-function nntp-open-rlogin)
-      (nntp-end-of-line "\n")
-      (nntp-rlogin-parameters
-       ("telnet" "the.real.nntp.host" "nntp")))
+      (nntp-open-connection-function nntp-open-via-rlogin-and-telnet)
+      (nntp-via-address "the.firewall.machine")
+      (nntp-address "the.real.nntp.host")
+      (nntp-end-of-line "\n"))
 @end lisp
 
 If you want to use the wonderful @code{ssh} program to provide a
-compressed connection over the modem line, you could create a virtual
-server that would look something like this:
+compressed connection over the modem line, you could add the following
+configuration to the example above:
 
 @lisp
-(nntp "news"
-       (nntp-address "copper.uio.no")
-       (nntp-rlogin-program "ssh")
-       (nntp-open-connection-function nntp-open-rlogin)
-       (nntp-end-of-line "\n")
-       (nntp-rlogin-parameters
-        ("telnet" "news.uio.no" "nntp")))
+      (nntp-via-rlogin-command "ssh")
+@end lisp
+
+If you're behind a firewall, but have direct access to the outside world
+through a wrapper command like "runsocks", you could open a socksified
+telnet connection to the news server as follows:
+
+@lisp
+(nntp "outside"
+      (nntp-pre-command "runsocks")
+      (nntp-open-connection-function nntp-open-via-telnet)
+      (nntp-address "the.news.server")
+      (nntp-end-of-line "\n"))
 @end lisp
 
 This means that you have to have set up @code{ssh-agent} correctly to
@@ -10771,7 +10776,7 @@ manual page, but here are the salient facts:
 The file contains one or more line, each of which define one server.
 
 @item
-Each line may contain an arbitrary number of token/value pairs.  
+Each line may contain an arbitrary number of token/value pairs.
 
 The valid tokens include @samp{machine}, @samp{login}, @samp{password},
 @samp{default}.  In addition Gnus introduces two new tokens, not present
@@ -10830,7 +10835,7 @@ The default value is
 
 @lisp
 '(("nntpd 1\\.5\\.11t"
-   (remove-hook 'nntp-server-opened-hook 
+   (remove-hook 'nntp-server-opened-hook
                 'nntp-send-mode-reader)))
 @end lisp
 
@@ -10882,127 +10887,6 @@ no timeouts are done.
 This hook is run as the last step when connecting to an @sc{nntp}
 server.
 
-@findex nntp-open-rlogin
-@findex nntp-open-telnet
-@findex nntp-open-network-stream
-@item nntp-open-connection-function
-@vindex nntp-open-connection-function
-This function is used to connect to the remote system.  Four pre-made
-functions are supplied:
-
-@table @code
-@item nntp-open-network-stream
-This is the default, and simply connects to some port or other on the
-remote system.
-
-@item nntp-open-rlogin
-Does an @samp{rlogin} on the
-remote system, and then does a @samp{telnet} to the @sc{nntp} server
-available there.
-
-@code{nntp-open-rlogin}-related variables:
-
-@table @code
-
-@item nntp-rlogin-program
-@vindex nntp-rlogin-program
-Program used to log in on remote machines.  The default is @samp{rsh},
-but @samp{ssh} is a popular alternative.
-
-@item nntp-rlogin-parameters
-@vindex nntp-rlogin-parameters
-This list will be used as the parameter list given to @code{rsh}.
-
-@item nntp-rlogin-user-name
-@vindex nntp-rlogin-user-name
-User name on the remote system.
-
-@end table
-
-@item nntp-open-telnet
-Does a @samp{telnet} to the remote system and then another @samp{telnet}
-to get to the @sc{nntp} server.
-
-@code{nntp-open-telnet}-related variables:
-
-@table @code
-@item nntp-telnet-command
-@vindex nntp-telnet-command
-Command used to start @code{telnet}.
-
-@item nntp-telnet-switches
-@vindex nntp-telnet-switches
-List of strings to be used as the switches to the @code{telnet} command.
-
-@item nntp-telnet-user-name
-@vindex nntp-telnet-user-name
-User name for log in on the remote system.
-
-@item nntp-telnet-passwd
-@vindex nntp-telnet-passwd
-Password to use when logging in.
-
-@item nntp-telnet-parameters
-@vindex nntp-telnet-parameters
-A list of strings executed as a command after logging in
-via @code{telnet}.
-
-@item nntp-telnet-shell-prompt
-@vindex nntp-telnet-shell-prompt
-Regexp matching the shell prompt on the remote machine.  The default is
-@samp{bash\\|\$ *\r?$\\|> *\r?}.
-
-@item nntp-open-telnet-envuser
-@vindex nntp-open-telnet-envuser
-If non-@code{nil}, the @code{telnet} session (client and server both)
-will support the @code{ENVIRON} option and not prompt for login name.
-This works for Solaris @code{telnet}, for instance.
-
-@end table
-
-@findex nntp-open-ssl-stream
-@item nntp-open-ssl-stream
-Opens a connection to a server over a @dfn{secure} channel.  To use this
-you must have SSLay installed
-(@uref{ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL}, and you also need
-@file{ssl.el} (from the W3 distribution, for instance).  You then
-define a server as follows:
-
-@lisp
-;; Type `C-c C-c' after you've finished editing.
-;;
-;; "snews" is port 563 and is predefined 
-;; in our /etc/services
-;;
-(nntp "snews.bar.com"
-      (nntp-open-connection-function 
-        nntp-open-ssl-stream)
-      (nntp-port-number "snews")
-      (nntp-address "snews.bar.com"))
-@end lisp
-
-@end table
-
-@item nntp-end-of-line
-@vindex nntp-end-of-line
-String to use as end-of-line marker when talking to the @sc{nntp}
-server.  This is @samp{\r\n} by default, but should be @samp{\n} when
-using @code{rlogin} to talk to the server.
-
-@item nntp-rlogin-user-name
-@vindex nntp-rlogin-user-name
-User name on the remote system when using the @code{rlogin} connect
-function.
-
-@item nntp-address
-@vindex nntp-address
-The address of the remote system running the @sc{nntp} server.
-
-@item nntp-port-number
-@vindex nntp-port-number
-Port number to connect to when using the @code{nntp-open-network-stream}
-connect function.
-
 @item nntp-buggy-select
 @vindex nntp-buggy-select
 Set this to non-@code{nil} if your select routine is buggy.
@@ -11050,6 +10934,200 @@ If non-@code{nil}, @code{nntp} will log all commands it sends to the
 buffer.  This is useful if you are debugging a Gnus/@sc{nntp} connection
 that doesn't seem to work.
 
+@item nntp-open-connection-function
+@vindex nntp-open-connection-function
+It is possible to customize how the connection to the nntp server will
+be opened.  If you specify an @code{nntp-open-connection-function}
+parameter, Gnus will use that function to establish the connection.
+Five pre-made functions are supplied.  These functions can be grouped in
+two categories: direct connection functions (three pre-made), and
+indirect ones (two pre-made).
+@end table
+
+@menu
+* Direct Functions::   Connecting directly to the server.
+* Indirect Functions:: Connecting indirectly to the server.
+* Common Variables::   Understood by several connection functions.
+@end menu
+
+
+@node Direct Functions
+@subsubsection Direct Functions
+@cindex direct connection functions
+
+These functions are called direct because they open a direct connection
+between your machine and the @sc{nntp} server.  The behavior of these
+functions is also affected by commonly understood variables
+(@pxref{Common Variables}).
+
+@table @code
+@findex nntp-open-network-stream
+@item nntp-open-network-stream
+This is the default, and simply connects to some port or other on the
+remote system.
+
+@findex nntp-open-ssl-stream
+@item nntp-open-ssl-stream
+Opens a connection to a server over a @dfn{secure} channel.  To use this
+you must have SSLay installed
+(@uref{ftp://ftp.psy.uq.oz.au/pub/Crypto/SSL}, and you also need
+@file{ssl.el} (from the W3 distribution, for instance).  You then
+define a server as follows:
+
+@lisp
+;; Type `C-c C-c' after you've finished editing.
+;;
+;; "snews" is port 563 and is predefined in our /etc/services
+;;
+(nntp "snews.bar.com"
+      (nntp-open-connection-function nntp-open-ssl-stream)
+      (nntp-port-number "snews")
+      (nntp-address "snews.bar.com"))
+@end lisp
+
+@findex nntp-open-telnet-stream
+@item nntp-open-telnet-stream
+Opens a connection to an @sc{nntp} server by simply @samp{telnet}'ing
+it.  You might wonder why this function exists, since we have the
+default @code{nntp-open-network-stream} which would do the job.  (One
+of) the reason(s) is that if you are behind a firewall but have direct
+connections to the outside world thanks to a command wrapper like
+@code{runsocks}, you can use it like this:
+
+@lisp
+(nntp "socksified"
+      (nntp-pre-command "runsocks")
+      (nntp-open-connection-function nntp-open-telnet-stream)
+      (nntp-address "the.news.server"))
+@end lisp
+
+With the default method, you would need to wrap your whole Emacs
+session, which is not a good idea.
+@end table
+
+
+@node Indirect Functions
+@subsubsection Indirect Functions
+@cindex indirect connection functions
+
+These functions are called indirect because they connect to an
+intermediate host before actually connecting to the @sc{nntp} server.
+All of these functions and related variables are also said to belong to
+the "via" family of connection: they're all prefixed with "via" to make
+things cleaner.  The behavior of these functions is also affected by
+commonly understood variables (@pxref{Common Variables}).
+
+@table @code
+@item nntp-open-via-rlogin-and-telnet
+@findex nntp-open-via-rlogin-and-telnet
+Does an @samp{rlogin} on a remote system, and then does a @samp{telnet}
+to the real @sc{nntp} server from there.  This is useful for instance if
+you need to connect to a firewall machine first.
+
+@code{nntp-open-via-rlogin-and-telnet}-specific variables:
+
+@table @code
+@item nntp-via-rlogin-command
+@vindex nntp-via-rlogin-command
+Command used to log in on the intermediate host.  The default is
+@samp{rsh}, but @samp{ssh} is a popular alternative.
+@end table
+
+@item nntp-open-via-telnet-and-telnet
+@findex nntp-open-via-telnet-and-telnet
+Does essentially the same, but uses @samp{telnet} instead of
+@samp{rlogin} to connect to the intermediate host.
+
+@code{nntp-open-via-telnet-and-telnet}-specific variables:
+
+@table @code
+@item nntp-via-telnet-command
+@vindex nntp-via-telnet-command
+Command used to @code{telnet} the intermediate host.  The default is
+@samp{telnet}.
+
+@item nntp-via-telnet-switches
+@vindex nntp-via-telnet-switches
+List of strings to be used as the switches to the
+@code{nntp-via-telnet-command} command.  The default is @samp{("-8")}.
+
+@item nntp-via-user-password
+@vindex nntp-via-user-password
+Password to use when logging in on the intermediate host.
+
+@item nntp-via-envuser
+@vindex nntp-via-envuser
+If non-@code{nil}, the intermediate @code{telnet} session (client and
+server both) will support the @code{ENVIRON} option and not prompt for
+login name. This works for Solaris @code{telnet}, for instance.
+
+@item nntp-via-shell-prompt
+@vindex nntp-via-shell-prompt
+Regexp matching the shell prompt on the intermediate host.  The default
+is @samp{bash\\|\$ *\r?$\\|> *\r?}.
+
+@end table
+
+@end table
+
+
+Here are some additional variables that are understood by all the above
+functions:
+
+@table @code
+
+@item nntp-via-user-name
+@vindex nntp-via-user-name
+User name to use when connecting to the intermediate host.
+
+@item nntp-via-address
+@vindex nntp-via-address
+Address of the intermediate host to connect to.
+
+@end table
+
+
+@node Common Variables
+@subsubsection Common Variables
+
+The following variables affect the behavior of all, or several of the
+pre-made connection functions. When not specified, all functions are
+affected.
+
+@table @code
+
+@item nntp-pre-command
+@vindex nntp-pre-command
+A command wrapper to use when connecting through a non native connection
+function (all except @code{nntp-open-network-stream} and
+@code{nntp-open-ssl-stream}.  This is where you would put a @samp{SOCKS}
+wrapper for instance.
+
+@item nntp-address
+@vindex nntp-address
+The address of the @sc{nntp} server.
+
+@item nntp-port-number
+@vindex nntp-port-number
+Port number to connect to the @sc{nntp} server.  The default is @samp{nntp}.
+
+@item nntp-end-of-line
+@vindex nntp-end-of-line
+String to use as end-of-line marker when talking to the @sc{nntp}
+server.  This is @samp{\r\n} by default, but should be @samp{\n} when
+using a non native connection function.
+
+@item nntp-telnet-command
+@vindex nntp-telnet-command
+Command to use when connecting to the @sc{nntp} server through
+@samp{telnet}.  This is NOT for an intermediate host.  This is just for
+the real @sc{nntp} server.  The default is @samp{telnet}.
+
+@item nntp-telnet-switches
+@vindex nntp-telnet-switches
+A list of switches to pass to @code{nntp-telnet-command}.  The default
+is @samp{("-8")}.
+
 @end table
 
 
@@ -11135,7 +11213,7 @@ Reading mail with a newsreader---isn't that just plain WeIrD? But of
 course.
 
 @menu
-* Mail in a Newsreader::         Important introductory notes.  
+* Mail in a Newsreader::         Important introductory notes.
 * Getting Started Reading Mail:: A simple cookbook example.
 * Splitting Mail::               How to create mail groups.
 * Mail Sources::                 How to tell Gnus where to get mail from.
@@ -11154,11 +11232,11 @@ course.
 @node Mail in a Newsreader
 @subsection Mail in a Newsreader
 
-If you are used to traditional mail readers, but have decided to switch 
+If you are used to traditional mail readers, but have decided to switch
 to reading mail with Gnus, you may find yourself experiencing something
 of a culture shock.
 
-Gnus does not behave like traditional mail readers.  If you want to make 
+Gnus does not behave like traditional mail readers.  If you want to make
 it behave that way, you can, but it's an uphill battle.
 
 Gnus, by default, handles all its groups using the same approach.  This
@@ -11172,7 +11250,7 @@ Does this mean that all the messages that have been marked as read are
 deleted?  How awful!
 
 But, no, it means that old messages are @dfn{expired} according to some
-scheme or other.  For news messages, the expire process is controlled by 
+scheme or other.  For news messages, the expire process is controlled by
 the news administrator; for mail, the expire process is controlled by
 you.  The expire process for mail is covered in depth in @pxref{Expiring
 Mail}.
@@ -11328,7 +11406,7 @@ If you wish to see where the previous mail split put the messages, you
 can use the @kbd{M-x nnmail-split-history} command.  If you wish to see
 where re-spooling messages would put the messages, you can use
 @code{gnus-summary-respool-trace} and related commands (@pxref{Mail
-Group Commands}). 
+Group Commands}).
 
 Gnus gives you all the opportunity you could possibly want for shooting
 yourself in the foot.  Let's say you create a group that will contain
@@ -11403,8 +11481,8 @@ Or using the default path:
 (file)
 @end lisp
 
-If the mail spool file is not located on the local machine, it's best to 
-use POP or @sc{imap} or the like to fetch the mail.  You can not use ange-ftp 
+If the mail spool file is not located on the local machine, it's best to
+use POP or @sc{imap} or the like to fetch the mail.  You can not use ange-ftp
 file names here---it has no way to lock the mail spool while moving the
 mail.
 
@@ -11595,12 +11673,12 @@ from locking problems).
 Two example maildir mail sources:
 
 @lisp
-(maildir :path "/home/user-name/Maildir/" 
+(maildir :path "/home/user-name/Maildir/"
          :subdirs ("cur" "new"))
 @end lisp
 
 @lisp
-(maildir :path "/user@@remotehost.org:~/Maildir/" 
+(maildir :path "/user@@remotehost.org:~/Maildir/"
          :subdirs ("new"))
 @end lisp
 
@@ -11693,8 +11771,8 @@ after finishing the fetch.
 An example @sc{imap} mail source:
 
 @lisp
-(imap :server "mail.mycorp.com" 
-      :stream kerberos4 
+(imap :server "mail.mycorp.com"
+      :stream kerberos4
       :fetchflag "\\Seen")
 @end lisp
 
@@ -11734,8 +11812,8 @@ folder after finishing the fetch.
 An example webmail source:
 
 @lisp
-(webmail :subtype 'hotmail 
-         :user "user-name" 
+(webmail :subtype 'hotmail
+         :user "user-name"
          :password "secret")
 @end lisp
 @end table
@@ -11753,7 +11831,7 @@ directory source to get mail, you can specify it as in this example:
 
 @lisp
 (setq mail-sources
-      '((directory :path "/home/pavel/.Spool/" 
+      '((directory :path "/home/pavel/.Spool/"
                    :suffix ""
                    :plugged t)))
 @end lisp
@@ -11962,7 +12040,7 @@ Let's look at an example value of this variable first:
       (any "procmail@@informatik\\.rwth-aachen\\.de" "procmail.list")
       (any "SmartList@@informatik\\.rwth-aachen\\.de" "SmartList.list")
       ;; Both lists below have the same suffix, so prevent
-      ;; cross-posting to mkpkg.list of messages posted only to 
+      ;; cross-posting to mkpkg.list of messages posted only to
       ;; the bugs- list, but allow cross-posting when the
       ;; message was really cross-posted.
       (any "bugs-mypackage@@somewhere" "mypkg.bugs")
@@ -12668,7 +12746,7 @@ The name of the mail box in the user's home directory.  Default is
 @item nnmbox-active-file
 @vindex nnmbox-active-file
 The name of the active file for the mail box.  Default is
-@file{~/.mbox-active}. 
+@file{~/.mbox-active}.
 
 @item nnmbox-get-new-mail
 @vindex nnmbox-get-new-mail
@@ -13002,8 +13080,8 @@ itself puts *all* one's mail in one file; @code{nnfolder} provides a
 little bit of optimization to this so that each of one's mail groups has
 a Unix mail box file.  It's faster than @code{nnmbox} because each group
 can be parsed separately, and still provides the simple Unix mail box
-format requiring minimal effort in moving the mail around.  In addition, 
-it maintains an ``active'' file making it much faster for Gnus to figure 
+format requiring minimal effort in moving the mail around.  In addition,
+it maintains an ``active'' file making it much faster for Gnus to figure
 out how many messages there are in each separate group.
 
 If you have groups that are expected to have a massive amount of
@@ -13029,13 +13107,13 @@ and click, and there's the discussion.  With mailing lists, you have to
 go through a cumbersome subscription procedure, and most people don't
 even know what a news group is.
 
-The problem with this scenario is that web browsers are not very good at 
-being newsreaders.  They do not keep track of what articles you've read; 
-they do not allow you to score on subjects you're interested in; they do 
+The problem with this scenario is that web browsers are not very good at
+being newsreaders.  They do not keep track of what articles you've read;
+they do not allow you to score on subjects you're interested in; they do
 not allow off-line browsing; they require you to click around and drive
 you mad in the end.
 
-So---if web browsers suck at reading discussion forums, why not use Gnus 
+So---if web browsers suck at reading discussion forums, why not use Gnus
 to do it instead?
 
 Gnus has been getting a bit of a collection of backends for providing
@@ -13053,7 +13131,7 @@ interfaces to these sources.
 All the web sources require Emacs/w3 and the url library to work.
 
 The main caveat with all these web sources is that they probably won't
-work for a very long time.  Gleaning information from the @sc{html} data 
+work for a very long time.  Gleaning information from the @sc{html} data
 is guesswork at best, and when the layout is altered, the Gnus backend
 will fail.  If you have reasonably new versions of these backends,
 though, you should be ok.
@@ -13216,7 +13294,7 @@ Where @code{nnslashdot} will store its files.  The default is
 @item nnslashdot-active-url
 @vindex nnslashdot-active-url
 The @sc{url} format string that will be used to fetch the information on
-news articles and comments.  Default:
+news articles and comments.  The default is
 @samp{http://slashdot.org/search.pl?section=&min=%d}.
 
 @item nnslashdot-comments-url
@@ -13255,7 +13333,7 @@ quite regular and nice interface, and it's possible to get the
 information Gnus needs to keep groups updated.
 
 The easiest way to get started with @code{nnultimate} is to say
-something like the following in the group buffer:  @kbd{B nnultimate RET 
+something like the following in the group buffer:  @kbd{B nnultimate RET
 http://www.tcj.com/messboard/ubbcgi/ RET}.  (Substitute the @sc{url}
 (not including @samp{Ultimate.cgi} or the like at the end) for a forum
 you're interested in; there's quite a list of them on the Ultimate web
@@ -13352,12 +13430,12 @@ the summary buffer.
 @cindex url
 @cindex Netscape
 
-Gnus uses the url library to fetch web pages and Emacs/w3 to display web 
+Gnus uses the url library to fetch web pages and Emacs/w3 to display web
 pages.  Emacs/w3 is documented in its own manual, but there are some
 things that may be more relevant for Gnus users.
 
 For instance, a common question is how to make Emacs/w3 follow links
-using the @code{browse-url} functions (which will call some external web 
+using the @code{browse-url} functions (which will call some external web
 browser like Netscape).  Here's one way:
 
 @lisp
@@ -14042,7 +14120,7 @@ Here's an example:
 
 @lisp
 (setq gnus-post-method
-      '(nngateway 
+      '(nngateway
         "mail2news@@replay.com"
         (nngateway-header-transformation
          nngateway-mail2news-header-transformation)))
@@ -14091,7 +14169,7 @@ A server configuration in @code{~/.gnus} with a few @sc{imap} servers
 might look something like this:
 
 @lisp
-(setq gnus-secondary-select-methods 
+(setq gnus-secondary-select-methods
       '((nnimap "simpleserver") ; no special configuration
         ; perhaps a ssh port forwarded server:
         (nnimap "dolk"
@@ -14153,7 +14231,7 @@ Example server specification:
 
 @lisp
 (nnimap "mail.server.com"
-        (nnimap-list-pattern ("INBOX" "Mail/*" "alt.sex.*" 
+        (nnimap-list-pattern ("INBOX" "Mail/*" "alt.sex.*"
                                ("~friend/Mail/" . "list/*"))))
 @end lisp
 
@@ -14374,7 +14452,7 @@ Neither did I, we need examples.
 
 @lisp
 (setq nnimap-split-rule
-      '(("INBOX.nnimap"  
+      '(("INBOX.nnimap"
          "^Sender: owner-nnimap@@vic20.globalcom.se")
         ("INBOX.junk"    "^Subject:.*MAKE MONEY")
         ("INBOX.private" "")))
@@ -15953,7 +16031,7 @@ returned is the local score file.  Phu.
 For example, to do hierarchical scoring but use a non-server-specific
 overall score file, you could use the value
 @example
-(list (lambda (group) ("all.SCORE")) 
+(list (lambda (group) ("all.SCORE"))
       'gnus-score-find-hierarchical)
 @end example
 
@@ -16638,7 +16716,7 @@ the @code{Xref} header.
 If you want to lower the score of articles that have been crossposted to
 more than, say, 3 groups:
 @lisp
-("xref" 
+("xref"
   ("[^:\n]+:[0-9]+ +[^:\n]+:[0-9]+ +[^:\n]+:[0-9]+"
    -1000 nil r))
 @end lisp
@@ -17872,7 +17950,7 @@ for composing mail and news while leaving the original frame intact.  To
 accomplish that, something like the following can be done:
 
 @lisp
-(message 
+(message
   (frame 1.0
          (if (not (buffer-live-p gnus-summary-buffer))
              (car (cdr (assoc 'group gnus-buffer-configuration)))
@@ -17914,7 +17992,7 @@ windows resized.
 @subsection Example Window Configurations
 
 @itemize @bullet
-@item 
+@item
 Narrow left hand side occupied by group buffer.  Right hand side split
 between summary buffer (top one-sixth) and article buffer (bottom).
 
@@ -18429,7 +18507,7 @@ never be totally undoable.
 @findex gnus-undo
 The undoability is provided by the @code{gnus-undo-mode} minor mode.  It
 is used if @code{gnus-use-undo} is non-@code{nil}, which is the
-default.  The @kbd{M-C-_} key performs the @code{gnus-undo} 
+default.  The @kbd{M-C-_} key performs the @code{gnus-undo}
 command, which should feel kinda like the normal Emacs @code{undo}
 command.
 
@@ -20461,7 +20539,7 @@ If you used procmail like in
 (setq nnmail-procmail-suffix "\\.in")
 @end lisp
 
-this now has changed to 
+this now has changed to
 
 @lisp
 (setq mail-sources
@@ -20490,7 +20568,7 @@ of variables starting with @code{gnus-treat-} have been added.
 @item The Gnus posting styles have been redone again and now works in a
 subtly different manner.
 
-@item New web-based backends have been added: @code{nnslashdot}, 
+@item New web-based backends have been added: @code{nnslashdot},
 @code{nnwarchive} and @code{nnultimate}.  nnweb has been revamped,
 again, to keep up with ever-changing layouts.
 
@@ -20569,16 +20647,16 @@ I guess most manuals are written after-the-fact; documenting a program
 that's already there.  This is not how this manual is written.  When
 implementing something, I write the manual entry for that something
 straight away.  I then see that it's difficult to explain the
-functionality, so I write how it's supposed to be, and then I change the 
+functionality, so I write how it's supposed to be, and then I change the
 implementation.  Writing the documentation and writing the code goes
 hand in hand.
 
 This, of course, means that this manual has no, or little, flow.  It
 documents absolutely everything in Gnus, but often not where you're
-looking for it.  It is a reference manual, and not a guide to how to get 
+looking for it.  It is a reference manual, and not a guide to how to get
 started with Gnus.
 
-That would be a totally different book, that should be written using the 
+That would be a totally different book, that should be written using the
 reference manual as source material.  It would look quite differently.
 
 
@@ -21799,8 +21877,8 @@ Below is a slightly shortened version of the @code{nndir} backend.
   "*Non-nil means that nndir will never retrieve NOV headers."
   nnml-nov-is-evil)
 
-(defvoo nndir-current-group "" 
-  nil 
+(defvoo nndir-current-group ""
+  nil
   nnml-current-group nnmh-current-group)
 (defvoo nndir-top-directory nil nil nnml-directory nnmh-directory)
 (defvoo nndir-get-new-mail nil nil nnml-get-new-mail nnmh-get-new-mail)
@@ -21819,7 +21897,7 @@ Below is a slightly shortened version of the @code{nndir} backend.
   (unless (assq 'nndir-directory defs)
     (push `(nndir-directory ,server) defs))
   (push `(nndir-current-group
-          ,(file-name-nondirectory 
+          ,(file-name-nondirectory
             (directory-file-name nndir-directory)))
         defs)
   (push `(nndir-top-directory