deferred.el API

Basic functions

Function deferred:next &optional callback arg
Create a deferred object and schedule executing.

:Arguments:
    CALLBACK
        a function with zero or one argument
:Return: a deferred object

This function is a short cut of following code::

 (deferred:callback-post (deferred:new callback)).
Function deferred:nextc d callback
Create a deferred object with OK callback and connect it to
the given deferred object.

:Arguments:
    D
        a deferred object
    CALLBACK
        a function with zero or one argument
:Return: a deferred object

Return a deferred object that wrap the given callback
function.  Then, connect the created deferred object with the
given deferred object.
Function deferred:error d callback
Create a deferred object with ERRORBACK and connect it to the
given deferred object D.

:Arguments:
    D
        a deferred object
    ERRORBACK
        a function with zero or one argument
:Return: a deferred object

Return a deferred object that wraps the given function as an
ERRORBACK.  Then, connect the created deferred object with the
given deferred object.  The given ERRORBACK function catches the
error occurred in the previous task.

If this function does not throw an error, the subsequent callback
functions are executed.
Function deferred:cancel d
Cancel all callbacks and deferred chain in the deferred object.
Function deferred:watch d callback
Create a deferred object with watch task and connect it to the given deferred object.
The watch task CALLBACK can not affect deferred chains with
return values. This function is used in following purposes,
simulation of try-finally block in asynchronous tasks, progress
monitoring of tasks.
Function deferred:wait msec
Return a deferred object scheduled at MSEC millisecond later.
Function deferred:$ &rest elements
Anaphoric function chain macro for deferred chains.

Utility functions

Function deferred:loop times-or-list func
Return a iteration deferred object.
Function deferred:parallel &rest args
Return a deferred object that calls given deferred objects or
functions in parallel and wait for all callbacks. The following
deferred task will be called with an array of the return
values. ARGS can be a list or an alist of deferred objects or
functions.
Function deferred:earlier &rest args
Return a deferred object that calls given deferred objects or
functions in parallel and wait for the first callback. The
following deferred task will be called with the first return
value. ARGS can be a list or an alist of deferred objects or
functions.

Wrapper functions

Function deferred:call f &rest args
Call the given function asynchronously.
Function deferred:apply f &optional args
Call the given function asynchronously.
Function deferred:process command &rest args
A deferred wrapper of `start-process'. Return a deferred
object. The process name and buffer name of the argument of the
`start-process' are generated by this function automatically.
The next deferred object receives stdout string from the command
process.
Function deferred:process-shell command &rest args
A deferred wrapper of `start-process-shell-command'. Return a deferred
object. The process name and buffer name of the argument of the
`start-process-shell-command' are generated by this function automatically.
The next deferred object receives stdout string from the command
process.
Function deferred:process-buffer command &rest args
A deferred wrapper of `start-process'. Return a deferred
object. The process name and buffer name of the argument of the
`start-process' are generated by this function automatically.
The next deferred object receives stdout buffer from the command
process.
Function deferred:process-shell-buffer command &rest args
A deferred wrapper of `start-process-shell-command'. Return a deferred
object. The process name and buffer name of the argument of the
`start-process-shell-command' are generated by this function automatically.
The next deferred object receives stdout buffer from the command
process.
Function deferred:wait-idle msec
Return a deferred object which will run when Emacs has been
idle for MSEC millisecond.
Function deferred:url-retrieve
Function deferred:url-get
Function deferred:url-post

Primitive functions

Function deferred:new &optional callback
Create a deferred object.
Function deferred:succeed &optional arg
Create a synchronous deferred object.
Function deferred:fail &optional arg
Create a synchronous deferred object.
Function deferred:callback d &optional arg
Start deferred chain with a callback message.
Function deferred:callback-post d &optional arg
Add the deferred object to the execution queue.
Function deferred:errorback d &optional arg
Start deferred chain with an errorback message.
Function deferred:errorback-post d &optional arg
Add the deferred object to the execution queue.

Utility Macros

Function deferred:try d &key catch finally
Try-catch-finally macro. This macro simulates the
try-catch-finally block asynchronously. CATCH and FINALLY can be
nil. Because of asynchrony, this macro does not ensure that the
task FINALLY should be called.
Function deferred:timeout timeout-msec timeout-form d
Time out macro on a deferred task D.  If the deferred task D
does not complete within TIMEOUT-MSEC, this macro cancels the
deferred task and return the TIMEOUT-FORM.
Function deferred:processc d command &rest args
Process chain of `deferred:process'.
Function deferred:process-bufferc d command &rest args
Process chain of `deferred:process-buffer'.
Function deferred:process-shellc d command &rest args
Process chain of `deferred:process'.
Function deferred:process-shell-bufferc d command &rest args
Process chain of `deferred:process-buffer'.