Run the program from Emacs and do not wait for the exit

How to get Emacs to run a program and not wait for an exit / response? I tried to open the pdf file in an external program:

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

But it will not open other files until the existing sumatrapdf process is closed. I'm tired of async-shell-command , but it opens a new buffer with Async output that I don't need.

What is the correct file path in external programs?

+5
source share
2 answers

start-process function can handle this:

 (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 do not want to bind bufer to an open process - pass nil as argument BUFFER

+10
source

See Ch k M-!

... If the command ends in an ampersand, execute it asynchronously. The output appears in the Async Shell Command buffer. This buffer is in the Mode ... shell.

IOW, M-! my_command --opt=foo arg1 arg2 & M-! my_command --opt=foo arg1 arg2 & my_command will start and create a buffer *Async Shell Command* with my_command running in it, but emacs will immediately return you control.

+3
source

Source: https://habr.com/ru/post/921397/


All Articles