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 ...
9
votes
Remembering history between sessions in Inferior Emacs Lisp Mode
You can save the buffer-local value of comint-input-ring in a global variable when an *ielm* buffer is killed and restore it in inferior-emacs-lisp-mode-hook:
;; global copy of the buffer-local ...
6
votes
How to make shell-command run using shell profile and current directory hooks (ex. direnv)
Running eval "$(direnv hook $0)" defines a function that hooks into $PROMPT_COMMAND, which is never called when bash is run as bash -ic because there is no prompt. You can change the line:
eval "$(...
6
votes
How to make shell-command run using shell profile and current directory hooks (ex. direnv)
This doesn't seem to be a problem with Emacs but with bash. shell-command just executes call-process on the shell and passes arguments. I tried this on a regular shell:
bash -ic "cd ~/code/foo &...
6
votes
Accepted
How to determine which program is running inside an emacs shell buffer?
Here's a simple function that gets the pid of the process running in the current buffer and then calls the pstree command to get the process tree of that process:
(defun iproc ()
(interactive)
(...
5
votes
Accepted
Is it possible to read user input from STDIN while tangling a source block?
Try this
Note: Made following minor changes to your code block:
Moved #!/bin/bash into code block header :shebang #!/bin/bash to automatically set executable file permissions when block is ...
5
votes
Accepted
How to make shell-command run using shell profile and current directory hooks (ex. direnv)
Thanks to Rekado and Erik for pointing out how the direnv hook works by using $PROMPT_COMMAND. Since shell-command doesn't use a prompt, this wasn't getting executed.
While Erik's answer works in my ...
5
votes
Accepted
How should comint-derived modes keep track of buffers and processes?
For the reasons you provided, I generally prefer to hold on to the buffer.
Then I write a foo-proc function which returns the corresponding process, potentially re-starting it if needed. And I even ...
5
votes
Accepted
How to clear shell in ielm?
inferior-emacs-lisp-mode (aka ielm), like various other subshell modes in Emacs, derives from comint-mode, a general COMmand INTerpreter. This means that ielm inherits a lot of comint's functionality ...
5
votes
Accepted
Sending `C-c C-c` to the process window without swithcing to it
You'll need to write your own function for doing this.
You'll want to read up on the functions get-buffer-process and signal-process to learn about how to send the right signal to the ESS process.
...
4
votes
Accepted
How can I tell if a buffer is a comint buffer, eshell buffer or neither?
You can test the current major-mode by querying the major-mode variable.
(if (eq major-mode 'eshell-mode) ...)
(if (eq major-mode 'comint-mode) ...)
If you would like to test a mode, and all of it's ...
4
votes
Accepted
How to explain this strange comint behavior?
Could someone explain this behavior?
The documentation of line-end-position has a note at the end that explains this behavior:
This function constrains the returned position to the current field
...
4
votes
savehist the comint input ring
I followed this guide:
https://oleksandrmanzyuk.wordpress.com/2011/10/23/a-persistent-command-history-in-emacs/
and also took hint of a comment in the similar SO-question you mentioned (which advised ...
4
votes
Accepted
How to go through command history based on what's been typed (matlab style)
You're looking for the commands comint-previous-matching-input-from-input and comint-next-matching-input-from-input, which by default are bound to C-c M-r and C-c M-s.
I recommend binding these ...
3
votes
Accepted
How does comint-mode override beginning of line behavior? I want same functionality to eshell
Dan's comment helped me on the way. Comint achieves the prompt protecting functionality with text-properties. I can add the needed properties in eshell by evaluating.
(add-text-properties (point-at-...
3
votes
In shell, eshell and comint-modes, the cursor moves back one chacacter when I switch buffers
there must be something wrong with my config, but I don't know what to look for that might be causing it.
So that's your question, in fact: How do I find how my init file caused a problem?
The ...
3
votes
multi line inputs in ipython
I realize it's an old question, but since it was left unanswered, I will bring the fix I found here after running into the same issue.
Make sure your version of IPython is at least 5.4
Install ...
3
votes
How to combine maxima-mode with *imaxima*?
I'm a beginner when it comes to Emacs (Lisp) but the following seems to work (at least for me). I'm also using the Spacemacs configuration framework so there's a possibility of some stuff being ...
3
votes
How to make shell-command run using shell profile and current directory hooks (ex. direnv)
nowadays you would likely want to use https://github.com/wbolster/emacs-direnv
it works similar to the hook that direnv installs in your shell. the emacs environment is updated on request (or ...
3
votes
I need example of correct using of comint and getting last comand output
One crude non-robust way to get the last output in term-modeis:
(defun term-recommended-hook ()
"Hook function recommended as `term-mode-hook'. (See file \"term.el\".)"
(setq term-prompt-regexp "^...
3
votes
How can I have comint buffer input histories betweens different comint sessions?
As far as I can tell, comint offers the variable comint-input-ring-file-name for this. It wouldn't make much sense to use this globally, because all "frontend" functions that use comint under the ...
3
votes
Accepted
Cargo-process does not accept user input
After some research, I was able to solve it by adding this to my init.el:
(with-eval-after-load 'rust-mode
(define-key rust-mode-map (kbd "C-r") 'my-cargo-run))
(defun my-cargo-run ()
"Build and ...
3
votes
2
votes
zsh EXTENDED_HISTORY corrupts shell-mode history
Setting comint-input-ring-separator so that the whole timestamp is treated as part of the command separator worked for me. For example:
; Remember lots of previous commands in shell-mode
(setq comint-...
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 ...
2
votes
Accepted
Using ESS in console Emacs
Source of the problem
So the problem is in the ESS variable ess-microsoft-p. Defined as:
(defvar ess-microsoft-p (or (equal window-system 'w32)
(equal window-system '...
2
votes
Accepted
Size of process output sent to filter functions
two options:
Advise comint functions which use (accept-process-output proc), so that accept-process-output is redefined to send nil instead of proc. Without proc, it will use adaptive read buffering ...
2
votes
In shell, eshell and comint-modes, the cursor moves back one chacacter when I switch buffers
It was easier to find than I thought.
This was the culprit (hiwin-activate) from hiwin-mode
I opened this issue: https://github.com/yoshida-mediba/hiwin-mode/issues/7
UPDATE
I switched to https://...
2
votes
Accepted
Replicate ipython history behaviour in Emacs
Not sure which ipy mode, You are referring. I use ipython shell which comes with elpy. It also has the same problem.
By default up arrow (or M-p) are bind to (comint-previous-input ARG). So no ...
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 (...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
comint × 73python × 15
shell × 15
process × 8
eshell × 6
ess × 5
shell-mode × 5
ipython × 4
subprocess × 4
ansi-term × 3
repl × 3
history-variables × 3
evil × 2
helm × 2
debugging × 2
window × 2
microsoft-windows × 2
font-lock × 2
major-mode × 2
term × 2
elpy × 2
javascript × 2
performance × 2
r × 2
compilation-mode × 2