Skip to content

Latest commit

 

History

History
106 lines (81 loc) · 4.19 KB

README.org

File metadata and controls

106 lines (81 loc) · 4.19 KB

M-x current-window-only

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.

Obligatory GIF section

My apologies for not recording key presses. I am basically just hitting enter to open things and q to close things.

CommandBeforeAfter
M-x calendarGIFGIF
M-x org-agendaGIFGIF
M-x magit-statusGIFGIF
M-x manGIFGIF

Or you can watch a short video.

Installation

The package is not available in MELPA yet. Please choose your preferred package manager to install.

Quelpa:

(use-package current-window-only
  :quelpa (current-window-only
           :fetcher github
           :repo "FrostyX/current-window-only")
  :config
  (current-window-only-mode))

Straight:

(use-package current-window-only
  :straight (current-window-only
             :type git
             :host github
             :repo "FrostyX/current-window-only")
  :config
  (current-window-only-mode))

Motivation

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?

See also

Tips and tricks

You might need to adjust some workflows after enabling the package.

Magit commit

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 or C-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 sidestep current-window-only