Open an Emacs buffer when a command tries to open an editor in shell-mode Open an Emacs buffer when a command tries to open an editor in shell-mode unix unix

Open an Emacs buffer when a command tries to open an editor in shell-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:

  • The versions of 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.
  • If you start the server in multiple Emacs processes/frames (e.g., because (server-start) is in your .emacs), the buffer will be created in the last frame to start the server.


There's emacsclient, gnuserv, and in Emacs 23, multi-tty that are all useful for this. Actually I think in Emacs 23, emacsclient has all of the interesting functionality of gnuserv.


Not entirely true. ansi-term can run an emacs fine (although I usually run mg for commit logs, in the rare event I don't commit from emacs directly). eshell can also run an emacs if you start a screen first and run it from within there.