本文介绍了从Emacs运行程序,不要等待输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使Emacs运行程序,不要等待输出/响应?我试图在外部程序中打开一个pdf:

 (shell-command(concatstart sumatrapdf(shell-quote-参数路径)-pagesearch))))

但是,直到现有的 sumatrapdf 进程已关闭。我厌倦了 async-shell-command ,但它打开了一个新的缓冲区,Async输出不需要。




解决方案

开始进程

code>函数可以处理:

 (start-process NAME BUFFER PROGRAM& rest PROGRAM-ARGS)

在子进程中启动一个程序。返回它的进程对象。
NAME是进程的名称。如有必要,将其修改为使其独一无二。
BUFFER是与进程关联的缓冲区(或缓冲区名称)。

除了您指定输出流或过滤器
函数以处理输出之外,进程输出(标准输出和标准错误流两者)在$ BUFFER结尾处都为
。 BUFFER也可能是零,意味着
这个进程与任何缓冲区都不相关。

PROGRAM是程序文件名。它在`exec-path'
(其中看到)中搜索。如果没有,只需将pty与缓冲区相关联。剩余
参数是给程序作为参数的字符串。

如果要将标准输出与标准错误分开,请通过shell调用
命令,并使用shell
语法重定向其中一个。

如果不想将bufer与打开的进程相关联 - pass nil 作为BUFFER参数


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 tired async-shell-command, but it opens a new buffer with Async output which I don't need for.

What is the right way to 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

这篇关于从Emacs运行程序,不要等待输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 19:03