8

I normally have my main Emacs frame split vertically into two side-by-side windows (as one gets with split-window-right, better known as C-x 3).

For as long as I can remember, whenever the need arose for a temporary *Completions* buffer, the inactive one of the two side-by-side windows would be used to hold this buffer.

I don't know what changed but now this is no longer what happens. Instead, a third window appears holding the *Completions* buffer, and running horizontally the full width of the Emacs frame. (So I now see the two original side-by-side windows on top, and one wide window for the transient *Completions* buffer along the bottom. IOW, the frame window topology looks similar to what it would look like if one ran the sequence C-x 1 C-x 2 C-x 3.)

I don't like this at all. I have a fairly wide monitor, which makes it uncomfortable to read completion options that are spread out along its full width.

Is it possible to customize this behavior?

kjo
  • 3,247
  • 17
  • 48

2 Answers2

4

You can change how the *Completions* buffer is displayed by adding an entry to display-buffer-alist. With the following snippet, Emacs will display the completions buffer in an existing non-current window, or failing that it will create a new window (if possible). In the scenario of 2 side-by-side windows, it will display the completions buffer in the inactive window.

(push '("\\*Completions\\*"
        (display-buffer-use-some-window display-buffer-pop-up-window)
        (inhibit-same-window . t))
      display-buffer-alist)

However, your desired behavior is what I already get by default when running stock emacs 24.5 (e.g. emacs-24.5 -Q -nw). If you're using Emacs 25, then maybe it is a deliberate change (just a guess). Otherwise, you should check if which part of your configuration changes the original behavior. For example, the package Popwin can cause it. Checking the value of display-buffer-alist might point to the culprit.

bmag
  • 1,713
  • 10
  • 12
2

I googled around and found this: https://stackoverflow.com/questions/4195666/display-compilation-in-inactive-buffer

I tested the code and the behavior seems to be what you want.

Here's the code for convenience:

(defun display-on-side (buffer &optional not-this-window frame)
  (let* ((window (or (minibuffer-selected-window)
                     (selected-window)))
         (display-buffer-function nil)
         (pop-up-windows nil))
    (with-selected-window (or window (error "display-on-side"))
      (when (one-window-p t)
        (split-window-horizontally))
      (display-buffer buffer not-this-window frame))))

(setq display-buffer-function 'display-on-side)
ruishigan
  • 21
  • 1