From: Emilio Lopes <eclig@gmx.net>
To: 18312@debbugs.gnu.org
Subject: bug#18312: PATCH: using `revert-buffer' to restart a closed telnet session.
Date: Thu, 21 Aug 2014 17:12:51 +0200 [thread overview]
Message-ID: <CANiPZaBHjQsm6-edozcK1UzaDxXHD=D6ukzKkzJZ7JZQDqAWkg@mail.gmail.com> (raw)
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
next reply other threads:[~2014-08-21 15:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-21 15:12 Emilio Lopes [this message]
2016-02-23 12:17 ` bug#18312: PATCH: using `revert-buffer' to restart a closed telnet session 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANiPZaBHjQsm6-edozcK1UzaDxXHD=D6ukzKkzJZ7JZQDqAWkg@mail.gmail.com' \
--to=eclig@gmx.net \
--cc=18312@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).