From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [PATCH] Save buffer in org-capture-refile Date: Sat, 15 Sep 2018 16:58:17 +0200 Message-ID: <87va76hkom.fsf@nicolasgoaziou.fr> References: <20180905103245.26222-1-andrew.burgess@embecosm.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g1CCM-0005NT-DF for emacs-orgmode@gnu.org; Sat, 15 Sep 2018 11:09:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g1C1d-00027U-U4 for emacs-orgmode@gnu.org; Sat, 15 Sep 2018 10:58:25 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:51369) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g1C1d-00022r-NA for emacs-orgmode@gnu.org; Sat, 15 Sep 2018 10:58:21 -0400 In-Reply-To: <20180905103245.26222-1-andrew.burgess@embecosm.com> (Andrew Burgess's message of "Wed, 5 Sep 2018 11:32:45 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Andrew Burgess Cc: emacs-orgmode@gnu.org Hello, Andrew Burgess 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 # 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