chiark / gitweb /
dot/emacs, el/dot-emacs: Trash files by default rather than deleting.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 3 Jun 2018 13:40:43 +0000 (14:40 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 3 Jun 2018 13:40:43 +0000 (14:40 +0100)
But extend the prefix-argument-really-deletes convention to Dired and
Magit.

dot/emacs
el/dot-emacs.el

index 908bc6c260548934573f7cdf8ec47f2577960776..cf5097c0ee63cffb8967d0e8b60d19c445a3f5d7 100644 (file)
--- a/dot/emacs
+++ b/dot/emacs
       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]
index b42431d7f998757a7aa39c01d30cbb2f294a9a7a..86ba4d5c52e9bae6639a6993eae6ecf800f444f9 100644 (file)
@@ -990,6 +990,12 @@ (defun mdw-dired-run (args &optional syncp)
           (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 @@ (eval-after-load "magit"
          (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 @@ (defadvice magit-wip-commit-buffer-file
     (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)