Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to delete a directory in emacs' dired-mode. I mark the directory with the "d" key, and then hit "x" to deleted flagged. I then get the following error:

file-error Non-regular file is a directory <name of dir>

Is there any way to get emacs to delete the directory and stop its whining?

share|improve this question
up vote 4 down vote accepted

I am not sure what emacs version you have, mine gives me this error: (file-error Removing directory Directory not empty ...) For empty directories, it doesn't complain.

Anyway, in the version I have, there is a variable: dired-recursive-deletes that decides if directories can be deleted if they have some content. You should thus customize this variable with:

M-x customize-variable

and then when prompter specify:

dired-recursive-deletes

You can then choose the behaviour by clicking on the "Value Menu" button and then save it with the button at the top of the buffer.

share|improve this answer
1  
In .emacs: (setq dired-recursive-deletes 'top) – oneself Feb 18 '11 at 21:26
1  
And with my version of emacs, with my personnal settings I don't remember tweaking about this, it just asks me if I (really) want to recursively delete the directory, and then proceeds. – Nikana Reklawyks Nov 18 '12 at 20:17

The simple way is: a. MARK (m) the directories you want to delete;
b. Position POINT on one of the marked files;
c. Type '!' [dired-do-command], at the prompt "Execute command ..." enter "rm -Rf"
d. Type 'g' to refresh the dired buffer because emacs doesn't know you changed the filesystem.

That last step could usefully be made an option for dired: "Refresh the buffer after shell command." Maybe it already is one.

BTW, the 'dired-recursive-deletes' gets me a "[no match]"

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .