Commit 901249a3 authored by Richard M. Stallman's avatar Richard M. Stallman
Browse files

(telnet): If we already have a telnet to HOST, just switch buffers.

parent a569dbc3
...@@ -171,21 +171,24 @@ rejecting one login and prompting for the again for a username and password.") ...@@ -171,21 +171,24 @@ rejecting one login and prompting for the again for a username and password.")
comint-last-input-end))) comint-last-input-end)))
;;;###autoload ;;;###autoload
(defun telnet (arg) (defun telnet (host)
"Open a network login connection to host named HOST (a string). "Open a network login connection to host named HOST (a string).
Communication with HOST is recorded in a buffer *HOST-telnet*. Communication with HOST is recorded in a buffer *HOST-telnet*.
Normally input is edited in Emacs and sent a line at a time." Normally input is edited in Emacs and sent a line at a time."
(interactive "sOpen telnet connection to host: ") (interactive "sOpen telnet connection to host: ")
(let ((name (concat arg "-telnet" ))) (let* ((name (concat host "-telnet" ))
(switch-to-buffer (make-comint name "telnet")) (buffer (get-buffer (concat "*" name "*"))))
(set-process-filter (get-process name) 'telnet-initial-filter) (if (and buffer (get-buffer-process buffer))
;; Don't send the `open' cmd till telnet is ready for it. (switch-to-buffer (concat "*" name "*"))
(accept-process-output (get-process name)) (switch-to-buffer (make-comint name "telnet"))
(erase-buffer) (set-process-filter (get-process name) 'telnet-initial-filter)
(send-string name (concat "open " arg "\n")) ;; Don't send the `open' cmd till telnet is ready for it.
(telnet-mode) (accept-process-output (get-process name))
(setq comint-input-sender 'telnet-simple-send) (erase-buffer)
(setq telnet-count telnet-initial-count))) (send-string name (concat "open " host "\n"))
(telnet-mode)
(setq comint-input-sender 'telnet-simple-send)
(setq telnet-count telnet-initial-count))))
(defun telnet-mode () (defun telnet-mode ()
"This mode is for using telnet (or rsh) from a buffer to another host. "This mode is for using telnet (or rsh) from a buffer to another host.
...@@ -205,13 +208,13 @@ Data is sent to the remote host when RET is typed. ...@@ -205,13 +208,13 @@ Data is sent to the remote host when RET is typed.
(run-hooks 'telnet-mode-hook)) (run-hooks 'telnet-mode-hook))
;;;###autoload ;;;###autoload
(defun rsh (arg) (defun rsh (host)
"Open a network login connection to host named HOST (a string). "Open a network login connection to host named HOST (a string).
Communication with HOST is recorded in a buffer *HOST-rsh*. Communication with HOST is recorded in a buffer *HOST-rsh*.
Normally input is edited in Emacs and sent a line at a time." Normally input is edited in Emacs and sent a line at a time."
(interactive "sOpen rsh connection to host: ") (interactive "sOpen rsh connection to host: ")
(require 'shell) (require 'shell)
(let ((name (concat arg "-rsh" ))) (let ((name (concat host "-rsh" )))
(switch-to-buffer (make-comint name "rsh")) (switch-to-buffer (make-comint name "rsh"))
(set-process-filter (get-process name) 'telnet-initial-filter) (set-process-filter (get-process name) 'telnet-initial-filter)
(telnet-mode) (telnet-mode)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment