Function: dired-query
dired-query is an autoloaded and byte-compiled function defined in
dired-aux.el.gz.
Signature
(dired-query SYM PROMPT &rest ARGS)
Documentation
Format PROMPT with ARGS, query user, and store the result in SYM.
The return value is either nil or t.
The user may type y or SPC to accept once; n or DEL to skip once;
! to accept this and subsequent queries; or q or ESC to decline
this and subsequent queries.
If SYM is already bound to a non-nil value, this function may return automatically without querying the user. If SYM is !, return t; if SYM is q or ESC, return nil.
Probably introduced at or before Emacs version 28.1.
Source Code
;; Defined in /usr/src/emacs/lisp/dired-aux.el.gz
;;;###autoload
(defun dired-query (sym prompt &rest args)
"Format PROMPT with ARGS, query user, and store the result in SYM.
The return value is either nil or t.
The user may type y or SPC to accept once; n or DEL to skip once;
! to accept this and subsequent queries; or q or ESC to decline
this and subsequent queries.
If SYM is already bound to a non-nil value, this function may
return automatically without querying the user. If SYM is !,
return t; if SYM is q or ESC, return nil."
(let* ((char (symbol-value sym))
(char-choices '(?y ?\s ?n ?\177 ?! ?q ?\e)))
(cond ((eq char ?!)
t) ; accept, and don't ask again
((memq char '(?q ?\e))
nil) ; skip, and don't ask again
(t ; no previous answer - ask now
(setq prompt
(concat (apply #'format-message prompt args)
(if help-form
(format " [Type yn!q or %s] "
(key-description (vector help-char)))
" [Type y, n, q or !] ")))
(set sym (setq char (read-char-choice prompt char-choices)))
(if (memq char '(?y ?\s ?!)) t)))))