I like to use Emacs' shell mode, but it has a few deficiencies. One of those is that it's not smart enough to open a new buffer when a shell command tries to invoke an editor. For example with the environment variable VISUAL
set to vim
I get the following from svn propedit
:
$ svn propedit svn:externals . "svn-prop.tmp" 2L, 149C[1;1H ~ [4;1H~ [5;1H~ [6;1H~ [7;1H~ ...
(It may be hard to tell from the representation, but it's a horrible, ugly mess.)
With VISUAL
set to "emacs -nw"
, I get
$ svn propedit svn:externals . emacs: Terminal type "dumb" is not powerful enough to run Emacs. It lacks the ability to position the cursor. If that is not the actual type of terminal you have, use the Bourne shell command `TERM=... export TERM' (C-shell: `setenv TERM ...') to specify the correct type. It may be necessary to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.svn: system('emacs -nw svn-prop.tmp') returned 256
(It works with VISUAL
set to just emacs
, but only from inside an Emacs X window, not inside a terminal session.)
Is there a way to get shell mode to do the right thing here and open up a new buffer on behalf of the command line process?
You can start an interactive shell in Emacs by typing M-x shell . By default, this will start the standard Windows shell cmd.exe . Emacs uses the SHELL environment variable to determine which program to use as the shell.
To enter Emacs, type emacs at the shell prompt. When you want to leave Emacs for a short time, type a C-z and Emacs will be suspended. To get back into Emacs, type %emacs at the shell prompt. To quit Emacs permanently, type C-x C-c.
Buffers in Emacs editing are objects that have distinct names and hold text that can be edited. Buffers appear to Lisp programs as a special data type. You can think of the contents of a buffer as a string that you can extend; insertions and deletions may occur in any part of the buffer.
All external, interactive shells in Emacs are derived from something called comint-mode . comint-mode introduces low-level functions for dealing with interactive shells that require user input, a history ring, and so on. Shells like M-x shell and M-x run-python inherit from comint mode.
You can attach to an Emacs session through emacsclient
. First, start the emacs server with
M-x server-start
or add (server-start)
to your .emacs
. Then,
export VISUAL=emacsclient
Edit away.
Note:
emacs
and emacsclient
must agree. If you have multiple versions of Emacs installed, make sure you invoke the version of emacsclient
corresponding to the version of Emacs running the server.(server-start)
is in your .emacs
), the buffer will be created in the last frame to start the server.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With