2022 Developer Survey is open! Take survey.
5 votes
Accepted

Set environment variables for spawned subprocesses

setenv-internal and setenv change the list stored in process-environment (as local or special variable) by side-effects. It does not help if you assign the list (pointer) to a local variable process-...
user avatar
  • 29.8k
5 votes
Accepted

How to call "echo ${GOPATH}" with call-process?

You're looking for (call-process-shell-command "echo ${GOPATH}" nil t nil). In this case, ${PATH} is syntax defined by a shell, not a native call, so you'll need to invoke a shell to interpret it. ...
user avatar
  • 9,993
4 votes

Differences between cmdproxy.exe and cmd.exe

I just found this: Proxy shell designed for use with Emacs on Windows 95 and NT. [...] The main function is simply to process the "-c string" option in the way /bin/sh does, since the standard ...
user avatar
  • 1,618
3 votes

Ignore stderr when calling call-shell-region

Your list is quoted, so you are passing in a list with two symbols rather than a buffer and nil. Use list rather than quote: (call-shell-region (point-min) (point-max) (concat "...
user avatar
  • 11.4k
3 votes
Accepted

How to start a persistent asynchronous process trough emacs?

You can use call-process the same way as you did, but just replace the third argument by 0. If the third argument is 0, Emacs don't wait for the process and quit without killing it. SHELL-PROMPT> ...
user avatar
3 votes

Why does :command argument of make-process not work when string passed as a variable?

You've quoted the list: :command '("sh" "-c" body) So you have passed it a symbol body not the string value of the variable. Try: :command (list "sh" "-c" body) or: :command `("sh" "-...
user avatar
  • 43.1k
3 votes

Run a process synchronously and obtain stdout and stderr in different buffers?

The c-function call-process is the basis for creating synchronous processes in Emacs. So you don't get more with any other functions. The info page (elisp) Synchronous Processes contains the ...
user avatar
  • 29.8k
2 votes

Set environment variables for spawned subprocesses

The "let binding" way is the following (notice that contrary to Tobias's answer, this does not involve any copying or "set"ting): (let ((process-environment (cons "HOME" (cons (...
user avatar
  • 25.2k
2 votes
Accepted

How to send quoted argument to call-process

I would like to run convert - -draw 'rectangle 0,0,100,100' - Note that you're quoting for the shell there, so that it will not break that argument into two, on account of the space. For example I ...
user avatar
  • 43.1k
2 votes

Cannot paste text copied from Emacs to synchronous subprocess

There are several ways of copying text between programs on Linux. I'm just guessing that you're using Linux, but I don't think that this problem could occur on Windows or OSX. I also surmise that you'...
user avatar
  • 11.4k
2 votes

How to pipe data through multiple processes?

Use the system shell, e.g., M-! ls | wc, there are many other APIs such as shell-command-to-string, call-process-shell-command and start-process-shell-command. An idea is emulating pipe like the ...
user avatar
  • 13.5k
2 votes

Elisp function to open file name with space?

I recommend using call-process instead of shell-command: (defun open-a-file () (interactive) (call-process "xdg-open" nil 0 nil (read-file-name "Open: "))) One large ...
user avatar
  • 11.4k
1 vote
Accepted

Getting the PID of process initiated with call-process

Here's a somewhat silly implementation of a function that does a call-process and returns its pid (sort-of): (defun call-process-pid () (let (l1 l2) (setq l1 (list-system-processes)) (call-...
user avatar
  • 19.6k
1 vote
Accepted

shell command on region with process substitution

You can use something like the following with M-|: cat > tmp.txt && python -m doctest -v tmp.txt
user avatar
  • 13.5k
1 vote
Accepted

Run a process synchronously and obtain stdout and stderr in different buffers?

Another way I could do this without rewriting the C code for call-process would be to use make-process and go into a busy-wait loop that is similar to the following: (defvar my-process-finished nil &...
user avatar
  • 522

Only top scored, non community-wiki answers of a minimum length are eligible