Hello, Andrew Burgess <andrew.burg...@embecosm.com> writes:
> I notice that if a capture template sets ':kill-buffer t', and I use > org-capture-refile to refile into a different file then I don't get > the result I expect. > > Let me give an example, here's my setup: > > $ mkdir ~/tmp > $ cd ~/tmp > $ echo "* loc1/tasks" > loc1.org > $ echo "* inbox/tasks" > inbox.org > $ cat test.el > (setq org-capture-templates > '(("t" "TASK that needs completing" entry > (file+headline "~/tmp/inbox.org" "inbox/tasks") > "** TODO %?" > :prepend t :kill-buffer t))) > (setq org-refile-targets (quote (("~/tmp/loc1.org" :maxlevel . 2)))) > $ emacs -Q -l test.el > > Now in emacs: > > org-capture # Start a capture > t # Select the template 't' > AAAAAA # Fill in a task title > org-capture-refile # Start refiling > l<TAB> # Select refile location, should complete to > # 'loc1/tasks (loc1.org)' > > At this point you should see the message: > > Buffer inbox.org modified; kill anyway? (yes or no) > > Neither answer gets you the result you want (I think). > > If you choose 'yes', then quit emacs (saving buffers as you go[1]) > you'll find that task 'AAAAAA' is now in both inbox.org and loc1.org. > > If you choose 'no', then quit emacs (saving buffers as you go) you'll > find that the task has moved out of inbox.org into loc1.org, but, > clearly the requested ':kill-buffer t' wasn't respected. > > The problem is that org-capture-refile calls org-capture-finalize, but > suppresses the call to kill-buffer in org-capture-finalize, instead > performing that call itself. However, org-capture-finalize calls > save-buffer, before calling kill-buffer, org-capture-refile doesn't. > > If I add a call to save-buffer into org-capture-refile in a similar > fashion to the call in org-capture-finalize, then I get the behaviour > I expect. Applied. Thank you. Regards, -- Nicolas Goaziou