* Re: enhancement to M-x telnet
2004-04-15 16:54 enhancement to M-x telnet Kim F. Storm
@ 2004-04-15 15:45 ` Andreas Schwab
2004-04-16 10:43 ` Kim F. Storm
2004-04-16 9:01 ` Mario Lang
1 sibling, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2004-04-15 15:45 UTC (permalink / raw)
Cc: emacs-devel
storm@cua.dk (Kim F. Storm) writes:
> I frequently use telnet to check connections to other hosts, and as such I need
> to specify an alternative port number to connect to.
>
> The following patch allows you to append the port number to the hostname,
> e.g.
> M-x telnet RET gnu.org:80 RET
>
> An alternative interface would be to specify the port number as a numeric
> prefix arg, but that seems rather obscure IMO.
How about letting it read the port interactively when called with a prefix
arg? Or maybe C-u to read interactively, other numeric prefixes specify
the port directly. This would allow implementing completion on port
names.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 5+ messages in thread
* enhancement to M-x telnet
@ 2004-04-15 16:54 Kim F. Storm
2004-04-15 15:45 ` Andreas Schwab
2004-04-16 9:01 ` Mario Lang
0 siblings, 2 replies; 5+ messages in thread
From: Kim F. Storm @ 2004-04-15 16:54 UTC (permalink / raw)
I frequently use telnet to check connections to other hosts, and as such I need
to specify an alternative port number to connect to.
The following patch allows you to append the port number to the hostname,
e.g.
M-x telnet RET gnu.org:80 RET
An alternative interface would be to specify the port number as a numeric
prefix arg, but that seems rather obscure IMO.
Any objections to installing this patch?
*** telnet.el 17 Feb 2004 00:19:18 +0100 1.7
--- telnet.el 15 Apr 2004 18:49:40 +0200
***************
*** 197,214 ****
;;;###autoload (add-hook 'same-window-regexps "\\*telnet-.*\\*\\(\\|<[0-9]+>\\)")
;;;###autoload
! (defun telnet (host)
"Open a network login connection to host named HOST (a string).
Communication with HOST is recorded in a buffer `*PROGRAM-HOST*'
where PROGRAM is the telnet program being used. This program
is controlled by the contents of the global variable `telnet-host-properties',
falling back on the value of the global variable `telnet-program'.
Normally input is edited in Emacs and sent a line at a time."
(interactive "sOpen connection to host: ")
(let* ((comint-delimiter-argument-list '(?\ ?\t))
(properties (cdr (assoc host telnet-host-properties)))
(telnet-program (if properties (car properties) telnet-program))
! (name (concat telnet-program "-" (comint-arguments host 0 nil) ))
(buffer (get-buffer (concat "*" name "*")))
(telnet-options (if (cdr properties) (cons "-l" (cdr properties))))
process)
--- 197,224 ----
;;;###autoload (add-hook 'same-window-regexps "\\*telnet-.*\\*\\(\\|<[0-9]+>\\)")
;;;###autoload
! (defun telnet (host &optional port)
"Open a network login connection to host named HOST (a string).
+ Optional arg PORT specifies alternative port to connect to. Interactively,
+ the port numbers is specified by appending :PORT to the host name.
Communication with HOST is recorded in a buffer `*PROGRAM-HOST*'
where PROGRAM is the telnet program being used. This program
is controlled by the contents of the global variable `telnet-host-properties',
falling back on the value of the global variable `telnet-program'.
Normally input is edited in Emacs and sent a line at a time."
(interactive "sOpen connection to host: ")
+ (if port
+ (if (numberp port)
+ (setq port (int-to-string port)))
+ (let ((hp (split-string host ": " t)))
+ (if (> (length hp) 1)
+ (setq host (car hp)
+ port (cadr hp)))))
(let* ((comint-delimiter-argument-list '(?\ ?\t))
(properties (cdr (assoc host telnet-host-properties)))
(telnet-program (if properties (car properties) telnet-program))
! (hname (if port (concat host ":" port) host))
! (name (concat telnet-program "-" (comint-arguments hname 0 nil) ))
(buffer (get-buffer (concat "*" name "*")))
(telnet-options (if (cdr properties) (cons "-l" (cdr properties))))
process)
***************
*** 221,227 ****
;; Don't send the `open' cmd till telnet is ready for it.
(accept-process-output process)
(erase-buffer)
! (send-string process (concat "open " host "\n"))
(telnet-mode)
(setq comint-input-sender 'telnet-simple-send)
(setq telnet-count telnet-initial-count))))
--- 231,239 ----
;; Don't send the `open' cmd till telnet is ready for it.
(accept-process-output process)
(erase-buffer)
! (send-string process (concat "open " host
! (if port " " "") (or port "")
! "\n"))
(telnet-mode)
(setq comint-input-sender 'telnet-simple-send)
(setq telnet-count telnet-initial-count))))
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: enhancement to M-x telnet
2004-04-15 16:54 enhancement to M-x telnet Kim F. Storm
2004-04-15 15:45 ` Andreas Schwab
@ 2004-04-16 9:01 ` Mario Lang
2004-04-16 13:35 ` Kim F. Storm
1 sibling, 1 reply; 5+ messages in thread
From: Mario Lang @ 2004-04-16 9:01 UTC (permalink / raw)
storm@cua.dk (Kim F. Storm) writes:
> I frequently use telnet to check connections to other hosts, and as such I
> need to specify an alternative port number to connect to.
>
> The following patch allows you to append the port number to the hostname,
> e.g.
> M-x telnet RET gnu.org:80 RET
Have you thought about the implication of IPv6 an this implementation?
I know that Emacs's process.c can actually handle IPv6 connections
already. What if a user wants to enter an IPv6 address.
Your current code will do something very wrong in this case I think.
> An alternative interface would be to specify the port number as a numeric
> prefix arg, but that seems rather obscure IMO.
What about something like
(interactive (list (read-string "Host: ")
(if current-prefix-arg
(read-string "Port: ")
"23")))
--
CYa,
Mario | Debian Developer <URL:http://debian.org/>
| Get my public key via finger mlang@db.debian.org
| 1024D/7FC1A0854909BCCDBE6C102DDFFC022A6B113E44
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: enhancement to M-x telnet
2004-04-15 15:45 ` Andreas Schwab
@ 2004-04-16 10:43 ` Kim F. Storm
0 siblings, 0 replies; 5+ messages in thread
From: Kim F. Storm @ 2004-04-16 10:43 UTC (permalink / raw)
Cc: emacs-devel
Andreas Schwab <schwab@suse.de> writes:
> storm@cua.dk (Kim F. Storm) writes:
>
> > I frequently use telnet to check connections to other hosts, and as such I need
> > to specify an alternative port number to connect to.
> >
> > The following patch allows you to append the port number to the hostname,
> > e.g.
> > M-x telnet RET gnu.org:80 RET
> >
> > An alternative interface would be to specify the port number as a numeric
> > prefix arg, but that seems rather obscure IMO.
>
> How about letting it read the port interactively when called with a prefix
> arg? Or maybe C-u to read interactively, other numeric prefixes specify
> the port directly. This would allow implementing completion on port
> names.
Yes, that's also a viable approach... (even without port name completion).
WDOT?
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: enhancement to M-x telnet
2004-04-16 9:01 ` Mario Lang
@ 2004-04-16 13:35 ` Kim F. Storm
0 siblings, 0 replies; 5+ messages in thread
From: Kim F. Storm @ 2004-04-16 13:35 UTC (permalink / raw)
Thanks to all for your suggestions.
Here is an new implementation, using a numeric prefix as port number,
and C-u prefix to request function to prompt for port number.
*** telnet.el 17 Feb 2004 00:19:18 +0100 1.7
--- telnet.el 16 Apr 2004 15:31:25 +0200
***************
*** 197,214 ****
;;;###autoload (add-hook 'same-window-regexps "\\*telnet-.*\\*\\(\\|<[0-9]+>\\)")
;;;###autoload
! (defun telnet (host)
"Open a network login connection to host named HOST (a string).
Communication with HOST is recorded in a buffer `*PROGRAM-HOST*'
where PROGRAM is the telnet program being used. This program
is controlled by the contents of the global variable `telnet-host-properties',
falling back on the value of the global variable `telnet-program'.
Normally input is edited in Emacs and sent a line at a time."
! (interactive "sOpen connection to host: ")
(let* ((comint-delimiter-argument-list '(?\ ?\t))
(properties (cdr (assoc host telnet-host-properties)))
(telnet-program (if properties (car properties) telnet-program))
! (name (concat telnet-program "-" (comint-arguments host 0 nil) ))
(buffer (get-buffer (concat "*" name "*")))
(telnet-options (if (cdr properties) (cons "-l" (cdr properties))))
process)
--- 197,224 ----
;;;###autoload (add-hook 'same-window-regexps "\\*telnet-.*\\*\\(\\|<[0-9]+>\\)")
;;;###autoload
! (defun telnet (host &optional port)
"Open a network login connection to host named HOST (a string).
+ Optional arg PORT specifies alternative port to connect to.
+ Interactively, use \\[universal-argument] prefix to be prompted for port number.
+
Communication with HOST is recorded in a buffer `*PROGRAM-HOST*'
where PROGRAM is the telnet program being used. This program
is controlled by the contents of the global variable `telnet-host-properties',
falling back on the value of the global variable `telnet-program'.
Normally input is edited in Emacs and sent a line at a time."
! (interactive (list (read-string "Open connection to host: ")
! (cond
! ((null current-prefix-arg) nil)
! ((consp current-prefix-arg) (read-string "Port: "))
! (t (prefix-numeric-value current-prefix-arg)))))
! (if (and port (numberp port))
! (setq port (int-to-string port)))
(let* ((comint-delimiter-argument-list '(?\ ?\t))
(properties (cdr (assoc host telnet-host-properties)))
(telnet-program (if properties (car properties) telnet-program))
! (hname (if port (concat host ":" port) host))
! (name (concat telnet-program "-" (comint-arguments hname 0 nil) ))
(buffer (get-buffer (concat "*" name "*")))
(telnet-options (if (cdr properties) (cons "-l" (cdr properties))))
process)
***************
*** 221,227 ****
;; Don't send the `open' cmd till telnet is ready for it.
(accept-process-output process)
(erase-buffer)
! (send-string process (concat "open " host "\n"))
(telnet-mode)
(setq comint-input-sender 'telnet-simple-send)
(setq telnet-count telnet-initial-count))))
--- 231,239 ----
;; Don't send the `open' cmd till telnet is ready for it.
(accept-process-output process)
(erase-buffer)
! (send-string process (concat "open " host
! (if port " " "") (or port "")
! "\n"))
(telnet-mode)
(setq comint-input-sender 'telnet-simple-send)
(setq telnet-count telnet-initial-count))))
--
Kim F. Storm <storm@cua.dk> http://www.cua.dk
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-04-16 13:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-15 16:54 enhancement to M-x telnet Kim F. Storm
2004-04-15 15:45 ` Andreas Schwab
2004-04-16 10:43 ` Kim F. Storm
2004-04-16 9:01 ` Mario Lang
2004-04-16 13:35 ` Kim F. Storm
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.