cjohansson
cjohansson

Reputation: 1103

Asynchrous copy-file and copy-directory in Emacs-Lisp?

Does it exists functions for Emacs Lisp which can copy files and directories (with support for TRAMP) and does this asynchronously?

My problem is that (copy-file) and (copy-directory) blocks my editor until they finish and if I do it over TRAMP with a remote-server it takes about 5-10 seconds until I can proceed.

Upvotes: 3

Views: 718

Answers (1)

cjohansson
cjohansson

Reputation: 1103

I found the answer to this myself, I use emacs-async like this:

(async-start
    `(lambda()
        (copy-file ,local ,remote-path t t)
        ,local)
    (lambda(return-path)
        (message "Upload '%s' finished" return-path))))

Place your paths in the variables local and remote-path. For directories, just change (copy-file) to (copy-directory).

Also I think you can use emacs-deferred too, however I haven't tried it yet.

Upvotes: 5

Related Questions