In aquamacs, the confirmation to delete files from dired is a y or n, and immediately on pressing one of them the file is deleted (no RET required after the y or n).

In emacs, the confirmation is yes or no, so that I need to type the full yes or no plus RET afterwards.

I would like to change emacs so that it behaves like aquamacs.

Is this possible at all? I did a google search plus checked M-x customize-group RET dired RET and couldn't find anything that helped (I found stuff to get rid of the confirmation altogether, but that's not what I am after).

2 Answers 2

(setq dired-deletion-confirmer #'y-or-n-p)

Note that recursive directory deletion hard-codes a yes-or-no-p because it's a more dangerous action.

  • Thx for reminding people about the reason for yes-or-no-p, and about dired-deletion-confirmer.
    – Drew
    Sep 24, 2015 at 12:55

Here is the dirty and unsafe hack, which is used widely:

(fset 'yes-or-no-p #'y-or-n-p)
  • Perfect, exactly what I wanted!
    – Vivi
    Sep 24, 2015 at 4:47
  • 1
    Vivi: Are you quite sure about that? xuchunyang isn't kidding about the "unsafe" bit. yes-or-no-p is typically as far as Emacs goes when it comes to making really sure you definitely want to do that destructive thing you asked it to do. Clobbering that function with y-or-n-p for any and all use-cases is not generally recommended, as it makes it extremely easy to tap away at the y key without actually reading the prompts properly (and hence without noticing that one of those questions wasn't actually what you assumed it was going to be).
    – phils
    Sep 24, 2015 at 6:42
  • You could also use an alias: (defalias 'yes-or-no-p 'y-or-n-p)
    – suvayu
    Sep 24, 2015 at 7:24
  • @suvayu Right, maybe defalias is easier to understand for newcomers?
    – xuchunyang
    Sep 24, 2015 at 7:46
  • 2
    @phils OK, I get it now. This answer will change all confirmations to y or n when I only wanted to change it for file deletion (as I have an option to throw deleted files to my system trash, so in case of mistake I have a backup). I don't think it is right to change this for all the other cases as I could possibly do something I didn't mean to. Thank you for your warning.
    – Vivi
    Sep 24, 2015 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.