From: Tim Visher <tim.visher@gmail.com>
To: 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: Thu, 11 May 2023 09:10:42 -0400 [thread overview]
Message-ID: <CAHa53uwGzr=tWgQ1VTxg4hZBiZDhef3qoTUrU_pNh-tAvt-x7A@mail.gmail.com> (raw)
In-Reply-To: <CAHa53uwZDB83t+XOB7wH62JytWPbBVDstPo5_BS2foGok0rRrA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2233 bytes --]
On Thu, May 11, 2023 at 9:05 AM Tim Visher <tim.visher@gmail.com> wrote:
> On Thu, May 11, 2023 at 8:42 AM Tim Visher <tim.visher@gmail.com> wrote:
>
>> On Wed, May 10, 2023 at 5:04 PM Tim Visher <tim.visher@gmail.com> wrote:
>>
>>> Can `org-capture` templates be made to result in a sub-heading of the
>>> current heading?
>>>
>>> So
>>>
>>> ```
>>> * This Week
>>> ** TODO A TODO Item
>>>
>>> [2023-05-05 Fri 10:47]
>>>
>>> A description <point's here>
>>> ```
>>>
>>> and I whack my capture keychord and get
>>>
>>> ```
>>> * This Week
>>> ** TODO A TODO Item
>>>
>>> [2023-05-05 Fri 10:47]
>>>
>>> A description
>>> *** [2023-05-10 Wed 17:02]
>>>
>>> [2023-05-10 Wed 17:02]
>>>
>>> <point's here>
>>> ```
>>>
>>
>> It's worth noting that with a capture template like
>>
>> ```
>> ("twj" "TODO Work TODO Journal" entry
>> (file+headline "~/Documents/todo.org" "Inbox")
>> "* %U
>>
>> %U
>>
>> %?")
>> ```
>>
>> If I do the usual `M-0 M-x org-capture` with point in the original spot
>> it behaves exactly as I want it to. My goal is to get it to behave that way
>> just by invoking the capture template.
>>
>
> OK after poking around in `org-capture-set-target-location` I think I have
> this sorted. Please let me know if I'm doing something obviously silly. :)
>
> ```
> (defun timvisher--org-capture-sub-heading-insertion-point
> ()
> (insert "\n")
> (forward-char)
> (org-capture-put :exact-position (point) :insert-here t))
>
> ;; Embedded in the capture templates list
> ("twj" "TODO Work TODO Journal" entry
> (function timvisher--org-capture-sub-heading-insertion-point)
> "* %U
>
> %U
>
> %?")
> ```
>
Minor correction. I need to both insert a newline _and *leave*_ point where
it was or I don't get a sub-heading at the proper level (the current level
of the previous journal entry). If I don't insert the newline then
cancelling the entry also pulls the next heading up into the text of the
current heading.
```
(defun timvisher--org-capture-sub-heading-insertion-point
()
(insert "\n")
(org-capture-put :exact-position (point) :insert-here t))
…
```
-- Tim Visher
[-- Attachment #2: Type: text/html, Size: 4341 bytes --]
next prev parent reply other threads:[~2023-05-11 13:12 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 [this message]
2023-05-12 12:08 ` Ihor Radchenko
2023-05-12 14:24 ` Tim Visher
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='CAHa53uwGzr=tWgQ1VTxg4hZBiZDhef3qoTUrU_pNh-tAvt-x7A@mail.gmail.com' \
--to=tim.visher@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).