aboutsummaryrefslogtreecommitdiff
path: root/emacs
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-06-26 17:19:43 +1000
committerYuchen Pei <id@ypei.org>2023-06-26 17:19:43 +1000
commit6c3fb77a11f3cf76f66de4e760de5430dad83439 (patch)
tree750632d1287256e94f073841ad593a5b094169bd /emacs
parente13c4fb1d8303affa0f64e5a5ba06e9b3b03d475 (diff)
Override dired-do-delete and dired-do-rename
- delete: don't move to trash with prefix arg - rename: don't use vc with prefix arg
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/init/ycp-dired.el2
-rw-r--r--emacs/.emacs.d/lisp/my/my-dired.el20
2 files changed, 18 insertions, 4 deletions
diff --git a/emacs/.emacs.d/init/ycp-dired.el b/emacs/.emacs.d/init/ycp-dired.el
index a0892ab..badd8ed 100644
--- a/emacs/.emacs.d/init/ycp-dired.el
+++ b/emacs/.emacs.d/init/ycp-dired.el
@@ -55,6 +55,8 @@
"<return>" #'my-dired-find-or-alternate
"r" #'my-dired-do-rename-and-symlink-back
"s" #'my-dired-toggle-sorting)
+ (advice-add 'dired-do-delete :around 'my-dired-do-delete)
+ (advice-add 'dired-do-rename :around 'my-dired-do-rename)
)
;;; dired-aux
diff --git a/emacs/.emacs.d/lisp/my/my-dired.el b/emacs/.emacs.d/lisp/my/my-dired.el
index a2485ab..d80c1c8 100644
--- a/emacs/.emacs.d/lisp/my/my-dired.el
+++ b/emacs/.emacs.d/lisp/my/my-dired.el
@@ -118,14 +118,26 @@ With a prefix arg, toggle `my-dired-reverse-sorting' instead."
(delete-directory trash-files-dir t)
(delete-directory trash-info-dir t)))
-(defun my-dired-do-delete (&arg)
- "Trash or (with a prefix arg) delete files."
+(defun my-dired-do-delete (delete-fun &optional arg)
+ "Wrapper of `dired-do-delete'.
+
+With a prefix-arg, delete without moving to trash."
(interactive "P")
(if arg
(let ((delete-by-moving-to-trash nil))
- (call-interactively 'dired-do-delete))
- (call-interactively 'dired-do-delete))
+ (funcall delete-fun))
+ (delete-fun))
)
+(defun my-dired-do-rename (rename-fun &optional arg)
+ "Wrapper on `dired-do-rename'
+
+With a prefix-arg, call it without using `vc-rename-file'."
+ (interactive "P")
+ (if arg
+ (let ((dired-vc-rename-file nil))
+ (funcall rename-fun))
+ (funcall rename-fun)))
+
(provide 'my-dired)
;;; my-dired.el ends here