Commit e7aabd8b authored by Tino Calancha's avatar Tino Calancha
Browse files

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.
parent cbea38e5
......@@ -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)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment