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."...
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.
(defun my-find-tag ()
"Update TAGS file and then call `...
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 ...
You can't usefully have two simultaneous Emacs session that use the same file to store the session state. Each time a session saves its state, it would overwrite the other session's state.
Many people run a single Emacs session. To open a file in the existing Emacs session, use emacsclient (see also the Emacs wiki). Emacsclient has several options to ...
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
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)))...
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)
Use :command '("hello-world") instead. Here is the related docstring of make-process.
:command COMMAND -- COMMAND is a list starting with the program file
name, followed by strings to give to the program as arguments.