From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id kEdeBgIjb2JHRgEAbAwnHQ (envelope-from ) for ; Mon, 02 May 2022 02:17:06 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id aHx/BQIjb2ICsAAAG6o9tA (envelope-from ) for ; Mon, 02 May 2022 02:17:06 +0200 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 5DFD43A2E9 for ; Mon, 2 May 2022 02:17:05 +0200 (CEST) Received: from localhost ([::1]:42004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nlJkO-0007Xr-5i for larch@yhetil.org; Sun, 01 May 2022 20:17:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nlJjx-0007Xi-1A for emacs-orgmode@gnu.org; Sun, 01 May 2022 20:16:37 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:44897) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nlJjv-000387-63 for emacs-orgmode@gnu.org; Sun, 01 May 2022 20:16:36 -0400 Received: by mail-pj1-x1030.google.com with SMTP id m14-20020a17090a34ce00b001d5fe250e23so11553477pjf.3 for ; Sun, 01 May 2022 17:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=Oy8MWKNj495dXFy/xGH4v5y4whecK0sMvFKNEBSAHsU=; b=Cf4LtXkCJHYaCcMAcBvEMT/SyCLkU054ya909g/XAAIPB2GreM4lcWYmmcYUIeRpVN rUWl1o0C2b159/+PPra+KvmnrgezvGYzNQTnsNiCGdqQGH37iP0Xutbq7+/8Jddclhdx g7dDCTLRCiHL1I8voIxfBZzMQ6AezW1xuTW8CGFFLfFHZRcIDGYMIG6VifB2k1sIze5e xXJyKLOAI0OBZv9vLhpb7OixOLiSJiL/G5D6tsmPX9y9aplps3CFDS1V6uvwyA/JGxdN pC2WmH8XcmchvyE20tZ6AxHVsxvjPI2ra6vFxnDLijmxrqqCxeyGhgBDmFFU4YcmTo25 gv/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=Oy8MWKNj495dXFy/xGH4v5y4whecK0sMvFKNEBSAHsU=; b=Tv0D5ieoBVpN5PErqu918EI7lIyid15J1eUdRRiQOlhtD7tz0XNUZ0GEmyM2A9ZWCg M3rGRrtUUn+YuBb/QWuKa7nq1FewBALf/89UZ8vo+aqgPgdMj+Np6XhHa2wI0N/thn/Y lYZ+5Ro6Iyon3pAKC7juWN0b5H/763tFyxoJJ4HXQJOsmp+3XV8mCRuVGZpL1499o60d DeScNkukJAVfhdWo/hn257YPZg9o71smSPJl1lVKlUbsyIvUOP6HP61zugJirBKJHf/I t5ALqIAr5Gt53saZyjveNKSPIMfULV3XONaAEdEZtmXN/Xp7xJiRnsIghsE904SbW5H8 +Zkw== X-Gm-Message-State: AOAM533F8a09rDXdOP8AXJqNBffWkn3QtEZLkDL6VOlB1x/mQXQ5owuF ZpAQHDp12e4hgQtxBhs5hEA= X-Google-Smtp-Source: ABdhPJwUu22IcjdUQmryB0uoFG9LvodSA8oTpjKbRszh9flOG/3KnznG/O8U24EtmG3tczAKJgnxBA== X-Received: by 2002:a17:902:d4cb:b0:15e:75e6:da2c with SMTP id o11-20020a170902d4cb00b0015e75e6da2cmr9631274plg.57.1651450592964; Sun, 01 May 2022 17:16:32 -0700 (PDT) Received: from localhost ([23.27.206.157]) by smtp.gmail.com with ESMTPSA id fv12-20020a17090b0e8c00b001cd4989fed0sm18432397pjb.28.2022.05.01.17.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 May 2022 17:16:32 -0700 (PDT) From: Ihor Radchenko To: Skip Collins Subject: [PATCH] Re: [BUG] folding error during capture In-Reply-To: References: Date: Mon, 02 May 2022 08:17:20 +0800 Message-ID: <87mtg0vldb.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=yantar92@gmail.com; helo=mail-pj1-x1030.google.com 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, 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, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Cc: emacs-org list Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1651450625; 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=Oy8MWKNj495dXFy/xGH4v5y4whecK0sMvFKNEBSAHsU=; b=g/Q+W9ypfMuH8P5v1pG1x6O4HzCuAjMNOfGYHZn2BZ/TGHxOHYa9aDYIZncDmznZbg+GXl 7q7P7Haw6U0M0afEsVzJMemJFsvAqA55DC1gOe2AM70bK+Qd2pU3QAemnctmF2sRLYpNXX gnlL2v02sbaIXU/+uMLc8YXeH4JowlmvPm45ihnJAUttrATPgLExSEz+0G9zyvuyfZXhul wCIwklcuVPde7WTgy/MW9rN1UGIUlx6Z7oPBcm932mJOqZP+UlvzcMkj1O3qaJ9VdlIGaP yAiPYWh0Lwa31sNOlKY4ixFafdJEO2fdf/kZsAz6z3aXwOJ8iGoMSb4C8PFfTg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651450625; a=rsa-sha256; cv=none; b=F5y+J8/Q6Xf+hMi+khfUt5J00hT/y3hulxMRJKEU8CtcCf0wJKPTal6ncVKHHf7UtHJYoj 7cUz3j2vBO/POnFKY1AKA+XHG/JliBhzC7RsBhCufyt85Dz4F10roJiNcmf9dd0LPCmehn XcLRu0y4Qf2Oz4ONe80MFKD3CjgkjjFIBxaOf6Bismf3ua807pSiPbpH5P4BTkpP2JN9pz 6dQqWw56XrTpC1deGn1R81GQRw0FpzFue/dkYM/zyuDhbclURRZKYUYthD+87EsDSlP4ZT /5wySYEKTVK7flVFakMQa7IVqcIjBRBfTb1F/2fC8p8N3PvL9+0XY20qW+LuiA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Cf4LtXkC; 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" X-Migadu-Spam-Score: -3.49 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=Cf4LtXkC; 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" X-Migadu-Queue-Id: 5DFD43A2E9 X-Spam-Score: -3.49 X-Migadu-Scanner: scn1.migadu.com X-TUID: Sd6TMCMgGYUh --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Skip Collins writes: > Recently, I get an error message when invoking custom capture > templates like this one: > ("n" "Note" entry > (file "~/Documents/org/beorg/capture.org") > "* %^{note} :note: %(org-set-property \"Created\" > (org-time-stamp-inactive '(16)))" :immediate-finish t) > > ... > But the pre-populated *Capture* window contains an error message: > * :note: %![Error: (error Calling =E2=80=98org-fold-core-region=E2=80=99= with missing SPEC)] > :PROPERTIES:... Thanks for the report! This is quite a hacky capture template... What you are seeing happens because template expansion happens in fundamental-mode and org-set-property does not work anymore outside org-mode. I'd say that setting org-mode during template expansion is reasonable. The fix is attached. I do not push the fix just yet. If anyone think that enabling org-mode during template expansion is undesired, please let me know. Best, Ihor --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-capture-Expand-sexps-in-template-with-Org-mode-b.patch >From 797dfd0c82c68696d8534a9b3103d0b3c622bee6 Mon Sep 17 00:00:00 2001 Message-Id: <797dfd0c82c68696d8534a9b3103d0b3c622bee6.1651450441.git.yantar92@gmail.com> From: Ihor Radchenko Date: Mon, 2 May 2022 08:11:28 +0800 Subject: [PATCH] org-capture: Expand sexps in template with Org mode being active * lisp/org-capture.el (org-capture-fill-template): Enable `org-mode' in the temporary template expansion buffer. Update docstring accordingly. (org-capture-templates): Clarify that %(sexp) expansion happens in a temporary Org mode buffer. Fixes https://orgmode.org/list/CABUh-776V-_+_JAZwcKQm9ATcs0WUV9SmGwjooGFbt=CtwQj8g@mail.gmail.com --- lisp/org-capture.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index 068e3eda2..9b17fa978 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -309,6 +309,8 @@ (defcustom org-capture-templates nil introduced with %[pathname] are expanded this way. Since this happens after expanding non-interactive %-escapes, those can be used to fill the expression. + The evaluation happens with Org mode set as major mode + in a temporary buffer. %<...> The result of `format-time-string' on the ... format specification. %t Time stamp, date only. The time stamp is the current @@ -1572,7 +1574,9 @@ (defun org-capture-fill-template (&optional template initial annotation) "Fill a TEMPLATE and return the filled template as a string. The template may still contain \"%?\" for cursor positioning. INITIAL content and/or ANNOTATION may be specified, but will be overridden -by their respective `org-store-link-plist' properties if present." +by their respective `org-store-link-plist' properties if present. + +Expansion occurs in a temporary Org mode buffer." (let* ((template (or template (org-capture-get :template))) (buffer (org-capture-get :buffer)) (file (buffer-file-name (or (buffer-base-buffer buffer) buffer))) @@ -1645,6 +1649,7 @@ (defun org-capture-fill-template (&optional template initial annotation) (setq buffer-file-name nil) (setq mark-active nil) (insert template) + (org-mode) (goto-char (point-min)) ;; %[] insert contents of a file. (save-excursion -- 2.35.1 --=-=-=--