2

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).

Vivi
  • 361
  • 3
  • 10

2 Answers2

5
(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.

phils
  • 50,977
  • 3
  • 79
  • 122
  • Thx for reminding people about the reason for yes-or-no-p, and about dired-deletion-confirmer. – Drew Sep 24 '15 at 12:55
2

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

(fset 'yes-or-no-p #'y-or-n-p)
xuchunyang
  • 14,527
  • 1
  • 19
  • 39
  • Perfect, exactly what I wanted! – Vivi Sep 24 '15 at 04: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 '15 at 06:42
  • You could also use an alias: (defalias 'yes-or-no-p 'y-or-n-p) – suvayu Sep 24 '15 at 07:24
  • @suvayu Right, maybe defalias is easier to understand for newcomers? – xuchunyang Sep 24 '15 at 07: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 '15 at 10:18
  • @xuchunyang I will change the accepted answer to the answer that does what I wanted (without impacting on the other stuff). I am still thankful for your answer and I still think it could be useful for someone that happens to bump into this site. – Vivi Sep 24 '15 at 10:19