views:

318

answers:

1

Ever since I installed emacs on a new machine I have seen an ugly behaviour. Unfortunately, my old .emacs files are rather fragmented and I can't determine whether I used to have elisp that took care of this.

The problem is this: it used to be that when I performed a command that would open a new buffer such as grep'ing, or clicking a file name within search results, one of two things would happen:

  1. If only one buffer is showing, the screen will split once
  2. If more than one buffer is showing, the buffer window after the current buffer window would open the desired file

I want this behaviour back. What I am getting now is the following:

Emacs will keep splitting the window until four buffer windows are open. If I continually click multiple grep results, the buffer window where they open cycles through the three other (non-grep-results) buffer windows. I'd like it if they just kept opening in the same location: the "next" buffer window beside/below the results--same buffer window every time.

Any thoughts on how to achieve this behaviour?

+2  A: 

Consider setting split-height-threshold to a larger value than the frame height; that will prevent unwanted vertical split.

(setq split-height-threshold 999)

If you prefer vertical split over horizontal split, customize split-width-threshold instead.

For more fine-grained control of how a new buffer is displayed, customize display-buffer-function; that will allow you to completely replace the default display-buffer function which dictates the buffer display policy.

huaiyuan