emacs-orgmode
[Top][All Lists]
Advanced

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

[O] Problem of refile in the org capture buffer


From: Liu Hui
Subject: [O] Problem of refile in the org capture buffer
Date: Wed, 8 Feb 2017 15:42:41 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1

Hello,

I find C-c C-w (refile) in the org capture buffer doesn't work correctly when there are empty lines (containing the point) in the end of buffer. Steps to reproduce:

1. echo -e "* A\n* B" > /tmp/test.org; cat /tmp/test.org
* A
* B

2. Emacs -Q, and evaluate the code:

(setq org-capture-templates
      '(("t" "Todo" entry (file+headline "/tmp/test.org" "A")
         "** test1 %?")))

3. M-x org-capture, and press t to open the org capture buffer

4. In the capture buffer, press C-j to insert a newline, then C-c C-w:

   => the subtree "B" will be refiled rather than the "test1".


The problem is caused by org-capture-finalize, which deletes the empty lines and, as a result, makes the point saved by org-capture-refile invalid. The following patch should fix the problem:

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 1a1a500..27cb60b 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -827,6 +827,9 @@ already gone. Any prefix argument will be passed to the refile command."
        (base (buffer-base-buffer (current-buffer)))
        (org-capture-is-refiling t)
        (kill-buffer (org-capture-get :kill-buffer 'local)))
+    (and (< (skip-chars-backward " \t\n") 0)
+        (not (bobp))
+        (setq pos (point)))
     (org-capture-put :kill-buffer nil)
     (org-capture-finalize)
     (save-window-excursion


Emacs  : GNU Emacs 26.0.50.2 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9)
 of 2016-12-17
Package: Org mode version 9.0.4 (release_9.0.4-283-g2064b0 @ ~/org-mode/lisp/)




reply via email to

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