On Fri, May 12, 2023 at 8:05 AM Ihor Radchenko <yanta...@posteo.net> wrote:
> Tim Visher <tim.vis...@gmail.com> writes: > > Can `org-capture` templates be made to result in a sub-heading of the > > current heading? > > Just use target `here' (as symbol). > Thanks for the suggestion, Ihor. Do you have an example of this actually working? I'm on `Org mode version 9.6.5` which looks to be the latest available from GNU ELPA and there seems to be a dispute between `org-capture-set-target-location` which understands <https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/org-capture.el?id=30b790f42bd0de95ca15d927e27b9125b6549043#n993> that the result of `(org-capture-get :target)` can return a symbol rather than a list vs. `org-capture` itself which assumes <https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/lisp/org-capture.el?id=30b790f42bd0de95ca15d927e27b9125b6549043#n719> that target will _always_ be a list. My testing code: ``` (timvisher--comment ;; Context (defmacro timvisher--comment (&rest _) nil) (defmacro wcb (buffer &rest body) `(with-current-buffer ,buffer ,@body)) ;; Demo code (setq org-capture-templates '(("1" "1" entry here "* 1") ("2" "2" entry (here) "* 2"))) ;; Fails with `Capture template ‘1’: Wrong type argument: listp, here` ;; because of `… (car (org-capture-get :target)) …` (wcb "todo.org" (org-capture nil "1")) ;; Fails with `Invalid capture target specification: (here)` because ;; `(pcase (or target (org-capture-get :target)) …)` doesn't have a case ;; for `(here)` (wcb "todo.org" (org-capture nil "2")) ) ```