SiteMap Search ElispArea HowTo Glossary RecentChanges News Problems Suggestions
Eritrea, Independence Day

SystemTrash

Last edit

Summary: Add info for Emacs 23.2

Changed:

< Recent Emacs versions (how recent?) support the use of the function
< `system-move-file-to-trash' to move files to the system's trash can
< rather then deleting them outright. If the function is defined, Emacs
< will
use it. However, Emacs does not provide this function --- you
< must write it yourself
.

to

> From the NEWS file for Emacs 23.2:
> ** The default value
of `trash-directory' is now nil.
> This means that `
move-file-to-trash' trashes files according to
> freedesktop.org specifications, the same method used by the Gnome,
> KDE, and XFCE desktops. (This change has no effect on Windows, which
> uses `
system-move-file-to-trash' for trashing.)
> ** File deletion
can make use of the Recycle Bin or system Trash folder.
> Set `delete-by-moving-to-trash' non-nil to
use this. Deleted files
> and directories will then be sent to the Recycle Bin on Windows
, and
> to `trash-directory' on other systems
.


From the NEWS file for Emacs 23.2:

Using the freedesktop.org trash specification

In emacs CVS HEAD (post 23.1)

Using the Freedesktop.org trashcan is the default.

However, Emacs only uses the trash can in your home directory, and it will trash every file it deletes, including a great quantity of temp and backup files. If you want full Freedesktop trash support including per-mountpoint trashcans, as well as control over what gets sent to the trash and what doesn’t, see below, under Earlier Emacs.

Earlier Emacs

The following code will configure Emacs to use the freedesktop.org trash specification, which is compatible with GNOME and KDE. This means that files deleted in Emacs will show up in the GNOME/KDE trash folder.

At the bottom of the file are two pieces of advice. They prevent some functions that normally delete directories recursively from also trashing them recursively.

Note that the following code requires the command `gvfs-trash,’ included with GNOME. If you do not use GNOME, you can install trash-cli and replace ‘gvfs-trash’ with `trash.’

Lisp:trash-settings.el

Setup

After loading this code, use M-x customize-group trash to specify certain files that should skip the system trash. If you do not set this, emacs will fill your trash directory with countless backup files and other temp files. My trash-exclusion settings are as follows:

(setq system-trash-exclude-matches '("#[^/]+#$" ".*~$" "\\.emacs\\.desktop.*"))
(setq system-trash-exclude-paths '("/tmp"))

This setting will prevent Emacs from trashing old desktop lock files (if you use DeskTop Mode) and backup files (with names like `#filename#’), as well as any files in /tmp (including the server file, which gets trashed on every emacs restart if you use server.el).


CategoryDirectories