Function: comint-watch-for-password-prompt
comint-watch-for-password-prompt is a byte-compiled function defined
in comint.el.gz.
Signature
(comint-watch-for-password-prompt STRING)
Documentation
Prompt in the minibuffer for password and send without echoing.
Looks for a match to comint-password-prompt-regexp in order
to detect the need to (prompt and) send a password. Ignores any
carriage returns (\r) in STRING.
This function could be in the list comint-output-filter-functions.
Probably introduced at or before Emacs version 19.23.
Source Code
;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-watch-for-password-prompt (string)
"Prompt in the minibuffer for password and send without echoing.
Looks for a match to `comint-password-prompt-regexp' in order
to detect the need to (prompt and) send a password. Ignores any
carriage returns (\\r) in STRING.
This function could be in the list `comint-output-filter-functions'."
(let ((string (string-limit
(string-replace "\r" "" string)
comint-password-prompt-max-length t))
prompt)
(when (let ((case-fold-search t))
(string-match comint-password-prompt-regexp string))
(setq prompt
(let ((content (string-trim (match-string 0 string)
"[ \n\r\t\v\f\b\a]+" "\n+"))
(suffix " "))
(concat content
(and (not (string-empty-p content))
(not (string-suffix-p suffix content))
suffix))))
;; Use `run-at-time' in order not to pause execution of the
;; process filter with a minibuffer
(run-at-time
0 nil
(lambda (current-buf)
(with-current-buffer current-buf
(let ((comint--prompt-recursion-depth
(1+ comint--prompt-recursion-depth)))
(if (> comint--prompt-recursion-depth 10)
(message "Password prompt recursion too deep")
(when (get-buffer-process (current-buffer))
(comint-send-invisible prompt))))))
(current-buffer)))))