5
votes
How to run a custom formatting tool on save?
This can be done using:
call-process-region to run the command and catch the stdout/stderr.
replace-buffer-contents to update the region without causing the entire buffer to be replaced.
This is ...
5
votes
Accepted
how to do command substitution in eshell generally (NOT just for loop)
I then tried various sorts of C-h and websearch, without success.
Please check the manual first! (or second, after docstrings) (eshell) Dollars Expansion:
Eshell has different ‘$’ expansion syntax ...
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-...
5
votes
Accepted
How to attach/connect two subprocesses?
For two processes A and B mutually killing each other you can use the following approach:
Start the first process just with start-process and remember its process (as lisp object).
Start the second ...
4
votes
Accepted
Asynchronous version of shell-command-on-region?
Something in this spirit should do the trick. I tried it with espeak under Ubuntu; I guess it would work with say as well.
(defun my-read-words-on-region ()
"Send the region to `espeak'."
(...
4
votes
Accepted
Execute program on string
You can use call-process-region to send string to a program as standard input, for example,
(with-temp-buffer
(call-process-region "Hello, World!" nil "cat" nil t nil "-n")
(buffer-string))
;; =&...
4
votes
Accepted
Looking for a better way to test whether the current Emacs process is running under GNU Screen
Skip all the pid stuff, and just check the STY environment variable. If it is set, then emacs is running inside screen.
4
votes
Accepted
start-process: Setting current directory: No such file or directory
Yes, that's the established technique. In my code I use temporary-file-directory instead, but this is just a detail.
3
votes
Interpret terminal escape codes in generic process output
You can use "process sentinel" mentioned in @steve-lorimer's answer if it is OK for you to get color AFTER the process is finished, otherwise you should use "process filter" instead.
Take command ...
3
votes
Accepted
How to stop a subprocess?
On my system, yes doesn't react to SIGTSTP, which is the signal sent by stop-process (rather than SIGSTOP as one might assume).
When you run yes in your terminal and shell, C-z is going to ...
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> ...
3
votes
Accepted
How to partially block user input while Emacs subprocess is running
I suspect that the simplest approach is entirely adequate here. Using a synchronous process will prevent you from inadvertently typing into the wrong buffer -- anything you do type while the command ...
3
votes
Accepted
Process input seems buggy in Emacs on OS X
Not sure how to fix it (I really mean it: I've tried to fix this bug in the past, but my POSIX-fu is not strong enough), but you can circumvent it by creating your process with process-connection-type ...
3
votes
Set environment variables for spawned subprocesses
Since Emacs 28.1 you can use the with-environment-variables macro.
Example:
(with-environment-variables (("DESKTOP_SESSION" "TEST_VALUE"))
(shell-command "echo $...
3
votes
How can Emacs set an environment/shell variable in a subordinate shell?
You can use the with-environment-variables macro.
(let ((buffer-auto-save-file-name "test-file.txt"))
(with-environment-variables (("BUFFER_AUTO_SAVE_FILE_NAME" buffer-auto-save-...
2
votes
Accepted
How can Emacs set an environment/shell variable in a subordinate shell?
After (re)reading the code of the shell function, here's what I'd do:
(advice-add 'make-comint-in-buffer :around
#'my-enable-auto-save-in-shell)
(defun my-enable-auto-save-in-shell (...
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 (...
2
votes
Accepted
How can I run a subprocess with emacs --script
Basically, Emacs exits before the subprocess has exited. All you have to do is delay the exit until the subprocess has exited. Since Emacs does not have anything useful to do, you can have it sleep ...
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'...
2
votes
Convenient piping for multiple processes?
This utility function takes list arguments, each one is a commend that is piped to the next command.
:input keyword argument for input from buffer/string (or nil for none).
:output keyword argument ...
1
vote
Looking for a better way to test whether the current Emacs process is running under GNU Screen
@db48x's answer is undoubtedly the best answer to the question. But it depends on the good graces of screen which conveniently sets the STY variable that sub-processes can check (tmux sets a TMUX ...
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-...
1
vote
Troubleshooting a hanging `list-processes`
If this happens it means that Emacs is having trouble communicating with some subprocess. It is a good idea to leave Emacs and look at its subprocesses from the hosting operating system.
For example, ...
1
vote
Accepted
Multi-processing via TRAMP with asynchronous shell commands
The quoted limitation does not exist any longer. Moreover, the function tramp-adb-handle-shell-command does not exist any longer. All different implementations of shell-command in Tramp have been ...
1
vote
How to let make-process prompt user in echo area
TRAMP does a pretty ugly hack to detect a network process prompting for input, it uses regex matching to detect a printed prompt, then asks for user input using tramp-read-passwd. This will obviously ...
1
vote
Accepted
How to run a command via elisp, completely ignoring its output and status? (fire and forget)
call-process, despite normally being used for synchronous process calls:
call-process is a built-in function in `C source code'.
(call-process PROGRAM &optional INFILE DESTINATION DISPLAY &...
1
vote
Accepted
redirect stderr to a file in call-process-region
You don't need the (:file ) just give the error file as second element in the list.
BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
REAL-BUFFER says what to do with standard ...
1
vote
Cleanly terminating asynchronous process after it reads stdin
Turns out I was doing this correctly, and the process was correctly returning a 1 result. So the posted code is the correct thing to do.
1
vote
Accepted
Wait for (tex-file) to execute before go on with an elisp script
I found a solution to my problem here: https://stackoverflow.com/questions/23021875/wait-on-shell-command-to-finish-before-executing-another-elisp-command
I resolved by using:
(call-process-shell-...
1
vote
How can Emacs set an environment/shell variable in a subordinate shell?
(let ((process-environment
`(,(concat "BUFFER_AUTO_SAVE_FILE_NAME="
buffer-auto-save-file-name)
,@process-environment)))
(shell))
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
subprocess × 53process × 18
async × 9
shell × 7
shell-command × 6
call-process × 5
eshell × 4
comint × 4
python × 2
tramp × 2
compilation × 2
performance × 2
compilation-mode × 2
error-handling × 2
environment × 2
x-window × 2
org-mode × 1
key-bindings × 1
latex × 1
elisp × 1
dired × 1
osx × 1
microsoft-windows × 1
frames × 1
emacsclient × 1