I wish I could run code from one emacsclient session inside other. I'm working in terminal via ssh, terminal has two panes connected to machine with emacs via ssh, each pane has its own emacsclient connected to server on the same machine, and I wish I could call function from one pane with first emacsclient so it will be evaluated in other emacsclient from other pane.

Is there some mechanism available for that? As far as I know emacsclient communicates with server via socket, can I manually add commands to that socket?

If not, maybe I can write for some file so that each emacsclient watches that file and if emacsclient ID (is it frame ID?) maches with command - simply execute text in file as command? Is there some workaround for that?

  • 2
    Are the emacsclients connected to the same emacs server? If so- the distinction between clients is generally not significant; they share the same global environment. Only the frame and window contexts will be different. Two functions that are very useful in that case are selected-frame and frame-list. – ebpa Nov 3 '17 at 19:01
  • @ebpa thanks, I tried to execute (select-frame (first (frame-list))) in other emacsclient - and smth strange happens, other emc. instance modeline shows gaining focus, and message displayed in it, but focus of terminal pane is still in current one. I believe that must solve my issue, coz now I evaluate code in there, but mb you also know how to get full focus, even in selected frame terminal window? – sandric Nov 3 '17 at 19:32
  • Note that Emacs' focus does not necessarily correspond to the window focus according to your window manager. I think Emacs does its best to grab focus when a frame comes into focus, but that may not happen for all window managers and I imagine that it might not be possible for Emacs to do so when it is running inside a terminal emulator (which I suspect may be the case for you). If you want cleaner focus you might try X forwarding so you have a graphical emacsclient running locally. You may want to create a different question for your focus issue. – ebpa Nov 3 '17 at 19:51
  • @ebpa yes of course, thanks a lot for pointing about frame-list. – sandric Nov 3 '17 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.