* Feature request: kill-buffer for org-capture-finalize
@ 2023-09-08 12:03 Eduardo Suarez
2023-09-08 12:10 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Eduardo Suarez @ 2023-09-08 12:03 UTC (permalink / raw)
To: emacs-orgmode
This is a feature request.
The function org-capture-finalize allows an argument to 'jump-to-capture'. I
think it may be a good idea to add a new argument to 'kill-buffer' after the
capture is finalized. This would be useful to avoid having to kill the capture
buffer manually. I assume that if ':kill-buffer' is intended as the default
behavior, then it would be better to set it in the capture template.
I mean something like 'C-u C-u C-c C-c'.
I can't think now of a better way to do it. Any idea is welcome.
Thanks for your work.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Feature request: kill-buffer for org-capture-finalize
2023-09-08 12:03 Feature request: kill-buffer for org-capture-finalize Eduardo Suarez
@ 2023-09-08 12:10 ` Ihor Radchenko
2023-09-08 12:34 ` Eduardo Suarez-Santana
0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2023-09-08 12:10 UTC (permalink / raw)
To: Eduardo Suarez; +Cc: emacs-orgmode
Eduardo Suarez <esuarez@itccanarias.org> writes:
> The function org-capture-finalize allows an argument to 'jump-to-capture'. I
> think it may be a good idea to add a new argument to 'kill-buffer' after the
> capture is finalized. This would be useful to avoid having to kill the capture
> buffer manually. I assume that if ':kill-buffer' is intended as the default
> behavior, then it would be better to set it in the capture template.
May you explain a bit more about the problem you are trying to solve?
Isn't the temporary capture buffer killed after capture already?
Or do you refer to the org buffer where the capture is recorded?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Feature request: kill-buffer for org-capture-finalize
2023-09-08 12:10 ` Ihor Radchenko
@ 2023-09-08 12:34 ` Eduardo Suarez-Santana
2023-09-08 12:38 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Eduardo Suarez-Santana @ 2023-09-08 12:34 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
On Fri, Sep 08, 2023 at 12:10:23PM +0000, Ihor Radchenko wrote:
> Eduardo Suarez <esuarez@itccanarias.org> writes:
>
> > The function org-capture-finalize allows an argument to 'jump-to-capture'. I
> > think it may be a good idea to add a new argument to 'kill-buffer' after the
> > capture is finalized. This would be useful to avoid having to kill the capture
> > buffer manually. I assume that if ':kill-buffer' is intended as the default
> > behavior, then it would be better to set it in the capture template.
>
> May you explain a bit more about the problem you are trying to solve?
> Isn't the temporary capture buffer killed after capture already?
> Or do you refer to the org buffer where the capture is recorded?
Sorry about that. I refer to the org buffer where the capture is recorded. I
meant:
"This would be useful to avoid having to kill the target buffer manually."
I like to keep the target buffer open after the capture is finalized so I can
review the changes later, but sometimes I'd rather prefer to kill it because I
already assume that the changes are correct. This helps to keep the buffer list
clean.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Feature request: kill-buffer for org-capture-finalize
2023-09-08 12:34 ` Eduardo Suarez-Santana
@ 2023-09-08 12:38 ` Ihor Radchenko
2023-09-08 12:47 ` Eduardo Suarez-Santana
0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2023-09-08 12:38 UTC (permalink / raw)
To: Eduardo Suarez-Santana; +Cc: emacs-orgmode
Eduardo Suarez-Santana <esuarez@itccanarias.org> writes:
>> May you explain a bit more about the problem you are trying to solve?
>> Isn't the temporary capture buffer killed after capture already?
>> Or do you refer to the org buffer where the capture is recorded?
>
> Sorry about that. I refer to the org buffer where the capture is recorded. I
> meant:
>
> "This would be useful to avoid having to kill the target buffer manually."
>
> I like to keep the target buffer open after the capture is finalized so I can
> review the changes later, but sometimes I'd rather prefer to kill it because I
> already assume that the changes are correct. This helps to keep the buffer list
> clean.
Did you consider :kill-buffer property in `org-capture-templates'?
:kill-buffer If the target file was not yet visited by a buffer when
capture was invoked, kill the buffer again after capture
is finalized.
Or do you mean that you sometimes want to kill the target org buffer and
sometimes not?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Feature request: kill-buffer for org-capture-finalize
2023-09-08 12:38 ` Ihor Radchenko
@ 2023-09-08 12:47 ` Eduardo Suarez-Santana
2023-09-09 9:18 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Eduardo Suarez-Santana @ 2023-09-08 12:47 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
On Fri, Sep 08, 2023 at 12:38:07PM +0000, Ihor Radchenko wrote:
> Did you consider :kill-buffer property in `org-capture-templates'?
>
> :kill-buffer If the target file was not yet visited by a buffer when
> capture was invoked, kill the buffer again after capture
> is finalized.
>
> Or do you mean that you sometimes want to kill the target org buffer and
> sometimes not?
Yes, I mean that I sometimes want to kill the target org buffer and sometimes
not. I don't want to kill the target buffer as the default behavior of my
capture template.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Feature request: kill-buffer for org-capture-finalize
2023-09-08 12:47 ` Eduardo Suarez-Santana
@ 2023-09-09 9:18 ` Ihor Radchenko
2023-09-09 14:11 ` Eduardo Suarez
0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2023-09-09 9:18 UTC (permalink / raw)
To: Eduardo Suarez-Santana; +Cc: emacs-orgmode
Eduardo Suarez-Santana <esuarez@itccanarias.org> writes:
>> Or do you mean that you sometimes want to kill the target org buffer and
>> sometimes not?
>
> Yes, I mean that I sometimes want to kill the target org buffer and sometimes
> not. I don't want to kill the target buffer as the default behavior of my
> capture template.
I see what you want.
I am not sure if it is something commonly needed.
Unless more people are interested, I do not find this feature as useful
for inclusion to Org mode.
For personal use-case, you can utilize
`org-capture-after-finalize-hook', checking `current-prefix-arg' and
killing the target org buffer according to the prefix argument passed.
Then, for example, you can make C-u C-u C-c C-c unconditionally kill the
target org buffer.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Feature request: kill-buffer for org-capture-finalize
2023-09-09 9:18 ` Ihor Radchenko
@ 2023-09-09 14:11 ` Eduardo Suarez
2023-09-10 8:19 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Eduardo Suarez @ 2023-09-09 14:11 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
On Sat, Sep 09, 2023 at 09:18:27AM +0000, Ihor Radchenko wrote:
> For personal use-case, you can utilize
> `org-capture-after-finalize-hook', checking `current-prefix-arg' and
> killing the target org buffer according to the prefix argument passed.
> Then, for example, you can make C-u C-u C-c C-c unconditionally kill the
> target org buffer.
I have tried something simple like
(defun my-org-capture-kill-buffer ()
(when (equal current-prefix-arg '(16))
(kill-buffer)))
as an after-finalize hook. It seems to recognize the 'current-prefix-arg'
variable.
However,
1. it looks to me that org-capture-finalize jumps to the captured item if there
are any number greater than zero of preffix arguments,
2. the code above tries to kill the buffer I was working before invoking the
capture process.
Any hint?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Feature request: kill-buffer for org-capture-finalize
2023-09-09 14:11 ` Eduardo Suarez
@ 2023-09-10 8:19 ` Ihor Radchenko
2023-09-10 10:48 ` Eduardo Suarez
0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2023-09-10 8:19 UTC (permalink / raw)
To: Eduardo Suarez; +Cc: emacs-orgmode
Eduardo Suarez <esuarez@itccanarias.org> writes:
> I have tried something simple like
>
> (defun my-org-capture-kill-buffer ()
> (when (equal current-prefix-arg '(16))
> (kill-buffer)))
>
> as an after-finalize hook. It seems to recognize the 'current-prefix-arg'
> variable.
>
> However,
>
> 1. it looks to me that org-capture-finalize jumps to the captured item if there
> are any number greater than zero of preffix arguments,
>
> 2. the code above tries to kill the buffer I was working before invoking the
> capture process.
>
> Any hint?
(defun my-org-capture-kill-buffer ()
(when (equal current-prefix-arg '(16))
(save-excursion
(org-capture-goto-last-stored)
(kill-buffer))))
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Feature request: kill-buffer for org-capture-finalize
2023-09-10 8:19 ` Ihor Radchenko
@ 2023-09-10 10:48 ` Eduardo Suarez
2023-09-10 10:57 ` Ihor Radchenko
0 siblings, 1 reply; 11+ messages in thread
From: Eduardo Suarez @ 2023-09-10 10:48 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
On Sun, Sep 10, 2023 at 08:19:25AM +0000, Ihor Radchenko wrote:
> (defun my-org-capture-kill-buffer ()
> (when (equal current-prefix-arg '(16))
> (save-excursion
> (org-capture-goto-last-stored)
> (kill-buffer))))
Thanks for the proposed solution. I have tried it and it didn't work for me. Or
it worked somehow. If it kills the buffer, then the buffer is opened again
right after it is killed, jumping to the last stored position. I think this is
because of the way the 'org-capture-finalize' function is implemented:
...
(cond
(abort-note
(cl-case abort-note
(clean
(message "Capture process aborted and target buffer cleaned up"))
(dirty
(error "Capture process aborted, but target buffer could not be \
ned up correctly"))))
(stay-with-capture ;; <- this cond is executed
(org-capture-goto-last-stored)))
...
It seems that the 'org-capture-goto-last-stored' function is called after the
hooks so the buffer is opened again.
This is just my interpretation. I'm not an expert in elisp.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Feature request: kill-buffer for org-capture-finalize
2023-09-10 10:48 ` Eduardo Suarez
@ 2023-09-10 10:57 ` Ihor Radchenko
2023-09-10 23:17 ` Eduardo Suarez
0 siblings, 1 reply; 11+ messages in thread
From: Ihor Radchenko @ 2023-09-10 10:57 UTC (permalink / raw)
To: Eduardo Suarez; +Cc: emacs-orgmode
Eduardo Suarez <esuarez@itccanarias.org> writes:
> On Sun, Sep 10, 2023 at 08:19:25AM +0000, Ihor Radchenko wrote:
>> (defun my-org-capture-kill-buffer ()
>> (when (equal current-prefix-arg '(16))
>> (save-excursion
>> (org-capture-goto-last-stored)
>> (kill-buffer))))
>
> Thanks for the proposed solution. I have tried it and it didn't work for me. Or
> it worked somehow. If it kills the buffer, then the buffer is opened again
> right after it is killed, jumping to the last stored position. I think this is
> because of the way the 'org-capture-finalize' function is implemented:
> ...
Right.
Then, what you can do is
(defun my-org-capture-finalize (arg)
"Like `org-capture-finalize', but kill Org buffer with double prefix arg."
(interactive "P")
(if (equal arg '(16))
(save-excursion
(org-capture-finalize)
(org-capture-goto-last-stored)
(kill-buffer))
(org-capture-finalize arg)))
(define-key org-capture-mode-map "\C-c\C-c" #'my-org-capture-finalize)
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Feature request: kill-buffer for org-capture-finalize
2023-09-10 10:57 ` Ihor Radchenko
@ 2023-09-10 23:17 ` Eduardo Suarez
0 siblings, 0 replies; 11+ messages in thread
From: Eduardo Suarez @ 2023-09-10 23:17 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode
On Sun, Sep 10, 2023 at 10:57:46AM +0000, Ihor Radchenko wrote:
> Then, what you can do is
>
> (defun my-org-capture-finalize (arg)
> "Like `org-capture-finalize', but kill Org buffer with double prefix arg."
> (interactive "P")
> (if (equal arg '(16))
> (save-excursion
> (org-capture-finalize)
> (org-capture-goto-last-stored)
> (kill-buffer))
> (org-capture-finalize arg)))
> (define-key org-capture-mode-map "\C-c\C-c" #'my-org-capture-finalize)
It worked! Thanks a lot for the help.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-09-10 23:35 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-08 12:03 Feature request: kill-buffer for org-capture-finalize Eduardo Suarez
2023-09-08 12:10 ` Ihor Radchenko
2023-09-08 12:34 ` Eduardo Suarez-Santana
2023-09-08 12:38 ` Ihor Radchenko
2023-09-08 12:47 ` Eduardo Suarez-Santana
2023-09-09 9:18 ` Ihor Radchenko
2023-09-09 14:11 ` Eduardo Suarez
2023-09-10 8:19 ` Ihor Radchenko
2023-09-10 10:48 ` Eduardo Suarez
2023-09-10 10:57 ` Ihor Radchenko
2023-09-10 23:17 ` Eduardo Suarez
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).