0

In bash in a terminal emulator, I run two independent emacs processes. I created them in bash by emacs -nw and in each, I opened several buffers.

I switch between them by making one process into background via Ctrl-Z and then making the other into forground via fg <jobid>.

Since switching between them is inconvenient, is it possible to merge the buffers opened in one emacs process into the other emacs process?

Thanks.

1 Answer 1

1

You can't do that, but you can use the client/server functionality in Emacs to simply connect to the exact same Emacs instance each time. After starting the server you would use emacsclient -nw to connect to the server instance, instead of starting a completely separate instance with emacs -nw. You will have access to the same set of buffers in all clients.

See: C-hig (emacs)Emacs Server

4
  • Thanks. Do you mean there is no way to merge the buffers in the two emacs processes created by emacs -nw?
    – Tim
    Commented Mar 22, 2018 at 0:42
  • Correct. At least to the very best of my knowledge -- I'm not an expert on the internals of Emacs, but I can't envisage any way that could work.
    – phils
    Commented Mar 22, 2018 at 0:44
  • That said, if you're only talking about file-visiting buffers and you don't care about losing undo history, then you can simply re-visit the files of one instance in the other, and you could use the desktop.el library to do it for you. In one instance you could M-x desktop-save and in the other you could M-x desktop-read. If you're not saving to the default location, you may need to customize desktop-path for the instance in which you're going to read the desktop file.
    – phils
    Commented Mar 22, 2018 at 0:53
  • n.b. I briefly but mistakenly suggested that desktop-change-dir could be used to select a directory to read from. Don't do that! It actually kills existing buffers and then reads the new desktop, which is not what you want.
    – phils
    Commented Mar 22, 2018 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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