comparison lisp/comint/telnet.el @ 4:b82b59fe008d r19-15b3

Import from CVS: tag r19-15b3
author cvs
date Mon, 13 Aug 2007 08:46:56 +0200
parents 376386a54a3c
children 27bc7f280385
comparison
equal deleted inserted replaced
3:30df88044ec6 4:b82b59fe008d
1 ;;; telnet.el --- run a telnet session from within an Emacs buffer 1 ;;; telnet.el --- run a telnet session from within an Emacs buffer
2 2
3 ;;; Copyright (C) 1985, 1988, 1992, 1993, 1994 Free Software Foundation, Inc. 3 ;;; Copyright (C) 1985, 1988, 1992, 1994 Free Software Foundation, Inc.
4 4
5 ;; Author: William F. Schelter 5 ;; Author: William F. Schelter
6 ;; Keywords: comm, unix 6 ;; Keywords: comm, unix
7 ;; Maintainer: FSF 7 ;; Maintainer: FSF
8 8
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details. 19 ;; General Public License for more details.
20 20
21 ;; You should have received a copy of the GNU General Public License 21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free 22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 24 ;; 02111-1307, USA.
25 ;;; Synched up with: FSF 19.30. 25
26 ;;; Synched up with: FSF 19.34.
26 27
27 ;;; Commentary: 28 ;;; Commentary:
28 29
29 ;; This mode is intended to be used for telnet or rsh to a remode host; 30 ;; This mode is intended to be used for telnet or rsh to a remode host;
30 ;; `telnet' and `rsh' are the two entry points. Multiple telnet or rsh 31 ;; `telnet' and `rsh' are the two entry points. Multiple telnet or rsh
52 53
53 (require 'comint) 54 (require 'comint)
54 55
55 (defvar telnet-new-line "\r") 56 (defvar telnet-new-line "\r")
56 (defvar telnet-mode-map nil) 57 (defvar telnet-mode-map nil)
57 (make-variable-buffer-local 'telnet-new-line) 58 (defvar telnet-prompt-pattern "^[^#$%>\n]*[#$%>] *")
58 (defvar telnet-default-prompt-pattern "^[^#$%>\n]*[#$%>] *")
59 (defvar telnet-prompt-pattern telnet-default-prompt-pattern)
60 (defvar telnet-replace-c-g nil) 59 (defvar telnet-replace-c-g nil)
61 (make-variable-buffer-local 'telnet-replace-c-g) 60 (make-variable-buffer-local
62 (defvar telnet-remote-echoes t 61 (defvar telnet-remote-echoes t
63 "True if the telnet process will echo input.") 62 "True if the telnet process will echo input."))
64 (make-variable-buffer-local 'telnet-remote-echoes) 63 (make-variable-buffer-local
65 (defvar telnet-interrupt-string "\C-c" 64 (defvar telnet-interrupt-string "\C-c" "String sent by C-c."))
66 "String sent by C-c.")
67 (make-variable-buffer-local 'telnet-interrupt-string)
68 65
69 (defvar telnet-count 0 66 (defvar telnet-count 0
70 "Number of output strings read from the telnet process 67 "Number of output strings read from the telnet process
71 while looking for the initial password.") 68 while looking for the initial password.")
72 (make-variable-buffer-local 'telnet-count) 69 (make-variable-buffer-local 'telnet-count)
91 88
92 (defun telnet-c-z () 89 (defun telnet-c-z ()
93 (interactive) 90 (interactive)
94 (process-send-string nil "\C-z")) 91 (process-send-string nil "\C-z"))
95 92
93 ;; XEmacs change (Keep telnet- prefix)
96 (defun telnet-send-process-next-char () 94 (defun telnet-send-process-next-char ()
97 (interactive) 95 (interactive)
98 (process-send-string nil 96 (process-send-string nil
99 (char-to-string 97 (char-to-string
100 (let ((inhibit-quit t)) 98 (let ((inhibit-quit t))
102 (setq quit-flag nil)))))) 100 (setq quit-flag nil))))))
103 101
104 ; initialization on first load. 102 ; initialization on first load.
105 (if telnet-mode-map 103 (if telnet-mode-map
106 nil 104 nil
107 (progn 105 (setq telnet-mode-map (nconc (make-sparse-keymap) comint-mode-map))
108 (setq telnet-mode-map (make-sparse-keymap)) 106 (define-key telnet-mode-map "\C-m" 'telnet-send-input)
109 (set-keymap-name telnet-mode-map 'telnet-mode-map) 107 ; (define-key telnet-mode-map "\C-j" 'telnet-send-input)
110 (set-keymap-parents telnet-mode-map (list comint-mode-map)) 108 (define-key telnet-mode-map "\C-c\C-q" 'send-process-next-char)
111 (define-key telnet-mode-map "\C-m" 'telnet-send-input) 109 (define-key telnet-mode-map "\C-c\C-c" 'telnet-interrupt-subjob)
112 ;;(define-key telnet-mode-map "\C-j" 'telnet-send-input) 110 (define-key telnet-mode-map "\C-c\C-z" 'telnet-c-z))
113 (define-key telnet-mode-map "\C-c\C-q" 'telnet-send-process-next-char)
114 (define-key telnet-mode-map "\C-c\C-c" 'telnet-interrupt-subjob)
115 (define-key telnet-mode-map "\C-c\C-z" 'telnet-c-z)))
116 111
117 ;;maybe should have a flag for when have found type 112 ;;maybe should have a flag for when have found type
118 (defun telnet-check-software-type-initialize (string) 113 (defun telnet-check-software-type-initialize (string)
119 "Tries to put correct initializations in. Needs work." 114 "Tries to put correct initializations in. Needs work."
120 (let ((case-fold-search t)) 115 (let ((case-fold-search t))
121 (cond ((string-match "unix" string) 116 (cond ((string-match "unix" string)
122 (setq telnet-prompt-pattern shell-prompt-pattern) 117 (setq telnet-prompt-pattern comint-prompt-pattern)
123 (setq telnet-new-line "\n")) 118 (setq telnet-new-line "\n"))
124 ((string-match "tops-20" string) ;;maybe add telnet-replace-c-g 119 ((string-match "tops-20" string) ;;maybe add telnet-replace-c-g
125 (setq telnet-prompt-pattern "[@>] *")) 120 (setq telnet-prompt-pattern "[@>] *"))
126 ((string-match "its" string) 121 ((string-match "its" string)
127 (setq telnet-prompt-pattern "^[^*>\n]*[*>] *")) 122 (setq telnet-prompt-pattern "^[^*>\n]*[*>] *"))