[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[BUG] org-capture is not reentrant [9.5.2 (9.5.2-gfbff08 @ /home/ignacio

From: Ignacio Casso
Subject: [BUG] org-capture is not reentrant [9.5.2 (9.5.2-gfbff08 @ /home/ignacio/.emacs.d/elpa/org-9.5.2/)]
Date: Thu, 10 Feb 2022 11:25:18 +0100
User-agent: mu4e 1.6.10; emacs 27.2


I recently tried to use (org-capture '(4) key) (i.e., C-u prefix
argument GOTO, so not actually capturing anything, just
moving to the target) as part of the function passed as target for
another capture template, using file+function, as in the example below:

       (setq org-capture-templates
             '(("i" "Inner" entry
                (file+headline "/tmp/foo.org" "Target")
                "* Wrong Heading"
                :immediate-finish t)
               ("o" "Outer" entry
                (file+function "/tmp/foo.org" capture-target) ;;
                "* It works!!"
                :immediate-finish t)))

       (defun capture-target ()
         (org-capture '(4) "i"))

       (org-capture nil "o")

The result was:
* Target
** Wrong heading

So it worked for moving point to the desired target, but it overwrote
other parts of the template. I took a quick look at the code and it
seems that a global property list is used internally for the capture
process, which seems to be only initialized at the start of the capture
process and therefore the inner capture would overwrite it in our
case. I saw also that the global property list is copied to a buffer
local property list for the case of starting a new capture process
before typing C-c C-c in the indirect capture buffer.

Do you think it would be easy to recycle that code to also have a stack
of property lists and allow reentrancy? Would yo consider it useful? I
would, but not really worth it to implement unless it's a low hanging
fruit. If it is, I'd volunteer to do so (although my elisp-fu may be a
little bit lacking yet).



Emacs  : GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20)
 of 2022-01-16
Package: Org mode version 9.5.2 (9.5.2-gfbff08 @ 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]