2

windows 10, Emacs 26.1, dired+

Suppose I want to delete (move to trash) file in dired mode.

D

Emacs asks me:

enter image description here

I press y

and now it's asking me again to kill file.

enter image description here

Why Emacs asks me twice? I want to answer only once to delete (move to trash) the file.

4
  • I don't think this has anything to do with Dired, beyond the fact that you initiated the deletion there.
    – Drew
    May 20, 2019 at 17:31
  • 3
    You apparently neglected, in your description/recipe, to say that you also, sometime prior to trying to trash the file, visited it, so there is a buffer visiting it. (And you neglected to say that you have option delete-by-moving-to-trash set to non-nil.
    – Drew
    May 20, 2019 at 17:32
  • FWIW those screenshots are really hard to read due to small size of text.
    – Reid
    May 20, 2019 at 23:42
  • @Reid 1. Trash "file_name"? (y/n), 2. Kill buffer of "file_name", too? (y/n) May 21, 2019 at 7:04

1 Answer 1

7

So when you open a file it creates a 'buffer' with the file's contents. The first yes moves the physical file to the trash. But the 'buffer' is still loaded in Emacs. If you say no to the second option you can still view the file in Emacs even though it's in the trash can. If this is too redundant I think this answer has the proper solution (although admittedly I have not tested it myself).

2
  • Yes, this is because before delete file I open it. So if NOT open file before delete, than Emacs ask me about delete only once May 21, 2019 at 7:11
  • Exactly, @Alexei. In Emacs, a buffer is not the same thing as a file. This a Good Thing. This may seem like a nuisance at first, but it's really very useful, even powerful, to be able to completely separate what is in Emacs' memory from what is on disk. May 21, 2019 at 17:22

Your Answer

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

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