2011-09-04 42 views
5

如何让Emacs运行程序并不等待输出/响应?我试图在外部程序中打开PDF:从Emacs运行程序,不要等待输出

(shell-command (concat "start sumatrapdf " (shell-quote-argument path) " -page " search)))) 

但直到现有sumatrapdf过程中关闭它不会打开另一个文件。我累async-shell-command,但它打开一个新的缓冲区,我不需要异步输出。

什么是正确的方式来在外部程序中的文件?

回答

9

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与开放的过程 - 通过nil缓冲参数

+0

谢谢你,维克多。用你的提示,我发现了一个稍微不同的函数('start-process-shell-command'),因为'start-process'没有正确引用参数。 –

+0

那么,如何让BUFFER结束并显示出来呢? – zobi8225

2

C-h k M-!

... 如果COMMAND以&符结束,则异步执行。输出 出现在缓冲区'异步外壳命令'中。该缓冲区在shell 模式下。 ...

督察,M-! my_command --opt=foo arg1 arg2 &将开始my_command并创建一个*Async Shell Command*缓冲区my_command在它运行,但Emacs会给予控制权交还给你的时候了。

+0

在我的情况下,Emacs不应该等待任何回应。只需打开一个文件并忘记它(实际上,它是针对组织模式和自定义超链接类型的,它将在特定页面上打开pdf)。无论如何,感谢你的关注,罗斯。 –