If I execute a shell command asynchronously in emacs lisp like so:
(shell-command “mycommand &”)
Is there a way to wait for the command to generate output before continuing? For my current application, it is probably sufficient to wait until the command generates any output at all, but ideally I’d like to capture the output for additional processing. Is this possible?
You should use
comint-output-filter-functionsvariable that contains function to call after output is inserted into the buffer.For example, you can do :
N.B. : From Emacs 23.2, you have the new command
async-shell-command, bound globally to M-&.This executes your command asynchronously without requiring an ampersand. The output of your command is sent to the buffer
*Async Shell Command*.