How can I prevent emacs switching to some windows with C-x o?

331 views Asked by At

Is there any way to set some windows non visitable in emacs?

For example, in gdb show-many-windows view, I dont want to switch to local variables window or stack window every time.

2

There are 2 answers

3
pmr On BEST ANSWER

C-x o is set to other-window. It is notoriously hard to customize, but here you go: It respects the window parameter 'no-other-window. Your goal will be to do (set-window-parameter gdb-window 'no-other-window t). Now, the only part that remains is to hook us into gud and set those properties on the windows.

A good start is

(defun make-selected-window-unselectable ()
  (interactive)
  (set-window-parameter (selected-window) 'no-other-window t))
(global-set-key "\M-p" 'make-selected-window-unselectable)

Someone will probably haggle about the name, as the window is not truly unselectable, but it will make do.

0
acm On

Instead of trying to customize other-window you could try using WindMove which enables frame navigation by direction.