From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 0GcTD5ToXGRTLwEASxT56A (envelope-from ) for ; Thu, 11 May 2023 15:07:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id GEDuDpToXGSTAAAA9RJhRA (envelope-from ) for ; Thu, 11 May 2023 15:07:32 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 006499219 for ; Thu, 11 May 2023 15:07:32 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1px609-0006ve-Um; Thu, 11 May 2023 09:06:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1px602-0006v4-ER for emacs-orgmode@gnu.org; Thu, 11 May 2023 09:06:27 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1px600-0007QM-C9 for emacs-orgmode@gnu.org; Thu, 11 May 2023 09:06:26 -0400 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2ac809ae92aso11371701fa.0 for ; Thu, 11 May 2023 06:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683810381; x=1686402381; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=F43CnFhQhKWxIRYiuY6ML9gAtHdmhDO/1uJ9bSawSfQ=; b=aPPV609Km6AOMncXODxNsW3K5YfEIRWE0CS5Xc0A+Z+/Ek0ACrva8Uvhcviss2YK59 2oAZBTTwoj6jd0R2F2gES+PiMJ1FZDW+rTAyuFZKmGx6g8KVpIyIBo7M02DReyksVCwP b1/Zyhke9fkO0h48Ifap13ofLc7PQlHI0WbGKLeJT945mf7Gek1d8eR/tPG9BebGG5E1 Sa8rNbiP0ubIbqYx+ozR+1Lf6nNKh2NPfeRdtXIO1/Dycb4yVPo+YQl4BpeYvHLprkk4 XIJmcHRZX5osNm49Mj5RNrkisG963P2yPrEDtt9cEfTZlZ4BEUFtXDxH6K8atXrTe6vh HBgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683810381; x=1686402381; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=F43CnFhQhKWxIRYiuY6ML9gAtHdmhDO/1uJ9bSawSfQ=; b=eEeaX9GKcEsARQCGqUIEV/QfqaMP4pDnu48vcjgWal6PauM/p+Kp1ZupyJy+kjoUFQ lHiVN5UY39trwBOLY2QMfLsFCUDnUQJHts6FG+fyiHn6qhB/klGc+/nxYflHRBPxDB7N PjsdA8wfJPkiZdPYXnhll7qaxAk5MhiHjnH+amEtyonUjrz+T/oCHWEmcKBOjUryOFcR TbshI3N+LUpmFgbEcE4p4/MoGNWueHrFPYuWjRFPFtwu5Ydsoq1mB+/uJq2kps7FyWlL fr84Zfoysz2iluKxmr5CFRv1Cv72KIxs+jXkfCwqhiDUNw4BG3jW0gPLmf9p17kpMp4W 8xEg== X-Gm-Message-State: AC+VfDzDot3xARWLKG1SlI1FpfrE1Q/VAwOjAlwAwmc0YOhYcFvCUOHV 4Ue7mbcCVUnAwVrQkO3hHTqnX5bZ1Gu31FS65NaAZb6/Zi34Ig== X-Google-Smtp-Source: ACHHUZ7C8kChElz4EzZczyDBRBWJogFht/qMi+Yl2Yc8g/9LwX22UAN4ZiaMf9Z3nw4nBoWhbIcBmJvASXGGjlauxE8= X-Received: by 2002:a2e:1f01:0:b0:2ac:82dd:f682 with SMTP id f1-20020a2e1f01000000b002ac82ddf682mr6481354ljf.5.1683810381285; Thu, 11 May 2023 06:06:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Tim Visher Date: Thu, 11 May 2023 09:05:44 -0400 Message-ID: Subject: Re: Can `org-capture` templates be made to result in a sub-heading of the current heading? To: Emacs Org Mode mailing list Content-Type: multipart/alternative; boundary="000000000000a5508b05fb6aa728" Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=tim.visher@gmail.com; helo=mail-lj1-x231.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1683810452; a=rsa-sha256; cv=none; b=nrGUXp0he0wNGOvQ/0oXXKqdQtkHQEzxU95inXwf3Ik9/dJWyT8xwQcFkrxMvKjMwIUMId o0wCCdzz2CpGNcwTUgYGemziZ1ymMKpYs9Lx58pb19r+AWAxAuGYLJIrUeVWN30i8ljCrQ +qCwqj2p5IGYJiBQwJvc9giqtHy0vtFqBObDXAs5A4UFPaYpNpXozBw7BZQrQpSirm4GJd x8oxds4+NTSK0DjDqFvgiciinnhKkHdXSnYmCEJ4e6AeIDBvk22SjpdsQzkzF3xnl9mP1y XUsZ2oMBOLNQYwcIifPVmf62tlRXmuliW/PA1RRQ2vzPjfI2kksJTQFc91F3GQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=aPPV609K; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1683810452; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=F43CnFhQhKWxIRYiuY6ML9gAtHdmhDO/1uJ9bSawSfQ=; b=dZemoy5Ig7LNQLHNxrxGhMwP/v0l0k21UgWTuhpy/V1RkFF292A91kJsJDcAITAGRZTQtb T89lkSUmVJ4xsTERbmIUGTQiPoLopOh9sS6X2pkqtz30HcavXZvJtYX9/6DQgfieQ+aDi7 6GRtwGXQblBW9uOBJAUAzQ1KDptN/Nhi9EFm6p/k+KrscNGT33x5bqds/YcIkA7L4u43dh G+WY6pvjeHa/jEOPrNsFEeTxuNM73lVWaEDL8J/wHBvEP2wHr/SUGfGEsHndBI6IeR1iee x81zOS7tyJ8PMYlc99zGqFplBuY4OqinqJyG3epTw3ig68g1Kl7onDQnhWu6Iw== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=aPPV609K; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.87 X-Spam-Score: -3.87 X-Migadu-Queue-Id: 006499219 X-TUID: MhvXJinxzA08 --000000000000a5508b05fb6aa728 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, May 11, 2023 at 8:42=E2=80=AFAM Tim Visher w= rote: > On Wed, May 10, 2023 at 5:04=E2=80=AFPM Tim Visher = 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 >> ``` >> >> 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] >> >> >> ``` >> > > 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 i= t > 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 %?") ``` The key was finding that it wasn't enough to merely move point to the proper location. I _also_ needed to call `org-capture-put`. The docs on this subject are a little misleading, IMHO. =E2=80=98(function function-finding-location)=E2=80=99 > Most general way: write your own function which both visits > the file and moves point to the right location. Empirically it seems like you have to visit the file, move point to the right location, _and_ call `org-capture-put`. -- Tim Visher --000000000000a5508b05fb6aa728 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, May 11, 2023 at 8:42=E2=80=AFAM T= im Visher <tim.visher@gmail.com<= /a>> wrote:
Can `org-capture` templates be made to result in a sub-hea= ding of the current heading?

