Mercurial > emacs
comparison lisp/telnet.el @ 5273:59fee4967e01
(telnet-filter): Rewrite, taken mostly from Lucid.
(telnet-prompt-pattern)
(telnet-check-software-type-initialize):
Don't let `telnet-prompt-pattern' match more than one line.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 23 Dec 1993 03:22:55 +0000 |
parents | 2d8ae66d6906 |
children | 65b2fa217aa0 |
comparison
equal
deleted
inserted
replaced
5272:00beab2bf9f0 | 5273:59fee4967e01 |
---|---|
49 | 49 |
50 (require 'comint) | 50 (require 'comint) |
51 | 51 |
52 (defvar telnet-new-line "\r") | 52 (defvar telnet-new-line "\r") |
53 (defvar telnet-mode-map nil) | 53 (defvar telnet-mode-map nil) |
54 (defvar telnet-prompt-pattern "^[^#$%>]*[#$%>] *") | 54 (defvar telnet-prompt-pattern "^[^#$%>\n]*[#$%>] *") |
55 (defvar telnet-replace-c-g nil) | 55 (defvar telnet-replace-c-g nil) |
56 (make-variable-buffer-local | 56 (make-variable-buffer-local |
57 (defvar telnet-remote-echoes t | 57 (defvar telnet-remote-echoes t |
58 "True if the telnet process will echo input.")) | 58 "True if the telnet process will echo input.")) |
59 (make-variable-buffer-local | 59 (make-variable-buffer-local |
113 (setq telnet-prompt-pattern comint-prompt-regexp) | 113 (setq telnet-prompt-pattern comint-prompt-regexp) |
114 (setq telnet-new-line "\n")) | 114 (setq telnet-new-line "\n")) |
115 ((string-match "tops-20" string) ;;maybe add telnet-replace-c-g | 115 ((string-match "tops-20" string) ;;maybe add telnet-replace-c-g |
116 (setq telnet-prompt-pattern "[@>]*")) | 116 (setq telnet-prompt-pattern "[@>]*")) |
117 ((string-match "its" string) | 117 ((string-match "its" string) |
118 (setq telnet-prompt-pattern "^[^*>]*[*>] *")) | 118 (setq telnet-prompt-pattern "^[^*>\n]*[*>] *")) |
119 ((string-match "explorer" string) ;;explorer telnet needs work | 119 ((string-match "explorer" string) ;;explorer telnet needs work |
120 (setq telnet-replace-c-g ?\n)))) | 120 (setq telnet-replace-c-g ?\n)))) |
121 (setq comint-prompt-regexp telnet-prompt-pattern)) | 121 (setq comint-prompt-regexp telnet-prompt-pattern)) |
122 | 122 |
123 (defun telnet-initial-filter (proc string) | 123 (defun telnet-initial-filter (proc string) |
142 (defun telnet-simple-send (proc string) | 142 (defun telnet-simple-send (proc string) |
143 (comint-send-string proc string) | 143 (comint-send-string proc string) |
144 (comint-send-string proc telnet-new-line)) | 144 (comint-send-string proc telnet-new-line)) |
145 | 145 |
146 (defun telnet-filter (proc string) | 146 (defun telnet-filter (proc string) |
147 (let ((at-end | 147 (save-excursion |
148 (and (eq (process-buffer proc) (current-buffer)) | 148 (set-buffer (process-buffer proc)) |
149 (= (point) (point-max))))) | 149 (let* ((last-insertion (marker-position (process-mark proc))) |
150 (save-excursion | 150 (delta (- (point) last-insertion)) |
151 (set-buffer (process-buffer proc)) | 151 (ie (and comint-last-input-end |
152 (marker-position comint-last-input-end))) | |
153 (w (get-buffer-window (current-buffer))) | |
154 (ws (and w (window-start w)))) | |
155 (goto-char last-insertion) | |
156 (insert-before-markers string) | |
157 (set-marker (process-mark proc) (point)) | |
158 (if ws (set-window-start w ws t)) | |
159 (if ie (set-marker comint-last-input-end ie)) | |
160 (while (progn (skip-chars-backward "^\C-m" last-insertion) | |
161 (> (point) last-insertion)) | |
162 (delete-region (1- (point)) (point))) | |
152 (goto-char (process-mark proc)) | 163 (goto-char (process-mark proc)) |
153 (let ((now (point))) | 164 (and telnet-replace-c-g |
154 ;; Insert STRING, omitting all C-m characters. | 165 (subst-char-in-region last-insertion (point) ?\C-g |
155 (let ((index 0) c-m) | 166 telnet-replace-c-g t)) |
156 (while (setq c-m (string-match "\C-m" string index)) | 167 ;; If point is after the insertion place, move it |
157 (insert-before-markers (substring string index c-m)) | 168 ;; along with the text. |
158 (setq index (1+ c-m))) | 169 (if (> delta 0) |
159 (insert-before-markers (substring string index))) | 170 (goto-char (+ (process-mark proc) delta)))))) |
160 (and telnet-replace-c-g | |
161 (subst-char-in-region now (point) ?\C-g telnet-replace-c-g))) | |
162 ; (if (and (integer-or-marker-p last-input-start) | |
163 ; (marker-position last-input-start) | |
164 ; telnet-remote-echoes) | |
165 ; (delete-region last-input-start last-input-end)) | |
166 ) | |
167 (if at-end | |
168 (goto-char (point-max))))) | |
169 | 171 |
170 (defun telnet-send-input () | 172 (defun telnet-send-input () |
171 (interactive) | 173 (interactive) |
172 ; (comint-send-input telnet-new-line telnet-remote-echoes) | 174 ; (comint-send-input telnet-new-line telnet-remote-echoes) |
173 (comint-send-input) | 175 (comint-send-input) |