I'm proposing the following trivial patch to bring more consistency to org-capture-mode's hooks. By setting org-capture-current-plist before invoking org-capture-mode in the capture buffer, users can access the same variable in org-capture-mode-hook as they would in org-capture-before-finalize-hook and org-capture-prepare-finalize-hook. org-capture-after-finalize-hook is the only outlier, but that makes sense as the capture buffer is no longer current when it runs.

~ Nicholas Vollmer

>From 0e8affeaea6034655bbd53faa412eed0826a7933 Mon Sep 17 00:00:00 2001
From: Nicholas Vollmer <iarchivedmywholel...@gmail.com>
Date: Sun, 3 May 2020 13:20:05 -0400
Subject: [PATCH] Allow org-capture-mode-hook to access
 org-capture-current-plist

Set buffer local org-capture-current-plist before putting capture buffer
in org-capture-mode. Allows hook functions to access the buffer local
version on the plist (consistent with before/prepare-finalize hooks).
---
 lisp/org-capture.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index d292defd6..f650c5473 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1128,8 +1128,8 @@ may have been stored before."
     (`plain (org-capture-place-plain-text))
     (`item (org-capture-place-item))
     (`checkitem (org-capture-place-item)))
-  (org-capture-mode 1)
-  (setq-local org-capture-current-plist org-capture-plist))
+  (setq-local org-capture-current-plist org-capture-plist)
+  (org-capture-mode 1))
 
 (defun org-capture-place-entry ()
   "Place the template as a new Org entry."
-- 
2.26.2

Reply via email to