mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-04 14:40:54 -08:00
dired-delete-file: Do not TAB complete the user answer
This action might delete directories containing valuable information. Before previous commit, we prompted users with `yes-or-no-p' which doesn't TAB complete the user answer. Let's play safe and keep requiring full answers. * emacs-master/lisp/dired.el (dired-delete-file): Use `read-string' instead of `completing-read' to read the user answers.
This commit is contained in:
parent
cbea38e5c4
commit
e7aabd8b1c
1 changed files with 21 additions and 16 deletions
|
|
@ -3011,27 +3011,32 @@ TRASH non-nil means to trash the file instead of deleting, provided
|
|||
(delete-file file trash)
|
||||
(let* ((valid-answers (list "yes" "no" "all" "quit" "help"))
|
||||
(answer "")
|
||||
(input-fn (lambda ()
|
||||
(setq answer
|
||||
(completing-read
|
||||
(format "Recursively %s %s? [yes, no, all, quit, help] "
|
||||
(if (and trash
|
||||
delete-by-moving-to-trash)
|
||||
"trash"
|
||||
"delete")
|
||||
(dired-make-relative file))
|
||||
valid-answers nil t))
|
||||
(when (string= answer "help")
|
||||
(setq answer "")
|
||||
(with-help-window "*Help*"
|
||||
(with-current-buffer "*Help*" (insert dired-delete-help))))
|
||||
answer)))
|
||||
(input-fn
|
||||
(lambda ()
|
||||
(setq answer
|
||||
(read-string
|
||||
(format "Recursively %s %s? [yes, no, all, quit, help] "
|
||||
(if (and trash
|
||||
delete-by-moving-to-trash)
|
||||
"trash"
|
||||
"delete")
|
||||
(dired-make-relative file))))
|
||||
(when (string= answer "help")
|
||||
(with-help-window "*Help*"
|
||||
(with-current-buffer "*Help*" (insert dired-delete-help))))
|
||||
answer)))
|
||||
(if (and recursive
|
||||
(directory-files file t dired-re-no-dot) ; Not empty.
|
||||
(eq recursive 'always))
|
||||
(if (eq recursive 'top) (setq recursive 'always)) ; Don't ask again.
|
||||
;; Otherwise prompt user:
|
||||
(while (string= "" answer) (funcall input-fn))
|
||||
(funcall input-fn)
|
||||
(while (not (member answer valid-answers))
|
||||
(unless (string= answer "help")
|
||||
(beep)
|
||||
(message "Please answer `yes' or `no' or `all' or `quit'")
|
||||
(sleep-for 2))
|
||||
(funcall input-fn))
|
||||
(pcase answer
|
||||
('"all" (setq recursive 'always dired-recursive-deletes recursive))
|
||||
('"yes" (if (eq recursive 'top) (setq recursive 'always)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue