emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ignacio Casso <ignaciocasso@hotmail.com>
To: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <PAXPR06MB77609C2CA8CAA7F6B79FE8BAC62F9@PAXPR06MB7760.eurprd06.prod.outlook.com> (raw)

Hello,

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

Regards,

Ignacio


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 @ /home/ignacio/.emacs.d/elpa/org-9.5.2/)


             reply	other threads:[~2022-02-10 10:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 10:25 Ignacio Casso [this message]
2022-10-20  3:35 ` [BUG] org-capture is not reentrant [9.5.2 (9.5.2-gfbff08 @ /home/ignacio/.emacs.d/elpa/org-9.5.2/)] Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PAXPR06MB77609C2CA8CAA7F6B79FE8BAC62F9@PAXPR06MB7760.eurprd06.prod.outlook.com \
    --to=ignaciocasso@hotmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).