如何让Emacs运行程序而不等待输出/响应?我试图在外部程序中打开pdf:
(shell-command (concat "start sumatrapdf " (shell-quote-argument path) " -page " search))))
但是在现有的 sumatrapdf 进程关闭之前,它不会打开另一个文件。我累了async-shell-command
,但它打开了一个带有异步输出的新缓冲区,我不需要它。
外部程序中文件的正确方法是什么?
答案 0 :(得分:11)
start-process
函数可以处理:
(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.
如果您不想将bufer与open进程关联 - 将nil
作为BUFFER参数传递
答案 1 :(得分:3)
请参阅C-h k M-!
... 如果COMMAND以&符号结尾,则异步执行。输出 出现在缓冲区` Async Shell Command '中。那个缓冲区在shell中 模式。 ...
IOW,M-! my_command --opt=foo arg1 arg2 &
将启动my_command
并创建一个*Async Shell Command*
缓冲区,其中包含my_command
,但emacs会立即向您发送控制权。