Hi Everyone,

I think this should likely involve an update to the manual but I don't want
to bother doing that unless the basic approach is approved.


>From eccc3f8f805c38b1de55fc8ad60c67a87e2feea4 Mon Sep 17 00:00:00 2001
From: Tim Visher <tim.vis...@gmail.com>
Date: Fri, 12 May 2023 11:32:21 -0400
Subject: [PATCH] org-capture.el: Allow `(here)' as a template target

* lisp/org-capture.el (org-capture-set-target-location): Allow `(here)' as
a template
target in addition to `here'.

Templates had no user accessible way to target the current location
directly from a capture template. Attempting to directly utilize the
behavior accessible through a 0 prefix arg exposed the inconsistent
treatment of the `:target` property in
`org-capture`. `org-capture-set-target-location` understood that it
could be both a symbol and a list, while `org-capture` itself required
it to be a list through its use of `car`.

This change opts to make `org-capture-set-target-location` more
liberal in what it accepts rather than making `org-capture` agree that
targets can be lists. This is because the manual implies, especially
in the `(clock)' entry, that targets are expected to be lists even if
they are meant as specific points.

 lisp/org-capture.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index d4311dd20..f14e95c5c 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -991,7 +991,8 @@ Store them in the capture property list."
   (let ((target-entry-p t))
       (pcase (or target (org-capture-get :target))
- (`here
+ ((or `here
+             `(here))
  (org-capture-put :exact-position (point) :insert-here t))
  (`(file ,path)
  (set-buffer (org-capture-target-buffer path))

Attachment: 0001-org-capture.el-Allow-here-as-a-template-target.patch
Description: Binary data

Reply via email to