aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoah Friedman1993-04-16 13:06:01 +0000
committerNoah Friedman1993-04-16 13:06:01 +0000
commit8ae3bc9f18081524e493c8d4d23aa9e92137fb9e (patch)
treefac30351797d9c5fcaf9846951407d96bf2cfb61
parent3dbae1e48ebcb86944b2a6d82f56b31143dc7099 (diff)
downloademacs-8ae3bc9f18081524e493c8d4d23aa9e92137fb9e.tar.gz
emacs-8ae3bc9f18081524e493c8d4d23aa9e92137fb9e.zip
*** empty log message ***
-rw-r--r--lisp/comint.el39
-rw-r--r--lisp/rlogin.el123
2 files changed, 99 insertions, 63 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index af9a8159bf7..8027c404d97 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -121,6 +121,7 @@
121;;; comint-input-filter - function modes. 121;;; comint-input-filter - function modes.
122;;; comint-input-send - function 122;;; comint-input-send - function
123;;; comint-eol-on-send - boolean 123;;; comint-eol-on-send - boolean
124;;; comint-process-echoes - boolean
124 125
125(defvar comint-prompt-regexp "^" 126(defvar comint-prompt-regexp "^"
126 "Regexp to recognise prompts in the inferior process. 127 "Regexp to recognise prompts in the inferior process.
@@ -139,6 +140,13 @@ This is a good thing to set in mode hooks.")
139(defvar comint-input-ring-size 30 140(defvar comint-input-ring-size 30
140 "Size of input history ring.") 141 "Size of input history ring.")
141 142
143(defvar comint-process-echoes nil
144 "*If non-`nil', assume that the subprocess echoes any input.
145If so, delete one copy of the input so that only one copy eventually
146appears in the buffer.
147
148This variable is buffer-local.")
149
142;;; Here are the per-interpreter hooks. 150;;; Here are the per-interpreter hooks.
143(defvar comint-get-old-input (function comint-get-old-input-default) 151(defvar comint-get-old-input (function comint-get-old-input-default)
144 "Function that submits old text in comint mode. 152 "Function that submits old text in comint mode.
@@ -247,6 +255,7 @@ Entry to this mode runs the hooks on comint-mode-hook"
247 (make-local-variable 'comint-eol-on-send) 255 (make-local-variable 'comint-eol-on-send)
248 (make-local-variable 'comint-ptyp) 256 (make-local-variable 'comint-ptyp)
249 (make-local-variable 'comint-exec-hook) 257 (make-local-variable 'comint-exec-hook)
258 (make-local-variable 'comint-process-echoes)
250 (run-hooks 'comint-mode-hook) 259 (run-hooks 'comint-mode-hook)
251 (or comint-input-ring 260 (or comint-input-ring
252 (setq comint-input-ring (make-ring comint-input-ring-size)))) 261 (setq comint-input-ring (make-ring comint-input-ring-size))))
@@ -563,18 +572,20 @@ fetches previous (older) inputs."
563 "Send input to process. 572 "Send input to process.
564After the process output mark, sends all text from the process mark to 573After the process output mark, sends all text from the process mark to
565point as input to the process. Before the process output mark, calls value 574point as input to the process. Before the process output mark, calls value
566of variable comint-get-old-input to retrieve old input, copies it to the 575of variable `comint-get-old-input' to retrieve old input, copies it to the
567process mark, and sends it. A terminal newline is also inserted into the 576process mark, and sends it. If variable `comint-process-echoes' is `nil',
568buffer and sent to the process. In either case, value of variable 577a terminal newline is also inserted into the buffer and sent to the process
569comint-input-sentinel is called on the input before sending it. The input 578(if it is non-`nil', all text from the process mark to point is deleted,
570is entered into the input history ring, if the value of variable 579since it is assumed the remote process will re-echo it). The value of
571comint-input-filter returns non-nil when called on the input. 580variable `comint-input-sentinel' is called on the input before sending it.
572 581The input is entered into the input history ring, if the value of variable
573If variable comint-eol-on-send is non-nil, then point is moved to the end of 582`comint-input-filter' returns non-`nil' when called on the input.
574line before sending the input. 583
575 584If variable `comint-eol-on-send' is non-`nil', then point is moved to the
576comint-get-old-input, comint-input-sentinel, and comint-input-filter are chosen 585end of line before sending the input.
577according to the command interpreter running in the buffer. E.g., 586
587`comint-get-old-input', `comint-input-sentinel', and `comint-input-filter'
588are chosen according to the command interpreter running in the buffer. E.g.,
578If the interpreter is the csh, 589If the interpreter is the csh,
579 comint-get-old-input is the default: take the current line, discard any 590 comint-get-old-input is the default: take the current line, discard any
580 initial string matching regexp comint-prompt-regexp. 591 initial string matching regexp comint-prompt-regexp.
@@ -603,7 +614,9 @@ Similarly for Soar, Scheme, etc."
603 (goto-char pmark) 614 (goto-char pmark)
604 (insert copy) 615 (insert copy)
605 copy)))) 616 copy))))
606 (insert ?\n) 617 (if comint-process-echoes
618 (delete-region pmark (point))
619 (insert ?\n))
607 (if (funcall comint-input-filter input) 620 (if (funcall comint-input-filter input)
608 (ring-insert comint-input-ring input)) 621 (ring-insert comint-input-ring input))
609 (funcall comint-input-sentinel input) 622 (funcall comint-input-sentinel input)
diff --git a/lisp/rlogin.el b/lisp/rlogin.el
index b3e2762bad5..79449f50cd8 100644
--- a/lisp/rlogin.el
+++ b/lisp/rlogin.el
@@ -1,5 +1,6 @@
1;;; rlogin.el --- remote login interface 1;;; rlogin.el --- remote login interface
2 2
3;; Author: Noah Friedman
3;; Maintainer: Noah Friedman <friedman@prep.ai.mit.edu> 4;; Maintainer: Noah Friedman <friedman@prep.ai.mit.edu>
4;; Keywords: unix, comm 5;; Keywords: unix, comm
5 6
@@ -29,29 +30,37 @@
29 30
30(require 'comint) 31(require 'comint)
31 32
33;;;###autoload
32(defvar rlogin-program "rlogin" 34(defvar rlogin-program "rlogin"
33 "*Name of program to invoke rlogin") 35 "*Name of program to invoke rlogin")
34 36
37;;;###autoload
35(defvar rlogin-explicit-args nil 38(defvar rlogin-explicit-args nil
36 "*List of arguments to pass to rlogin on the command line.") 39 "*List of arguments to pass to rlogin on the command line.")
37 40
41;;;###autoload
38(defvar rlogin-mode-hook nil 42(defvar rlogin-mode-hook nil
39 "*Hooks to run after setting current buffer to rlogin-mode.") 43 "*Hooks to run after setting current buffer to rlogin-mode.")
40 44
41;; I think this is so obnoxious I refuse to enable it by default. 45;;;###autoload
42;; In any case, there is a bug with regards to generating a quit while 46(defvar rlogin-process-connection-type nil
43;; reading keyboard input in a process filter, so until that's fixed it's 47 "*If non-`nil', use a pty for the local rlogin process.
44;; not safe to enable this anyway. 48If `nil', use a pipe (if pipes are supported on the local system).
45(defvar rlogin-password-paranoia nil
46 "*If non-`nil', query user for a password in the minibuffer when a
47Password: prompt appears. Stars will echo as characters are type.
48 49
49It's also possible to selectively enter passwords without echoing them in 50Generally it is better not to waste ptys on systems which have a static
50the minibuffer using the function `rlogin-password'.") 51number of them. On the other hand, some implementations of `rlogin' assume
52a pty is being used, and errors will result from using a pipe instead.")
51 53
52(defvar rlogin-last-input-line nil nil) 54;; Leave this nil because it makes rlogin-filter a tiny bit faster. Plus
55;; you can still call rlogin-password by hand.
56;;;###autoload
57(defvar rlogin-password-paranoia nil
58 "*If non-`nil', query user for a password in the minibuffer when a Password: prompt appears.
59It's also possible to selectively enter passwords without echoing them in
60the minibuffer using the command `rlogin-password' explicitly.")
53 61
54;; Initialize rlogin mode map. 62;; Initialize rlogin mode map.
63;;;###autoload
55(defvar rlogin-mode-map '()) 64(defvar rlogin-mode-map '())
56(cond ((not rlogin-mode-map) 65(cond ((not rlogin-mode-map)
57 (setq rlogin-mode-map (full-copy-sparse-keymap comint-mode-map)) 66 (setq rlogin-mode-map (full-copy-sparse-keymap comint-mode-map))
@@ -78,7 +87,8 @@ The variable `rlogin-explicit-args' is a list of arguments to give to
78the rlogin when starting." 87the rlogin when starting."
79 (interactive (list current-prefix-arg 88 (interactive (list current-prefix-arg
80 (read-from-minibuffer "Open rlogin connection to host: "))) 89 (read-from-minibuffer "Open rlogin connection to host: ")))
81 (let* ((buffer-name (format "*rlogin-%s*" host)) 90 (let* ((process-connection-type rlogin-process-connection-type)
91 (buffer-name (format "*rlogin-%s*" host))
82 (args (if (and rlogin-explicit-args (listp rlogin-explicit-args)) 92 (args (if (and rlogin-explicit-args (listp rlogin-explicit-args))
83 (cons host rlogin-explicit-args) 93 (cons host rlogin-explicit-args)
84 (list host))) 94 (list host)))
@@ -91,7 +101,9 @@ the rlogin when starting."
91 (comint-mode) 101 (comint-mode)
92 (comint-exec (current-buffer) buffer-name rlogin-program nil args) 102 (comint-exec (current-buffer) buffer-name rlogin-program nil args)
93 (setq proc (get-process buffer-name)) 103 (setq proc (get-process buffer-name))
94 (set-marker (process-mark proc) (point-min)) 104 ;; Set process-mark to point-max in case there is text in the
105 ;; buffer from a previous exited process.
106 (set-marker (process-mark proc) (point-max))
95 (set-process-filter proc 'rlogin-filter) 107 (set-process-filter proc 'rlogin-filter)
96 (rlogin-mode))))) 108 (rlogin-mode)))))
97 109
@@ -106,7 +118,7 @@ value of `rlogin-explicit-args'."
106 (rlogin-explicit-args nil)) 118 (rlogin-explicit-args nil))
107 (unwind-protect 119 (unwind-protect
108 (progn 120 (progn
109 (while (string-match "[ \t]*\\([^ \t]\\)+$" args) 121 (while (string-match "[ \t]*\\([^ \t]+\\)$" args)
110 (setq rlogin-explicit-args 122 (setq rlogin-explicit-args
111 (cons (substring args 123 (cons (substring args
112 (match-beginning 1) 124 (match-beginning 1)
@@ -117,17 +129,31 @@ value of `rlogin-explicit-args'."
117 (rlogin 1 host))) 129 (rlogin 1 host)))
118 130
119;;;###autoload 131;;;###autoload
120(defun rlogin-password () 132(defun rlogin-password (&optional proc)
121 "Play the paranoia game by not echoing entered password in buffer 133 "Read a password and send it to an rlogin session.
122(stars will echo in the minibuffer instead." 134For each character typed, a `*' is echoed in the minibuffer.
135End with RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line.
136C-g aborts attempt to read and send password.
137
138Optional argument PROC is the process to which the password should be sent.
139If not provided, send to the process in the current buffer. This argument
140is intended primarily for use by `rlogin-filter'."
123 (interactive) 141 (interactive)
124 (let ((input (comint-read-noecho "Enter password: " 'stars))) 142 (or proc (setq proc (get-buffer-process (current-buffer))))
125 (insert-before-markers "\n") 143 (let* ((buffer-name (buffer-name (process-buffer proc)))
126 (comint-send-string (get-buffer-process (current-buffer)) 144 (pass (comint-read-noecho (format "Password for buffer \"%s\": "
127 (format "%s\n" input)))) 145 buffer-name)
146 'stars)))
147 (and pass
148 (save-excursion
149 (set-buffer buffer-name)
150 (insert-before-markers "\n")
151 (comint-send-string proc (format "%s\n" pass))))))
128 152
129;;;###autoload 153;;;###autoload
130(defun rlogin-mode () 154(defun rlogin-mode ()
155 "Set major-mode for rlogin sessions.
156If `rlogin-mode-hook' is set, run it."
131 (interactive) 157 (interactive)
132 (kill-all-local-variables) 158 (kill-all-local-variables)
133 (comint-mode) 159 (comint-mode)
@@ -137,52 +163,49 @@ value of `rlogin-explicit-args'."
137 (use-local-map rlogin-mode-map) 163 (use-local-map rlogin-mode-map)
138 (run-hooks 'rlogin-mode-hook)) 164 (run-hooks 'rlogin-mode-hook))
139 165
166
140(defun rlogin-filter (proc string) 167(defun rlogin-filter (proc string)
141 (let ((old-buffer (current-buffer)) 168 (save-excursion
142 (old-match-data (match-data)) 169 (set-buffer (process-buffer proc))
143 at-max-pos 170 (let ((proc-mark (process-mark proc))
144 moving) 171 (region-begin (point)))
145 (unwind-protect 172 (goto-char proc-mark)
146 (progn 173 (insert-before-markers string)
147 (set-buffer (process-buffer proc)) 174 (goto-char region-begin)
148 (setq moving (= (point) (process-mark proc))) 175 (while (search-forward "\C-m" proc-mark t)
149 (save-excursion 176 (delete-char -1))))
150 (goto-char (process-mark proc)) 177 ;; Kludgy workaround for scroll-step bug in emacs. If point is at the
151 (save-restriction 178 ;; top of the window, scroll step is nonzero, and you call
152 (let ((beg (point))) 179 ;; insert-before-markers, the text is inserted off-screen. If
153 (insert-before-markers string) 180 ;; scroll-step is 0, this doesn't happen.
154 (narrow-to-region beg (point)) 181 (and (/= scroll-step 0)
155 (goto-char (point-min)) 182 (eq (process-buffer proc) (window-buffer (selected-window)))
156 (while (search-forward "\C-m" nil t) 183 (eq (point) (window-start))
157 (delete-char -1)) 184 (set-window-start (selected-window)
158 (and rlogin-password-paranoia 185 (save-excursion
159 (setq string (buffer-substring (point-min) (point-max)))) 186 (beginning-of-line)
160 (goto-char (point-max)))) 187 (point))
161 (set-marker (process-mark proc) (point))) 188 'noforce))
162 (and moving
163 (goto-char (process-mark proc))))
164 (set-buffer old-buffer)
165 (store-match-data old-match-data)))
166 (and rlogin-password-paranoia 189 (and rlogin-password-paranoia
167 (string= "Password:" string) 190 (string= "Password:" string)
168 (let ((input (comint-read-noecho "Enter password: " 'stars))) 191 (rlogin-password proc)))
169 (and input
170 (progn
171 (insert-before-markers "\n")
172 (comint-send-string proc (format "%s\n" input)))))))
173 192
193;;;###autoload
174(defun rlogin-send-Ctrl-C () 194(defun rlogin-send-Ctrl-C ()
175 (interactive) 195 (interactive)
176 (send-string nil "\C-c")) 196 (send-string nil "\C-c"))
177 197
198;;;###autoload
178(defun rlogin-send-Ctrl-Z () 199(defun rlogin-send-Ctrl-Z ()
179 (interactive) 200 (interactive)
180 (send-string nil "\C-z")) 201 (send-string nil "\C-z"))
181 202
203;;;###autoload
182(defun rlogin-send-Ctrl-backslash () 204(defun rlogin-send-Ctrl-backslash ()
183 (interactive) 205 (interactive)
184 (send-string nil "\C-\\")) 206 (send-string nil "\C-\\"))
185 207
208;;;###autoload
186(defun rlogin-delchar-or-send-Ctrl-D (arg) 209(defun rlogin-delchar-or-send-Ctrl-D (arg)
187 "Delete ARG characters forward, or send a C-d to process if at end of 210 "Delete ARG characters forward, or send a C-d to process if at end of
188buffer." 211buffer."