20

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 filter functions to intercept the output. You don't need to create or delete the filter(s) depending on whether you still have lines to send. Rather, you will ...


12

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. I have an idea of how it could be accomplished based on section 6.3 of this document (basically, store visual line information in the current buffer and ...


8

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, here it does. (let ((default-directory "/some/directory/")) ...)


6

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.


5

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 process B with async-start-process and kill A in its finish-func. Define a process sentinel for A which kills B at exit of A. Running example: (defun make-kill-...


5

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-environment. You still have only a single list for the process-environment which is just bound to two variables -- the global variable process-environment and ...


4

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 passphrase in a separate GUI window. If you want to stay within Emacs, or if you want a solution that works whether X11 is available or not, you can make Emacs ...


4

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 SLIME.


4

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'." (interactive) (start-process "espeak-process" "espeak-buffer" "espeak" "-v" "en-us") (process-send-region "espeak-process" (region-beginning) (region-end))) EDIT: ...


4

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-string For example see functions py--start-fast-process and py--fast-send-string-intern


4

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" read by Emacs and passed to the process filter, which is a function you provide via set-process-filter. The main difficulty is that you don't get to choose ...


4

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)) ;; => " 1 Hello, World!"


4

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 from other shells. There are some similarities, but don’t let these lull you into a false sense of familiarity. [...] ‘${command}’ Returns the output of ‘...


4

Yes, that's the established technique. In my code I use temporary-file-directory instead, but this is just a detail.


4

Skip all the pid stuff, and just check the STY environment variable. If it is set, then emacs is running inside screen.


3

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 bound to nil so it doesn't use a tty but a pipe.


3

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 echo -e "\e[31mHello World\e[0m" as an example, you can simply use comint-output-filter (I learnt this by reading shell-command's source code) (let ((process ...


3

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.md" "ac-comphist.dat" #("auto-save-list" 0 14 (font-lock-face eshell-ls-directory)) #("bin" 0 3 (font-lock-face eshell-ls-directory)) "custom.el"...


3

Just expand the file name: (let ((default-directory "/Users/HOME/Desktop/tmp")) (start-process "touch-file" nil "touch" (expand-file-name "test.txt")))


3

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 is running will be buffered and will end up where you want it: as input to the find-tag prompt. e.g.: (defun my-find-tag () "Update TAGS file and then call `...


3

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 important to avoid this to be seen as one very large undo-step which risks loosing your undo history for example. This code used clang-format package as a ...


3

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> emacs -Q --batch --eval '(call-process "okular" nil 0 nil)'


3

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 additionally prevent the process from having a terminal to write to -- so if the process is still running and generating output, the kernel will stop it at that point (via ...


2

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.


2

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 (origfun procname &rest args) (if (not (equal procname "shell")) (apply origfun procname args) ;; Not a shell, nothing to do. ;; Enable auto-save-...


2

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 likely to be generating heavy output are created later than the ones where you want interactivity. That way the interactive shells are the first to be handled by ...


2

{ ... } 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/echo a b c} | tr [[:lower:]] [[:upper:]] ~ $ A B C ~ $ echo {echo a b c} ("a" "b" "c") ~ $ echo {/bin/echo a b c} ~ $ echo {/bin/echo hi} ~ $ echo {echo hi} hi ~ ...


2

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 (concat "OLDHOME=" (getenv "HOME")) process-environment)))) (start-process "proc" (current-buffer) ...))


2

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're running Emacs as an X Windows application, not inside a terminal, else you wouldn't have this problem. The first is by selecting text in program A and ...


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