I just read Mickey’s wonderful article on window management, and has given me the push I need to take control over my emacs windows/frames. I have an idea of what I will configure; maximum of two windows per frame, and if is my portrait frame split horizontally and split vertically for my landscape frame, plus some additional config for Magit. Before I take the plunge, I wanted to quickly reach out to see what other people have done for their configs to get some ideas. Figure might also be good to collect a few different configurations of window configs for people interested.
Some configs I have found on the way and will update with any suggestions people have:
- Karthink’s config, good integration with the popper package
- emacs-pure - has some display-buffer-alist settings for magit which are of interest to me, as the built in magit methods for handling new frames isn’t exactly what I want.
Any recommendations, please feel free to share them.
I wanted to make the window management as simple as possible and created this package - https://github.com/FrostyX/current-window-only . Not everybody will like it but that’s okay.
(add-to-list 'display-buffer-alist '("\\*sly-mrepl" (display-buffer-at-bottom) (window-height . 12))) (add-to-list 'display-buffer-alist '("\\*Calendar*" (display-buffer-at-bottom))) (add-to-list 'display-buffer-alist '("\\*shell:" (display-buffer-below-selected) (window-height . 12))) (add-to-list 'display-buffer-alist '("\\magit:" (display-buffer-same-window))) (add-to-list 'display-buffer-alist '("\\*Man" (display-buffer-same-window))) (add-to-list 'display-buffer-alist '("\\*Help" (display-buffer-same-window))) (add-to-list 'display-buffer-alist '("\\*helpful" (display-buffer-same-window)))
The
*shell:
pattern is for use with this package: https://github.com/elizagamedev/shell-command-x.elIf you haven’t tried it, I heartily recommend it. I don’t use a dedicated terminal much anymore; this package and https://github.com/bard/emacs-run-command serve my shell needs these days.
Awesome thanks for sharing. I have a note for emacs-run-command to comeback and check it out, but hadn’t come across shell-command-x.el. Will have to check them out.
Do you notice any wierd behaviour with Magit? I have just been going through the documentation about how Magit spawns/reuses their own frames, and was wondering if playing with display-buffer-alist would get in the way of how Magit wants to do it.
I think that preferences for
display-buffer-alist
will depend on each user’s workflow. With my rule it will pop upmagit-status
in the currently active window, then split to show logs, diffs, etc. I don’t normally use more than two windows per frame, so it’s not too bad if it messes things up, but I haven’t noticed it doing that. If it does do something weird, I just usewinner-undo
until I get back to where I was. For this you have to have(winner-mode)
somewhere in your config or start it manually I guess.For instance, if you had two windows in a vertical split like
A | B
with point inA
, then runmagit-status
,A
will show magit andB
won’t change unless you run something likemagit-log
. Pressingq
in the log window will restoreB
to what it was showing before.Changing this behavior is probably possible, but I’m satisfied with this so far.
Mine is just the default
nil
. I don’t use any of the packages. But I prefer magit to be fullscreen and to restore back to where I was on quit:(setq magit-display-buffer-function 'magit-display-buffer-fullframe-status-topleft-v1) (setq magit-bury-buffer-function 'magit-restore-window-configuration)
I tried Magit full-screen but It wasnt restoring my previous windows. I didn’t know about the bury buffer function so this helps me out a lot. Thanks!
I never took care of setting this aspect of emacs properly. Thanks a ton
(add-to-list 'display-buffer-alist '("\\*e?shell\\*" (display-buffer-in-side-window) (side . bottom) (slot . -1) ;; -1 == L 0 == Mid 1 == R (window-height . 0.33) ;; take 2/3 on bottom left (window-parameters (no-delete-other-windows . nil)))) (add-to-list 'display-buffer-alist '("\\*\\(Backtrace\\|Compile-log\\|Messages\\|Warnings\\)\\*" (display-buffer-in-side-window) (side . bottom) (slot . 0) (window-height . 0.33) (window-parameters (no-delete-other-windows . nil)))) (add-to-list 'display-buffer-alist '("\\*\\([Hh]elp\\|Command History\\|command-log\\)\\*" (display-buffer-in-side-window) (side . right) (slot . 0) (window-width . 80) (window-parameters (no-delete-other-windows . nil)))) (add-to-list 'display-buffer-alist '("\\*TeX errors\\*" (display-buffer-in-side-window) (side . bottom) (slot . 3) (window-height . shrink-window-if-larger-than-buffer) (dedicated . t))) (add-to-list 'display-buffer-alist '("\\*TeX Help\\*" (display-buffer-in-side-window) (side . bottom) (slot . 4) (window-height . shrink-window-if-larger-than-buffer) (dedicated . t)))