emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: async.el: A simple asynchronous framework for Emacs


From: John Wiegley
Subject: Re: async.el: A simple asynchronous framework for Emacs
Date: Tue, 19 Jun 2012 19:53:47 -0500
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1 (darwin)

Apropos of nothing, just discovered that `apply-partially' is a nice way to
run one-liners asynchronously:

  (async-start (apply-partially #'copy-file from to ok-flag preserve-time)
               (apply-partially #'message "Copy done: %s -> %s" from to))

The alternative is less consistent:

  (async-start `(lambda () (copy-file ,from ,to ,ok-flag ,preserve-time))
               (lambda () (message "Copy done: %s -> %s" from to)))

Since `form' and `to' need their values passed to the child process, while the
variables remain in scope for the callback (thanks to closures).  Of course,
the <24 version is equally consistent in its ugliness:

  (async-start `(lambda () (copy-file ,from ,to ,ok-flag ,preserve-time))
               `(lambda () (message "Copy done: %s -> %s" ,from ,to)))

John



reply via email to

[Prev in Thread] Current Thread [Next in Thread]