]> code.delx.au - gnu-emacs/commitdiff
(nntp-netcat-command): Rename from nntp-via-netcat-command.
authorStefan Monnier <monnier@iro.umontreal.ca>
Sun, 30 Mar 2008 03:54:15 +0000 (03:54 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Sun, 30 Mar 2008 03:54:15 +0000 (03:54 +0000)
(nntp-netcat-switches): Rename from nntp-via-netcat-switches.
(nntp-open-telnet, nntp-open-rlogin): Use with-current-buffer.
(nntp-service-to-port): New function.
(nntp-open-via-rlogin-and-netcat, nntp-open-via-telnet-and-telnet)
(nntp-open-telnet-stream, nntp-open-via-rlogin-and-telnet): Use it.
(nntp-open-netcat-stream): New function.
(nntp-open-via-rlogin-and-netcat): Don't use a pty.

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

index 203d4b17b2978efec9f748f391de21065a71a6d9..a6380aea3b5cf7efcf167087460ed18d46103075 100644 (file)
@@ -13144,7 +13144,7 @@ netcat connection to the news server as follows:
 @lisp
 (nntp "outside"
       (nntp-pre-command "runsocks")
-      (nntp-open-connection-function nntp-open-via-netcat)
+      (nntp-open-connection-function nntp-open-netcat-stream)
       (nntp-address "the.news.server"))
 @end lisp
 
@@ -13619,8 +13619,8 @@ then define a server as follows:
       (nntp-address "snews.bar.com"))
 @end lisp
 
