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.

1

2 Answers 2

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)
2
  • Now that's a convenient way to use this dedicated window feature! Thanks, it works like a charm.
    – piwi
    Oct 16, 2014 at 7:25
  • indeed, better inside a function+keybing.
    – Nsukami _
    Oct 16, 2014 at 10:04
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.