Emacs 是否在特定窗口中打开组织捕获缓冲区?

Emacs 是否在特定窗口中打开组织捕获缓冲区?,emacs,org-mode,Emacs,Org Mode,我已经使用Emacs大约一年了。我通常会在每次会话中设置相同的窗口(四个窗口) 我已经设置了捕获模板,可以捕获我想要的内容,但是:与捕获模式临时将我从窗口设置中拉出不同,我希望选择的捕获模板在新(第五个)窗口中打开,保留我现有的布局。我通常希望捕获模板打开一段时间,因此会造成中断 这似乎是一个显而易见的选择,但我想不出来。提前感谢所有的Emacs负责人。我想出了一个更易于使用的版本来回答链接的问题: (defun my-org-capture-place-template-dont-delete

我已经使用Emacs大约一年了。我通常会在每次会话中设置相同的窗口(四个窗口)

我已经设置了捕获模板,可以捕获我想要的内容,但是:与捕获模式临时将我从窗口设置中拉出不同,我希望选择的捕获模板在新(第五个)窗口中打开,保留我现有的布局。我通常希望捕获模板打开一段时间,因此会造成中断


这似乎是一个显而易见的选择,但我想不出来。提前感谢所有的Emacs负责人。

我想出了一个更易于使用的版本来回答链接的问题:

(defun my-org-capture-place-template-dont-delete-windows (oldfun args)
  (cl-letf (((symbol-function 'delete-other-windows) 'ignore))
    (apply oldfun args)))

(with-eval-after-load "org-capture"
  (advice-add 'org-capture-place-template :around 'my-org-capture-place-template-dont-delete-windows))
也就是说,在调用
组织捕获位置模板
时,这段代码暂时将
删除其他窗口
重新定义为
忽略
,而不必修改组织模式代码并删除对
删除其他窗口
的调用

它并不能完全满足您的需要:它选择了一个现有的窗口,并将捕获缓冲区放在那里。至少它比默认的删除所有以前的窗口(只有一个)的行为要好

通过自定义变量
display buffer alist
,可能有一种方法可以实现您想要的功能,但我想不出来…

您也可以在加载后使用和修补org capture(查找(el patch remove(delete other windows)):


你想做什么就做什么?@Legossia不,很不幸。“批准”的答案不起作用,评论中的链接也不起作用。@詹姆斯:我刚刚试着在
组织捕获位置模板中注释
(删除其他窗口)
,正如@legocia指出的答案一样,效果很好:捕获缓冲区在一个现有窗口中打开,其他窗口保持不变,当捕获完成时,修改后的窗口将变为以前的状态。但是,您不应该从该答案复制函数:您应该编辑您正在使用的
org capture.el
文件,如果您使用编译后的代码运行,则可能会重新编译该文件,然后执行
M-x org reload
以激活更改,这不是配置:您必须修改
org capture place模板
功能。但是您确实在某个地方有文件
org capture.el
:do
M-x查找文件org capture.el
,以找到它。然后,您可以编辑、保存、编译(如果需要)并重新加载组织模式。但我知道你可能会觉得这有点难以接受:你可以试试下面@legossia的答案,它可以添加到你的
.emacs
@NickD-ah中,现在我明白了。我找到了
org capture.el
,并注释掉了
delete other windows
,就像你所描述的那样——它成功了。我不知道包的目录/文件结构,但现在我也了解了这一点。感谢您的回复,非常感谢。感谢您,您最初链接到的那篇文章在@NickD解释了有关修改
org capture.el
的细节后起了作用。如果您最初的评论是一个答案,我会将其标记为最佳答案。我认为您应该接受这个答案:它包含指向另一个答案的指针,并且它还包含一种实现道德等价于另一个答案的方法,而无需修改组织来源本身。您可能应该尝试将上述答案中的代码添加到您的.emacs中,而不要修改
org capture.el
。这将使您不必在每次升级组织模式版本时进行相同的修改。@NickD同意。完成。您也可以在加载后使用el-patch来修补组织捕获,如下所示:(el-patch功能组织捕获)(使用eval-after-load“组织捕获”(el-patch defun-org-capture-place-template)(&optional-inhibit-wconf-store)“在目标位置插入模板,并显示缓冲区。当“禁止wconf存储”时,不要存储窗口配置,因为它以前可能存储过。”(除非禁止wconf存储(组织捕获放置:返回到wconf(当前窗口配置))(el修补程序删除(删除其他窗口)))我尝试了这个,但得到的错误是,
org set local
的函数定义无效
  (el-patch-feature org-capture) 
  (with-eval-after-load 'org-capture
    (el-patch-defun org-capture-place-template  (&optional inhibit-wconf-store)
      "Insert the template at the target location, and display the buffer.
When `inhibit-wconf-store', don't store the window configuration, as it
may have been stored before."
      (unless inhibit-wconf-store
    (org-capture-put :return-to-wconf (current-window-configuration)))
      (el-patch-remove (delete-other-windows))
      (org-switch-to-buffer-other-window
       (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE"))
      (widen)
      (org-show-all)
      (goto-char (org-capture-get :pos))
      (setq-local outline-level 'org-outline-level)
      (pcase (org-capture-get :type)
    ((or `nil `entry) (org-capture-place-entry))
    (`table-line (org-capture-place-table-line))
    (`plain (org-capture-place-plain-text))
    (`item (org-capture-place-item))
    (`checkitem (org-capture-place-item)))
      (org-capture-mode 1)
      (setq-local org-capture-current-plist org-capture-plist)) )