aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTino Calancha2017-08-06 21:53:07 +0900
committerTino Calancha2017-08-06 21:53:07 +0900
commite7aabd8b1ced130c8bf5abecf2fa14b962a9b012 (patch)
tree694be7bfff57341ef231cc92af7bd7979f4bc496
parentcbea38e5c4af5386192fb9a48ef4fca5080d6561 (diff)
downloademacs-e7aabd8b1ced130c8bf5abecf2fa14b962a9b012.tar.gz
emacs-e7aabd8b1ced130c8bf5abecf2fa14b962a9b012.zip
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.
-rw-r--r--lisp/dired.el37
1 files changed, 21 insertions, 16 deletions
diff --git a/lisp/dired.el b/lisp/dired.el
index 0bad2562eb4..54bc6217031 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3011,27 +3011,32 @@ TRASH non-nil means to trash the file instead of deleting, provided
3011 (delete-file file trash) 3011 (delete-file file trash)
3012 (let* ((valid-answers (list "yes" "no" "all" "quit" "help")) 3012 (let* ((valid-answers (list "yes" "no" "all" "quit" "help"))
3013 (answer "") 3013 (answer "")
3014 (input-fn (lambda () 3014 (input-fn
3015 (setq answer 3015 (lambda ()
3016 (completing-read 3016 (setq answer
3017 (format "Recursively %s %s? [yes, no, all, quit, help] " 3017 (read-string
3018 (if (and trash 3018 (format "Recursively %s %s? [yes, no, all, quit, help] "
3019 delete-by-moving-to-trash) 3019 (if (and trash
3020 "trash" 3020 delete-by-moving-to-trash)
3021 "delete") 3021 "trash"
3022 (dired-make-relative file)) 3022 "delete")
3023 valid-answers nil t)) 3023 (dired-make-relative file))))
3024 (when (string= answer "help") 3024 (when (string= answer "help")
3025 (setq answer "") 3025 (with-help-window "*Help*"
3026 (with-help-window "*Help*" 3026 (with-current-buffer "*Help*" (insert dired-delete-help))))
3027 (with-current-buffer "*Help*" (insert dired-delete-help)))) 3027 answer)))
3028 answer)))
3029 (if (and recursive 3028 (if (and recursive
3030 (directory-files file t dired-re-no-dot) ; Not empty. 3029 (directory-files file t dired-re-no-dot) ; Not empty.
3031 (eq recursive 'always)) 3030 (eq recursive 'always))
3032 (if (eq recursive 'top) (setq recursive 'always)) ; Don't ask again. 3031 (if (eq recursive 'top) (setq recursive 'always)) ; Don't ask again.
3033 ;; Otherwise prompt user: 3032 ;; Otherwise prompt user:
3034 (while (string= "" answer) (funcall input-fn)) 3033 (funcall input-fn)
3034 (while (not (member answer valid-answers))
3035 (unless (string= answer "help")
3036 (beep)
3037 (message "Please answer `yes' or `no' or `all' or `quit'")
3038 (sleep-for 2))
3039 (funcall input-fn))
3035 (pcase answer 3040 (pcase answer
3036 ('"all" (setq recursive 'always dired-recursive-deletes recursive)) 3041 ('"all" (setq recursive 'always dired-recursive-deletes recursive))
3037 ('"yes" (if (eq recursive 'top) (setq recursive 'always))) 3042 ('"yes" (if (eq recursive 'top) (setq recursive 'always)))