How to make Emacs run a program and don't wait for output/respond? I tried to open a pdf in an external program:
(shell-command (concat "start sumatrapdf " (shell-quote-argument path) " -page " search))))
But it won't open another files until the existing sumatrapdf process is closed. I tried async-shell-command
, but it opens a new buffer 开发者_StackOverflowwith Async output which I don't need.
What is the right way to open files in external programs?
start-process
function can handle that:
(start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS)
Start a program in a subprocess. Return the process object for it.
NAME is name for process. It is modified if necessary to make it unique.
BUFFER is the buffer (or buffer name) to associate with the process.
Process output (both standard output and standard error streams) goes
at end of BUFFER, unless you specify an output stream or filter
function to handle the output. BUFFER may also be nil, meaning that
this process is not associated with any buffer.
PROGRAM is the program file name. It is searched for in `exec-path'
(which see). If nil, just associate a pty with the buffer. Remaining
arguments are strings to give program as arguments.
If you want to separate standard output from standard error, invoke
the command through a shell and redirect one of them using the shell
syntax.
If you don't want to associate bufer with open process — pass nil
as BUFFER argument
See C-h k M-!
... If COMMAND ends in ampersand, execute it asynchronously. The output appears in the buffer `Async Shell Command'. That buffer is in shell mode. ...
IOW, M-! my_command --opt=foo arg1 arg2 &
will start my_command
and create a *Async Shell Command*
buffer with my_command
running in it but emacs will give control back to you right away.
精彩评论