In Emacs, how do I change the minibuffer completion list window?

≡放荡痞女 提交于 2019-12-20 23:26:40

问题


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.


回答1:


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*.




回答2:


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?



回答3:


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.



来源:https://stackoverflow.com/questions/900372/in-emacs-how-do-i-change-the-minibuffer-completion-list-window

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!