diff options
| author | Richard M. Stallman | 1993-12-23 03:22:55 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-12-23 03:22:55 +0000 |
| commit | e3683fc7671f2ef3a6e910467f6e0ebae7674e51 (patch) | |
| tree | 6895059b2a55d732ca817cefff0b0107315379cf | |
| parent | ff4373ed6348d468250a46b6cf06fb74790c150b (diff) | |
| download | emacs-e3683fc7671f2ef3a6e910467f6e0ebae7674e51.tar.gz emacs-e3683fc7671f2ef3a6e910467f6e0ebae7674e51.zip | |
(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.
| -rw-r--r-- | lisp/telnet.el | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/lisp/telnet.el b/lisp/telnet.el index e3f17187b35..871e1f18213 100644 --- a/lisp/telnet.el +++ b/lisp/telnet.el | |||
| @@ -51,7 +51,7 @@ | |||
| 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 |
| @@ -115,7 +115,7 @@ rejecting one login and prompting for the again for a username and password.") | |||
| 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)) |
| @@ -144,28 +144,30 @@ rejecting one login and prompting for the again for a username and password.") | |||
| 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) |