branch: externals/async
commit afe10c44c2e51aa91d1f497977c440d55b3378a0
Author: Allen Li <[email protected]>
Commit: Allen Li <[email protected]>
Add one-shot dired-async commands
---
dired-async.el | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/dired-async.el b/dired-async.el
index 485786c..5428206 100644
--- a/dired-async.el
+++ b/dired-async.el
@@ -362,6 +362,39 @@ ESC or `q' to not overwrite any of the remaining files,
(ad-deactivate 'dired-create-files)
(ad-deactivate 'wdired-do-renames))))
+(defmacro dired-async--with-async-create-files (&rest body)
+ "Evaluate BODY with ‘dired-create-files’ set to ‘dired-async-create-files’."
+ (declare (indent 0))
+ `(cl-letf (((symbol-function 'dired-create-files)
#'dired-async-create-files))
+ ,@body))
+
+;;;###autoload
+(defun dired-async-do-copy (&optional arg)
+ "Run ‘dired-do-copy’ asynchronously."
+ (interactive "P")
+ (dired-async--with-async-create-files
+ (dired-do-copy arg)))
+
+;;;###autoload
+(defun dired-async-do-symlink (&optional arg)
+ "Run ‘dired-do-symlink’ asynchronously."
+ (interactive "P")
+ (dired-async--with-async-create-files
+ (dired-do-symlink arg)))
+
+;;;###autoload
+(defun dired-async-do-hardlink (&optional arg)
+ "Run ‘dired-do-hardlink’ asynchronously."
+ (interactive "P")
+ (dired-async--with-async-create-files
+ (dired-do-hardlink arg)))
+
+;;;###autoload
+(defun dired-async-do-rename (&optional arg)
+ "Run ‘dired-do-rename’ asynchronously."
+ (interactive "P")
+ (dired-async--with-async-create-files
+ (dired-do-rename arg)))
(provide 'dired-async)