In normal file managers like
nautilus, if i select an item and press delete button, it will delete that item.
How can i achieve the same in dired? When point is at file, pressing delete button should delete that item?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
If you use library Dired+ then the
delete key is bound by default to to command
diredp-delete-this-file, which deletes the file named on the line of the cursor, after confirmation. (
C-k is bound to the same command.)
This is the entire definition of the command:
(defun diredp-delete-this-file () ; Bound to `C-k', `delete' "In Dired, delete the file on the cursor line, upon confirmation." (interactive) (dired-do-delete 1))
We can write a simple function to delete file at point and then bind it to delete button.
(defun delete-current-item () "Delete file at point" (interactive) (dired-flag-file-deletion 1) (dired-do-flagged-delete)) (define-key dired-mode-map [delete] 'delete-current-item)