tags:

views:

558

answers:

3

I would like to set a specific window for the minibuffer completion list. Currently, I have 3 windows in this configuration:

 ______
|    | |
|____| |
|____|_|

In this case, I'd like to use the bottom left window for the minibuffer completion list.

Currently, it seems to a window at random, and most of the time it likes to use the far right window, which is too thin to show the completion list without me having to scroll horizontally, which is irritating.

Also, I'm using a lisp script called revive.el to restore my window configuration from a file (~/.revive.el) when I load Emacs.

+2  A: 

After starting down the path of trying to use minibuffer-scroll-window (which turns out to not be user customizable). I tried this approach:

(add-to-list 'special-display-buffer-names '("*Completions*" my-display-completions))

(defun my-display-completions (buf)
  "put the *completions* buffer in the right spot"
  (let ((windows (delete (minibuffer-window) (window-list))))
    (if (eq 1 (length windows))
        (progn 
          (select-window (car windows))
          (split-window-vertically)))
    (let ((target-window (window-at 0 (- (frame-height) 2)))
          (pop-up-windows t))
      (set-window-buffer target-window buf)
      target-window)))

This works by splitting the sole window in two and displaying *Completions* in the bottom window, or, if there are already 2 or more windows shown, using the bottom-left window to show the *Completions*.

Trey Jackson
Perhaps you need to use setq-default instead of setq.
Svante
It looks like minibuffer-complete sets the variable to nil upon entry the first time it is called. I'm unsure how that variable can ever be customized.
Trey Jackson
Hmm, the my-minibuffer-setup-hook function you specified seems to have no effect for me sadly.
nbolton
Good update - seems to work for me.
luapyad
Since your update, I can confirm that it is working! :) Thanks a lot, its perfect.
nbolton
+1  A: 

A slightly cheating answer that may do what you want:

Manually make the bottom left window the *Completions* buffer using

C-x b *Completions* RET

when the cursor is active in that window. Then whenever the minibuffer has to display some completions it should always use this particular window. However, this will rely on this buffer staying open and visible all the time - probably not quite what you want?

Other possibilities:

  1. See if "Icicles" helps - e.g. it mentions "There are lots of Icicles features that enhance the display and behavior of ‘*Completions*’".
  2. Minibuffer Commands That Do Completion may be useful?
luapyad
I've tried both but I can't seem to get them to remember the window to be used for the *Completions* buffer. Thanks anyway!
nbolton
Oh, also, yes, I aware that changing the buffer for a window is a way of fixing the issue - but as you probably know, it's temporary. When I press tab on the minibuffer next time, it doesn't use the window that it used last. Quite frustrating.
nbolton
A: 

Not as robust as Trey's answer, but also seems to work in a crude manner.

; Go to the 3rd window, and make it dedicated.
(other-window 2)
(set-window-dedicated-p (selected-window) 1)

This only works if you don't mind the 3rd window being locked. Unfortunately it will still try and use the 1st window from time to time (which is less frustrating, but still undesirable).

Note: I just tried Trey's solution and it worked now, so I recommend people use that.

nbolton