4

Windows 10, Emacs 25.1

In my init.el I set:

delete-by-moving-to-trash t

So as result when I delete file it move to trash. Nice. But how I restore delete file from trash by Emacs?

3
  • Looking through a copy of the emacs source from git, there doesn't appear to be a way to do what you want. You can probably navigate to the trash folder and move files back manually.
    – Realraptor
    Commented Dec 14, 2017 at 15:53
  • What are you mean "navigate to trash"? Using external program?
    – Alex
    Commented Dec 14, 2017 at 15:58
  • This might answer to your request ;-) github.com/shingo256/trashed Commented Nov 8, 2019 at 13:13

2 Answers 2

2

I don't use trash, so this is a bit of a guess. And I don't find anything about restoring trashed files in the Emacs or Elisp manuals. You might want to just check your system docs for info about restoring from your system trash can.

Anyway...


First, customize option trash-directory, if you have not already. Thereafter, trashed files will be put in that directory.

To restore a file that has been trashed there, use C-x d to open Dired on that directory, then use R to move one or more trashed files to another directory. R moves all marked files (or just the file of the current line, if none are marked). At the prompt, type the name of the target directory.


If you have not set option trash-directory then files get trashed to your system recycle bin (trash can), provided function system-move-file-to-trash is defined.

In that case, use C-x d to open your system trash folder (it may be $trash/files).

However, See https://specifications.freedesktop.org/trash-spec/trashspec-latest.html for information about the kind of trash can that is used by default, and how to obtain the original file name of a trashed file.

0

You can use Trashed in MELPA. This package provides you a simple but convenient user interface to manage trashed files. It supports both MS Windows Recycle Bin and freedesktop.org Trash Can. See https://github.com/shingo256/trashed

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.