emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] Reverse capture finalize and refile, hack buffer killing.


From: Jan Seeger
Subject: [O] [PATCH] Reverse capture finalize and refile, hack buffer killing.
Date: Mon, 28 Sep 2015 10:06:58 +0200
User-agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (Goj┼Ź) APEL/10.8 EasyPG/1.0.0 Emacs/24.5 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO)

* org-capture.el (org-capture-refile): Call finalize first, then
  refile. If the capture buffer needs to be killed afterwards, kill
  after refiling.

Refiling before finalizing led to an incorrect cursor position during
refile. Since adjusting the buffer position and bounds for the refiled
entry is difficult, I reverted the org-capture-refile function to its
original order of finalizing and then refiling. However, this leads to a
bug with killing the buffer on capture, described in
http://permalink.gmane.org/gmane.emacs.orgmode/78027/. To work around
this, now the :kill-buffer flag is cleared before calling finalize, and
the capture buffer is killed after org-refile is called.

TINYCHANGE
---
 lisp/org-capture.el | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 67dc319..b1cda3d 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -792,7 +792,10 @@ already gone.  Any prefix argument will be passed to the 
refile command."
      "Refiling from a capture buffer makes only sense for `entry'-type 
templates"))
   (let ((pos (point))
        (base (buffer-base-buffer (current-buffer)))
-       (org-refile-for-capture t))
+       (org-refile-for-capture t)
+       (kill-buffer (org-capture-get :kill-buffer 'local)))
+    (org-capture-put :kill-buffer nil)
+    (org-capture-finalize)
     (save-window-excursion
       (with-current-buffer (or base (current-buffer))
        (save-excursion
@@ -800,7 +803,7 @@ already gone.  Any prefix argument will be passed to the 
refile command."
            (widen)
            (goto-char pos)
            (call-interactively 'org-refile)))))
-    (org-capture-finalize)))
+    (when kill-buffer (kill-buffer base))))
 
 (defun org-capture-kill ()
   "Abort the current capture process."
-- 
2.4.9



reply via email to

[Prev in Thread] Current Thread [Next in Thread]