diff options
Diffstat (limited to 'lisp/comint.el')
| -rw-r--r-- | lisp/comint.el | 72 |
1 files changed, 7 insertions, 65 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index 8b2c779ecd3..16fd9782116 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -369,10 +369,10 @@ Takes one argument, the input. If non-nil, the input may be saved on the input | |||
| 369 | history list. Default is to save anything that isn't all whitespace.") | 369 | history list. Default is to save anything that isn't all whitespace.") |
| 370 | 370 | ||
| 371 | (defvar comint-input-filter-functions '() | 371 | (defvar comint-input-filter-functions '() |
| 372 | "Special hook run before input is sent to the process. | 372 | "Abnormal hook run before input is sent to the process. |
| 373 | These functions get one argument, a string containing the text to send.") | 373 | These functions get one argument, a string containing the text to send.") |
| 374 | 374 | ||
| 375 | (defvar comint-output-filter-functions '(comint-postoutput-scroll-to-bottom) | 375 | (defvar comint-output-filter-functions '(comint-postoutput-scroll-to-bottom comint-watch-for-password-prompt) |
| 376 | "Functions to call after output is inserted into the buffer. | 376 | "Functions to call after output is inserted into the buffer. |
| 377 | One possible function is `comint-postoutput-scroll-to-bottom'. | 377 | One possible function is `comint-postoutput-scroll-to-bottom'. |
| 378 | These functions get one argument, a string containing the text as originally | 378 | These functions get one argument, a string containing the text as originally |
| @@ -788,7 +788,7 @@ buffer. The hook `comint-exec-hook' is run after each exec." | |||
| 788 | 788 | ||
| 789 | (defun comint-insert-input (&optional event) | 789 | (defun comint-insert-input (&optional event) |
| 790 | "In a Comint buffer, set the current input to the previous input at point." | 790 | "In a Comint buffer, set the current input to the previous input at point." |
| 791 | (interactive (list last-input-event)) | 791 | (interactive "@") |
| 792 | (if event (mouse-set-point event)) | 792 | (if event (mouse-set-point event)) |
| 793 | (let ((pos (point))) | 793 | (let ((pos (point))) |
| 794 | (if (not (eq (get-char-property pos 'field) 'input)) | 794 | (if (not (eq (get-char-property pos 'field) 'input)) |
| @@ -1901,65 +1901,7 @@ prompt skip is done by skipping text matching the regular expression | |||
| 1901 | 1901 | ||
| 1902 | ;; These three functions are for entering text you don't want echoed or | 1902 | ;; These three functions are for entering text you don't want echoed or |
| 1903 | ;; saved -- typically passwords to ftp, telnet, or somesuch. | 1903 | ;; saved -- typically passwords to ftp, telnet, or somesuch. |
| 1904 | ;; Just enter m-x send-invisible and type in your line, or add | 1904 | ;; Just enter m-x send-invisible and type in your line. |
| 1905 | ;; `comint-watch-for-password-prompt' to `comint-output-filter-functions'. | ||
| 1906 | |||
| 1907 | (defun comint-read-noecho (prompt &optional stars) | ||
| 1908 | "Read a single line of text from user without echoing, and return it. | ||
| 1909 | Prompt with argument PROMPT, a string. Optional argument STARS causes | ||
| 1910 | input to be echoed with '*' characters on the prompt line. Input ends with | ||
| 1911 | RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. C-g aborts (if | ||
| 1912 | `inhibit-quit' is set because e.g. this function was called from a process | ||
| 1913 | filter and C-g is pressed, this function returns nil rather than a string). | ||
| 1914 | |||
| 1915 | Note that the keystrokes comprising the text can still be recovered | ||
| 1916 | \(temporarily) with \\[view-lossage]. Some people find this worrisome (see, | ||
| 1917 | however, `clear-this-command-keys'). | ||
| 1918 | Once the caller uses the password, it can erase the password | ||
| 1919 | by doing (clear-string STRING)." | ||
| 1920 | (let ((ans "") | ||
| 1921 | (newans nil) | ||
| 1922 | (c 0) | ||
| 1923 | (echo-keystrokes 0) | ||
| 1924 | (cursor-in-echo-area t) | ||
| 1925 | (message-log-max nil) | ||
| 1926 | (done nil)) | ||
| 1927 | (while (not done) | ||
| 1928 | (if stars | ||
| 1929 | (message "%s%s" prompt (make-string (length ans) ?*)) | ||
| 1930 | (message "%s" prompt)) | ||
| 1931 | ;; Use this instead of `read-char' to avoid "Non-character input-event". | ||
| 1932 | (setq c (read-char-exclusive)) | ||
| 1933 | (cond ((= c ?\C-g) | ||
| 1934 | ;; This function may get called from a process filter, where | ||
| 1935 | ;; inhibit-quit is set. In later versions of emacs read-char | ||
| 1936 | ;; may clear quit-flag itself and return C-g. That would make | ||
| 1937 | ;; it impossible to quit this loop in a simple way, so | ||
| 1938 | ;; re-enable it here (for backward-compatibility the check for | ||
| 1939 | ;; quit-flag below would still be necessary, so this seems | ||
| 1940 | ;; like the simplest way to do things). | ||
| 1941 | (setq quit-flag t | ||
| 1942 | done t)) | ||
| 1943 | ((or (= c ?\r) (= c ?\n) (= c ?\e)) | ||
| 1944 | (setq done t)) | ||
| 1945 | ((= c ?\C-u) | ||
| 1946 | (clear-string ans) | ||
| 1947 | (setq ans "")) | ||
| 1948 | ((and (/= c ?\b) (/= c ?\177)) | ||
| 1949 | (setq newans (concat ans (char-to-string c))) | ||
| 1950 | (clear-string ans) | ||
| 1951 | (setq ans newans)) | ||
| 1952 | ((> (length ans) 0) | ||
| 1953 | (aset ans (1- (length ans)) 0) | ||
| 1954 | (setq ans (substring ans 0 -1))))) | ||
| 1955 | (if quit-flag | ||
| 1956 | ;; Emulate a true quit, except that we have to return a value. | ||
| 1957 | (prog1 | ||
| 1958 | (setq quit-flag nil) | ||
| 1959 | (message "Quit") | ||
| 1960 | (beep t)) | ||
| 1961 | (message "") | ||
| 1962 | ans))) | ||
| 1963 | 1905 | ||
| 1964 | (defun send-invisible (&optional prompt) | 1906 | (defun send-invisible (&optional prompt) |
| 1965 | "Read a string without echoing. | 1907 | "Read a string without echoing. |
| @@ -1970,7 +1912,7 @@ Security bug: your string can still be temporarily recovered with | |||
| 1970 | (interactive "P") ; Defeat snooping via C-x ESC ESC | 1912 | (interactive "P") ; Defeat snooping via C-x ESC ESC |
| 1971 | (let ((proc (get-buffer-process (current-buffer)))) | 1913 | (let ((proc (get-buffer-process (current-buffer)))) |
| 1972 | (if proc | 1914 | (if proc |
| 1973 | (let ((str (comint-read-noecho (or prompt "Non-echoed text: ") t))) | 1915 | (let ((str (read-passwd (or prompt "Non-echoed text: ")))) |
| 1974 | (if (stringp str) | 1916 | (if (stringp str) |
| 1975 | (progn | 1917 | (progn |
| 1976 | (comint-snapshot-last-prompt) | 1918 | (comint-snapshot-last-prompt) |
| @@ -2340,7 +2282,7 @@ preceding newline is removed." | |||
| 2340 | 2282 | ||
| 2341 | (defun comint-kill-whole-line (&optional arg) | 2283 | (defun comint-kill-whole-line (&optional arg) |
| 2342 | "Kill current line, ignoring read-only and field properties. | 2284 | "Kill current line, ignoring read-only and field properties. |
| 2343 | With prefix ARG, kill that many lines starting from the current line. | 2285 | With prefix arg, kill that many lines starting from the current line. |
| 2344 | If arg is negative, kill backward. Also kill the preceding newline, | 2286 | If arg is negative, kill backward. Also kill the preceding newline, |
| 2345 | instead of the trailing one. \(This is meant to make \\[repeat] work well | 2287 | instead of the trailing one. \(This is meant to make \\[repeat] work well |
| 2346 | with negative arguments.) | 2288 | with negative arguments.) |
| @@ -2488,7 +2430,7 @@ Provides a default, if there is one, and returns the result filename. | |||
| 2488 | 2430 | ||
| 2489 | See `comint-source-default' for more on determining defaults. | 2431 | See `comint-source-default' for more on determining defaults. |
| 2490 | 2432 | ||
| 2491 | PROMPT is the prompt string. PREV-DIR/FILE is the (directory . file) pair | 2433 | PROMPT is the prompt string. PREV-DIR/FILE is the (DIRECTORY . FILE) pair |
| 2492 | from the last source processing command. SOURCE-MODES is a list of major | 2434 | from the last source processing command. SOURCE-MODES is a list of major |
| 2493 | modes used to determine what file buffers contain source files. (These | 2435 | modes used to determine what file buffers contain source files. (These |
| 2494 | two arguments are used for determining defaults). If MUSTMATCH-P is true, | 2436 | two arguments are used for determining defaults). If MUSTMATCH-P is true, |