From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id mECHEyklNmaP3AAAe85BDQ:P1 (envelope-from ) for ; Sat, 04 May 2024 14:08:09 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id mECHEyklNmaP3AAAe85BDQ (envelope-from ) for ; Sat, 04 May 2024 14:08:09 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=VaMSDWpJ; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1714824489; 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=0Cnf+zjc2kM+pOH3w6zExEdCkelJrk12Hy5/1H6omcg=; b=Nz44UUYY/c4q8bzVEFlwfltN3CDnh7MFJWvX1ql1xcPyLeembO+iLHiAyIZuDWy2UggQv5 gjjjl48rwItZDbR6G67hB6rVQZhMBTn5VgyoEWXDmlEaZBHo6b2oJzG/BXYHutcaEiyThY c9UfeJaExcRfPx/ZOJ+/Y5y0+34gGa6rYXp3bISswVAPuOCAZXaDxgU42JUEexSfw3KYWt x1dwNgYQMRHdjyNt59kQwGV2p2OGNDtyskUFe8lCKHpATFbPSVTTtQYdrVmxiSH0JD5/1U G5+EHmmd4RhnjS0+camcBv2tquhCc4JmS8e19YiOlcwrbmkQuMARWlYQplFh9A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=VaMSDWpJ; 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"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1714824489; a=rsa-sha256; cv=none; b=F/JuYNFp/g8X53EztZuCdIiakymV8sJhsIJ7eirAtMjw6mOB/d7IU17aqfFV7uKC5/TKuv WZ/F/lclIerfzI7uEO3bSf6HL/dlHwrtmdpbh/YOo7mb05Vf7GfwaLg+IWlUbThGMNLEYh qNkAlMUXiFOBB6oJFvVtHG8QcmdE4kccrN4bt29zYtFl+ei1YM1OLVPWw3pOH8wzOMLTMd i/Ae7VVi75DbzGbfv7WRs2ebvxZnHmR9nuhVayD2PnV6vM/GQkPxVP0qA6L08uxj+JheHC SfyGpGG8bg+JqcVEgZJdUN1jtITW4DFEKDV9fx3vMBXYAZ/bkG6wzYZ+my3c4w== 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 221ED6BE83 for ; Sat, 4 May 2024 14:08:09 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3EAk-0000YV-Bz; Sat, 04 May 2024 08:07:22 -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 1s3EAb-0000Y7-La for emacs-orgmode@gnu.org; Sat, 04 May 2024 08:07:14 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s3EAX-0003sw-JF for emacs-orgmode@gnu.org; Sat, 04 May 2024 08:07:13 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 6F474240028 for ; Sat, 4 May 2024 14:07:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1714824427; bh=zCbNX15L90bY9C37tIq7TIHJsUyeJ6HMp4hKA/sUqnM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=VaMSDWpJx7JrR4H16MFcYEYofz3jNQhbNZNIhci1w1DLx3dsKu6353/hHOWOxx/FV vq9dxQpusKXVtCss1QxTvEjGXUYxGO5vGOPbl/hOcTJ61a4xmBATJBZ2jFdosKj3jN hqWpeQ3XohKcGrcqdpQn9yFa2sRx8VsAnzIZIkEUrpofWPC1rlK03IE/raWm2iD436 KZ1qLKtp2JwhZHS9qlHo+4q8lkrsySDsNd6bHcZnaJho3k5crsiz4WYevnKUBsWE7F Nqz2R31sJERuMnxisOQf9LtE8IoVJLG2opoE99WzZIRO6WM80SRdWjr1bf8NlY9fsh EbT2PLQCsiiCA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VWmcp354bz9rxK; Sat, 4 May 2024 14:07:06 +0200 (CEST) From: Ihor Radchenko To: Nafiz Islam Cc: emacs-orgmode@gnu.org Subject: Re: [FR] Support headline as a function for file+headline target for org-capture-templates In-Reply-To: References: <87mspb6nf2.fsf@localhost> <87r0eleqi2.fsf@localhost> <87jzkdsksv.fsf@localhost> <87wmoc9yuc.fsf@localhost> <87ttjftany.fsf@localhost> Date: Sat, 04 May 2024 12:08:25 +0000 Message-ID: <87a5l5ye2u.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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: -7.90 X-Spam-Score: -7.90 X-Migadu-Queue-Id: 221ED6BE83 X-Migadu-Scanner: mx13.migadu.com X-TUID: 9r9RJrZN5nR2 Nafiz Islam writes: > So far I have written this code... > > (defun org-capture-expand-headline (headline) > "Expand functions, symbols and strings for HEADLINE. > > > When HEADLINE is a function, call it. When it is a form, evaluate > it. When it is a variable, return its value. When it is a string, > treat it as a headline title. When it is `t', select existing headline > title or enter a new one. In any other case, raise an error." Let's not add "t" variant yet. It is going beyond what `org-capture-expand-file' does. > ((functionp headline) (funcall headline > headlines)) Let's not over-complicate things. Just (funcall headline) will do, making sure that it is called in the right context - current buffer being selected according to file part of the capture target. > What I am concerned about is the amount of tests I might have to write or > update for `org-capture'. > > testing/lisp/test-org-capture.el > ... > 144: `(("t" "Todo" entry (file+headline ,file2 "A") > ... > How do you think it should be tested if the headline can be 4 different > types? It is enough to make sure that basic entry type works correctly, expanding the HEADLINE part of the template definition. Other tests you listed are really not testing this; they are checking the logic of inserting the right entry/item/table/etc. Also, since we are adding more flexible HEADLINE expansion, may as well allow functions for OLP in file+olp and file+olp+datetree. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at