Запустите программу из Emacs и не ждите вывода - PullRequest
6 голосов
/ 04 сентября 2011

Как заставить Emacs запустить программу и не ждать вывода / ответа?Я пытался открыть pdf во внешней программе:

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

Но другие файлы не открываются, пока не будет закрыт существующий процесс sumatrapdf .Я устал async-shell-command, но он открывает новый буфер с выходом Async, который мне не нужен.

Как правильно обращаться с файлами во внешних программах?

Ответы [ 2 ]

11 голосов
/ 04 сентября 2011

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.

Если вы не хотите связывать буфер с открытым процессом - передайте nil в качестве аргумента BUFFER

3 голосов
/ 04 сентября 2011

См. C-h k M-!

... Если COMMAND заканчивается амперсандом, выполнить его асинхронно.Вывод появляется в буфере ` Async Shell Command '.Этот буфер находится в режиме оболочки....

IOW, M-! my_command --opt=foo arg1 arg2 & запустит my_command и создаст буфер *Async Shell Command* с запущенным в нем my_command, но emacs сразу же вернет вам управление.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...