【问题标题】:Emacs switch to buffer in different frameEmacs 切换到不同帧的缓冲区
【发布时间】:2012-05-22 09:06:13
【问题描述】:

我目前正在使用 emacs 进行编程。我在 .emacs 中定义了一个函数,它保存我的所有工作并执行解释器以在当前打开的 shell 缓冲区中运行我的工作。通常我会在一帧或多帧中进行编辑,并在单独的帧中打开外壳。我遇到的问题是,当我运行我的保存和执行功能时,所有内容都已保存,但外壳缓冲区随后会显示在我当前正在编辑的帧中。所以我有两帧显示 shell 缓冲区,我看不到我刚刚编辑的源代码。很多时候,当我在编程时,我想立即将代码的输出与我刚刚编写的代码进行比较。不得不切换回我的代码缓冲区,然后在引用刚刚编写的代码时转到另一个 shell 缓冲区的末尾查看输出,这有点烦人。

(defun execute-script ()
  "Switch to shell buffer and re-execute the last command."
  (interactive)
  (save-some-buffers)
  (switch-to-buffer "*shell*")
  (end-of-buffer)
  (comint-previous-input 0)
  (comint-send-input))

正如你所见,我的功能目前相当原始,只是在 shell 中重新执行最近使用的命令。

我知道 Emacs 具有切换到不同帧中的缓冲区的功能,就像 ido 缓冲区切换器代码一样。有没有人知道我需要用什么来替换我对 switch-to-buffer 的调用以获得预期的效果?

问候贾尔斯。

【问题讨论】:

    标签: emacs frame


    【解决方案1】:

    交流

    (switch-to-buffer "*shell*")
    

    (switch-to-buffer-other-window "*shell*")
    

    这将强制使用两个窗口布局,左侧是先前的缓冲区,右侧是 shell 缓冲区。
    编辑:如果您使用的是多个 框架 布局,而不是您可以使用的多个 窗口 布局

    (switch-to-buffer-other-frame "*shell*")
    

    【讨论】:

      【解决方案2】:

      您还可以使用pop-to-buffer,稍后您可以自定义其行为方式,例如通过display-buffer-reuse-frame,或display-buffer-alist,或special-display-regexp

      【讨论】:

        猜你喜欢
        • 2011-10-12
        • 1970-01-01
        • 2011-01-11
        • 1970-01-01
        • 1970-01-01
        • 2011-08-02
        • 1970-01-01
        • 2018-06-08
        • 1970-01-01
        相关资源
        最近更新 更多