emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Leo Vivier <leo.vivier+dev@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] org-capture: Update plist before finalizing
Date: Wed, 02 Sep 2020 00:50:36 -0400	[thread overview]
Message-ID: <87zh68g4tf.fsf@kyleam.com> (raw)
In-Reply-To: <87h7tv9pkm.fsf@hidden>

Leo Vivier writes:

> Hi there,
>
> I’m working on the parallelisation of `org-capture' for Org-roam, and
> I’ve run into a problem with the updating of `org-capture-plist'.
>
> ;;---------------------------------------------------------------------
> ;; DESCRIPTION
> ;;---------------------------------------------------------------------
> We use the global-variable `org-capture-plist' to populate the
> local-variable `org-capture-current-plist' on the init of the
> `org-capture' buffer.  However, we do not do the opposite (i.e. update
> the global-variable with the local-variable) on `org-capture-finalize'.
>
> This is fine for the majority of `org-capture-finalize', since we’re
> using the LOCAL arg of `org-capture-get' to read
> `org-capture-current-plist' instead of `org-capture-list', but this
> trick does not work for `org-capture-after-finalize', since the hook is
> run after the `org-capture-buffer' has been closed.
>
> This causes problem with `:kill-buffer t', and it limits what can be
> done with cleanup functions in `org-capture-after-finalize'.
[...]

> ;;---------------------------------------------------------------------
> ;; PATCH
> ;;---------------------------------------------------------------------
> I propose to update `org-capture-plist' early in `org-capture-finalize'.
> I don’t think this would have unforeseen effects, since
> `org-capture-list' is already meant to be transient, and we’d only be
> expanding its use from init-only to init-and-exit.

Thanks for the detailed write-up and the patch (and sorry for the slow
reply).  Based on a quick glance, I too think this would be safe to do.

> Subject: [PATCH] org-capture: Update plist before finalizing
>
> * lisp/org-capture.el (org-capture-finalize): Update
> `org-capture-plist' with local-value before finalizing.

It'd be good to at least point to the motivation/usecase for this change
here.  (Your description section above already does a nice job of that.)

> ---
>  lisp/org-capture.el | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/lisp/org-capture.el b/lisp/org-capture.el
> index 2cc1ce394..223ed4124 100644
> --- a/lisp/org-capture.el
> +++ b/lisp/org-capture.el
> @@ -728,6 +728,9 @@ captured item after finalizing."
>  
>    (run-hooks 'org-capture-prepare-finalize-hook)
>  
> +  ;; Update `org-capture-plist' with the local-value
> +  (setq org-capture-plist org-capture-current-plist)

Convention nit: please end your comment with a period.

Perhaps add a brief mention of `org-capture-after-finalize' (or some
other hint of why) here.


  reply	other threads:[~2020-09-02  4:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-25 22:50 [PATCH] org-capture: Update plist before finalizing Leo Vivier
2020-09-02  4:50 ` Kyle Meyer [this message]
2020-09-05  7:11   ` Leo Vivier
2020-09-05  9:14     ` Bastien

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=87zh68g4tf.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=leo.vivier+dev@gmail.com \
    /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).