From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id KH9fOppKMWYoaAAA62LTzQ:P1 (envelope-from ) for ; Tue, 30 Apr 2024 21:46:35 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id KH9fOppKMWYoaAAA62LTzQ (envelope-from ) for ; Tue, 30 Apr 2024 21:46:35 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EXk8F5tZ; 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=1714506394; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=QSTG/OLHGpzlRzjdOM5TLw2TBd8ThMhvM6huI9ClXtw=; b=AvmjTS8U7UwGru8CU1qvpN+gbe+3S1QqcUNaeKHVjAtXqbzWwTReAeTYk0H8s/9i7iPQzz pGU7To9Ebl0/VeiDJWRNK4Q9ssFV05SWqysA/u/Vtywz5RjpdB1SBHgrrnqbj+3cE8D0np CVSLD0yWwJSRqfY97JKljn9DLgIZfyulEW+ZMG8xKbrVUrGrAnhqUoZSi6UhsO3rZPKTb+ QGf4iwYFxbitvLKB5xaozY6G/xVwmIl5xCUX3HxM76zOSg2M0v1D7YU2jeJvpG5V2AXILi YpGLswi+699Abxn1Dgu68F2Vo3CJ2jT0vkC3AtRC0HSCCnsdAdu/MAiOod28Dg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1714506394; a=rsa-sha256; cv=none; b=s4U88h3kne4XzvfPYkCjbzMh7+dM3KctOm1gVf79IyaffSuRStEUUef2UIara2AVaIcATJ sg6prNUC2AwnfLmUrTFqxTQiIYQd/rESlWGmaOUXVSHZPCxNk/xYn44zkWm23NoPD8Blnd dCL9D7uyiOg0uLu0nJfksBYyk1XkECNaGMBcHdTpwo/99J0/PqSesEmehnpzdsheQMryKF BATrqXX8pJud1daib3DDlYCk78aZNU7d6Yzie8d4T+jQu46R8NL2rOFmZEXACZmqApfjNu sfzStHYYbgkW/Cdy6S/qSAIVHEN6rXmstiY0xAG6IWJI0Vds6b/HOMVYYdmh8w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=EXk8F5tZ; 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" 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 6BBA73EF3B for ; Tue, 30 Apr 2024 21:46:34 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s1tQ8-0005Ce-Gv; Tue, 30 Apr 2024 15:45:44 -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 1s1tQ4-0005A5-Gc for emacs-orgmode@gnu.org; Tue, 30 Apr 2024 15:45:40 -0400 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1tPz-0007JQ-C4 for emacs-orgmode@gnu.org; Tue, 30 Apr 2024 15:45:40 -0400 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-a5872b74c44so692374166b.3 for ; Tue, 30 Apr 2024 12:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714506333; x=1715111133; darn=gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=QSTG/OLHGpzlRzjdOM5TLw2TBd8ThMhvM6huI9ClXtw=; b=EXk8F5tZYStMMeS4G/C+hUuV1ZVB9gdNZe7JAX+oXFHE48MHavwlyGtKFti62RG+sl pBeo6p31uqGVL4jiRnBxByCBor0eg5IfzgK6rRUPkdzzbwyUiCQu7ISeViulZGMyRCmU g0NaHr6e5v5ABdIqS+imdFpVGrwn6Xth5y7R9Akucl4gi9wxohKaQi8iubPZnMKrGMJn gkRtpj793ljSk//jCq+Kb6teSNsY9CqCdGdtGZ2TAUj1SGheojqyl4+ftqMep0bLeRYw ETlUMgF4QhEvp8lFbpoyIbv3NbzERoh9W8B6O8//woGKSEg5b1lnh8lzBQNHYJxwLk56 MSRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714506333; x=1715111133; h=cc: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=QSTG/OLHGpzlRzjdOM5TLw2TBd8ThMhvM6huI9ClXtw=; b=Pozwcr2X5zOfmN2JLOSbow6t+xz+V95adVswQLTf8jSJ+ckTVnMD6QsxIICxudPJKd E20lH3YN2eakgHl+pzEFhgnbIySlYhtH8jViAnexQPFoy8ozGCKHHxUeFiPO4gWdS1hR OKKeTtymuIq/MEpVm5yZ9lHF3wdkHWvsakMX0yNPJ0IpyPvd+ABI2N1TDQmbLBwHKVPr Gz6d9WT2EZbFTP27sE5B2vQmPb+0YGSy4ax4jgcYcwAWzdsndKqR08AUIIyWHkHjhqIB sgZAjKIUXBcz5h7XGpd/PfX1uraF7dpr2DRJFVQ3WPhQBKLD4tSDXCMuoY4MnfktSxxP FoEA== X-Gm-Message-State: AOJu0YwGWEf+OGSgio7NV85muwMANR/eXwdWipx9iKif0jGjhJgFilpq 1h4eRtkQpeV5d0ctmMaTsYrbvK8pby7wC9meubFYkGkkbCPEeV0aANk2ojkLJE7Ko60qM0BnZXQ OXUtm89kFmkw/rjof7N0i0Mtkr/9AARV8 X-Google-Smtp-Source: AGHT+IGyaMvr4DxgVew/GBpy08wG+l1u86vml0ey60aIE7nC3UWrsZCEPXGzloH7PzOjSCw3RdQByU92GALafviZ59I= X-Received: by 2002:a17:907:970b:b0:a59:48fd:674d with SMTP id jg11-20020a170907970b00b00a5948fd674dmr174640ejc.3.1714506332210; Tue, 30 Apr 2024 12:45:32 -0700 (PDT) MIME-Version: 1.0 References: <87mspb6nf2.fsf@localhost> In-Reply-To: <87mspb6nf2.fsf@localhost> From: Nafiz Islam Date: Tue, 30 Apr 2024 15:45:21 -0400 Message-ID: Subject: Re: [FR] Support headline as a function for file+headline target for org-capture-templates To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Content-Type: multipart/alternative; boundary="000000000000e58eee0617559ced" Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=nafiz.islam1001@gmail.com; helo=mail-ej1-x636.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=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 X-Migadu-Spam-Score: -6.71 X-Spam-Score: -6.71 X-Migadu-Queue-Id: 6BBA73EF3B X-Migadu-Scanner: mx11.migadu.com X-TUID: 23P+e7GikrGh --000000000000e58eee0617559ced Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable The problem with my implementation is that it modifies the org file before prompting the user for item entry. As a result, if I cancel/abort my org-capture, that modification will still be present. I've made another attempt which is slightly more successful using advice. (defun my/diary-capture-advice (oldfun r) (let ((org-capture-templates `(("d" "Diary Template" item (file+headline (lambda () (expand-file-name (concat org-directory "Diary" "/" (format-time-string "%Y-%m-%d.org ")))) ,(format-time-string (org-time-stamp-format t t) (current-time))) "- %?" :empty-lines 0)))) (call-interactively oldfun))) (advice-add #'org-capture :around #'my/diary-capture-advice) On Tue, Apr 30, 2024 at 8:31=E2=80=AFAM Ihor Radchenko wrote: > Nafiz Islam writes: > > >> Upon closer look at the `org-capture`, `org-capture-set-target-locatio= n` > > and `org-capture-place-entry`, I'm starting to realize that > "file+function" > > can be used for what I'm looking for. I was just worried about the use = of > > `(org-capture-put :exact-position (point))` > > > > My disappointing attempt at using file+function target to replicate my > idea > > What is the problem with it? > > -- > Ihor Radchenko // yantar92, > Org mode contributor, > Learn more about Org mode at . > Support Org development at , > or support my work at > --000000000000e58eee0617559ced Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The problem with my implementation is that it modifie= s the org file before prompting the user for item entry. As a result, if I = cancel/abort my org-capture, that modification will still be present. I'= ;ve made another attempt which is slightly more successful using advice.

