From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Liu Hui <liuhui1610@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Problem of refile in the org capture buffer
Date: Sun, 19 Feb 2017 15:40:47 +0100 [thread overview]
Message-ID: <87bmtyz1jk.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <d1d7712f-1f82-602f-fa37-45eea1b10173@gmail.com> (Liu Hui's message of "Mon, 6 Feb 2017 20:08:14 +0800")
Hello,
Liu Hui <liuhui1610@gmail.com> writes:
> I find C-c C-w (refine) 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 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
Thank you for the patch and the analysis. I eventually fixed it with
a slightly different solution, however.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2017-02-19 14:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-06 12:08 Problem of refile in the org capture buffer Liu Hui
2017-02-19 14:40 ` Nicolas Goaziou [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-02-08 7:42 Liu Hui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bmtyz1jk.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=liuhui1610@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).