From: Tim Visher <tim.visher@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Emacs Org Mode mailing list <emacs-orgmode@gnu.org>
Subject: Re: Can `org-capture` templates be made to result in a sub-heading of the current heading?
Date: Fri, 12 May 2023 10:24:12 -0400 [thread overview]
Message-ID: <CAHa53uww3SFFngpufJG2G+PV6pAVZLf9knLFsw7kNzVr1qxJ6w@mail.gmail.com> (raw)
In-Reply-To: <87o7mpwy4g.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 1700 bytes --]
On Fri, May 12, 2023 at 8:05 AM Ihor Radchenko <yantar92@posteo.net> wrote:
> Tim Visher <tim.visher@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"))
)
```
[-- Attachment #2: Type: text/html, Size: 2499 bytes --]
prev parent reply other threads:[~2023-05-12 14:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-10 21:04 Can `org-capture` templates be made to result in a sub-heading of the current heading? Tim Visher
2023-05-11 12:42 ` Tim Visher
2023-05-11 13:05 ` Tim Visher
2023-05-11 13:10 ` Tim Visher
2023-05-12 12:08 ` Ihor Radchenko
2023-05-12 14:24 ` Tim Visher [this message]
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=CAHa53uww3SFFngpufJG2G+PV6pAVZLf9knLFsw7kNzVr1qxJ6w@mail.gmail.com \
--to=tim.visher@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/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).