emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 349b778: Support opening a new connection when reve


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 349b778: Support opening a new connection when reverting a telnet buffer
Date: Tue, 25 Jun 2019 17:41:05 -0400 (EDT)

branch: master
commit 349b778dde7f583a92dd1531aef3ff5c336e9aee
Author: Emilio C. Lopes <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    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
---
 etc/NEWS           |  5 +++++
 lisp/net/telnet.el | 14 ++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index d237e4c..7de94a7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -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
diff --git a/lisp/net/telnet.el b/lisp/net/telnet.el
index cf3634f..5d23ee3 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.
 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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]