Emacs强制组织模式捕获缓冲区在新窗口中打开 [英] Emacs force org-mode capture buffer to open in a new window

查看:86
本文介绍了Emacs强制组织模式捕获缓冲区在新窗口中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何强制组织模式的捕获缓冲区在新窗口中打开?我试过

How do I force org-mode's capture buffer to open in a new window? I tried

(setq special-display-regexps
    '("^\\*Capture\\*$"))

但这没用-我暂时看到一个新窗口,然后-mode进行两个垂直拆分(我使用3个垂直拆分),然后将捕获缓冲区放入正确的拆分中。当我用 C-c C-c C-c C-k 完成操作时,将还原原始的拆分设置。

but it did not work - I see a new window momentarily and then org-mode makes two vertical splits (I'm using 3 vertical splits), and put the capture buffer into the right split. When I'm done by either C-c C-c or C-c C-k, the original split setting is restored.

推荐答案

我也喜欢使用许多并排拆分(通常是4个-我分布在多个监视器),因此 org-capture 的行为将4个常规窗口变成2个真正的宽窗口,使我每次都爆头-这往往使我无法自拔

I, too, like to use many side-by-side splits (usually 4 -- I'm spread across multiple monitors), so org-capture's behavior of turning 4 regular windows into 2 really wide ones makes my head explode every time -- which tends to knock me out of my flow.

+---+---+---+---+     +-------+-------+
| 1 | 2 | 3 | 4 | --> |   1   |capture| = head explosion
+---+---+---+---+     +-------+-------+

所以这是防止 org-capture 修改窗口配置的方法。

So here's a way to prevent org-capture from modifying your window configuration.

经过一些搜索之后,看起来似乎没有一种简单的方法可以自定义此行为(或者至少不是一个显而易见的方法)。跟踪源代码中的函数调用会将我们带到 org-capture-place-template ,这将保存您的原始窗口配置,然后删除其他窗口,然后为您提供两个窗口的拆分。当然,当您完成捕获时,您可以在以后重新获得窗口配置,但是消除不用您说一遍就改变窗口布局这一步骤当然也很好。

After some searching, it does not look like there is an easy way to customize this behavior (or at least not an obvious one). Tracing the function calls in the source code brings us to org-capture-place-template, which saves your original window configuration, then deletes the other windows, then gives you the two-window split. You get your window configuration back later when you finalize the capture, of course, but it sure would be nice to get rid of that "let's change your window layout without your say-so" step.

结果非常简单。在注释掉调用(delete-other-windows) org-capture-place-template >:

Turns out it's pretty simple. Just re-evaluate org-capture-place-template after commenting out the single line calling (delete-other-windows):

(defun org-capture-place-template ()
  "Insert the template at the target location, and display the buffer."
  (org-capture-put :return-to-wconf (current-window-configuration))
  ;; (delete-other-windows)                ; this is the culprit!
  (org-switch-to-buffer-other-window
   (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE"))
  (widen)
  (show-all)
  (goto-char (org-capture-get :pos))
  (org-set-local 'org-capture-target-marker
         (point-marker))
  (org-set-local 'outline-level 'org-outline-level)
  (let* ((template (org-capture-get :template))
     (type (org-capture-get :type)))
    (case type
      ((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)
  (org-set-local 'org-capture-current-plist org-capture-plist))

Aaaah。就像 org-capture 每次我用它时都在打我的脸,但现在它停止了。

Aaaah. It was like org-capture was punching me in the face every time I used it, but now it's stopped.

(编辑:以下是组织模式的较新版本)

(Edited: the following is for a newer version of org-mode)

(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)))
  ;(delete-other-windows)
  (org-switch-to-buffer-other-window
   (org-capture-get-indirect-buffer (org-capture-get :buffer) "CAPTURE"))
  (widen)
  (show-all)
  (goto-char (org-capture-get :pos))
  (org-set-local 'org-capture-target-marker
         (point-marker))
  (org-set-local 'outline-level 'org-outline-level)
  (let* ((template (org-capture-get :template))
     (type (org-capture-get :type)))
    (case type
      ((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)
  (org-set-local 'org-capture-current-plist org-capture-plist))

这篇关于Emacs强制组织模式捕获缓冲区在新窗口中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