Open things only in the current window. No other windows, no splits.
In the ideal world, this package should not be necessary and one would
simply configure display-buffer-alist
to display buffers only in the
current window. But not all commands respect this variable
(e.g. org-agenda
), and so this package implements multiple tricks to
achieve the desired behavior.
My apologies for not recording key presses. I am basically just
hitting enter to open things and q
to close things.
Command | Before | After |
---|---|---|
M-x calendar | GIF | GIF |
M-x org-agenda | GIF | GIF |
M-x magit-status | GIF | GIF |
M-x man | GIF | GIF |
Or you can watch a short video.
The package is available on MELPA
(use-package current-window-only
:ensure t)
The Demystifying Emacs’s Window Manager article provides a great explanation of the key concepts, behavior, and configuration of the window manager. Are you ready for the red pill and seeing how deep the rabbit hole goes? The rest of us want reasonable behavior without being required to understand.
In short, a user can adjust how buffers should be displayed by adding
new rules to the display-buffer-alist
variable. The general
consensus is that the rules are just too cryptic, too complicated, and
not many people understand them. As a consequence third-party packages
such as shackle
and popwin
appeared, allowing to define
human-readable rules.
My humble guess is that the majority of people add rules for Emacs to
stop breaking their splits, to open things in the current window,
and nothing else. Why define some rules in the first place, when
you can simply M-x current-window-only
?
- Demystifying Emacs’s Window Manager
- The Emacs Window Management Almanac
- Emacs: control where buffers are displayed
- Emacs: window rules and parameters
- shackle
- popwin
You might need to adjust some workflows after enabling the package.
When creating a new commit, Magit spawns two buffers - diff with file
changes and a commit message. It is useful to see the changes while
writing the commit message but with current-window-only
, they will
open in the same window and therefore only one of them remains
visible. This is consistent with the goals of this package but if you
don’t like it, you can:
- Use
evil-switch-to-windows-last-buffer
orC-x b RET
to easily jump back and forth between the two buffers within one window. - Move the cursor to any appropriate window and manually open the other Magit buffer there
- Use
(setq magit-commit-diff-inhibit-same-window t)
to sidestepcurrent-window-only