2

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.

aspirin
  • 347
  • 1
  • 5
  • duplicate of http://stackoverflow.com/questions/1574922/how-can-i-make-window-movement-commands-ignore-a-certain-window – Patrick Jul 31 '12 at 00:02
  • @Patrick Oh, this is pretty. A lot less intrusive than the way I'm going. I should move my answer there. – pmr Jul 31 '12 at 00:09
  • I use windmove (S-up, S-down, S-left, S-right) instead of using `C-x o`. Much more likely to get me what I want. http://emacswiki.org/emacs/WindMove – Michael Hoffman Jul 31 '12 at 00:10
  • @Patrick, thanks for letting me know. I was searching for that question for days. And as far as I understand sadly there is no very straightforward way. – aspirin Jul 31 '12 at 00:38

2 Answers2

2

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.

pmr
  • 58,701
  • 10
  • 113
  • 156
  • Thanks. It sounds like it will work for me. But I am not an experienced user to write my own script for my init file. Can you give an sample code to put my init file? Let say I want to bind Super + P key to a function that toggles current window to be not selectable? – aspirin Jul 31 '12 at 21:28
  • Sample code didnt work for me. Probably I am doing something wrong. Did you try the code? Here what I do: I added sample code to my init file. I run M-x gdb and enable show many windows. Then I select *stack* window and do M-p. But still Its selectable with C-x o. – aspirin Jul 31 '12 at 22:31
  • @aspirin Yes, it did. I had to bind it to `M-n` though, because `comint-mode` overwrites that key. The convention is that users should bind their things to something like `C-c LETTER`. – pmr Jul 31 '12 at 22:43
0

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

acm
  • 12,183
  • 5
  • 39
  • 68