How to make emacsclient find the emacs daemon it is executed from
I'm trying to move most of my editing and shell activities into emacs, so that I can easily continue my workflow from different computers. I also have different emacs instances for my different projects. E.g., I start up:
emacs --daemon=project1
emacs --daemon=project2
Then whenever I want to start a frame to work on project1, I do:
emacsclient -s project1 -c
Mostly it works great, but I have trouble with executing tools from my emacs shells that are trying to fire up an editor using $EDITOR. Of course, what I would want in this case is that a new buffer opens in my current emacs instance, exactly what emacsclient is designed for. So if in a shell buffer in project1's emacs I say:
export EDITOR='emacsclient -s project1'
then in that particular shell everything works perfectly.
My question is, how could I auto开发者_如何学Gomatically set the EDITOR variable in a way that it points to the emacs instance the current shell is running in?
Here is one way to do it:
(add-hook 'shell-mode-hook (lambda () (comint-send-string (get-buffer-process (current-buffer)) (concat "export EDITOR='emacsclient -s " (daemonp) " -c'\n"))))
精彩评论