问题描述
对于我的日常工作,我住在 Emacs.绝了.我也非常依赖 CScope 来帮助我在代码中查找内容.
For my day job, I live in Emacs. Utterly. I also have become pretty dependent on CScope to help me find things in the code.
通常,我有 2 个分割窗口 (C-x 3):替代文字 http://bitthicket.com/files/emacs-2split.JPG
Normally, I have 2 windows in a split (C-x 3):alt text http://bitthicket.com/files/emacs-2split.JPG
我将右侧窗口用于代码缓冲区,左侧窗口用于 CScope 搜索缓冲区.当您执行 CScope 搜索并选择结果时,它会自动更新右侧窗口以显示结果引用的缓冲区.这一切都很好,只是它使我失去了在我正在学习的其他缓冲区中的位置.有时这没什么大不了的,因为 [C-s u] 让我回到原来的位置.
And I use the right window for code buffers and the left window for the CScope search buffer. When you do a CScope search and select a result, it automatically updates the right-side window to show the buffer referred to by the result. This is all well and good, except that it causes me to lose my place in some other buffer that I was studying. Sometimes this is no biggie, because [C-s u] gets me back to where I was.
不过,最好有 3 个这样的拆分窗口(左侧窗口中的 [C-x 2]):替代文字 http://bitthicket.com/files/emacs-3split.jpg
What would be better, though, is to have 3 split windows like this ([C-x 2] in the left window):alt text http://bitthicket.com/files/emacs-3split.jpg
让左下角的窗口包含 CScope 搜索缓冲区,左上角的窗口是 CScope 唯一更新的缓冲区.这样,我就可以看到我的 CScope 搜索并浏览代码,而不会丢失我关注的缓冲区.
And have the bottom left window contain the CScope search buffer, and the top left window be the only buffer that CScope ever updates. That way, I can see my CScope searches and navigate around the code without losing the buffer I'm focused on.
有人知道我该怎么做吗?
Anyone know how I can do that?
推荐答案
把它放在你的 .emacs 文件中:
Put this in your .emacs file:
;; Toggle window dedication
(defun toggle-window-dedicated ()
"Toggle whether the current active window is dedicated or not"
(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)))
然后将它绑定到某个键 - 我使用暂停键:
Then bind it to some key - I use the Pause key:
(global-set-key [pause] 'toggle-window-dedicated)
然后用它来专用"你想要锁定的窗口.那么 cscope 只能在其他窗口中从其结果窗口打开文件.很有魅力.我专门将它用于此目的 - 始终在屏幕上保留一个源文件,同时在第二个缓冲区/窗口中使用 cscope,查看 cscope 会导致第三个.
And then use it to "dedicate" the window you want locked. then cscope can only open files from its result window in some OTHER window. Works a charm. I specifically use it for exactly this purpose - keeping one source file always on screen, while using cscope in a second buffer/window, and looking at cscope results in a third.
这篇关于将 Emacs 缓冲区固定到窗口(用于 cscope)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!