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
This commit is contained in:
Emilio C. Lopes 2019-06-25 23:40:22 +02:00 committed by Lars Ingebrigtsen
parent 52e17e53b7
commit 349b778dde
2 changed files with 19 additions and 0 deletions

View file

@ -475,6 +475,11 @@ current and the previous or the next line, as before.
* Changes in Specialized Modes and Packages in Emacs 27.1
---
** telnet-mode
*** Reverting a buffer in `telnet-mode' will restart a closed
connection.
** goto-addr
*** A way to more conveniently specify what URI address schemes that
should be ignored have been added via the

View file

@ -95,11 +95,22 @@ After this many passes, we stop looking for initial setup data.
Should be set to the number of terminal writes telnet will make
rejecting one login and prompting again for a username and password.")
(defvar telnet-connect-command nil
"Command used to start the `telnet' (or `rsh') connection.")
(defun telnet-interrupt-subjob ()
"Interrupt the program running through telnet on the remote host."
(interactive)
(process-send-string nil telnet-interrupt-string))
(defun telnet-revert-buffer (ignore-auto noconfirm)
(if buffer-file-name
(let (revert-buffer-function)
(revert-buffer ignore-auto noconfirm))
(if (or noconfirm
(yes-or-no-p (format "Restart connection? ")))
(apply telnet-connect-command))))
(defun telnet-c-z ()
(interactive)
(process-send-string nil "\C-z"))
@ -229,6 +240,7 @@ Normally input is edited in Emacs and sent a line at a time."
(if port " " "") (or port "")
"\n"))
(telnet-mode)
(setq-local telnet-connect-command (list 'telnet host port))
(setq comint-input-sender 'telnet-simple-send)
(setq telnet-count telnet-initial-count))))
@ -240,6 +252,7 @@ It has most of the same commands as comint-mode.
There is a variable `telnet-interrupt-string' which is the character
sent to try to stop execution of a job on the remote host.
Data is sent to the remote host when RET is typed."
(setq-local revert-buffer-function 'telnet-revert-buffer)
(set (make-local-variable 'window-point-insertion-type) t)
(set (make-local-variable 'comint-prompt-regexp) telnet-prompt-pattern)
(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."
(switch-to-buffer (make-comint name remote-shell-program nil host))
(set-process-filter (get-process name) 'telnet-initial-filter)
(telnet-mode)
(setq-local telnet-connect-command (list 'rsh host))
(setq telnet-count -16)))
(provide 'telnet)