Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make window movement commands ignore a certain window?

So I generally have 3 buffers open in Emacs.

  1. One buffer for the actual code I am writing.
  2. One buffer for the unit test for said code.
  3. A third buffer that displays the results of the unit test. This buffer comes into being below the two other buffers when I run my unit test C-x SPACE.

How do I disable this third buffer such that when I press C-x o I am only switching between buffer 1 and buffer 2? Currently, I switch between buffer 1, then buffer 2, then buffer 3, then buffer 1, etc. To be specific, I want C-x o to only switch between buffer 1 and 2.

Thank you.

like image 682
Stephen Cagle Avatar asked Oct 15 '09 20:10

Stephen Cagle


People also ask

What does Ctrl Shift n do?

Opens a new window in incognito mode. Ctrl+Shift+N. Opens a file from your computer in Google Chrome. PressCtrl+O, then select file. Opens the link in a new tab in the background.

What is Ctrl Shift S?

Ctrl-Shift-SSave current data under a different name. The file name associated with the data changes to the new name.


1 Answers

A general solution to this (can look) something like the following:

(defvar ignore-windows-containing-buffers-matching-res '("\\*Help")
      "List of regular expressions specifying windows to skip (if window contains buffer that matches, skip)")

(defadvice other-window (before other-window-ignore-windows-containing activate)
  "skip over windows containing buffers which match regular expressions in 'ignore-windows-containing-buffers-matching-res"
  (if (and (= 1 (ad-get-arg 0)) (interactive-p))
      (let* ((win (next-window))
             (bname (buffer-name (window-buffer win))))
        (when (some 'identity (mapcar '(lambda (re)
                                        (string-match re bname))
                                     ignore-windows-containing-buffers-matching-res))
          (ad-set-arg 0 2)))))

Customize the variable to be a regular expression matching the buffer names you want to skip.

like image 155
Trey Jackson Avatar answered Oct 15 '22 10:10

Trey Jackson