关闭缓冲区后显示的 Emacs 缓冲区

发布于 2024-11-08 03:23:50 字数 404 浏览 1 评论 0原文

如何修改 emacs 在关闭缓冲区后选择显示哪个缓冲区的方式?

当我有多列显示相同的缓冲区,然后在其中一个缓冲区中打开另一个文件,然后关闭新打开的缓冲区时,它不会切换回前一个缓冲区,而是切换回另一个缓冲区。

我将尝试用一个例子来解释:

  • 开始新的 emacs
  • 从 *scratch* Cx 2 (分成两列)
  • Cx Cf 1 (查找文件 1)
  • Cx o (切换到其他框架)
  • Cx b 1 (查找文件 1) )
  • Cx Cf 2 (查找文件 2)
  • Cx k (杀死缓冲区)

现在它切换到 scratch 但我希望它再次在两个窗口中显示 1,是否有可能使 emacs 这样做?

How can I modify the way emacs picks which buffer to show after closing a buffer?

When I have multiple columns showing the same buffer, and then open another file in one of the buffers and then close the newly opened buffer, it doesn't switch back to the previous buffer, but to another buffer.

I'll try to explain with an example:

  • Start with a new emacs at *scratch*
  • C-x 2 (split into two columns)
  • C-x C-f 1 (find file 1)
  • C-x o (switch to other frame)
  • C-x b 1 (find file 1)
  • C-x C-f 2 (find file 2)
  • C-x k (kill buffer)

Now it switches to scratch but I would like it to show 1 in both windows again, is it possible to make emacs behave this way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

耀眼的星火 2024-11-15 03:23:50

这可能不是您问题的直接答案,但可能会有所帮助。

Emacs 管理其缓冲区列表,包括决定在杀死一个缓冲区时显示哪个缓冲区(通过 kill-buffer)。我还没有研究它是如何完成的,但是 文档是“在那里”。很多人创建了自定义缓冲区堆栈 管理魔法改变了 emacs 的工作方式,也许其中一些是基于贝叶斯分析,或者其他什么。你可以想象各种可能性。

我从未考虑过改变 emacs 管理缓冲区的方式。相反,我只是将 other-windowswitch-to-buffer 绑定到简单的击键(Cx o、Cx b),并且我非常擅长使用它们。

您可以根据需要创建一个简单的函数:它应该销毁所有其他窗口,然后分割窗口,以便当前缓冲区显示在两个窗口中。幸运的是,emacs 具有可以完成这些任务的函数。

(defun cheeso-show-buffer-two-windows ()
  "Close all other windows; then split, and show the current
buffer in both windows."
  (interactive)
  (delete-other-windows)
  (split-window-vertically))

将其与按键绑定,然后 badda-bing,你就在那里。这是垂直拆分 - 窗口显示在垂直堆栈中。如果您希望它水平分割(窗口并排),则替换......好吧,您知道。

This may not be a direct answer to your question, but it might help.

Emacs manages its buffer list, including deciding which buffer gets displayed when you kill one (via kill-buffer). I haven't looked into how it's done, but the documentation is "out there". Lots of people have created custom buffer-stack management magic to change the way emacs does things, maybe some of them are based on bayesian analysis, or whatever. You can imagine the possibilities.

I've never looked into changing the way emacs manages its buffers. Instead I just bind other-window and switch-to-buffer to easy keystrokes (C-x o, C-x b) and I get really good at using them.

you could create a simple function for what you want: it should destroys all other windows, then split the window so that the current buffer is displayed in both. Luckily, emacs has functions that do exactly those things.

(defun cheeso-show-buffer-two-windows ()
  "Close all other windows; then split, and show the current
buffer in both windows."
  (interactive)
  (delete-other-windows)
  (split-window-vertically))

Bind that to a keystroke, and badda-bing, you're there. This is a vertical split - the windows are displayed in a vertical stack. If you want it horizontally split (the windows are side-by-side), then replace ... well, you know.

柒夜笙歌凉 2024-11-15 03:23:50

这也没有直接帮助,但获胜者模式可能会帮助你到达你想要到达的地方。

This also doesn't quite help directly, but Winner mode might help you get where you want to get.

扮仙女 2024-11-15 03:23:50

您使用的是 tabbar 模式吗?我遇到了同样的问题,对我来说,标签栏就是原因。 Tabbar 将函数 tabbar-buffer-kill-buffer-hook 添加到 kill-buffer-hook。您可以使用 (remove-hook 'kill-buffer-hook 'tabbar-buffer-kill-buffer-hook) 删除它。

如果您不使用选项卡栏,请尝试 Mxdescribe-variable kill-buffer-hook。此列表中的函数之一应该负责扰乱您的缓冲区。

Are you using tabbar-mode? I had the same problem and for me tabbar was the cause. Tabbar adds the function tabbar-buffer-kill-buffer-hook to kill-buffer-hook. You can remove it with (remove-hook 'kill-buffer-hook 'tabbar-buffer-kill-buffer-hook).

If you don't use tabbar try M-x describe-variable kill-buffer-hook. One of the functions in this list should be responsible for messing with your buffers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文