emacsgdbemacs-ecb

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


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.


Solution

  • 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.