From 2a67803a39ecbd2f45d33f395fe2775943a75073 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 3 Jun 2018 14:40:43 +0100 Subject: [PATCH] dot/emacs, el/dot-emacs: Trash files by default rather than deleting. But extend the prefix-argument-really-deletes convention to Dired and Magit. --- dot/emacs | 1 + el/dot-emacs.el | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/dot/emacs b/dot/emacs index 908bc6c..cf5097c 100644 --- a/dot/emacs +++ b/dot/emacs @@ -337,6 +337,7 @@ eshell-cmpl-cycle-completions nil) (setq dired-deletion-confirmer ;Make deletion easier in dired (symbol-function 'y-or-n-p) + delete-by-moving-to-trash t dired-listing-switches "-alF" ;Do `ls -F' things in dired windows wdired-allow-to-change-permissions 'advanced) (setq read-quoted-char-radix 16) ;C-q HEX-STUFF [RET] diff --git a/el/dot-emacs.el b/el/dot-emacs.el index b42431d..86ba4d5 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -990,6 +990,12 @@ options." (concat (shell-quote-argument (dired-get-filename nil)) " " args))) +(defadvice dired-do-flagged-delete + (around mdw-delete-if-prefix-argument activate compile) + (let ((delete-by-moving-to-trash (and (null current-prefix-arg) + delete-by-moving-to-trash))) + ad-do-it)) + (eval-after-load "dired" '(define-key dired-mode-map "X" 'mdw-dired-run)) @@ -4033,6 +4039,7 @@ This allows you to pass a list of arguments through `ansi-term'." (magit-wip-after-apply-mode 1) (magit-wip-before-change-mode 1) (add-to-list 'magit-no-confirm 'safe-with-wip) + (add-to-list 'magit-no-confirm 'trash) (push '(:eval (if (or magit-wip-after-save-local-mode magit-wip-after-apply-mode magit-wip-before-change-mode) @@ -4051,6 +4058,13 @@ This allows you to pass a list of arguments through `ansi-term'." (around mdw-just-this-buffer activate compile) (let ((magit-save-repository-buffers nil)) ad-do-it)) +(defadvice magit-discard + (around mdw-delete-if-prefix-argument activate compile) + (let ((magit-delete-by-moving-to-trash + (and (null current-prefix-arg) + magit-delete-by-moving-to-trash))) + ad-do-it)) + (setq magit-repolist-columns '(("Name" 16 magit-repolist-column-ident nil) ("Version" 18 magit-repolist-column-version nil) -- 2.11.0