diff options
| author | Richard M. Stallman | 2004-10-17 06:51:10 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2004-10-17 06:51:10 +0000 |
| commit | fe0bd1428b45ba2c4778b09db7553bbc09d3b594 (patch) | |
| tree | 66b3498404f8aebd44da4e6f79a1478d05ae0f12 | |
| parent | efa0a47a838421348332d96af1e3ab26ef70051b (diff) | |
| download | emacs-fe0bd1428b45ba2c4778b09db7553bbc09d3b594.tar.gz emacs-fe0bd1428b45ba2c4778b09db7553bbc09d3b594.zip | |
(comint-output-filter-functions): Add comint-watch-for-password-prompt.
(comint-read-noecho): Function deleted.
(send-invisible): Use read-passwd.
| -rw-r--r-- | lisp/comint.el | 64 |
1 files changed, 3 insertions, 61 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index 8b2c779ecd3..cfbd618c896 100644 --- a/lisp/comint.el +++ b/lisp/comint.el | |||
| @@ -372,7 +372,7 @@ history list. Default is to save anything that isn't all whitespace.") | |||
| 372 | "Special hook run before input is sent to the process. | 372 | "Special 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 |
| @@ -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) |