20 votes
Accepted

Asynchronously wait for output from a comint process

First of all, you shouldn't be using accept-process-output if you want asynchronous processing. Emacs will accept output every time when it is waiting for user input. The proper way to go is to use ...
user avatar
12 votes
Accepted

How to prevent slow-down when an inferior processes generates long lines?

As already answered in the comments, Emacs becoming very slow in its redisplay for long lines is a well-known issue. Fixing it would be very nice, but needs lots of thought to be pulled off correctly....
user avatar
  • 21.1k
8 votes
Accepted

Temporarily set the `default-directory` for `start-process`

default-directory has to be a directory, not the filename of a directory. In other words it has to end with a slash. In some places it does not matter whether a directory path ends with a slash or not,...
user avatar
  • 24.3k
6 votes
Accepted

Capturing stderr of subprocesses

This is fixed in Emacs 25, where you can use the make-process function with the :stderr argument. I don't think there's anything suitable in Emacs 24.
user avatar
  • 5,510
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 ...
user avatar
  • 30.3k
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
  • 30.3k
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 ...
user avatar
  • 8,793
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 ...
user avatar
  • 7,199
4 votes
Accepted

Run ssh-add from Emacs and enter a passphrase

The easy way would be to install ssh-askpass. This is the program that ssh-add runs when its standard input is not a terminal but an X11 display is available. The program ssh-askpass prompts for your ...
user avatar
4 votes
Accepted

How to set up Emacs with Clozure CL but without SLIME

Just run-lisp. Afterwards, you can use e.g. C-c C-l (lisp-load-file) to eval a source file. C-c C-e (lisp-eval-defun) to eval a statement. Still, I can't imagine why someone wouldn't want to run ...
user avatar
  • 13.6k
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'." (...
user avatar
  • 6,041
4 votes

How to prevent slow-down when an inferior processes generates long lines?

As this happened with Python likewise, solution at python-mode.el, https://launchpad.net/python-mode, is to connect to process directly, not via comint-mode. Relies on start-process and process-send-...
user avatar
4 votes
Accepted

How does one create back and forth communication to a process

The functionality used by comint mode is start-process, so I think you might like to start with that. You send data to the process with process-send-string, and the process's output is "automatically"...
user avatar
  • 25.3k
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)) ;; =&...
user avatar
  • 13.6k
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.
user avatar
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.
user avatar
  • 11.8k
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 ...
user avatar
  • 25.3k
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 ...
user avatar
  • 13.6k
3 votes

What is the syntax for a subshell in eshell?

In eshell, process subshells are generally done with ${...} syntax. However, the output is produced in the form of an intermediate Emacs Lisp expression. ~ $ echo ${cd ~/.emacs.d; ls} | cat ("README....
user avatar
  • 10k
3 votes

Temporarily set the `default-directory` for `start-process`

Just expand the file name: (let ((default-directory "/Users/HOME/Desktop/tmp")) (start-process "touch-file" nil "touch" (expand-file-name "test.txt")))
user avatar
  • 13.6k
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 ...
user avatar
  • 43.5k
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
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 ...
user avatar
  • 43.5k
2 votes

Persistent environment for M-x compile

Can you do the setup in your shell before you start emacs? The compile sub-shell should inherit the environment from its grandparent via emacs.
user avatar
  • 193
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 (...
user avatar
  • 25.3k
2 votes

How do I prevent one subprocess from starving others?

So this isn't a proper solution but I ran your test the other way around (e.g. the while [1] on the second shell) and it works fine. As a work around you could ensure that any shell buffers that are ...
user avatar
  • 4,546
2 votes

What is the syntax for a subshell in eshell?

{ ... } has very varying behavior (at least, from the point of view of bash): ~ $ {echo a b c} | tr [[:lower:]] [[:upper:]] ("A" "B" "C")~ $ ~ $ {echo hi} | tr [[:lower:]] [[:upper:]] HI~ $ {/bin/...
user avatar
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.3k
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.8k

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