Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using M-x ansi-term within emacs, and a lot of the tools I use (not only git) are opening editors using $EDITOR.

Because running emacs within itself is kind of annoying, I'd like to configure my $EDITOR variable such that it opens a new buffer in the emacs session that's running the current instance of ansi-term.

Is there any way to do this?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

This has been asked before on stackoverflow. Here is the accepted answer:

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:

  1. 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.
  2. 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.
share|improve this answer
1  
Works perfectly! If you're running ansi-term, the $EMACS variable will be set, so I can figure out which editor to use on my various systems really nicely. Here's my setup for anyone curious. –  Stefano Palazzo Jul 2 '13 at 9:09
    
@StefanoPalazzo: or you could just use the ALTERNATE_EDITOR approach, leave (server-start) out of your init file, and let emacsclient worry about whether an emacs needs to be started... –  SamB Jan 2 at 6:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.