Mercurial > emacs
changeset 6507:ff41e0e932b8
(comint-run): New command.
(comint-watch-for-password-prompt): New function.
(comint-mode, comint-show-output): Doc fix.
(comint-replace-by-expanded-history): Add enable property.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 24 Mar 1994 07:50:47 +0000 |
parents | 0d4be1fbfb4d |
children | 965beb0c97d2 |
files | lisp/comint.el |
diffstat | 1 files changed, 33 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/comint.el Thu Mar 24 07:36:56 1994 +0000 +++ b/lisp/comint.el Thu Mar 24 07:50:47 1994 +0000 @@ -81,6 +81,7 @@ ;;; c-c c-h comint-dynamic-list-input-ring List input history ;;; ;;; Not bound by default in comint-mode (some are in shell mode) +;;; comint-run Run a program under comint-mode ;;; send-invisible Read a line w/o echo, and send to proc ;;; comint-dynamic-complete-filename Complete filename at point. ;;; comint-dynamic-complete-variable Complete variable name at point. @@ -289,6 +290,8 @@ "Index of last matched history element.") (defvar comint-matching-input-from-input-string "" "Input previously used to match input history.") + +(put 'comint-replace-by-expanded-history 'menu-enable 'comint-input-autoexpand) (put 'comint-input-ring 'permanent-local t) (put 'comint-input-ring-index 'permanent-local t) (put 'comint-input-autoexpand 'permanent-local t) @@ -321,7 +324,7 @@ and addition is controlled by the variable `comint-input-ignoredups'. Commands with no default key bindings include `send-invisible', -`comint-dynamic-complete', `comint-list-dynamic-completions', and +`comint-dynamic-complete', `comint-dynamic-list-filename-completions', and `comint-magic-space'. Input to, and output from, the subprocess can cause the window to scroll to @@ -500,6 +503,18 @@ (comint-exec buffer name program startfile switches))) buffer)) +;;;###autoload +(defun comint-run (program) + "Run PROGRAM in a comint buffer and switch to it. +The buffer name is made by surrounding the file name of PROGRAM with `*'s. +The file name is used to make a symbol name, such as `comint-sh-hook', and any +hooks on this symbol are run in the buffer. +See `make-comint' and `comint-exec'." + (interactive "sRun program: ") + (let ((name (file-name-nondirectory program))) + (switch-to-buffer (make-comint name program)) + (run-hooks (intern-soft (concat "comint-" name "-hook"))))) + (defun comint-exec (buffer name command startfile switches) "Start up a process in buffer BUFFER for comint modes. Blasts any old process running in the buffer. Doesn't set the buffer mode. @@ -1289,9 +1304,10 @@ (beginning-of-line) (if (null arg) (comint-skip-prompt))) -;;; These two functions are for entering text you don't want echoed or +;;; These three functions are for entering text you don't want echoed or ;;; saved -- typically passwords to ftp, telnet, or somesuch. -;;; Just enter m-x send-invisible and type in your line. +;;; Just enter m-x send-invisible and type in your line, or add +;;; `comint-watch-for-password-prompt' to `comint-output-filter-functions'. (defun comint-read-noecho (prompt &optional stars) "Read a single line of text from user without echoing, and return it. @@ -1349,12 +1365,20 @@ \\[view-lossage]." (interactive "P") ; Defeat snooping via C-x esc (let ((proc (get-buffer-process (current-buffer)))) - (if (not proc) (error "Current buffer has no process") - (comint-send-string proc - (if (stringp str) str - (comint-read-noecho "Non-echoed text: " t))) - (comint-send-string proc "\n")))) + (if (not proc) + (error "Current buffer has no process") + (comint-send-string + proc (if (stringp str) str (comint-read-noecho "Non-echoed text: " t))) + (comint-send-string proc "\n")))) +(defun comint-watch-for-password-prompt (string) + "Prompt in the minibuffer for password and send without echoing. +This function uses `send-invisible' to read and send a password to the buffer's +process if STRING contains a password prompt (matches \"^[Pp]assword:\\\\s *\\\\'\"). + +This function could be in the list `comint-output-filter-functions'." + (if (string-match "^[Pp]assword:\\s *\\'" string) + (send-invisible nil))) ;;; Low-level process communication @@ -1401,7 +1425,7 @@ (defun comint-show-output () "Display start of this batch of interpreter output at top of window. -Also put cursor there if the current position is not visible." +Sets mark to the value of point when this command is run." (interactive) (push-mark) (let ((pos (point)))