aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorEmilio C. Lopes2019-06-25 23:40:22 +0200
committerLars Ingebrigtsen2019-06-25 23:40:22 +0200
commit349b778dde7f583a92dd1531aef3ff5c336e9aee (patch)
treedf3222dc09c67893d9b79f97c82f52249f2cec8e /lisp
parent52e17e53b7dbafb4877d98d99188c335db6a3b5b (diff)
downloademacs-349b778dde7f583a92dd1531aef3ff5c336e9aee.tar.gz
emacs-349b778dde7f583a92dd1531aef3ff5c336e9aee.zip
Support opening a new connection when reverting a telnet buffer
* net/telnet.el (telnet-connect-command): New variable. (telnet-revert-buffer): New function. (telnet-mode): Use `telnet-revert-buffer' as `revert-buffer-function'. (telnet, rsh): Set `telnet-connect-command' accordingly (bug#18312). Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/telnet.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lisp/net/telnet.el b/lisp/net/telnet.el
index cf3634f7d92..5d23ee3dce7 100644
--- a/lisp/net/telnet.el
+++ b/lisp/net/telnet.el
@@ -95,11 +95,22 @@ After this many passes, we stop looking for initial setup data.
95Should be set to the number of terminal writes telnet will make 95Should be set to the number of terminal writes telnet will make
96rejecting one login and prompting again for a username and password.") 96rejecting one login and prompting again for a username and password.")
97 97
98(defvar telnet-connect-command nil
99 "Command used to start the `telnet' (or `rsh') connection.")
100
98(defun telnet-interrupt-subjob () 101(defun telnet-interrupt-subjob ()
99 "Interrupt the program running through telnet on the remote host." 102 "Interrupt the program running through telnet on the remote host."
100 (interactive) 103 (interactive)
101 (process-send-string nil telnet-interrupt-string)) 104 (process-send-string nil telnet-interrupt-string))
102 105
106(defun telnet-revert-buffer (ignore-auto noconfirm)
107 (if buffer-file-name
108 (let (revert-buffer-function)
109 (revert-buffer ignore-auto noconfirm))
110 (if (or noconfirm
111 (yes-or-no-p (format "Restart connection? ")))
112 (apply telnet-connect-command))))
113
103(defun telnet-c-z () 114(defun telnet-c-z ()
104 (interactive) 115 (interactive)
105 (process-send-string nil "\C-z")) 116 (process-send-string nil "\C-z"))
@@ -229,6 +240,7 @@ Normally input is edited in Emacs and sent a line at a time."
229 (if port " " "") (or port "") 240 (if port " " "") (or port "")
230 "\n")) 241 "\n"))
231 (telnet-mode) 242 (telnet-mode)
243 (setq-local telnet-connect-command (list 'telnet host port))
232 (setq comint-input-sender 'telnet-simple-send) 244 (setq comint-input-sender 'telnet-simple-send)
233 (setq telnet-count telnet-initial-count)))) 245 (setq telnet-count telnet-initial-count))))
234 246
@@ -240,6 +252,7 @@ It has most of the same commands as comint-mode.
240There is a variable `telnet-interrupt-string' which is the character 252There is a variable `telnet-interrupt-string' which is the character
241sent to try to stop execution of a job on the remote host. 253sent to try to stop execution of a job on the remote host.
242Data is sent to the remote host when RET is typed." 254Data is sent to the remote host when RET is typed."
255 (setq-local revert-buffer-function 'telnet-revert-buffer)
243 (set (make-local-variable 'window-point-insertion-type) t) 256 (set (make-local-variable 'window-point-insertion-type) t)
244 (set (make-local-variable 'comint-prompt-regexp) telnet-prompt-pattern) 257 (set (make-local-variable 'comint-prompt-regexp) telnet-prompt-pattern)
245 (set (make-local-variable 'comint-use-prompt-regexp) t)) 258 (set (make-local-variable 'comint-use-prompt-regexp) t))
@@ -255,6 +268,7 @@ Normally input is edited in Emacs and sent a line at a time."
255 (switch-to-buffer (make-comint name remote-shell-program nil host)) 268 (switch-to-buffer (make-comint name remote-shell-program nil host))
256 (set-process-filter (get-process name) 'telnet-initial-filter) 269 (set-process-filter (get-process name) 'telnet-initial-filter)
257 (telnet-mode) 270 (telnet-mode)
271 (setq-local telnet-connect-command (list 'rsh host))
258 (setq telnet-count -16))) 272 (setq telnet-count -16)))
259 273
260(provide 'telnet) 274(provide 'telnet)