1

I am thinking of switching from tmux + terminal emacs (emacs -nw) to just pure emacs. The only thing that is holding me back is tmux offer switching between sessions without switching the terminal window itself (C-b s). For instance, if I have tmux session 0 and tmux session 1. If my current tmux session is attach to session 0, I can easily switch to session 1 by using the keybinding (C-b s 1) without leaving my current Xterm window. I know that there are frames, windows, buffer and server in emacs, but I still can't find anything equivalent to this (swap between frame/server without leaving my main GUI).

UPDATE:

I found something pretty close to what I need by starting two emacs server:

In xterm1:

emacs --daemon="one"

In xterm2:

emacs --daemon="two"

By doing this, I can group all the file buffers and ansi-term by projects in each emacs server. However, are there any easy way to switch between daemon (the help page use the term "socket") within the Emacs without leaving the GUI?

  • 3
    Not using tmux, I'm not sure what the purpose of the different sessions is. What is your ultimate goal: do you want to edit files on different remote machines? or do you want to run multiple Emacs instances on the same machine? – Tyler Oct 8 at 16:41
  • i usually work in multiple project and i used to separate each project into session (to group xterm together). Sometimes, when I want to quickly check on something on another project, what I did is just switch session and I am instantly in the xterm of the other project. Once Im done, I can just easily switch back – user9870 Oct 10 at 11:18
  • please refer to my latest update on the post, I found a similar method, I think I am just left with the final piece and I can migrate to emacs fully. – user9870 Oct 10 at 11:37
  • That's an interesting idea. I don't think there's a way to switch an Emacs frame from one daemon process to another. It might be easier to do this with your window manager. For example, in i3wm, you can configure a shortcut key to switch from one emacs gui to another in the same space. However, I think the usual Emacs approach to this would be to open both projects in the same Emacs process, and just shuffle the visible buffers as needed. By the end of a day I usually have ~50 buffers open, and switching between them has become second nature. – Tyler Oct 10 at 14:05
  • 1
    Actually, I found something much more relevant (that's beauty of emacs, new discovery everyday). Spacemacs actually has the concept of layout and workspace which is exactly what I am looking for. I haven't update this thread yet because I still want to understand more on it.I have very similar experience with you (a lot of buffers opened). In my case, sometime those files name across project are very similar and things get messy – user9870 Oct 11 at 15:47
0

I can do that entirely in the gui emacs by running tmux in either ansi-term or zsh (set as the multi-term-program). The two or more tmux sessions can either be created inside or out of emacs.

  • I considered this before, running tmux within emacs, but all my buffers (file opened) will be "global" across all the tmux session. What I am trying to achieve here is, I want to group file buffers into "session" so that I won't get a huge list of file buffer (of diff projects) when I use an emacsclient – user9870 Oct 10 at 11:21
  • please refer to my latest update on the post, I found a similar method, I think I am just left with the final piece and I can migrate to emacs fully. – user9870 Oct 10 at 11:37
  • Excellent! Are you able to post your final solution here? – m43cap Oct 15 at 10:35
  • please check my latest solution. Btw, thanks for reminding to update this thread – user9870 Oct 16 at 14:30
  • Interesting. You may have convinced me to give spacemacs a try. – m43cap Oct 17 at 19:01
0

In Spacemacs, there is the Layout concept where you can isolate buffers into different layout. It groups buffers together and adjacent layout would not have the access to the buffers at the other layout.

My solution is actually very simple. I launch an emacs and create a new frames with M-x new-frame. Now I have multiple emacs windows (say windows 1 and windows 2).Tho, windows here means emacs frame

I used emacs keybinding. So, you may replace M-m with SPC if you used Vim keybinding.

In Windows 1, I create a layout by using the following command:

M-m l 2

Just give your layout a name when it prompts you for a name. I call it work1. Then Open a few files.

In Windows 2, I repeated the same steps with :

M-m l 3

Let's call it work2 and open up a few files.

In Window 2 (work2), u can switch your buffers by using :

C-x b

You will found out that the buffers opened in work1 is not available here (It is so much cleaner!!).

You may easily switch between work1 and work2 by using:

M-m l <your layout index>

Your Answer

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

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