The question was asked in 2016. Now in 2019, there exists M-x proced:
Mode for displaying system processes and sending signals to them.
Proced makes an Emacs buffer containing a listing of the current system processes. You can use the normal Emacs commands to move around in this buffer, and special Proced commands to operate on the processes listed....
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 ()
(let ((pid (process-id (get-buffer-process (current-buffer)))))
(shell-command (format "pstree -p %d" pid))))
If I have a *shell* buffer running bash, run ...
If your ~/dotfiles/rundo.sh accepts stdin as input, like many other commands
such as grep/wc/bash/python, to run a command with the region as stdin, simply
run M-| ~/dotfiles/rundo.sh (M-| runs shell-command-on-region).
If the command doesn't support stdin, the following should do what you described
(defun rundo (beg end)
"Wrapper of ~/dotfiles/rundo.sh."...
Emacs 26.1 added the confirm-kill-processes variable. To disable conformation to kill processes on Emacs exit, add to your init file:
(setq confirm-kill-processes nil)
Non-nil if Emacs should confirm killing processes on exit. If this variable is nil, the value of process-query-on-exit-flag is ignored. Otherwise, if there are processes ...
Note that script-proc-buffer will always be new-buffer since that is an existing buffer when make-comint-in-buffer is called.
To bind kill-process to the key sequence q make it somehow interactive and use local-set-key with the wanted buffer current, e.g.:
(local-set-key "q" (lambda () (interactive) (kill-process)))...
Try M-x cider-connect if you've already started a REPL via leiningen yourself.
cider-jack-in tries to start a repl-server and connect to it. For some reason, this fails, maybe because of the already running REPL, so you might try cider-jack-in without starting a REPL manually first.
Running Emacs in server-mode, you can use emacsclient to execute lisp code in that Emacs process. This makes it relatively simple to find out the file name of the currently selected window:
emacsclient -e '(buffer-file-name (window-buffer (selected-window)))'
You may need to add some more logic to deal with the case where your active window isn't visiting ...
You should start with Process Information:
(process-command (get-buffer-process "*Python*"))
==> ("python3" "-i")
(process-status (get-buffer-process "*Python*"))
You should not be running ftp and python under bash under Emacs, but rather use the specific modes for them (e.g., M-x run-python &c).
If you insist on doing it your way, you ...
In a private email, Christopher Wellons answered my question. The problem is that server-process is a special variable defined in server.el. Special variables are always dynamically bound. As a result, the filter closure doesn't close over the server-process variable. When the filter closure is evaluated, the server-process variable's value is the one from ...
It seems like the problem is that both Emacs and Vim want to control the entire screen. If I edit the function in the question to use date or a utility like that instead of Vim, there is no hang and the output replaces the buffer contents in the way I want.
Fortunately, Emacs has a function called suspend-emacs which can be used to suspend Emacs, run some ...
One way I discovered is to construct the command send to the bash process in such a way that after the execution the bash process gets stopped:
(format "%s; kill -s STOP %s\n" command (process-id bash-process))
This way a process-sentinel can be used to detect when the execution is done and can enable the process again:
(defun sentinel (proc status)
So you want to, after a certain amount of time, run some code?
You can use a timer. In the simplest way of using it, you can pass it a number of seconds to wait, tell it not to repeat, then give it a lambda to run. For example:
(run-at-time 1 ;; in one second
nil ;; do NOT repeat
(lambda () ;; this lambda is called