Function: ghostel--prompt-password
ghostel--prompt-password is a natively compiled function defined in
ghostel.el.
Signature
(ghostel--prompt-password)
Documentation
Run ghostel-password-prompt-functions until one returns a password.
The cursor row text is captured once and passed to each source,
so handlers that match against the prompt don't each pay for a
separate buffer scan. Sends the result + carriage return to the
subprocess, clears the string, and arms the post-submission
suppression so the detector doesn't re-fire while the foreground
program restores echo. State cleanup runs even when a source
signals quit (keyboard-quit during read-passwd), so the
indicator and suppression always reach a sane state.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--prompt-password ()
"Run `ghostel-password-prompt-functions' until one returns a password.
The cursor row text is captured once and passed to each source,
so handlers that match against the prompt don't each pay for a
separate buffer scan. Sends the result + carriage return to the
subprocess, clears the string, and arms the post-submission
suppression so the detector doesn't re-fire while the foreground
program restores echo. State cleanup runs even when a source
signals quit (`keyboard-quit' during `read-passwd'), so the
indicator and suppression always reach a sane state."
(let* ((pwd nil)
(row (ghostel--cursor-row-text))
(origin (current-buffer)))
(setq ghostel--password-prompt-outer-depth (minibuffer-depth)
ghostel--password-prompt-active t
ghostel--password-prompt-mb-buffer nil)
(unwind-protect
(minibuffer-with-setup-hook
(lambda ()
;; Runs in the minibuffer buffer during setup; `current-buffer' is
;; the new minibuffer and `selected-window' is its window.
;; Only capture when the minibuffer was entered from ORIGIN - an
;; unrelated minibuffer opened concurrently has a different parent
;; window and must not poison our captured buffer.
(let ((sw (minibuffer-selected-window))
(mb (current-buffer)))
(when (and sw (eq (window-buffer sw) origin))
(with-current-buffer origin
(setq ghostel--password-prompt-mb-buffer mb)))))
(setq pwd (run-hook-with-args-until-success
'ghostel-password-prompt-functions
row)))
(setq ghostel--password-prompt-active nil
ghostel--password-prompt-outer-depth nil
ghostel--password-prompt-mb-buffer nil)
;; The (concat pwd "\r") wire copy is freshly allocated and owned by us,
;; so `clear-string' it after the send. Nested `unwind-protect' so the
;; wire is cleared even if `ghostel--write-pty' errors (e.g. the PTY dies
;; between prompt detection and the send).
;;
;; Deliberately do NOT clear PWD itself: an `auth-source' backend that
;; returns the secret as a string may share that string with the
;; auth-source cache (the :secret in the cached plist). Clearing it would
;; zero the cache in place and break later lookups. The default
;; `ghostel--default-password-source' uses `read-passwd' which returns a new
;; string; that one lives until GC. Sources whose backend hands out shared
;; strings should `copy-sequence' before returning if they want clearing.
(when pwd
(let ((wire (concat pwd "\r")))
(unwind-protect (ghostel--write-pty ghostel--term wire)
(clear-string wire))))
(setq ghostel--password-handled-cursor ghostel--cursor-pos)
(setq ghostel--password-mode-p nil)
(ghostel--mode-line-refresh))))