Function: ghostel--cancel-password-prompt

ghostel--cancel-password-prompt is a natively compiled function defined in ghostel.el.

Signature

(ghostel--cancel-password-prompt)

Documentation

Abort our in-flight read-passwd minibuffer, if it is the innermost ours.

Two gates make sure we abort only a minibuffer we opened:

  - Depth: current minibuffer-depth must be outer+1, i.e. exactly
    one minibuffer-level (ours) opened since our prompt began.
  - Minibuffer identity: (active-minibuffer-window)'s buffer must
    equal ghostel--password-prompt-mb-buffer, captured by the
    setup hook when our read-passwd was entered. This is robust
    to the user switching focus out of the minibuffer (which makes
    minibuffer-selected-window return nil) and to cross-buffer
    races where an unrelated minibuffer (e.g. M-x in another
    buffer) is at the matching depth.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--cancel-password-prompt ()
  "Abort our in-flight `read-passwd' minibuffer, if it is the innermost ours.
Two gates make sure we abort only a minibuffer we opened:

  - Depth: current `minibuffer-depth' must be `outer+1', i.e. exactly
    one minibuffer-level (ours) opened since our prompt began.
  - Minibuffer identity: `(active-minibuffer-window)''s buffer must
    equal `ghostel--password-prompt-mb-buffer', captured by the
    setup hook when our `read-passwd' was entered.  This is robust
    to the user switching focus out of the minibuffer (which makes
    `minibuffer-selected-window' return nil) and to cross-buffer
    races where an unrelated minibuffer (e.g. `M-x' in another
    buffer) is at the matching depth."
  (when (and ghostel--password-prompt-active
             ghostel--password-prompt-outer-depth
             (= (minibuffer-depth)
                (1+ ghostel--password-prompt-outer-depth))
             ghostel--password-prompt-mb-buffer
             (let ((amw (active-minibuffer-window)))
               (and amw (eq (window-buffer amw)
                            ghostel--password-prompt-mb-buffer))))
    (abort-recursive-edit)))