gpt4 book ai didi

emacs - 将 Emacs 缓冲区固定到 Windows(用于 cscope)

转载 作者:行者123 更新时间:2023-12-03 10:57:42 25 4
gpt4 key购买 nike

对于我的日常工作,我住在 Emacs。完全。我也变得非常依赖 CScope 来帮助我在代码中找到东西。

通常,我有 2 个窗口拆分(C-x 3):
alt text http://bitthicket.com/files/emacs-2split.JPG

我将右侧窗口用于代码缓冲区,将左侧窗口用于 CScope 搜索缓冲区。当您进行 CScope 搜索并选择一个结果时,它会自动更新右侧窗口以显示结果引用的缓冲区。这一切都很好,只是它使我在我正在学习的其他缓冲区中失去了自己的位置。有时这没什么大不了的,因为 [C-s u] 让我回到原来的位置。

不过,最好有 3 个像这样的拆分窗口(左侧窗口中的 [C-x 2]):
alt text http://bitthicket.com/files/emacs-3split.jpg

并让左下角的窗口包含 CScope 搜索缓冲区,左上角的窗口是 CScope 唯一更新的缓冲区。这样,我可以看到我的 CScope 搜索并在代码中导航,而不会丢失我关注的缓冲区。

有谁知道我该怎么做?

最佳答案

把它放在你的 .emacs 文件中:

;; 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)))

然后将其绑定(bind)到某个键 - 我使用 Pause 键:
(global-set-key [pause] 'toggle-window-dedicated)

然后用它来“专用”你想要锁定的窗口。然后 cscope 只能在某个 OTHER 窗口中从其结果窗口打开文件。很有魅力。我专门将它用于此目的 - 始终在屏幕上保留一个源文件,同时在第二个缓冲区/窗口中使用 cscope,并查看 cscope 结果为第三个。

关于emacs - 将 Emacs 缓冲区固定到 Windows(用于 cscope),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43765/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com