unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#18312: PATCH: using `revert-buffer' to restart a closed telnet session.
@ 2014-08-21 15:12 Emilio Lopes
  2016-02-23 12:17 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 15+ messages in thread
From: Emilio Lopes @ 2014-08-21 15:12 UTC (permalink / raw)
  To: 18312

The following patch allows one to use `revert-buffer' to restart a
closed telnet/rsh connection.  It also defines `ssh' as an alias for
`rsh' since `remote-shell-program' is set to `ssh' by default anyway.

Regards

 Emílio

--- lisp/ChangeLog    2014-08-21 08:40:29 +0000
+++ lisp/ChangeLog    2014-08-21 14:57:57 +0000
@@ -1,3 +1,9 @@
+2014-08-21  Emilio C. Lopes  <eclig@gmx.net>
+
+    * 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' according to their
call parameters.
 2014-08-21  Martin Rudalics  <rudalics@gmx.at>

     * window.el (window--side-window-p): New function.

=== modified file 'lisp/net/telnet.el'
--- lisp/net/telnet.el    2014-02-10 01:34:22 +0000
+++ lisp/net/telnet.el    2014-08-21 14:53:17 +0000
@@ -95,6 +95,9 @@
 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)
@@ -190,6 +193,13 @@
       (delete-region comint-last-input-start
              comint-last-input-end)))

+(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))))
+
 ;;;###autoload
 (defun telnet (host &optional port)
   "Open a network login connection to host named HOST (a string).
@@ -229,6 +239,7 @@
                                            (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 +251,7 @@
 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."
+  (set (make-local-variable '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,8 +267,11 @@
     (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)))

+(defalias 'ssh 'rsh)
+
 (provide 'telnet)

 ;;; telnet.el ends here





^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-07-01  8:09 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-21 15:12 bug#18312: PATCH: using `revert-buffer' to restart a closed telnet session Emilio Lopes
2016-02-23 12:17 ` Lars Ingebrigtsen
2016-02-25 14:38   ` Emilio Lopes
2016-02-26  5:54     ` Lars Ingebrigtsen
2019-06-25 21:40       ` Lars Ingebrigtsen
2019-06-27  2:46         ` Richard Stallman
2019-06-27  7:48           ` Michael Albinus
2019-06-27  8:00           ` Andreas Schwab
2019-06-28  2:52             ` Richard Stallman
2019-06-28  8:34               ` Robert Pluim
2019-07-01  8:09               ` Andreas Schwab
2019-06-27  8:08           ` Robert Pluim
2019-06-28  2:52             ` Richard Stallman
2019-06-28  7:50               ` Robert Pluim
2019-06-29  3:18                 ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).