3 `async.el` is a module for doing asynchronous processing in Emacs.
7 Add to your `.emacs.el`:
9 (autoload 'dired-async-mode "dired-async.el" nil t)
12 This will allow you to run asynchronously
13 the dired commands for copying, renaming and symlinking.
14 If you are a [helm](https://github.com/emacs-helm/helm) user, this will allow you
15 to copy, rename etc... asynchronously from [helm](https://github.com/emacs-helm/helm).
16 Note that with [helm](https://github.com/emacs-helm/helm)
17 you can disable this by running the copy, rename etc... commands with a prefix argument.
19 If you don't want to make dired/helm asynchronous disable it with `dired-async-mode`.
23 The interface is intended to be very easy to use:
27 async-start START-FUNC FINISH-FUNC
29 Execute START-FUNC (often a lambda) in a subordinate Emacs process. When
30 done, the return value is passed to FINISH-FUNC. Example:
33 ;; What to do in the child process
35 (message "This is a test")
39 ;; What to do when it finishes
41 (message "Async process done, result should be 222: %s" result)))
43 If FINISH-FUNC is `nil` or missing, a future is returned that can be inspected
44 using `async-get`, blocking until the value is ready. Example:
46 (let ((proc (async-start
47 ;; What to do in the child process
49 (message "This is a test")
53 (message "I'm going to do some work here") ;; ....
55 (message "Waiting on async process, result should be 222: %s"
58 If you don't want to use a callback, and you don't care about any return value
59 from the child process, pass the `'ignore` symbol as the second argument (if
60 you don't, and never call `async-get`, it will leave ``*emacs*`` process buffers
65 (delete-file "a remote file on a slow link" nil))
68 Note: Even when FINISH-FUNC is present, a future is still returned except that
69 it yields no value (since the value is passed to FINISH-FUNC). Calling
70 `async-get` on such a future always returns `nil`. It can still be useful,
71 however, as an argument to `async-ready` or `async-wait`.
73 ## async-start-process
75 async-start-process NAME PROGRAM FINISH-FUNC &rest PROGRAM-ARGS
77 Start the executable PROGRAM asynchronously. See `async-start`. PROGRAM is
78 passed PROGRAM-ARGS, calling FINISH-FUNC with the process object when done.
79 If FINISH-FUNC is `nil`, the future object will return the process object when
80 the program is finished. Set DEFAULT-DIRECTORY to change PROGRAM's current
87 Get the value from an asynchronously called function when it is ready. FUTURE is
88 returned by `async-start` or `async-start-process` when its FINISH-FUNC is
95 Query a FUTURE to see if its function's value is ready -- i.e., if no blocking
96 would result from a call to `async-get` on that FUTURE.
102 Wait for FUTURE to become ready.
104 ## async-inject-variables
106 async-inject-variables INCLUDE-REGEXP &optional PREDICATE EXCLUDE-REGEXP
108 Return a `setq` form that replicates part of the calling environment. It sets
109 the value for every variable matching INCLUDE-REGEXP and also PREDICATE. It
110 will not perform injection for any variable matching EXCLUDE-REGEXP (if
111 present). It is intended to be used as follows:
117 (insert ,(buffer-substring-no-properties (point-min) (point-max)))
118 ;; Pass in the variable environment for smtpmail
119 ,(async-inject-variables "\\`\\(smtpmail\\|\\(user-\\)?mail\\)-")