From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:1008:1e59::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 0NbmCDIih2U2WwAAkFu2QA (envelope-from ) for ; Sat, 23 Dec 2023 19:08:50 +0100 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 mFQ9AzIih2VaawEA62LTzQ (envelope-from ) for ; Sat, 23 Dec 2023 19:08:50 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=JJBAAfVT; 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=1703354929; 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=HZT7tiP+2Wwbr9hcjPC+Ns9eC7iuCl239+pMkUYgAmI=; b=LGnFbhCatvHJgSh78X4udLRJppfTHXFSpFrgCOR4/Nrsoo21vtUxf4CRX02UEIyy+DZldg FvgNpGTcoZZ6EgI99d7kPH0dnZ6ikvZ8x6pq1ojBlEQ48SYBIfhQbR1HwyLMGkTDpqGGpQ 60Ji4C8UK8QDvKTRaBjqcvcvEgN8JeBpQYs13v0or3gRkZhKTxBWkU0h5csWzklZkwDpWz DNUp3F2EUwq4rTCq9MzX2tKGhcPPfWWxLljwaPzqms3Rf/xMRCTVFrB/+HQ/q4sId09+oq ugrPVKFZd0+y1z20x2uq5vzgXoDe4eHF67ZkPJj4DNCv1TgSeHEK4HxBXX0i+A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1703354929; a=rsa-sha256; cv=none; b=oELoGkiHJWnnrpEIfg7PWVTAf4eOg0Cn5vKXOMxbxJiLjdryAWjpAYvA6NFYEwLFx40bkx fxA+7wmXWh7HRwGxszoYD63YvtPIUTQnb26WuzIMAA77cof1k+KliOwwiEXaGMMb/uc5Qt cQonpnhRAQpu26HmGZ70UEJ1oOm/wgNn34qCLN+RK69+r+TazCV2EG+ki0KV46LbOknhwP v+0h77omzl6pHJpGQ6F1OavwCKzBMuw0+IIaoISxEr46xTKxab/JktcR5+xrKiV4jjthIq yuYnR7jGtrNc3YzboFCLfwJavrNUL2Ep/n5GrY3PtuohEbqfy/z+FhLMUG2q4g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=JJBAAfVT; 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 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 C9B75465CA for ; Sat, 23 Dec 2023 19:08:49 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rH6Q3-0001wv-6f; Sat, 23 Dec 2023 13:08:16 -0500 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 1rH6Q1-0001wR-As for emacs-orgmode@gnu.org; Sat, 23 Dec 2023 13:08:13 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rH6Pz-00085G-1m for emacs-orgmode@gnu.org; Sat, 23 Dec 2023 13:08:12 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 435A8240101 for ; Sat, 23 Dec 2023 19:08:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1703354888; bh=+GLRIk/Hp3RBae/ST424pGUToOh7qssspXHbWv/a3A8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=JJBAAfVTCYrlzZ2OnegQ6yRuN6Od6H9j61VuRF2pMo7rRJD+GDgHk5h52O2oHFz2v l2DE5uCRlzZIpfrbA8m4NhnMGF86pHv9REXj1oMmwN6hwb+/y9Ua/kwO7c5ZyBVizT /cPhmO+WCEhsGVsYxTYWIGew13V+zN7XIopDgqh8rjZPhMjSw4g7aXTMOVVdoUd0P0 zEkLws8l6eoht7guEK8p31ykFYvi/wMHj9maiL8tbxN2DpQvZgTx/tNkIyKEjYLi+F eBRRlVuDkAzFK657yHsHJaS4mvy8Hl7F3C/wZr4q46G40RW6wPTQn9TWMisLIv9id5 KEz1+o9uTLHFw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SyBwl5RGlz6tm4; Sat, 23 Dec 2023 19:08:07 +0100 (CET) From: Ihor Radchenko To: Tim Landscheidt Cc: emacs-orgmode@gnu.org Subject: Re: How to execute Lisp code /after/ a capture template has been filled before it is finalized? In-Reply-To: <87plywu8cv.fsf@vagabond.tim-landscheidt.de> References: <87plywu8cv.fsf@vagabond.tim-landscheidt.de> Date: Sat, 23 Dec 2023 18:11:20 +0000 Message-ID: <877cl4dc1j.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 X-Migadu-Spam-Score: -7.44 X-Spam-Score: -7.44 X-Migadu-Queue-Id: C9B75465CA X-Migadu-Scanner: mx11.migadu.com X-TUID: /8FPFwuGxQz7 Tim Landscheidt writes: > I (want to) have a capture template that fills a table and > then (re-)calculates a cell based on a formula (and aligns > the table): > ... > If I naively append "%(org-table-recalculate t)" to that > template, the expression gets evaluated immediately when I > start the capture and the text: > > | %![Error: (user-error Not at a table)] > > gets appended to the capture buffer /before/ I get prompted > for the first field. > > Looking at the hooks for org-capture-mode, I also thought > about recalculating the table at finalizing the capture (*1) > and tried: > | %(progn (message "org-capture-prepare-finalize-hook = %S" org-capture-prepare-finalize-hook) (add-hook 'org-capture-prepare-finalize-hook (lambda nil (message "Hook called.")) 0 t) (message "org-capture-prepare-finalize-hook = %S" org-capture-prepare-finalize-hook) "") %(...) expansion is executed _before_ capture template is fully calculated. It is generally not designed to side-effect functions. You can instead use template-local hooks, introduced in Org 9.6. See https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/etc/ORG-NEWS#n1270 -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at