From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 6KV9Oowbh2UrRQAAkFu2QA (envelope-from ) for ; Sat, 23 Dec 2023 18:40:29 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id MBXYMowbh2U9WAAAe85BDQ (envelope-from ) for ; Sat, 23 Dec 2023 18:40:28 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; 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=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1703353208; 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: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9Sq6Q8ywP1eAMZfojpf44yNZqNzBhZd9GSJM0NuP98o=; b=uljW9shP4ezmVvJUwsiDPhvtI0PHseDA4iLaagvZGbKlGqFM2ad/RHYY3EyedSFuvDC0TL zdHJoFgJmam6FpFsaKylzl0aAQHZdcabZOosRYac05qNmwe0QHseuCPCNfrce7w4VGix4N VhOxkzk9FF31sDsZgTh4Rdlk0PvfWLBvnULSuccA9oG5zVXRCIHRb1+1xsXmHnXZjstl5P CvJZr0f57mYrDAiU0DeNG6/2D5hJ7m2Dj6kg0H3Pz7/h+SmRld8Osk08RZNw8dKql5aTXa ouBlno+FSGJ4Bq2Qn6IVl7PSqEevbF1Qth9kimVrZT2bOMoGpPQUDp65j1LRYg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1703353208; a=rsa-sha256; cv=none; b=Pa3WuhKxY7lZU0C9WZYknwuL9TI+DTRsuUEOkFVPogCGHw9rg1GXdJkzvSf21Y2rFc0pRJ AeZG9jPcPZqvEuYJlmUIQFEZ9/Jne7Ytl2w4cqeQyzgZsvppzP/I9+zdttfZML2El2y9ue 0T9p4gD3eADt0lVzyJbHVKrDixFh9zuajQ4Ehq/gKxB9GNm267Lm1+0mK/wwnAZ5b8jibc whwZSjSWBcdPuDZEFQ3iaBgkJQP1Q+2lnWOiHkdZiBvA0S+qJRh2bHv73pbz7+izucwD9g Dcyvo167zYMswqk6PIgr60NskhtZn1Lp/VwjeJ1ocFno/pJVkaGabk2YabTbcw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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=none 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 4B7D346182 for ; Sat, 23 Dec 2023 18:40:06 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rH5xq-0003kW-CT; Sat, 23 Dec 2023 12:39:06 -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 1rH5xo-0003kO-Li for emacs-orgmode@gnu.org; Sat, 23 Dec 2023 12:39:04 -0500 Received: from gavdos.tim-landscheidt.de ([2a01:4f8:1c0c:4bd6::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rH5xn-0006lD-2N for emacs-orgmode@gnu.org; Sat, 23 Dec 2023 12:39:04 -0500 Received: from port-62-145-29-194.static.as20676.net ([62.145.29.194]:48700 helo=vagabond) by gavdos.tim-landscheidt.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1rH5xh-008AtM-2g for emacs-orgmode@gnu.org; Sat, 23 Dec 2023 17:38:57 +0000 From: Tim Landscheidt To: emacs-orgmode@gnu.org Subject: How to execute Lisp code /after/ a capture template has been filled before it is finalized? Organization: https://www.tim-landscheidt.de/ Date: Sat, 23 Dec 2023 17:38:56 +0000 Message-ID: <87plywu8cv.fsf@vagabond.tim-landscheidt.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a01:4f8:1c0c:4bd6::1; envelope-from=tim@tim-landscheidt.de; helo=gavdos.tim-landscheidt.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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: -5.21 X-Spam-Score: -5.21 X-Migadu-Queue-Id: 4B7D346182 X-Migadu-Scanner: mx11.migadu.com X-TUID: yNKPcJjT2tvK Hi, 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): | - Note taken on %U \\\\ | | Coin | Count | |-------+--------| | | 0.01 | %^{Number of =A4 0.01 coins|0} | | | 0.02 | %^{Number of =A4 0.02 coins|0} | | | 0.05 | %^{Number of =A4 0.05 coins|0} | | | 0.10 | %^{Number of =A4 0.10 coins|0} | | | 0.20 | %^{Number of =A4 0.20 coins|0} | | | 0.50 | %^{Number of =A4 0.50 coins|0} | | | 1.00 | %^{Number of =A4 1.00 coins|0} | | | 2.00 | %^{Number of =A4 2.00 coins|0} | | |-------+--------| | | | | | #+TBLFM: @>$>=3D(@I$1..@II$1)*(@I$2..@II$2) 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 =3D %S" org-capture-p= repare-finalize-hook) (add-hook 'org-capture-prepare-finalize-hook (lambda = nil (message "Hook called.")) 0 t) (message "org-capture-prepare-finalize-h= ook =3D %S" org-capture-prepare-finalize-hook) "") but to my surprise, org-capture-prepare-finalize-hook is nil prior to the add-hook call, has stored the function after the add-hook call, but in the interactive capture buffer is nil again (and no message is printed in *Messages*). How can I evaluate Lisp code after all prompts have been answered? TIA, Tim (*1) I would prefer not doing this, as in this case I could not see the result prior to finalizing.