17

Typically, I have a frame split into four windows, where two at the bottom are dedicated to my *compilation* and *grep* buffers. When browsing compilation errors, next-error will eventually replace my *grep* buffer with one of the target file.

How can I configure next-error to not use the window containing the *grep* buffer?

My specific use-case is the next-error command, but more general answers are welcome as well.

Malabarba
  • 22,878
  • 6
  • 78
  • 163
piwi
  • 273
  • 1
  • 7
  • 1
    Related: http://emacs.stackexchange.com/questions/327/how-can-i-block-a-frame-from-being-split/338#338 – Malabarba Oct 15 '14 at 12:46

2 Answers2

21

I second @Nsukami's suggestion to use dedicated windows. Since it is a function, not a command, using set-window-dedicated-p directly can be cumbersome. With the following command and associated key binding, you can toggle "dedicatedness" of any window by pressing C-c t:

(defun toggle-window-dedicated ()
  "Control whether or not Emacs is allowed to display another
buffer in current window."
  (interactive)
  (message
   (if (let (window (get-buffer-window (current-buffer)))
         (set-window-dedicated-p window (not (window-dedicated-p window))))
       "%s: Can't touch this!"
     "%s is up for grabs.")
   (current-buffer)))

(global-set-key (kbd "C-c t") 'toggle-window-dedicated)
itsjeyd
  • 14,586
  • 3
  • 58
  • 87
5

May I suggest dedicated-window?

You'll have to dedicate windows to buffers using this function:

set-window-dedicated-p window flag: This function marks window as dedicated to its buffer if flag is non-nil, and non-dedicated otherwise.

Courtesy of gnu

Nsukami _
  • 6,341
  • 2
  • 22
  • 35