emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* capture template property :kill-buffer does not let me refile
@ 2013-10-25 22:54 Rodrigo Amestica
  2013-10-27 16:39 ` Rodrigo Amestica
  0 siblings, 1 reply; 6+ messages in thread
From: Rodrigo Amestica @ 2013-10-25 22:54 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

for some days I have been capturing one of my templates using C-c C-w
(org-capture-refile). This option let's me conveniently select under which exact
header (within the target file) to insert the new entry.

Leaving the target file buffer alive after inserting a new item is inconvenient
in my case. So I added ':kill-buffer t' to the template configuration. But doing
so resulted in that now C-c C-w does not offer me to select anything, the entry
is simple inserted at the beginning of the file and the buffer is killed.

My template is shown below. Is it actually possible to combine
org-capture-refile with :kill-buffer?

Thanks,
 Rodrigo

("t"
 "Template"
 entry
 (file "~/my/file.org")
 "* \n  :PROPERTIES:\n  :Some:   \n  :Properties:   \n  :END:"
 :prepend t :kill-buffer t)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: capture template property :kill-buffer does not let me refile
  2013-10-25 22:54 capture template property :kill-buffer does not let me refile Rodrigo Amestica
@ 2013-10-27 16:39 ` Rodrigo Amestica
  2013-10-28  1:48   ` Rodrigo Amestica
  0 siblings, 1 reply; 6+ messages in thread
From: Rodrigo Amestica @ 2013-10-27 16:39 UTC (permalink / raw)
  To: emacs-orgmode

please, no body else having the same issue? 

I tried to understand in org-refile and org-capture-refile how is that refile
and closing the buffer intermix, but I'm not that lisp proficient :-(

Then I tried providing some code for

org-capture-after-finalize-hook, and
org-after-refile-insert-hook

My idea was to save and close the buffer associated to the file I'm capturing to
from one of those hooks. However, it seems that both hooks are invoked before
the new captured text has been inserted into the buffer. For example, if in the
hook I add code to only select and close the associated buffer then after the
capture process has finished then the buffer appears as modified requiring an
explicit save.
 
Any hints?

Many thanks,
 Rodrigo

emacs 24.3.1
org 8.2.1

At Fri, 25 Oct 2013 18:54:33 -0400,
Rodrigo Amestica wrote:
> 
> Hello,
> 
> for some days I have been capturing one of my templates using C-c C-w
> (org-capture-refile). This option let's me conveniently select under which exact
> header (within the target file) to insert the new entry.
> 
> Leaving the target file buffer alive after inserting a new item is inconvenient
> in my case. So I added ':kill-buffer t' to the template configuration. But doing
> so resulted in that now C-c C-w does not offer me to select anything, the entry
> is simple inserted at the beginning of the file and the buffer is killed.
> 
> My template is shown below. Is it actually possible to combine
> org-capture-refile with :kill-buffer?
> 
> Thanks,
>  Rodrigo
> 
> ("t"
>  "Template"
>  entry
>  (file "~/my/file.org")
>  "* \n  :PROPERTIES:\n  :Some:   \n  :Properties:   \n  :END:"
>  :prepend t :kill-buffer t)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: capture template property :kill-buffer does not let me refile
  2013-10-27 16:39 ` Rodrigo Amestica
@ 2013-10-28  1:48   ` Rodrigo Amestica
  2013-11-06 13:42     ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Rodrigo Amestica @ 2013-10-28  1:48 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

based on 'printf' type logging I have found one solution that looks to me like a
bug fix in org-capture-refile. But I'm obviously far from guessing any side
effect that I could be missing.

In org-capture-refile if I move org-capture-finalize after the
save-window-excursion form then the :kill-buffer option works as expected
without interfering with the refile operation.

I meant to say a bug fix because to me it sounds more reasonable to call
org-capture-finalize really when finished, in this specific case after refile.

Does that make sense?

Thanks,
 Rodrigo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: capture template property :kill-buffer does not let me refile
  2013-10-28  1:48   ` Rodrigo Amestica
@ 2013-11-06 13:42     ` Bastien
  2013-11-06 15:17       ` Rodrigo Amestica
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2013-11-06 13:42 UTC (permalink / raw)
  To: Rodrigo Amestica; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 879 bytes --]

Hi Rodrigo,

Rodrigo Amestica <ramestica@gmail.com> writes:

