comparison lisp/comint.el @ 53391:ab9195f48a6f

(comint-watch-for-password-prompt): Pass `string' as arg to send-invisible (send-invisible): Doc fix. The argument is now a prompt, not the string to send. (comint-read-noecho): Doc fix.
author Eli Zaretskii <eliz@is.elta.co.il>
date Mon, 29 Dec 2003 13:42:37 +0000
parents bb2708b976f1
children 9a9d11c249b9
comparison
equal deleted inserted replaced
53390:78acd70ae2f2 53391:ab9195f48a6f
1899 RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. C-g aborts (if 1899 RET, LFD, or ESC. DEL or C-h rubs out. C-u kills line. C-g aborts (if
1900 `inhibit-quit' is set because e.g. this function was called from a process 1900 `inhibit-quit' is set because e.g. this function was called from a process
1901 filter and C-g is pressed, this function returns nil rather than a string). 1901 filter and C-g is pressed, this function returns nil rather than a string).
1902 1902
1903 Note that the keystrokes comprising the text can still be recovered 1903 Note that the keystrokes comprising the text can still be recovered
1904 \(temporarily) with \\[view-lossage]. Some people find this worrysome. 1904 \(temporarily) with \\[view-lossage]. Some people find this worrysome (see,
1905 however, `clear-this-command-keys').
1905 Once the caller uses the password, it can erase the password 1906 Once the caller uses the password, it can erase the password
1906 by doing (clear-string STRING)." 1907 by doing (clear-string STRING)."
1907 (let ((ans "") 1908 (let ((ans "")
1908 (newans nil) 1909 (newans nil)
1909 (c 0) 1910 (c 0)
1946 (message "Quit") 1947 (message "Quit")
1947 (beep t)) 1948 (beep t))
1948 (message "") 1949 (message "")
1949 ans))) 1950 ans)))
1950 1951
1951 (defun send-invisible (str) 1952 (defun send-invisible (&optional prompt)
1952 "Read a string without echoing. 1953 "Read a string without echoing.
1953 Then send it to the process running in the current buffer. 1954 Then send it to the process running in the current buffer.
1954 The string is sent using `comint-input-sender'. 1955 The string is sent using `comint-input-sender'.
1955 Security bug: your string can still be temporarily recovered with 1956 Security bug: your string can still be temporarily recovered with
1956 \\[view-lossage]." 1957 \\[view-lossage]; `clear-this-command-keys' can fix that."
1957 (interactive "P") ; Defeat snooping via C-x ESC ESC 1958 (interactive "P") ; Defeat snooping via C-x ESC ESC
1958 (let ((proc (get-buffer-process (current-buffer)))) 1959 (let ((proc (get-buffer-process (current-buffer))))
1959 (cond ((not proc) 1960 (if proc
1960 (error "Current buffer has no process")) 1961 (let ((str (comint-read-noecho (or prompt "Non-echoed text: ") t)))
1961 ((stringp str) 1962 (if (stringp str)
1962 (comint-snapshot-last-prompt) 1963 (progn
1963 (funcall comint-input-sender proc str)) 1964 (comint-snapshot-last-prompt)
1964 (t 1965 (funcall comint-input-sender proc str))
1965 (let ((str (comint-read-noecho "Non-echoed text: " t))) 1966 (message "Warning: text will be echoed")))
1966 (if (stringp str) 1967 (error "Current buffer has no process"))))
1967 (send-invisible str)
1968 (message "Warning: text will be echoed")))))))
1969 1968
1970 (defun comint-watch-for-password-prompt (string) 1969 (defun comint-watch-for-password-prompt (string)
1971 "Prompt in the minibuffer for password and send without echoing. 1970 "Prompt in the minibuffer for password and send without echoing.
1972 This function uses `send-invisible' to read and send a password to the buffer's 1971 This function uses `send-invisible' to read and send a password to the buffer's
1973 process if STRING contains a password prompt defined by 1972 process if STRING contains a password prompt defined by
1975 1974
1976 This function could be in the list `comint-output-filter-functions'." 1975 This function could be in the list `comint-output-filter-functions'."
1977 (when (string-match comint-password-prompt-regexp string) 1976 (when (string-match comint-password-prompt-regexp string)
1978 (when (string-match "^[ \n\r\t\v\f\b\a]+" string) 1977 (when (string-match "^[ \n\r\t\v\f\b\a]+" string)
1979 (setq string (replace-match "" t t string))) 1978 (setq string (replace-match "" t t string)))
1980 (let ((pw (comint-read-noecho string t))) 1979 (send-invisible string)))
1981 (send-invisible pw))))
1982 1980
1983 ;; Low-level process communication 1981 ;; Low-level process communication
1984 1982
1985 (defun comint-send-string (process string) 1983 (defun comint-send-string (process string)
1986 "Like `process-send-string', but also does extra bookkeeping for comint mode." 1984 "Like `process-send-string', but also does extra bookkeeping for comint mode."