From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: enhancement to M-x telnet Date: 15 Apr 2004 18:54:27 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1082041718 21196 80.91.224.253 (15 Apr 2004 15:08:38 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 15 Apr 2004 15:08:38 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Thu Apr 15 17:08:30 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BE8Te-0005Wd-00 for ; Thu, 15 Apr 2004 17:08:30 +0200 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BE8Te-0005PL-00 for ; Thu, 15 Apr 2004 17:08:30 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BE8Qk-000310-Ps for emacs-devel@quimby.gnus.org; Thu, 15 Apr 2004 11:05:30 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BE8Kj-0001Eq-5s for emacs-devel@gnu.org; Thu, 15 Apr 2004 10:59:17 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BE8H2-0000YP-5P for emacs-devel@gnu.org; Thu, 15 Apr 2004 10:55:59 -0400 Original-Received: from [195.41.46.237] (helo=pfepc.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.30) id 1BE8H0-0000XY-C6 for emacs-devel@gnu.org; Thu, 15 Apr 2004 10:55:26 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepc.post.tele.dk (Postfix) with SMTP id 2ACDF26281F for ; Thu, 15 Apr 2004 16:54:49 +0200 (CEST) Original-To: emacs-devel@gnu.org Original-Lines: 86 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:21696 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:21696 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 http://www.cua.dk