reddit / emacs
Is there emacs functionality similar to tmux's 'next-window' command?
grep_Name · 2022-09-12 14:51
This is a little hard to discuss because emacs and tmux use the term 'window' differently, but in tmux the window is basically your full terminal. So, your terminal might have 6 'panes' across 2 'windows' in a session, with one window containing 2 panes and the other four in a second window. Rather than be in separate floating program windows in your DE though, tmux windows are not visible until you cycle to them. So your setup might look like:
________________ _________________
| | | | | |
| | | | vim | node |
| st | python | -> :next-window -> |________|________|
| | | | | |
| | | | watch | ranger |
|_______|________| |________|________|
Is there any way to get this functionality (multiple buffers laid out in different ways in one wm box that can be cycled through) in emacs? (I'm focusing on the GUI version of emacs for now, not particularly interested in running emacs inside tmux at the moment)
edit: another thing I'm looking for is the ability to toggle 'zoom' an emacs window to fullscreen and back to its place, which I believe is 'c-b z' in tmux
redblobgames · 2022-09-12 15:30
I think you want "window configurations", which can be saved into registers. You might try tab-bar-mode for cycling through them. Or there's also https://github.com/alphapapa/burly.el/ . (I'd like something similar but haven't found something that matches what I want)
moonfogprophet · 2022-09-12 15:34
I'm not sure if I understood your question right but I use a package called eyebrowse (https://depp.brause.cc/eyebrowse/) to make window management a bit easier.
With it you can have multiple workspaces or window layouts saved and switch between them.
I just use it with pretty much default settings and keybinds. `C-c C-w 1` to switch to workspace #1, `C-c C-w 2` to switch to second one etc.
>edit: another thing I'm looking for is the ability to toggle 'zoom' an emacs window to fullscreen and back to its place, which I believe is 'c-b z' in tmux
I think you can do something like this with `winner-mode`, perhaps. I think that one is included in Emacs already. Basically `delete-other-windows` (`C-x 1`) and then to restore the layout, use `winner-undo` (`C-c <left>`)
arthurno1 · 2022-09-12 15:35
C-x 1, and Winner undo. Built-in. But only if you don't change window configuration in-between those two states. Otherwise, Emacs 28 has tabs which you could use to achieve similar and more general effect. There are also some external packages, but I personally don't use any.
_viz_ · 2022-09-12 15:37
The first is tab bar mode. You can also hide the tabbar.
For the second I just open a new tab with the buffer of interest. The other option is to C-x 1 then undo the window configuration when winner-mode is enabled.
grep_Name · 2022-09-12 16:31
> The first is tab bar mode. You can also hide the tabbar.
Thanks! Huge brain fart not realizing that these are basically just tabs in tmux in the first place.
> For the second I just open a new tab with the buffer of interest. The other option is to C-x 1 then undo the window configuration when winner-mode is enabled.
This is an interesting idea, but if I wanted to fullscreen something to edit some extra-long offscreen lines, wouldn't the editing put the 'C-x 1' command behind the edits in the undo buffer?
grep_Name · 2022-09-12 16:36
Thanks, I'll give that a try tonight :) I think I didn't consider tabs because in vim tabs can only operate on a single window rather than a collection of windows (or at least that's how it is by default).
grep_Name · 2022-09-12 16:42
Thanks, I always thought "window configurations" were more just scaffoldings for starting up a project in a familiar setup, not necessarily meant to be static references to buffers that can be cycled through and referenced over and over? (Although now that I think about it, since all the buffers are in memory anyway and windows just point to them, that might be a distinction without a practical difference and I might just have to start thinking about window groupings a little differently)
redblobgames · 2022-09-12 16:50
Emacs has both tab-bar mode (one tab per window configurations) and tab-line mode (one tab per buffer), and I think vim's are more like tab-line mode.
tonicinhibition · 2022-09-12 18:09
Yes, and I use it daily. What you are looking for is [perspective.el](https://github.com/nex3/perspective-el). This manages both named window configurations and the list of associated buffers.
It lets you save off the configuration and reload it in different sessions, and then you can cycle between those perspectives. Figuring out how to save your configuration correctly takes a little experimentation. Here is my basic setup, which shadows a couple of common buffer functions so that they are limited to the current open perspective.
(use-package perspective
:bind (("C-x b" . persp-switch-to-buffer*)
("C-x k" . persp-kill-buffer*))
:init
(persp-mode)
(setq persp-state-default-file "~/.emacs.d/saved-perspectives"))
Someone else mentioned `winner-mode`, which in my experience is merely complementary behavior. I use `winner-mode` in the same way that I use `undo-tree`. If I temporarily close or resize some of the windows within a perspective I'll revert the behavior to save some keystrokes.
moonfogprophet · 2022-09-12 22:40
Thanks for your comment. Perspective looks really interesting as an alternative to eyebrowse, I'm gonna give it a try myself.
baaa-sh · 2022-09-12 22:54
>learned me a thing thanks to this too. :-)
_viz_ · 2022-09-13 02:32
Window configuration history and buffer text undo history are two different things.
divinedominion · 2022-09-13 06:50
Huge +1 to tab-bar-mode with winner-mode. The tab-looking UI affordance is a bit weird at times, because it's not about content tabs but rather workspaces, but the combo is super powerful.
You can undo accidental closing of tabs and restore layouts, and with winner you get a dedicated window layout undo stack.
This can replace packages that manage window configurations because with the winner-mode's undo functionality, you can restore whichever layout you had previously.
It's a different approach, but it works really well.