aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/net
diff options
context:
space:
mode:
authorKim F. Storm2004-04-21 21:42:06 +0000
committerKim F. Storm2004-04-21 21:42:06 +0000
commit8fb5d2f1d901a7793797c82f27c74d561664c1db (patch)
treeb41ac5f204287c25d639e3fc1e3a97b1652c2681 /lisp/net
parentd88beab585b2c1b0c4b1f624780d228da92b0114 (diff)
downloademacs-8fb5d2f1d901a7793797c82f27c74d561664c1db.tar.gz
emacs-8fb5d2f1d901a7793797c82f27c74d561664c1db.zip
(telnet): Add optional port arg.
Diffstat (limited to 'lisp/net')
-rw-r--r--lisp/net/telnet.el20
1 files changed, 16 insertions, 4 deletions
diff --git a/lisp/net/telnet.el b/lisp/net/telnet.el
index dac6f228cd6..d42c4335daa 100644
--- a/lisp/net/telnet.el
+++ b/lisp/net/telnet.el
@@ -197,18 +197,28 @@ rejecting one login and prompting again for a username and password.")
197;;;###autoload (add-hook 'same-window-regexps "\\*telnet-.*\\*\\(\\|<[0-9]+>\\)") 197;;;###autoload (add-hook 'same-window-regexps "\\*telnet-.*\\*\\(\\|<[0-9]+>\\)")
198 198
199;;;###autoload 199;;;###autoload
200(defun telnet (host) 200(defun telnet (host &optional port)
201 "Open a network login connection to host named HOST (a string). 201 "Open a network login connection to host named HOST (a string).
202Optional arg PORT specifies alternative port to connect to.
203Interactively, use \\[universal-argument] prefix to be prompted for port number.
204
202Communication with HOST is recorded in a buffer `*PROGRAM-HOST*' 205Communication with HOST is recorded in a buffer `*PROGRAM-HOST*'
203where PROGRAM is the telnet program being used. This program 206where PROGRAM is the telnet program being used. This program
204is controlled by the contents of the global variable `telnet-host-properties', 207is controlled by the contents of the global variable `telnet-host-properties',
205falling back on the value of the global variable `telnet-program'. 208falling back on the value of the global variable `telnet-program'.
206Normally input is edited in Emacs and sent a line at a time." 209Normally input is edited in Emacs and sent a line at a time."
207 (interactive "sOpen connection to host: ") 210 (interactive (list (read-string "Open connection to host: ")
211 (cond
212 ((null current-prefix-arg) nil)
213 ((consp current-prefix-arg) (read-string "Port: "))
214 (t (prefix-numeric-value current-prefix-arg)))))
215 (if (and port (numberp port))
216 (setq port (int-to-string port)))
208 (let* ((comint-delimiter-argument-list '(?\ ?\t)) 217 (let* ((comint-delimiter-argument-list '(?\ ?\t))
209 (properties (cdr (assoc host telnet-host-properties))) 218 (properties (cdr (assoc host telnet-host-properties)))
210 (telnet-program (if properties (car properties) telnet-program)) 219 (telnet-program (if properties (car properties) telnet-program))
211 (name (concat telnet-program "-" (comint-arguments host 0 nil) )) 220 (hname (if port (concat host ":" port) host))
221 (name (concat telnet-program "-" (comint-arguments hname 0 nil) ))
212 (buffer (get-buffer (concat "*" name "*"))) 222 (buffer (get-buffer (concat "*" name "*")))
213 (telnet-options (if (cdr properties) (cons "-l" (cdr properties)))) 223 (telnet-options (if (cdr properties) (cons "-l" (cdr properties))))
214 process) 224 process)
@@ -221,7 +231,9 @@ Normally input is edited in Emacs and sent a line at a time."
221 ;; Don't send the `open' cmd till telnet is ready for it. 231 ;; Don't send the `open' cmd till telnet is ready for it.
222 (accept-process-output process) 232 (accept-process-output process)
223 (erase-buffer) 233 (erase-buffer)
224 (send-string process (concat "open " host "\n")) 234 (send-string process (concat "open " host
235 (if port " " "") (or port "")
236 "\n"))
225 (telnet-mode) 237 (telnet-mode)
226 (setq comint-input-sender 'telnet-simple-send) 238 (setq comint-input-sender 'telnet-simple-send)
227 (setq telnet-count telnet-initial-count)))) 239 (setq telnet-count telnet-initial-count))))