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.
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.