Hello, Calling `org-capture-kill' from any of the four `org-capture-template' hooks always fail. Here is a way to reproduce this and the observed behavior:
start a fresh emacs
#+begin_src shell
emacs -Q ~/tmp/refile.org
#+end_src
evaluate this
#+begin_src emacs-lisp
(defun my-org-capture-abort-hook ()
(org-capture-kill))
(setq org-capture-templates
'(("a" "hook" entry (file "~/tmp/refile.org")
"* test hook"
:hook my-org-capture-abort-hook
:immediate-finish t)
("b" "prepare-finalize" entry (file "~/tmp/refile.org")
"* test prepare-finalize"
:prepare-finalize my-org-capture-abort-hook
:immediate-finish t)
("c" "before-finalize" entry (file "~/tmp/refile.org")
"* test before-finalize"
:before-finalize my-org-capture-abort-hook
:immediate-finish t)
("d" "after-finalize" entry (file "~/tmp/refile.org")
"* test after-finalize"
:after-finalize my-org-capture-abort-hook
:immediate-finish t)
))
#+end_src
The results after doing `M-x org-capture'
- (a) in ~hook~
- error ~org-capture: Capture template ‘a’: This does not seem to be a
capture buffer for Org mode~
- the capture has happened, but the file is not saved
- (b) in ~prepare-finalize~
- error ~org-capture-finalize: Lisp nesting exceeds
‘max-lisp-eval-depth’: 1601~
- there is a buffer ~CAPTURE-refile.org~ with the captured text, and
~refile.org~ is also modified
- (c) in ~before-finalize~
- error ~org-capture: Selecting deleted buffer~
- this seems to delete the ~refile.org~ buffer if it is selected
- otherwise I’m asked to select a file to save the current buffer (for
instance in my case it was ~*Messages*~), then an error
~org-capture-finalize: Wrong type argument: window-configuration-p,
nil~
- ~refile.org~ is not modified
- (d) in ~after-finalize~
- error ~org-capture-finalize: This does not seem to be a capture
buffer for Org mode~
- ~refile.org~ is modified with the added capture entry
Context:
I’m trying to have some code that aborts an org-capture initiated by org
protocol under some conditions.
Best,
Alan
signature.asc
Description: PGP signature
