diff options
| author | Emilio C. Lopes | 2019-06-25 23:40:22 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-06-25 23:40:22 +0200 |
| commit | 349b778dde7f583a92dd1531aef3ff5c336e9aee (patch) | |
| tree | df3222dc09c67893d9b79f97c82f52249f2cec8e | |
| parent | 52e17e53b7dbafb4877d98d99188c335db6a3b5b (diff) | |
| download | emacs-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
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/net/telnet.el | 14 |
2 files changed, 19 insertions, 0 deletions
| @@ -475,6 +475,11 @@ current and the previous or the next line, as before. | |||
| 475 | 475 | ||
| 476 | * Changes in Specialized Modes and Packages in Emacs 27.1 | 476 | * Changes in Specialized Modes and Packages in Emacs 27.1 |
| 477 | 477 | ||
| 478 | --- | ||
| 479 | ** telnet-mode | ||
| 480 | *** Reverting a buffer in `telnet-mode' will restart a closed | ||
| 481 | connection. | ||
| 482 | |||
| 478 | ** goto-addr | 483 | ** goto-addr |
| 479 | *** A way to more conveniently specify what URI address schemes that | 484 | *** A way to more conveniently specify what URI address schemes that |
| 480 | should be ignored have been added via the | 485 | should be ignored have been added via the |
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. | |||
| 95 | Should be set to the number of terminal writes telnet will make | 95 | Should be set to the number of terminal writes telnet will make |
| 96 | rejecting one login and prompting again for a username and password.") | 96 | rejecting 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. | |||
| 240 | There is a variable `telnet-interrupt-string' which is the character | 252 | There is a variable `telnet-interrupt-string' which is the character |
| 241 | sent to try to stop execution of a job on the remote host. | 253 | sent to try to stop execution of a job on the remote host. |
| 242 | Data is sent to the remote host when RET is typed." | 254 | Data 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) |