在特定 window 中打开 Org Capture 缓冲区?
Open Org Capture buffer in specific window?
我使用 Emacs 大约一年了。我通常有相同的 window 设置每个会话(四个 windows)。
我已经设置了捕获模板并可以捕获我想要的内容,但是:与其让捕获模式暂时让我退出 window 设置,我希望所选的捕获模板在新(第五)window,保留我现有的布局。我通常希望捕获模板打开一段时间,所以它会造成干扰。
这似乎 似乎是一个显而易见的选择,但我想不通。提前感谢所有 Emacs 负责人。
我想出了一个更易于使用的 Dan's answer 版本来解决链接问题:
(defun my-org-capture-place-template-dont-delete-windows (oldfun &rest 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))
也就是说,不必修改 Org-mode 代码并删除对 delete-other-windows
的调用,这段代码暂时将 delete-other-windows
重新定义为 ignore
而 org-capture-place-template
正在呼叫中。
它并没有完全满足您的要求:它选择现有的 windows 之一并将捕获缓冲区放在那里。至少它比删除所有以前的默认行为更好 windows 除了一个。
可能有一种方法可以通过自定义变量 display-buffer-alist
来完成您想要的操作,但我想不出来...
您还可以在加载后使用 https://github.com/raxod502/el-patch 和补丁 org-capture(查找 (el-patch-remove (delete-other-windows))):
(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)) )
出于某种原因,@legoscia 方法在 emacs 28 中对我来说失败了。
这里是之前建议的 el-patch
片段:
(el-patch-feature org-capture)
(with-eval-after-load 'org-capture
(el-patch-define-and-eval-template
(defun org-capture-place-template)
(el-patch-remove (delete-other-windows))))
我使用 Emacs 大约一年了。我通常有相同的 window 设置每个会话(四个 windows)。
我已经设置了捕获模板并可以捕获我想要的内容,但是:与其让捕获模式暂时让我退出 window 设置,我希望所选的捕获模板在新(第五)window,保留我现有的布局。我通常希望捕获模板打开一段时间,所以它会造成干扰。
这似乎 似乎是一个显而易见的选择,但我想不通。提前感谢所有 Emacs 负责人。
我想出了一个更易于使用的 Dan's answer 版本来解决链接问题:
(defun my-org-capture-place-template-dont-delete-windows (oldfun &rest 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))
也就是说,不必修改 Org-mode 代码并删除对 delete-other-windows
的调用,这段代码暂时将 delete-other-windows
重新定义为 ignore
而 org-capture-place-template
正在呼叫中。
它并没有完全满足您的要求:它选择现有的 windows 之一并将捕获缓冲区放在那里。至少它比删除所有以前的默认行为更好 windows 除了一个。
可能有一种方法可以通过自定义变量 display-buffer-alist
来完成您想要的操作,但我想不出来...
您还可以在加载后使用 https://github.com/raxod502/el-patch 和补丁 org-capture(查找 (el-patch-remove (delete-other-windows))):
(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)) )
出于某种原因,@legoscia 方法在 emacs 28 中对我来说失败了。
这里是之前建议的 el-patch
片段:
(el-patch-feature org-capture)
(with-eval-after-load 'org-capture
(el-patch-define-and-eval-template
(defun org-capture-place-template)
(el-patch-remove (delete-other-windows))))