I use CScope to navigate source code from within Emacs. It’s very, very useful and integrates will into Emacs. However, I’ve been wanting a way to control how cscope updates the buffer/window mappings as it locates search results for you. Sometimes, I like that CScope updates the buffer where I initiated the search to reflect the results, and it’s easy to get back to the point of origin using the C-c s u command.
However, sometimes I want CScope to leave my origin buffer alone and show the result location in another window so I can see both at the same time. It’s bothersome to have to arrange the buffers manually after performing a search, so I asked on stackoverflow.com, and voila! I got a good answer – create a simple keybinding to a function for dedicating a window/buffer mapping:
;; keybindings (global-set-key [pause] 'toggle-window-dedicated) ;; buffer dedication (mostly for cscope (defun toggle-window-dedicated () "Toggle whether the current active window is dedicated" (interactive) (message (if (let (window (get-buffer-window (current-buffer))) (set-window-dedicated-p window (not (window-dedicated-p window)))) "Window '%s' is dedicated" "Window '%s' is normal") (current-buffer)))
Now, using this, I can just hit the pause button on my keyboard when I want to pin down my main source buffer.
Very nice, thanks for the tip!