diff options
| author | Stefan Monnier | 2008-03-30 03:54:15 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-03-30 03:54:15 +0000 |
| commit | 990e2c2fbce776825ce853151707136cebaff03d (patch) | |
| tree | 6b1e105aeeff2e9d7a54bb7fd0a6bef3d53bb91c | |
| parent | 02a0861d53eb665af22df38dd85a95d7060b2dd9 (diff) | |
| download | emacs-990e2c2fbce776825ce853151707136cebaff03d.tar.gz emacs-990e2c2fbce776825ce853151707136cebaff03d.zip | |
(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.
| -rw-r--r-- | doc/misc/gnus.texi | 20 | ||||
| -rw-r--r-- | lisp/gnus/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/gnus/nntp.el | 89 |
3 files changed, 79 insertions, 41 deletions
diff --git a/doc/misc/gnus.texi b/doc/misc/gnus.texi index 203d4b17b29..a6380aea3b5 100644 --- a/doc/misc/gnus.texi +++ b/doc/misc/gnus.texi | |||
| @@ -13144,7 +13144,7 @@ netcat connection to the news server as follows: | |||
| 13144 | @lisp | 13144 | @lisp |
| 13145 | (nntp "outside" | 13145 | (nntp "outside" |
| 13146 | (nntp-pre-command "runsocks") | 13146 | (nntp-pre-command "runsocks") |
| 13147 | (nntp-open-connection-function nntp-open-via-netcat) | 13147 | (nntp-open-connection-function nntp-open-netcat-stream) |
| 13148 | (nntp-address "the.news.server")) | 13148 | (nntp-address "the.news.server")) |
| 13149 | @end lisp | 13149 | @end lisp |
| 13150 | 13150 | ||
| @@ -13619,8 +13619,8 @@ then define a server as follows: | |||
| 13619 | (nntp-address "snews.bar.com")) | 13619 | (nntp-address "snews.bar.com")) |
| 13620 | @end lisp | 13620 | @end lisp |
| 13621 | 13621 | ||
| 13622 | @findex nntp-open-via-netcat | 13622 | @findex nntp-open-netcat-stream |
| 13623 | @item nntp-open-via-netcat | 13623 | @item nntp-open-netcat-stream |
| 13624 | Opens a connection to an @acronym{NNTP} server using the @code{netcat} | 13624 | Opens a connection to an @acronym{NNTP} server using the @code{netcat} |
| 13625 | program. You might wonder why this function exists, since we have | 13625 | program. You might wonder why this function exists, since we have |
| 13626 | the default @code{nntp-open-network-stream} which would do the job. (One | 13626 | 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 | |||
| 13631 | @lisp | 13631 | @lisp |
| 13632 | (nntp "socksified" | 13632 | (nntp "socksified" |
| 13633 | (nntp-pre-command "runsocks") | 13633 | (nntp-pre-command "runsocks") |
| 13634 | (nntp-open-connection-function nntp-open-via-netcat) | 13634 | (nntp-open-connection-function nntp-open-netcat-stream) |
| 13635 | (nntp-address "the.news.server")) | 13635 | (nntp-address "the.news.server")) |
| 13636 | @end lisp | 13636 | @end lisp |
| 13637 | 13637 | ||
| @@ -13640,7 +13640,7 @@ session, which is not a good idea. | |||
| 13640 | 13640 | ||
| 13641 | @findex nntp-open-telnet-stream | 13641 | @findex nntp-open-telnet-stream |
| 13642 | @item nntp-open-telnet-stream | 13642 | @item nntp-open-telnet-stream |
| 13643 | Like @code{nntp-open-via-netcat}, but uses @code{telnet} rather than | 13643 | Like @code{nntp-open-netcat-stream}, but uses @code{telnet} rather than |
| 13644 | @code{netcat}. @code{telnet} is a bit less robust because of things | 13644 | @code{netcat}. @code{telnet} is a bit less robust because of things |
| 13645 | like line-end-conversion, but sometimes netcat is simply | 13645 | like line-end-conversion, but sometimes netcat is simply |
| 13646 | not available. The previous example would turn into: | 13646 | 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} | |||
| 13821 | server. This is @samp{\r\n} by default, but should be @samp{\n} when | 13821 | server. This is @samp{\r\n} by default, but should be @samp{\n} when |
| 13822 | using a non native telnet connection function. | 13822 | using a non native telnet connection function. |
| 13823 | 13823 | ||
| 13824 | @item nntp-via-netcat-command | 13824 | @item nntp-netcat-command |
| 13825 | @vindex nntp-via-netcat-command | 13825 | @vindex nntp-netcat-command |
| 13826 | Command to use when connecting to the @acronym{NNTP} server through | 13826 | Command to use when connecting to the @acronym{NNTP} server through |
| 13827 | @samp{netcat}. This is @emph{not} for an intermediate host. This is | 13827 | @samp{netcat}. This is @emph{not} for an intermediate host. This is |
| 13828 | just for the real @acronym{NNTP} server. The default is | 13828 | just for the real @acronym{NNTP} server. The default is |
| 13829 | @samp{nc}. | 13829 | @samp{nc}. |
| 13830 | 13830 | ||
| 13831 | @item nntp-via-netcat-switches | 13831 | @item nntp-netcat-switches |
| 13832 | @vindex nntp-via-netcat-switches | 13832 | @vindex nntp-netcat-switches |
| 13833 | A list of switches to pass to @code{nntp-via-netcat-command}. The default | 13833 | A list of switches to pass to @code{nntp-netcat-command}. The default |
| 13834 | is @samp{()}. | 13834 | is @samp{()}. |
| 13835 | 13835 | ||
| 13836 | @end table | 13836 | @end table |
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index e908b8f2761..0151f681e29 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2008-03-30 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * nntp.el (nntp-netcat-command): Rename from nntp-via-netcat-command. | ||
| 4 | (nntp-netcat-switches): Rename from nntp-via-netcat-switches. | ||
| 5 | (nntp-open-telnet, nntp-open-rlogin): Use with-current-buffer. | ||
| 6 | (nntp-service-to-port): New function. | ||
| 7 | (nntp-open-via-rlogin-and-netcat, nntp-open-via-telnet-and-telnet) | ||
| 8 | (nntp-open-telnet-stream, nntp-open-via-rlogin-and-telnet): Use it. | ||
| 9 | (nntp-open-netcat-stream): New function. | ||
| 10 | (nntp-open-via-rlogin-and-netcat): Don't use a pty. | ||
| 11 | |||
| 1 | 2008-03-29 Stefan Monnier <monnier@iro.umontreal.ca> | 12 | 2008-03-29 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 13 | ||
| 3 | * message.el (message-make-in-reply-to): Use mm-with-multibyte-buffer. | 14 | * message.el (message-make-in-reply-to): Use mm-with-multibyte-buffer. |
diff --git a/lisp/gnus/nntp.el b/lisp/gnus/nntp.el index a1a7e38d240..f43d1a1aaa4 100644 --- a/lisp/gnus/nntp.el +++ b/lisp/gnus/nntp.el | |||
| @@ -84,11 +84,12 @@ Direct connections: | |||
| 84 | - `nntp-open-network-stream' (the default), | 84 | - `nntp-open-network-stream' (the default), |
| 85 | - `nntp-open-ssl-stream', | 85 | - `nntp-open-ssl-stream', |
| 86 | - `nntp-open-tls-stream', | 86 | - `nntp-open-tls-stream', |
| 87 | - `nntp-open-netcat-stream'. | ||
| 87 | - `nntp-open-telnet-stream'. | 88 | - `nntp-open-telnet-stream'. |
| 88 | 89 | ||
| 89 | Indirect connections: | 90 | Indirect connections: |
| 90 | - `nntp-open-via-rlogin-and-telnet', | ||
| 91 | - `nntp-open-via-rlogin-and-netcat', | 91 | - `nntp-open-via-rlogin-and-netcat', |
| 92 | - `nntp-open-via-rlogin-and-telnet', | ||
| 92 | - `nntp-open-via-telnet-and-telnet'.") | 93 | - `nntp-open-via-telnet-and-telnet'.") |
| 93 | 94 | ||
| 94 | (defvoo nntp-never-echoes-commands nil | 95 | (defvoo nntp-never-echoes-commands nil |
| @@ -143,12 +144,13 @@ This command is used by the `nntp-open-via-telnet-and-telnet' method.") | |||
| 143 | (defvoo nntp-via-telnet-switches '("-8") | 144 | (defvoo nntp-via-telnet-switches '("-8") |
| 144 | "*Switches given to the telnet command `nntp-via-telnet-command'.") | 145 | "*Switches given to the telnet command `nntp-via-telnet-command'.") |
| 145 | 146 | ||
| 146 | (defvoo nntp-via-netcat-command "nc" | 147 | (defvoo nntp-netcat-command "nc" |
| 147 | "*Netcat command used to connect to the nntp server. | 148 | "*Netcat command used to connect to the nntp server. |
| 148 | This command is used by the `nntp-open-via-rlogin-and-netcat' method.") | 149 | This command is used by the `nntp-open-netcat-stream' and |
| 150 | `nntp-open-via-rlogin-and-netcat' methods.") | ||
| 149 | 151 | ||
| 150 | (defvoo nntp-via-netcat-switches nil | 152 | (defvoo nntp-netcat-switches nil |
| 151 | "*Switches given to the netcat command `nntp-via-netcat-command'.") | 153 | "*Switches given to the netcat command `nntp-netcat-command'.") |
| 152 | 154 | ||
| 153 | (defvoo nntp-via-user-name nil | 155 | (defvoo nntp-via-user-name nil |
| 154 | "*User name to log in on an intermediate host with. | 156 | "*User name to log in on an intermediate host with. |
| @@ -1801,9 +1803,21 @@ via telnet.") | |||
| 1801 | (defvoo nntp-telnet-passwd nil | 1803 | (defvoo nntp-telnet-passwd nil |
| 1802 | "Password to use to log in via telnet with.") | 1804 | "Password to use to log in via telnet with.") |
| 1803 | 1805 | ||
| 1806 | (defun nntp-service-to-port (svc) | ||
| 1807 | (cond | ||
| 1808 | ((integerp svc) (number-to-string svc)) | ||
| 1809 | ((string-match "\\`[[:digit:]]\\'" svc) svc) | ||
| 1810 | (t | ||
| 1811 | (with-temp-buffer | ||
| 1812 | (ignore-errors (insert-file-contents "/etc/services")) | ||
| 1813 | (goto-char (point-min)) | ||
| 1814 | (if (re-search-forward (concat "^" (regexp-quote svc) | ||
| 1815 | "[ \t]+\\([[:digit:]]+\\)/tcp")) | ||
| 1816 | (match-string 1) | ||
| 1817 | svc))))) | ||
| 1818 | |||
| 1804 | (defun nntp-open-telnet (buffer) | 1819 | (defun nntp-open-telnet (buffer) |
| 1805 | (save-excursion | 1820 | (with-current-buffer buffer |
| 1806 | (set-buffer buffer) | ||
| 1807 | (erase-buffer) | 1821 | (erase-buffer) |
| 1808 | (let ((proc (apply | 1822 | (let ((proc (apply |
| 1809 | 'start-process | 1823 | 'start-process |
| @@ -1859,8 +1873,7 @@ via telnet.") | |||
| 1859 | (apply 'start-process | 1873 | (apply 'start-process |
| 1860 | "nntpd" buffer nntp-rlogin-program nntp-address | 1874 | "nntpd" buffer nntp-rlogin-program nntp-address |
| 1861 | nntp-rlogin-parameters)))) | 1875 | nntp-rlogin-parameters)))) |
| 1862 | (save-excursion | 1876 | (with-current-buffer buffer |
| 1863 | (set-buffer buffer) | ||
| 1864 | (nntp-wait-for-string "^\r*20[01]") | 1877 | (nntp-wait-for-string "^\r*20[01]") |
| 1865 | (beginning-of-line) | 1878 | (beginning-of-line) |
| 1866 | (delete-region (point-min) (point)) | 1879 | (delete-region (point-min) (point)) |
| @@ -1873,7 +1886,7 @@ via telnet.") | |||
| 1873 | 1886 | ||
| 1874 | (defun nntp-open-telnet-stream (buffer) | 1887 | (defun nntp-open-telnet-stream (buffer) |
| 1875 | "Open a nntp connection by telnet'ing the news server. | 1888 | "Open a nntp connection by telnet'ing the news server. |
| 1876 | `nntp-open-via-netcat' is recommended in place of this function | 1889 | `nntp-open-netcat-stream' is recommended in place of this function |
| 1877 | because it is more reliable. | 1890 | because it is more reliable. |
| 1878 | 1891 | ||
| 1879 | Please refer to the following variables to customize the connection: | 1892 | Please refer to the following variables to customize the connection: |
| @@ -1886,9 +1899,7 @@ Please refer to the following variables to customize the connection: | |||
| 1886 | (let ((command `(,nntp-telnet-command | 1899 | (let ((command `(,nntp-telnet-command |
| 1887 | ,@nntp-telnet-switches | 1900 | ,@nntp-telnet-switches |
| 1888 | ,nntp-address | 1901 | ,nntp-address |
| 1889 | ,(if (integerp nntp-port-number) | 1902 | ,(nntp-service-to-port nntp-port-number))) |
| 1890 | (number-to-string nntp-port-number) | ||
| 1891 | nntp-port-number))) | ||
| 1892 | proc) | 1903 | proc) |
| 1893 | (and nntp-pre-command | 1904 | (and nntp-pre-command |
| 1894 | (push nntp-pre-command command)) | 1905 | (push nntp-pre-command command)) |
| @@ -1932,9 +1943,7 @@ Please refer to the following variables to customize the connection: | |||
| 1932 | (with-current-buffer buffer | 1943 | (with-current-buffer buffer |
| 1933 | (nntp-wait-for-string "^r?telnet") | 1944 | (nntp-wait-for-string "^r?telnet") |
| 1934 | (process-send-string proc (concat "open " nntp-address " " | 1945 | (process-send-string proc (concat "open " nntp-address " " |
| 1935 | (if (integerp nntp-port-number) | 1946 | (nntp-service-to-port nntp-port-number) |
| 1936 | (number-to-string nntp-port-number) | ||
| 1937 | nntp-port-number) | ||
| 1938 | "\n")) | 1947 | "\n")) |
| 1939 | (nntp-wait-for-string "^\r*20[01]") | 1948 | (nntp-wait-for-string "^\r*20[01]") |
| 1940 | (beginning-of-line) | 1949 | (beginning-of-line) |
| @@ -1960,26 +1969,46 @@ Please refer to the following variables to customize the connection: | |||
| 1960 | - `nntp-via-rlogin-command-switches', | 1969 | - `nntp-via-rlogin-command-switches', |
| 1961 | - `nntp-via-user-name', | 1970 | - `nntp-via-user-name', |
| 1962 | - `nntp-via-address', | 1971 | - `nntp-via-address', |
| 1963 | - `nntp-via-netcat-command', | 1972 | - `nntp-netcat-command', |
| 1964 | - `nntp-via-netcat-switches', | 1973 | - `nntp-netcat-switches', |
| 1965 | - `nntp-address', | 1974 | - `nntp-address', |
| 1966 | - `nntp-port-number', | 1975 | - `nntp-port-number'." |
| 1967 | - `nntp-end-of-line'." | ||
| 1968 | (let ((command `(,@(when nntp-pre-command | 1976 | (let ((command `(,@(when nntp-pre-command |
| 1969 | (list nntp-pre-command)) | 1977 | (list nntp-pre-command)) |
| 1970 | ,nntp-via-rlogin-command | 1978 | ,nntp-via-rlogin-command |
| 1971 | ,@(when nntp-via-rlogin-command-switches | 1979 | ,@nntp-via-rlogin-command-switches |
| 1972 | nntp-via-rlogin-command-switches) | ||
| 1973 | ,@(when nntp-via-user-name | 1980 | ,@(when nntp-via-user-name |
| 1974 | (list "-l" nntp-via-user-name)) | 1981 | (list "-l" nntp-via-user-name)) |
| 1975 | ,nntp-via-address | 1982 | ,nntp-via-address |
| 1976 | ,nntp-via-netcat-command | 1983 | ,nntp-netcat-command |
| 1977 | ,@nntp-via-netcat-switches | 1984 | ,@nntp-netcat-switches |
| 1978 | ,nntp-address | 1985 | ,nntp-address |
| 1979 | ,(if (integerp nntp-port-number) | 1986 | ,(nntp-service-to-port nntp-port-number)))) |
| 1980 | (number-to-string nntp-port-number) | 1987 | ;; A non-nil connection type results in mightily odd behavior where |
| 1981 | nntp-port-number)))) | 1988 | ;; (process-send-string proc "\^M") ends up sending a "\n" to the |
| 1982 | (apply 'start-process "nntpd" buffer command))) | 1989 | ;; ssh process. --Stef |
| 1990 | ;; Also a nil connection allow ssh-askpass to work under X11. | ||
| 1991 | (let ((process-connection-type nil)) | ||
| 1992 | (apply 'start-process "nntpd" buffer command)))) | ||
| 1993 | |||
| 1994 | (defun nntp-open-netcat-stream (buffer) | ||
| 1995 | "Open a connection to an nntp server through netcat. | ||
| 1996 | I.e. use the `nc' command rather than Emacs's builtin networking code. | ||
| 1997 | |||
| 1998 | Please refer to the following variables to customize the connection: | ||
| 1999 | - `nntp-pre-command', | ||
| 2000 | - `nntp-netcat-command', | ||
| 2001 | - `nntp-netcat-switches', | ||
| 2002 | - `nntp-address', | ||
| 2003 | - `nntp-port-number'." | ||
| 2004 | (let ((command `(,nntp-netcat-command | ||
| 2005 | ,@nntp-netcat-switches | ||
| 2006 | ,nntp-address | ||
| 2007 | ,(nntp-service-to-port nntp-port-number)))) | ||
| 2008 | (and nntp-pre-command (push nntp-pre-command command)) | ||
| 2009 | (let ((process-connection-type nil)) ;See `nntp-open-via-rlogin-and-netcat'. | ||
| 2010 | (apply 'start-process "nntpd" buffer command)))) | ||
| 2011 | |||
| 1983 | 2012 | ||
| 1984 | (defun nntp-open-via-telnet-and-telnet (buffer) | 2013 | (defun nntp-open-via-telnet-and-telnet (buffer) |
| 1985 | "Open a connection to an nntp server through an intermediate host. | 2014 | "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: | |||
| 2037 | ,nntp-telnet-command | 2066 | ,nntp-telnet-command |
| 2038 | ,@nntp-telnet-switches | 2067 | ,@nntp-telnet-switches |
| 2039 | ,nntp-address | 2068 | ,nntp-address |
| 2040 | ,(if (integerp nntp-port-number) | 2069 | ,(nntp-service-to-port nntp-port-number)))) |
| 2041 | (number-to-string nntp-port-number) | ||
| 2042 | nntp-port-number)))) | ||
| 2043 | (process-send-string proc | 2070 | (process-send-string proc |
| 2044 | (concat (mapconcat 'identity | 2071 | (concat (mapconcat 'identity |
| 2045 | real-telnet-command " ") | 2072 | real-telnet-command " ") |