How do I force org-mode's capture buffer to open in a new window? I tried
(setq special-display-regexps
'("^\\*Capture\\*$"))
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.
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
+---+---+---+---+ +-------+-------+
So here's a way to prevent org-capture
from modifying your window configuration.
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.
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. 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))