有没有办法修改/告诉dired异步复制文件?如果您在dired中标记多个文件,然后使用'C‘复制它们,emacs会锁定,直到复制完每个文件。相反,我想让这个拷贝开始,让我在后台继续编辑。有没有办法获得这种行为?
编辑:实际上,C在dired-aux中调用' dired -do-copy‘,而不是在dired本身中。很抱歉造成任何混淆。
发布于 2008-12-19 03:19:53
我认为emacs主要局限于单个线程--所以这可能不能直接通过标准的dired命令来实现,比如'C‘copy。
但是,有一个dired命令"dired-do-shell-command“,它调用shell在后台执行工作。如果您选择要复制的文件,然后使用键'!‘(这将运行dired-do-shell-command),然后键入'cp ? destination‘(如果您是在windows上,则可以使用'copy’)。我还没有对此进行过测试,因此请参阅"dired-do-shell-command“上的帮助以了解完整的详细信息。
发布于 2014-01-16 17:34:24
另请参阅Emacs函数dired-do-async-shell-command。
有关更通用的解决方案,请参阅https://github.com/jwiegley/emacs-async,您还可以通过调用单独的Emacs进程来评估任意的Emacs Lisp代码(这当然会带来一些额外的延迟)。更具体地说,关于文件操作,请参阅此存储库中的dired-async.el文件。
还要注意的是,在Emacs中已经有了工作名为Concurrent Emacs的线程方面的工作,但它还没有出现。详情请参见http://www.emacswiki.org/emacs/ConcurrentEmacs。
发布于 2017-04-27 03:17:47
我发现这个答案很有帮助:https://emacs.stackexchange.com/a/13802/10761。阅读该答案可以使dired使用scp方法进行复制,而不是使用ssh方法(后者最初使用gzip对文件进行编码,这可能非常慢)。仅当文件大于tramp-copy-size-limit (默认情况下为10240 )时,scp方法才会随scp程序一起复制。将此scp方法与dired-async-mode结合使用是非常好的,因为它不仅可以通过scp快速复制,而且还可以异步执行,而且不会影响您的工作。
另外,我认为这是有用的:https://oremacs.com/2016/02/24/dired-rsync/。它提供了使用rsync在dired中复制文件的代码片段
;;;###autoload
(defun ora-dired-rsync (dest)
(interactive
(list
(expand-file-name
(read-file-name
"Rsync to:"
(dired-dwim-target-directory)))))
;; store all selected files into "files" list
(let ((files (dired-get-marked-files
nil current-prefix-arg))
;; the rsync command
(tmtxt/rsync-command
"rsync -arvz --progress "))
;; add all selected file names as arguments
;; to the rsync command
(dolist (file files)
(setq tmtxt/rsync-command
(concat tmtxt/rsync-command
(shell-quote-argument file)
" ")))
;; append the destination
(setq tmtxt/rsync-command
(concat tmtxt/rsync-command
(shell-quote-argument dest)))
;; run the async shell command
(async-shell-command tmtxt/rsync-command "*rsync*")
;; finally, switch to that window
(other-window 1)))
(define-key dired-mode-map "Y" 'ora-dired-rsync)https://stackoverflow.com/questions/379940
复制相似问题