2

I like to have my emacs set up as one full-screen frame with two side-by-side windows at all time. To do this, I've used this code to force emacs not to split windows arbitrarily:

(defun never-split-a-window nil)
(setq split-window-preferred-function 'never-split-a-window)

This works great, and importantly, I can still use popwin to display temporary popup windows as splits. Other packages still successfully split as well, for example Helm. And a few weeks ago, so did Magit's popups. It was nice to have the main Magit buffer occupy one whole window, but then have popups split the window (temporarily).

Now, since some changes to Magit to consolidate window handling, I get my Magit popups in the opposite window rather than as a split. Is there any easy way to get back the splitting behavior, without allowing Emacs to go nuts and split things willy-nilly (as it did before changing split-window-preferred-function)?

4

I doubt that using a dummy function which always returns nil as split-window-preferred-function is what you should be doing, but since it otherwise works for you, here's how you can tell magit-popup to use the default splitter function:

(advice-add 'magit-popup-mode-display-buffer :around
            'magit-popup-mode-display-buffer--split-window-sensibly)

(defun magit-popup-mode-display-buffer--split-window-sensibly (fn buffer mode)
  (let ((split-window-preferred-function 'split-window-sensibly))
    (funcall fn buffer mode)))

Alternatively you could replace never-split-a-window with only-sometimes-split-a-window (depending on e.g. the major-mode of the current buffer).

  • Yaaaay, it's back to the way I like it! Thank you for the help, and thank you for all your work on Magit! It's my favorite. – bhollis Jan 29 '16 at 0:08

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.