> based on 'printf' type logging I have found one solution that looks to me like a
> bug fix in org-capture-refile. But I'm obviously far from guessing any side
> effect that I could be missing.
>
> In org-capture-refile if I move org-capture-finalize after the
> save-window-excursion form then the :kill-buffer option works as expected
> without interfering with the refile operation.
>
> I meant to say a bug fix because to me it sounds more reasonable to call
> org-capture-finalize really when finished, in this specific case after refile.
>
> Does that make sense?

Yes it does -- I attach a patch, can you confirm it is what you did
and it does what you want?

Also, I'd be glad if a few others could test the patch so that we can
make more sure there are no side-effects -- I could not think of any.

Thanks,


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: org-capture-refile.patch --]
[-- Type: text/x-diff, Size: 708 bytes --]

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 871382d..b832798 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -787,14 +787,14 @@ already gone.  Any prefix argument will be passed to the refile command."
   (let ((pos (point))
 	(base (buffer-base-buffer (current-buffer)))
 	(org-refile-for-capture t))
-    (org-capture-finalize)
     (save-window-excursion
       (with-current-buffer (or base (current-buffer))
 	(save-excursion
 	  (save-restriction
 	    (widen)
 	    (goto-char pos)
-	    (call-interactively 'org-refile)))))))
+	    (call-interactively 'org-refile)))))
+    (org-capture-finalize)))
 
 (defun org-capture-kill ()
   "Abort the current capture process."

[-- Attachment #3: Type: text/plain, Size: 14 bytes --]


-- 
 Bastien

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: capture template property :kill-buffer does not let me refile
  2013-11-06 13:42     ` Bastien
@ 2013-11-06 15:17       ` Rodrigo Amestica
  2013-11-06 15:27         ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Rodrigo Amestica @ 2013-11-06 15:17 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

At Wed, 06 Nov 2013 14:42:25 +0100,
Bastien wrote:
> 
> [1  <text/plain (7bit)>]
> Hi Rodrigo,
> 
> Rodrigo Amestica <ramestica@gmail.com> writes:
> 
> > based on 'printf' type logging I have found one solution that looks to me like a
> > bug fix in org-capture-refile. But I'm obviously far from guessing any side
> > effect that I could be missing.
> >
> > In org-capture-refile if I move org-capture-finalize after the
> > save-window-excursion form then the :kill-buffer option works as expected
> > without interfering with the refile operation.
> >
> > I meant to say a bug fix because to me it sounds more reasonable to call
> > org-capture-finalize really when finished, in this specific case after refile.
> >
> > Does that make sense?
> 
> Yes it does -- I attach a patch, can you confirm it is what you did
> and it does what you want?

yes, that's what I did and it works as I expected. 

many thanks,
 Rodrigo

> 
> Also, I'd be glad if a few others could test the patch so that we can
> make more sure there are no side-effects -- I could not think of any.
> 
> Thanks,
> 
> [2 org-capture-refile.patch <text/x-diff (7bit)>]
> diff --git a/lisp/org-capture.el b/lisp/org-capture.el
> index 871382d..b832798 100644
> --- a/lisp/org-capture.el
> +++ b/lisp/org-capture.el
> @@ -787,14 +787,14 @@ already gone.  Any prefix argument will be passed to the refile command."
>    (let ((pos (point))
>  	(base (buffer-base-buffer (current-buffer)))
>  	(org-refile-for-capture t))
> -    (org-capture-finalize)
>      (save-window-excursion
>        (with-current-buffer (or base (current-buffer))
>  	(save-excursion
>  	  (save-restriction
>  	    (widen)
>  	    (goto-char pos)
> -	    (call-interactively 'org-refile)))))))
> +	    (call-interactively 'org-refile)))))
> +    (org-capture-finalize)))
>  
>  (defun org-capture-kill ()
>    "Abort the current capture process."
> [3  <text/plain (7bit)>]
> 
> -- 
>  Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: capture template property :kill-buffer does not let me refile
  2013-11-06 15:17       ` Rodrigo Amestica
@ 2013-11-06 15:27         ` Bastien
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2013-11-06 15:27 UTC (permalink / raw)
  To: Rodrigo Amestica; +Cc: emacs-orgmode

Rodrigo Amestica <ramestica@gmail.com> writes:

> yes, that's what I did and it works as I expected. 

Applied, thanks for confirming!

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-11-06 15:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-25 22:54 capture template property :kill-buffer does not let me refile Rodrigo Amestica
2013-10-27 16:39 ` Rodrigo Amestica
2013-10-28  1:48   ` Rodrigo Amestica
2013-11-06 13:42     ` Bastien
2013-11-06 15:17       ` Rodrigo Amestica
2013-11-06 15:27         ` Bastien

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).