So

=
```
* This Week
<= div>** TODO A TODO Item

=C2=A0 =C2= =A0[2023-05-05 Fri 10:47]

=C2=A0 =C2=A0A description <poin= t's here>
```

and I whack = my capture keychord and get

```
* This Week
** TODO A TODO Item

<= /div>
=C2=A0 =C2=A0[2023-05-05 Fri 10:47]

=C2=A0 =C2=A0A description
***=C2=A0[2023-05-10 Wed 17:02]

=C2=A0 =C2=A0=C2=A0= [2023-05-10 Wed 17:02]

=C2=A0 =C2=A0 <point's here>=
```

It's = worth noting that with a capture template like

```=
("twj" "TODO Work TODO J= ournal" entry
=C2=A0(file+headline "~/Documents/todo.org" "Inbox")
= =C2=A0"* %U

=C2=A0 =C2=A0%U

=C2=A0 =C2=A0%?")
```=C2=A0

If I do the usual `M-0 M= -x org-capture` with point in the original spot it behaves exactly as I wan= t it to. My goal is to get it to behave that way just by invoking the captu= re template.

OK after pok= ing 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--o= rg-capture-sub-heading-insertion-point
=C2=A0 =C2=A0 ()
=C2=A0 (inser= t "\n")
=C2=A0 (forward-char)
=C2=A0 (org-capture-put :exac= t-position (point) :insert-here t))

;; Embedded in the capture templ= ates list
("twj" "TODO Work TODO Journal" entry
= =C2=A0(function timvisher--org-capture-sub-heading-insertion-point)
=C2= =A0"* %U

=C2=A0 %U

=C2=A0 %?")

```

The key was finding that it wasn't enough= to merely move point to the proper location. I _also_ needed to call `org-= capture-put`. The docs on this subject are a little misleading, IMHO.
=

=E2=80=98(function function-finding-location)=E2=80= =99
=C2=A0 =C2=A0 =C2=A0Most general way: write your own function which = both visits
=C2=A0 =C2=A0 =C2=A0the file and moves point to the right lo= cation.

Empirically it seems like yo= u have to visit the file, move point to the right location, _and_ call `org= -capture-put`.

--=C2=A0Tim Visher=C2=A0
--000000000000a5508b05fb6aa728--