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:
- If only one buffer is showing, the screen will split once
- 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?
Consider setting
split-height-thresholdto a larger value than the frame height; that will prevent unwanted vertical split.If you prefer vertical split over horizontal split, customize
split-width-thresholdinstead.For more fine-grained control of how a new buffer is displayed, customize
display-buffer-function; that will allow you to completely replace the defaultdisplay-bufferfunction which dictates the buffer display policy.