]> code.delx.au - gnu-emacs-elpa/blob - README.md
Updated README
[gnu-emacs-elpa] / README.md
1 # emacs-async
2
3 async.el is an exceedingly simple module for doing asynchronous processing in
4 Emacs, by spawning a child Emacs interpreter to execute a lambda function, and
5 calling back when the job is done.
6
7 It uses a very simple syntax:
8
9 (async-start
10 ;; What to do in the child process
11 (lambda ()
12 (message "This is a test")
13 (sleep-for 3)
14 222)
15
16 ;; What to do when it finishes
17 (lambda (result)
18 (message "Async process done, result should be 222: %s" result)))
19
20 If you omit the callback function, `async-start` returns a process object that
21 you can call `async-get` on when you're ready to wait for the result value:
22
23 (let ((proc (async-start
24 ;; What to do in the child process
25 (lambda ()
26 (message "This is a test")
27 (sleep-for 3)
28 222))))
29
30 (message "I'm going to do some work here") ;; ....
31
32 (message "Waiting on async process, result should be 222: %s"
33 (async-get proc)))
34
35 If you don't want to use a callback, and you don't care about any return value
36 form the child process, pass the `ignore` symbol as the second argument (if
37 you don't, and never call `async-get', it will leave *emacs* process buffers
38 hanging around):
39
40 (async-start
41 (lambda ()
42 (delete-file "a remote file on a slow link" nil))
43 'ignore)