(defun my/diary-capture-advice (oldfun r)
=C2=A0 = =C2=A0 (let ((org-capture-templates `(("d"
=C2=A0 =C2=A0&= quot;Diary Template"
=C2=A0 =C2=A0item
=C2=A0 =C2=A0(f= ile+headline (lambda () (expand-file-name
=C2=A0 =C2=A0 =C2=A0 (= concat org-directory "Diary" "/" (format-time-string &q= uot;%Y-%m-%d.org"))))
=C2=A0 ,(= format-time-string (org-time-stamp-format t t) (current-time)))
=C2= =A0 =C2=A0"- %?"
=C2=A0 =C2=A0:empty-lines 0))))
=C2= =A0 =C2=A0 =C2=A0 (call-interactively oldfun)))
(advice-add #'= ;org-capture :around #'my/diary-capture-advice)

On Tue, Apr 30, 20= 24 at 8:31=E2=80=AFAM Ihor Radchenko <yantar92@posteo.net> wrote:
Nafiz Islam <nafiz.islam1001@gmail.com= > writes:

>> Upon closer look at the `org-capture`, `org-capture-set-target-loc= ation`
> and `org-capture-place-entry`, I'm starting to realize that "= file+function"
> can be used for what I'm looking for. I was just worried about the= use of
> `(org-capture-put :exact-position (point))`
>
> My disappointing attempt at using file+function target to replicate my= idea

What is the problem with it?

--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,=
or support my work at <https://liberapay.com/yantar92>
--000000000000e58eee0617559ced--