My windows configuration looks like this:
+----------+-----------+
| | |
| | |
| | |
| | |
| | |
| +-----------+
| | |
+----------+-----------+
And I use the lower right window for special displays (like help, completion etc.), but emacs insists on using that window when I call commands (find-file-other-window
, etc.) that use display-buffer
, and resize that window as well. It's annoying... Is there a way that I can force emacs NOT to use that windows? I was thinking of advising display-buffer
, but it's a function in c. Any thoughts on this?
EDIT:
Based heavily on Trey's answer, this is what works for me so far:
(setq special-display-function 'my-display-buffer)
(setq special-display-regexps '(".*"))
(defun display-special-buffer (buf)
"put the special buffers in the right spot (bottom rigt)"
(let ((target-window (window-at (- (frame-width) 4) (- (frame-height) 4)))
(pop-up-windows t))
(set-window-buffer target-window buf)
target-window))
(defun my-display-buffer (buf)
"put all buffers in a window other than the one in the bottom right"
(message (buffer-name buf))
(if (member (buffer-name buf) special-display-buffer-names)
(display-special-buffer buf)
(progn
(let ((pop-up-windows t)
(windows (delete (window-at (- (frame-width) 4) (- (frame-height) 4))
(delete (minibuffer-window) (window-list)))))
(message (buffer-name (window-buffer (car windows))))
(set-window-buffer (car (cdr windows)) buf)
(car (cdr windows))))))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…