From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id EOt4LH8rS2YnPQEAqHPOHw:P1 (envelope-from ) for ; Mon, 20 May 2024 12:52:47 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id EOt4LH8rS2YnPQEAqHPOHw (envelope-from ) for ; Mon, 20 May 2024 12:52:47 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=P7H8pndX; dmarc=pass (policy=none) header.from=posteo.net; 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-Seal: i=1; s=key1; d=yhetil.org; t=1716202367; a=rsa-sha256; cv=none; b=lBwADSF+einYfj7SzlLNHcfVpkVlJvk8sG6TDjTcEY33eISGnogERXgsJPbpVGrVERS3SG XfMJxCHCQbKjfKfOle1OkWy4DQz+WPZ1nE4SMn60Cp7NhLS6Xe4KN5xJjBCwxJW0aEVwWE gxiSVQ9QWlrn3bejjnsVvxcnGoVIk8hsxBjvAfrNqtqWBOw91vb2lRM1K4D+d531Eys0FC SQ7GuY3l5OKw7pFvulSiyS8QmZ9pp0F4GS8VvE1ztHv/HNkkW9qfZX+NLvgZMnuEIt6xBs QvW5qzdGCLsMgVWTXN29GhsdiGNMi0Yx3wGkdSKmUIMh3yS0U2De9EgBvnjVYQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=P7H8pndX; dmarc=pass (policy=none) header.from=posteo.net; 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=1716202367; 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=yCfPSuL2wWK0Bho8bOqCD6r2OlO3hqpu7n1IJ//O3X4=; b=dV24Dput2kdtLTRK01k89AD92Lay7m6tcbGVmZgzBjXggJHg/3PjI63eoqlDPZsF0L7tZa TAjltCSlF9J5i2lGTDJDhgGDt1xvaLCOR/RbXbscvRfTnBtjvQDL0SCCWD+2+dlZi2BOuv QewSiwTLfMffZssT0LTnCaS3Dp6ewV4iSDplgReOf/6W/h42LqFbEDhWDHzsRgtY2ID7hB VvRPTug20b6xJ82MRegQfzGxYgVKVmTZ2K6vBR6tgekCI3fVXhRdW2P2L28FUKyVd03Kyx JQ40ExJd79vPl59a1W+MAtvYsmkP37YTQ7y9mgGMpOp+gAsIJN+UHHKi0hJlJg== 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 8C51A1A336 for ; Mon, 20 May 2024 12:52:47 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s90cd-0000Y0-Uy; Mon, 20 May 2024 06:52:03 -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 1s90cc-0000Xq-AL for emacs-orgmode@gnu.org; Mon, 20 May 2024 06:52:02 -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 1s90ca-00038j-2i for emacs-orgmode@gnu.org; Mon, 20 May 2024 06:52:02 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 4E500240027 for ; Mon, 20 May 2024 12:51:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716202318; bh=Pf5MAy1gM3yJoyK9ZKYIA+qxLwSwPP6OqzPWBJCwEjM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=P7H8pndXGzbgZxMWaaTIVJRSlApLKtKRPESWy7YK/e+NDIgF1K4mDzzGoyujYly05 Phz+N2vt3gYBqpmMDS7D/poYSoBxtpiv5EzgCNHjQngK3ujD2WU58NP6TfU8FnMYUB LrJFXev7dMx0XnweuH5R0S3u5J1F39oZqkXYgru2SWXrPhfCHJvqFbBTwlKEVNsL+G Idz+pf5O/n6JvKeuH+CQ0f/VcFYwHuwzynAZ2RE/KRnx/FfChgXBFzClapebv1rilO 031k7TdO0tbvCPT8l5P6wge8uzQMapwj3prYeFAXJbpksCm2AB9mniO8KZqzMVlVcO PqiCXZ3Die+MA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VjZBj68tRz9rxG; Mon, 20 May 2024 12:51:57 +0200 (CEST) From: Ihor Radchenko To: Nafiz Islam Cc: emacs-orgmode@gnu.org Subject: Re: [PATCH] function and symbol for headline and olp for org-capture-templates In-Reply-To: References: Date: Mon, 20 May 2024 10:53:40 +0000 Message-ID: <87pltgrbyj.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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: 8C51A1A336 X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -8.07 X-Spam-Score: -8.07 X-TUID: WMBqwHjtliX8 Nafiz Islam writes: >> I've also updated the docstring for `org-capture-templates', filtered out >> incorrect target, and updated `org-capture-expand-olp' to take file >> argument. I do not think that it does what you expect. AFAIU, the idea was to pass the FILE and extra OLP arguments to the custom function provided by the user. But it is not what your code does. > +(defun org-capture-expand-function-or-symbol (input) > + "Expand functions and symbols. When INPUT is a > +function, call it. When it is a variable, return > +its value. In any other case, return `nil'." > + (let* ((output (cond ((functionp input) (funcall input)) > + ((and (symbolp input) (boundp input)) (symbol-value input)) > + (t nil)))) > + output)) > ... > +(defun org-capture-expand-olp (file &rest olp) > + "Expand functions, symbols and outline paths for OLP. > +When OLP is a function, call it. When it is a variable, > +return its value. When it is a list of string, return it. > +In any other case, return `nil'. The current buffer is > +set to the FILE before executing OLP as a function." > + (with-current-buffer (find-file-noselect file) > + (let* ((final-olp (cond ((stringp (car olp)) olp) > + ((not (cdr olp)) (org-capture-expand-function-or-symbol (car olp))) > + (t (error "Invalid outline path: %S" olp))))) > + final-olp))) You are still calling `org-capture-expand-function-or-symbol' without passing the rest of OLP there. Or was it the intention? Also, is there any point calling `find-file-noselect' when the outline path spec is _not_ a function? Finally, you need to describe the calling convention and environment when the function spec for OLP is called - that it is called with no (or some?) arguments and that the current buffer is the FILE-visiting buffer. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at