-@findex nntp-open-via-netcat
-@item nntp-open-via-netcat
+@findex nntp-open-netcat-stream
+@item nntp-open-netcat-stream
 Opens a connection to an @acronym{NNTP} server using the @code{netcat}
 program.  You might wonder why this function exists, since we have
 the default @code{nntp-open-network-stream} which would do the job.  (One
@@ -13631,7 +13631,7 @@ connections to the outside world thanks to a command wrapper like
 @lisp
 (nntp "socksified"
       (nntp-pre-command "runsocks")
-      (nntp-open-connection-function nntp-open-via-netcat)
+      (nntp-open-connection-function nntp-open-netcat-stream)
       (nntp-address "the.news.server"))
 @end lisp
 
@@ -13640,7 +13640,7 @@ session, which is not a good idea.
 
 @findex nntp-open-telnet-stream
 @item nntp-open-telnet-stream
-Like @code{nntp-open-via-netcat}, but uses @code{telnet} rather than
+Like @code{nntp-open-netcat-stream}, but uses @code{telnet} rather than
 @code{netcat}.  @code{telnet} is a bit less robust because of things
 like line-end-conversion, but sometimes netcat is simply
 not available.  The previous example would turn into:
@@ -13821,16 +13821,16 @@ String to use as end-of-line marker when talking to the @acronym{NNTP}
 server.  This is @samp{\r\n} by default, but should be @samp{\n} when
 using a non native telnet connection function.
 
-@item nntp-via-netcat-command
-@vindex nntp-via-netcat-command
+@item nntp-netcat-command
+@vindex nntp-netcat-command
 Command to use when connecting to the @acronym{NNTP} server through
 @samp{netcat}.  This is @emph{not} for an intermediate host.  This is
 just for the real @acronym{NNTP} server.  The default is
 @samp{nc}.
 
-@item nntp-via-netcat-switches
-@vindex nntp-via-netcat-switches
-A list of switches to pass to @code{nntp-via-netcat-command}.  The default
+@item nntp-netcat-switches
+@vindex nntp-netcat-switches
+A list of switches to pass to @code{nntp-netcat-command}.  The default
 is @samp{()}.
 
 @end table
index e908b8f2761c4de671db414305f6e389a3c3b2d2..0151f681e29857f62cd48deefde9e162b3ba67f4 100644 (file)
@@ -1,3 +1,14 @@
+2008-03-30  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * nntp.el (nntp-netcat-command): Rename from nntp-via-netcat-command.
+       (nntp-netcat-switches): Rename from nntp-via-netcat-switches.
+       (nntp-open-telnet, nntp-open-rlogin): Use with-current-buffer.
+       (nntp-service-to-port): New function.
+       (nntp-open-via-rlogin-and-netcat, nntp-open-via-telnet-and-telnet)
+       (nntp-open-telnet-stream, nntp-open-via-rlogin-and-telnet): Use it.
+       (nntp-open-netcat-stream): New function.
+       (nntp-open-via-rlogin-and-netcat): Don't use a pty.
+
 2008-03-29  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * message.el (message-make-in-reply-to): Use mm-with-multibyte-buffer.
index a1a7e38d24048b2c5ac3b724b6f0fe933c345b3b..f43d1a1aaa47b73141f59523aa0352dbe00a7313 100644 (file)
@@ -84,11 +84,12 @@ Direct connections:
 - `nntp-open-network-stream' (the default),
 - `nntp-open-ssl-stream',
 - `nntp-open-tls-stream',
+- `nntp-open-netcat-stream'.
 - `nntp-open-telnet-stream'.
 
 Indirect connections:
-- `nntp-open-via-rlogin-and-telnet',
 - `nntp-open-via-rlogin-and-netcat',
+- `nntp-open-via-rlogin-and-telnet',
 - `nntp-open-via-telnet-and-telnet'.")
 
 (defvoo nntp-never-echoes-commands nil
@@ -143,12 +144,13 @@ This command is used by the `nntp-open-via-telnet-and-telnet' method.")
 (defvoo nntp-via-telnet-switches '("-8")
   "*Switches given to the telnet command `nntp-via-telnet-command'.")
 
-(defvoo nntp-via-netcat-command "nc"
+(defvoo nntp-netcat-command "nc"
   "*Netcat command used to connect to the nntp server.
-This command is used by the `nntp-open-via-rlogin-and-netcat' method.")
+This command is used by the `nntp-open-netcat-stream' and
+`nntp-open-via-rlogin-and-netcat' methods.")
 
-(defvoo nntp-via-netcat-switches nil
-  "*Switches given to the netcat command `nntp-via-netcat-command'.")
+(defvoo nntp-netcat-switches nil
+  "*Switches given to the netcat command `nntp-netcat-command'.")
 
 (defvoo nntp-via-user-name nil
   "*User name to log in on an intermediate host with.
@@ -1801,9 +1803,21 @@ via telnet.")
 (defvoo nntp-telnet-passwd nil
   "Password to use to log in via telnet with.")
 
+(defun nntp-service-to-port (svc)
+  (cond
+   ((integerp svc) (number-to-string svc))
+   ((string-match "\\`[[:digit:]]\\'" svc) svc)
+   (t
+    (with-temp-buffer
+      (ignore-errors (insert-file-contents "/etc/services"))
+      (goto-char (point-min))
+      (if (re-search-forward (concat "^" (regexp-quote svc)
+                                     "[ \t]+\\([[:digit:]]+\\)/tcp"))
+          (match-string 1)
+        svc)))))
+
 (defun nntp-open-telnet (buffer)
-  (save-excursion
-    (set-buffer buffer)
+  (with-current-buffer buffer
     (erase-buffer)
     (let ((proc (apply
                 'start-process
@@ -1859,8 +1873,7 @@ via telnet.")
                (apply 'start-process
                       "nntpd" buffer nntp-rlogin-program nntp-address
                       nntp-rlogin-parameters))))
-    (save-excursion
-      (set-buffer buffer)
+    (with-current-buffer buffer
       (nntp-wait-for-string "^\r*20[01]")
       (beginning-of-line)
       (delete-region (point-min) (point))
@@ -1873,7 +1886,7 @@ via telnet.")
 
 (defun nntp-open-telnet-stream (buffer)
   "Open a nntp connection by telnet'ing the news server.
-`nntp-open-via-netcat' is recommended in place of this function
+`nntp-open-netcat-stream' is recommended in place of this function
 because it is more reliable.
 
 Please refer to the following variables to customize the connection:
@@ -1886,9 +1899,7 @@ Please refer to the following variables to customize the connection:
   (let ((command `(,nntp-telnet-command
                   ,@nntp-telnet-switches
                   ,nntp-address
-                  ,(if (integerp nntp-port-number)
-                       (number-to-string nntp-port-number)
-                     nntp-port-number)))
+                  ,(nntp-service-to-port nntp-port-number)))
        proc)
     (and nntp-pre-command
         (push nntp-pre-command command))
@@ -1932,9 +1943,7 @@ Please refer to the following variables to customize the connection:
     (with-current-buffer buffer
       (nntp-wait-for-string "^r?telnet")
       (process-send-string proc (concat "open " nntp-address " "
-                                       (if (integerp nntp-port-number)
-                                           (number-to-string nntp-port-number)
-                                         nntp-port-number)
+                                       (nntp-service-to-port nntp-port-number)
                                        "\n"))
       (nntp-wait-for-string "^\r*20[01]")
       (beginning-of-line)
@@ -1960,26 +1969,46 @@ Please refer to the following variables to customize the connection:
 - `nntp-via-rlogin-command-switches',
 - `nntp-via-user-name',
 - `nntp-via-address',
-- `nntp-via-netcat-command',
-- `nntp-via-netcat-switches',
+- `nntp-netcat-command',
+- `nntp-netcat-switches',
 - `nntp-address',
-- `nntp-port-number',
-- `nntp-end-of-line'."
+- `nntp-port-number'."
   (let ((command `(,@(when nntp-pre-command
                       (list nntp-pre-command))
                   ,nntp-via-rlogin-command
-                  ,@(when nntp-via-rlogin-command-switches
-                      nntp-via-rlogin-command-switches)
+                  ,@nntp-via-rlogin-command-switches
                   ,@(when nntp-via-user-name
                       (list "-l" nntp-via-user-name))
                   ,nntp-via-address
-                  ,nntp-via-netcat-command
-                  ,@nntp-via-netcat-switches
+                  ,nntp-netcat-command
+                  ,@nntp-netcat-switches
                   ,nntp-address
-                  ,(if (integerp nntp-port-number)
-                       (number-to-string nntp-port-number)
-                     nntp-port-number))))
-    (apply 'start-process "nntpd" buffer command)))
+                  ,(nntp-service-to-port nntp-port-number))))
+    ;; A non-nil connection type results in mightily odd behavior where
+    ;; (process-send-string proc "\^M") ends up sending a "\n" to the
+    ;; ssh process.  --Stef
+    ;; Also a nil connection allow ssh-askpass to work under X11.
+    (let ((process-connection-type nil))
+      (apply 'start-process "nntpd" buffer command))))
+
+(defun nntp-open-netcat-stream (buffer)
+  "Open a connection to an nntp server through netcat.
+I.e. use the `nc' command rather than Emacs's builtin networking code.
+
+Please refer to the following variables to customize the connection:
+- `nntp-pre-command',
+- `nntp-netcat-command',
+- `nntp-netcat-switches',
+- `nntp-address',
+- `nntp-port-number'."
+  (let ((command `(,nntp-netcat-command
+                  ,@nntp-netcat-switches
+                   ,nntp-address
+                   ,(nntp-service-to-port nntp-port-number))))
+    (and nntp-pre-command (push nntp-pre-command command))
+    (let ((process-connection-type nil)) ;See `nntp-open-via-rlogin-and-netcat'.
+      (apply 'start-process "nntpd" buffer command))))
 
 (defun nntp-open-via-telnet-and-telnet (buffer)
   "Open a connection to an nntp server through an intermediate host.
@@ -2037,9 +2066,7 @@ Please refer to the following variables to customize the connection:
                                     ,nntp-telnet-command
                                     ,@nntp-telnet-switches
                                     ,nntp-address
-                                    ,(if (integerp nntp-port-number)
-                                         (number-to-string nntp-port-number)
-                                       nntp-port-number))))
+                                    ,(nntp-service-to-port nntp-port-number))))
          (process-send-string proc
                               (concat (mapconcat 'identity
                                                  real-telnet-command " ")