How to get emacsclient to find the emacs daemon, it runs from

I am trying to transfer most of my editing and shell operations to emacs so that I can easily continue my workflow from different computers. I also have different emacs instances for my different projects. For example, I run:

emacs --daemon=project1 emacs --daemon=project2 

Then, when I want to run the frame to work on project1, I do:

 emacsclient -s project1 -c 

It basically works fine, but I am having problems running tools from my emacs shells that are trying to start the editor using $ EDITOR. Of course, in this case, I want a new buffer to appear in my current emacs instance for what emacsclient is for. Therefore, if in the shell buffer in emacs project1 I say:

 export EDITOR='emacsclient -s project1' 

then in this particular shell everything works fine.

My question is, how can I automatically set the EDITOR variable so that it points to the emacs instance in which the current shell is running?

+4
source share
1 answer

Here is one way to do this:

  (add-hook 'shell-mode-hook
       (lambda ()
         (comint-send-string 
          (get-buffer-process (current-buffer))
          (concat "export EDITOR = 'emacsclient -s" 
              (daemonp)
              "-c '\ n"))))
+3
source

Source: https://habr.com/ru/post/1334359/


All Articles