diff options
| author | Richard M. Stallman | 1994-03-24 07:50:47 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-03-24 07:50:47 +0000 |
| commit | 21d9bf27d7954017df88ad1dc04dc85ba277a2bd (patch) | |
| tree | 922e609bce839f8daf134d950b978300b0b958d7 | |
| parent | 10bc4f1dc0408e9a64822e26213b558d82180b7d (diff) | |
| download | emacs-21d9bf27d7954017df88ad1dc04dc85ba277a2bd.tar.gz emacs-21d9bf27d7954017df88ad1dc04dc85ba277a2bd.zip | |
(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.
| -rw-r--r-- | lisp/comint.el | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index 55f95c42361..11e49d4fdb7 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -81,6 +81,7 @@ | |||
| 81 | ;;; c-c c-h comint-dynamic-list-input-ring List input history | 81 | ;;; c-c c-h comint-dynamic-list-input-ring List input history |
| 82 | ;;; | 82 | ;;; |
| 83 | ;;; Not bound by default in comint-mode (some are in shell mode) | 83 | ;;; Not bound by default in comint-mode (some are in shell mode) |
| 84 | ;;; comint-run Run a program under comint-mode | ||
| 84 | ;;; send-invisible Read a line w/o echo, and send to proc | 85 | ;;; send-invisible Read a line w/o echo, and send to proc |
| 85 | ;;; comint-dynamic-complete-filename Complete filename at point. | 86 | ;;; comint-dynamic-complete-filename Complete filename at point. |
| 86 | ;;; comint-dynamic-complete-variable Complete variable name at point. | 87 | ;;; comint-dynamic-complete-variable Complete variable name at point. |
| @@ -289,6 +290,8 @@ This is to work around a bug in Emacs process signalling.") | |||
| 289 | "Index of last matched history element.") | 290 | "Index of last matched history element.") |
| 290 | (defvar comint-matching-input-from-input-string "" | 291 | (defvar comint-matching-input-from-input-string "" |
| 291 | "Input previously used to match input history.") | 292 | "Input previously used to match input history.") |
| 293 | |||
| 294 | (put 'comint-replace-by-expanded-history 'menu-enable 'comint-input-autoexpand) | ||
| 292 | (put 'comint-input-ring 'permanent-local t) | 295 | (put 'comint-input-ring 'permanent-local t) |
| 293 | (put 'comint-input-ring-index 'permanent-local t) | 296 | (put 'comint-input-ring-index 'permanent-local t) |
| 294 | (put 'comint-input-autoexpand 'permanent-local t) | 297 | (put 'comint-input-autoexpand 'permanent-local t) |
| @@ -321,7 +324,7 @@ Input ring expansion is controlled by the variable `comint-input-autoexpand', | |||
| 321 | and addition is controlled by the variable `comint-input-ignoredups'. | 324 | and addition is controlled by the variable `comint-input-ignoredups'. |
| 322 | 325 | ||
| 323 | Commands with no default key bindings include `send-invisible', | 326 | Commands with no default key bindings include `send-invisible', |
| 324 | `comint-dynamic-complete', `comint-list-dynamic-completions', and | 327 | `comint-dynamic-complete', `comint-dynamic-list-filename-completions', and |
| 325 | `comint-magic-space'. | 328 | `comint-magic-space'. |
| 326 | 329 | ||
| 327 | Input to, and output from, the subprocess can cause the window to scroll to | 330 | Input to, and output from, the subprocess can cause the window to scroll to |
| @@ -500,6 +503,18 @@ the process. Any more args are arguments to PROGRAM." | |||
| 500 | (comint-exec buffer name program startfile switches))) | 503 | (comint-exec buffer name program startfile switches))) |
| 501 | buffer)) | 504 | buffer)) |
| 502 | 505 | ||
| 506 | ;;;###autoload | ||
| 507 | (defun comint-run (program) | ||
| 508 | "Run PROGRAM in a comint buffer and switch to it. | ||
| 509 | The buffer name is made by surrounding the file name of PROGRAM with `*'s. | ||
| 510 | The file name is used to make a symbol name, such as `comint-sh-hook', and any | ||
| 511 | hooks on this symbol are run in the buffer. | ||
| 512 | See `make-comint' and `comint-exec'." | ||
| 513 | (interactive "sRun program: ") | ||
| 514 | (let ((name (file-name-nondirectory program))) | ||
| 515 | (switch-to-buffer (make-comint name program)) | ||
| 516 | (run-hooks (intern-soft (concat "comint-" name "-hook"))))) | ||
| 517 | |||
| 503 | (defun comint-exec (buffer name command startfile switches) | 518 | (defun comint-exec (buffer name command startfile switches) |
| 504 | "Start up a process in buffer BUFFER for comint modes. | 519 | "Start up a process in buffer BUFFER for comint modes. |
| 505 | Blasts any old process running in the buffer. Doesn't set the buffer mode. | 520 | Blasts any old process running in the buffer. Doesn't set the buffer mode. |
| @@ -1289,9 +1304,10 @@ in your hook, `comint-mode-hook'." | |||
| 1289 | (beginning-of-line) | 1304 | (beginning-of-line) |
| 1290 | (if (null arg) (comint-skip-prompt))) | 1305 | (if (null arg) (comint-skip-prompt))) |
| 1291 | 1306 | ||
| 1292 | ;;; These two functions are for entering text you don't want echoed or | 1307 | ;;; These three functions are for entering text you don't want echoed or |
| 1293 | ;;; saved -- typically passwords to ftp, telnet, or somesuch. | 1308 | ;;; saved -- typically passwords to ftp, telnet, or somesuch. |
| 1294 | ;;; Just enter m-x send-invisible and type in your line. | 1309 | ;;; Just enter m-x send-invisible and type in your line, or add |
| 1310 | ;;; `comint-watch-for-password-prompt' to `comint-output-filter-functions'. | ||
| 1295 | 1311 | ||
| 1296 | (defun comint-read-noecho (prompt &optional stars) | 1312 | (defun comint-read-noecho (prompt &optional stars) |
| 1297 | "Read a single line of text from user without echoing, and return it. | 1313 | "Read a single line of text from user without echoing, and return it. |
| @@ -1349,12 +1365,20 @@ Security bug: your string can still be temporarily recovered with | |||
| 1349 | \\[view-lossage]." | 1365 | \\[view-lossage]." |
| 1350 | (interactive "P") ; Defeat snooping via C-x esc | 1366 | (interactive "P") ; Defeat snooping via C-x esc |
| 1351 | (let ((proc (get-buffer-process (current-buffer)))) | 1367 | (let ((proc (get-buffer-process (current-buffer)))) |
| 1352 | (if (not proc) (error "Current buffer has no process") | 1368 | (if (not proc) |
| 1353 | (comint-send-string proc | 1369 | (error "Current buffer has no process") |
| 1354 | (if (stringp str) str | 1370 | (comint-send-string |
| 1355 | (comint-read-noecho "Non-echoed text: " t))) | 1371 | proc (if (stringp str) str (comint-read-noecho "Non-echoed text: " t))) |
| 1356 | (comint-send-string proc "\n")))) | 1372 | (comint-send-string proc "\n")))) |
| 1357 | 1373 | ||
| 1374 | (defun comint-watch-for-password-prompt (string) | ||
| 1375 | "Prompt in the minibuffer for password and send without echoing. | ||
| 1376 | This function uses `send-invisible' to read and send a password to the buffer's | ||
| 1377 | process if STRING contains a password prompt (matches \"^[Pp]assword:\\\\s *\\\\'\"). | ||
| 1378 | |||
| 1379 | This function could be in the list `comint-output-filter-functions'." | ||
| 1380 | (if (string-match "^[Pp]assword:\\s *\\'" string) | ||
| 1381 | (send-invisible nil))) | ||
| 1358 | 1382 | ||
| 1359 | ;;; Low-level process communication | 1383 | ;;; Low-level process communication |
| 1360 | 1384 | ||
| @@ -1401,7 +1425,7 @@ Does not delete the prompt." | |||
| 1401 | 1425 | ||
| 1402 | (defun comint-show-output () | 1426 | (defun comint-show-output () |
| 1403 | "Display start of this batch of interpreter output at top of window. | 1427 | "Display start of this batch of interpreter output at top of window. |
| 1404 | Also put cursor there if the current position is not visible." | 1428 | Sets mark to the value of point when this command is run." |
| 1405 | (interactive) | 1429 | (interactive) |
| 1406 | (push-mark) | 1430 | (push-mark) |
| 1407 | (let ((pos (point))) | 1431 | (let ((pos (point))) |