From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WApwFIofK2KVhQAAgWs5BA (envelope-from ) for ; Fri, 11 Mar 2022 11:08:10 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id gAI5DYofK2KHYAAAG6o9tA (envelope-from ) for ; Fri, 11 Mar 2022 11:08:10 +0100 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 AC0F139490 for ; Fri, 11 Mar 2022 11:08:09 +0100 (CET) Received: from localhost ([::1]:33050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nScBs-0006je-4t for larch@yhetil.org; Fri, 11 Mar 2022 05:08:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nScB1-0006gw-E1 for emacs-orgmode@gnu.org; Fri, 11 Mar 2022 05:07:15 -0500 Received: from [2a00:1450:4864:20::232] (port=45940 helo=mail-lj1-x232.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nScAz-0002zr-Ez for emacs-orgmode@gnu.org; Fri, 11 Mar 2022 05:07:14 -0500 Received: by mail-lj1-x232.google.com with SMTP id l12so11344795ljh.12 for ; Fri, 11 Mar 2022 02:07:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=185XovNVE94BUP5NwNWIS1W2sngtFL5K1WS1/o3EU+8=; b=nq7QnNN4HQB/1wN83q1/bSRsEBxWcbZEbOMls3eDxkxCRB+pxHvE5lbIH9ECON7PY1 XEpyZMaDBkWudnEWhvO6FAB1TOeuUooDTGJUwhKNvAR0dZiuHCTLG1oqRXa2wRxMoz11 AEpG38qjaL7e/kBL+FKl97UZ0BGnzqE4klN8Zv9JOryG0u5MtC2jdYABcRuja+Em5g0v 8v5OJANG5N38gLlcC0Luedkh03C+jBdniQS0ADQPT85RyUr3V8HyzyogH0PvJhMF70iS 9bBMvxfWKwtJlNd8VKOujg2nwdEsLqXqf5kSjJIhyRyrz9AaH+IuVVug95w2D8n9Sy6N t6xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:message-id:date:mime-version:user-agent :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=185XovNVE94BUP5NwNWIS1W2sngtFL5K1WS1/o3EU+8=; b=pCmiVrXx/Cly3W8B5BUYZmiQqD7zjzmS0bvpGvweXJcnqG1qtvZQM4mfybrfTZlkEe qtqHBKnh3DcLiA0+t8t1IOGLFBVuUyguF5GC7zkd7VqU6JiXPJkw8qre+Sm2smzYTCBs 1TNRrSstHNhIg4yi+CtMIKP+yD60aixJXHmE7GM6fzvQLzB0M+FjD1zolgZFlaVYHNso ixmW25DMXBlGfNiBKFYRjyn0NoiCOQ6dQpZ0tmSSAN45VziFSZFWlBT/+1HSAdcAGvcF PwFZcIXMj4jcyFQNLcL2Cni0LiKvL5rB09UUzmJeCvaiHf9Q8hsFv68WBMbnnm2wVUYQ PYFA== X-Gm-Message-State: AOAM5307h+MuaAD+/N5Ohpc0acVfY594xDbKSgi+rqY8DHPylRbSfaoT +PPPjliWaCFLZvGDuJDUVpE= X-Google-Smtp-Source: ABdhPJzfhYBIcl85e4Va7TS0DGULKCmDQ9K8I1sBiHu5E3zUGs1312AWJX2rib+PGGuL3NzajqLMkQ== X-Received: by 2002:a2e:8502:0:b0:247:eb12:c34a with SMTP id j2-20020a2e8502000000b00247eb12c34amr5391054lji.405.1646993231179; Fri, 11 Mar 2022 02:07:11 -0800 (PST) Received: from [192.168.0.101] (nat-0-0.nsk.sibset.net. [5.44.169.188]) by smtp.googlemail.com with ESMTPSA id m11-20020a05651202eb00b00443130ce80asm1513215lfq.138.2022.03.11.02.07.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Mar 2022 02:07:10 -0800 (PST) Message-ID: Date: Fri, 11 Mar 2022 17:07:03 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [BUG] org-capture autoload bug? [9.5.2 (9.5.2-gfbff08 @ /home/ignacio/.emacs.d/elpa/org-9.5.2/)] Content-Language: en-US To: Ignacio Casso References: From: Max Nikulin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::232 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::232; envelope-from=manikulin@gmail.com; helo=mail-lj1-x232.google.com X-Spam_score_int: -6 X-Spam_score: -0.7 X-Spam_bar: / X-Spam_report: (-0.7 / 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_FROM=0.001, NICE_REPLY_A=-0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: c.buhtz@posteo.jp, emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1646993289; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=185XovNVE94BUP5NwNWIS1W2sngtFL5K1WS1/o3EU+8=; b=FAd/abSKHr/+D6Bz2ndRWXmBBF6mx/uT6XLBpOboSgzlNodEReyU2O1+K6NAmbiAJxBhLL AMszHvxb8lHvTjtKp3ZYkXXyQUhnd8E/LVkLdkR0DUa35KW3Soeoha5fUBWc4bA5sEx882 SuZDyrJIxj3+1hetUbfwmkHp3Fu/0y+h4veEk7UNUTCK2vsI8Wf/2wjD2fG1VncWywa2Td Q9dvSTqQHUaPl6rrCvdvDyI/F2uWxqid8Vts3WF/NTk+tyQZDEoTafERsKXNdNZcZTMAWW Cg7UXml62lz98f5qSjT/bdQZBFl6CZ5ocq26KwzUiNp1fqWM0SXb/ZeehE64qg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1646993289; a=rsa-sha256; cv=none; b=nYleU2YgACiKvpbmAXdP1POp4XW6NiC/80ga2Z6PDjfEuIvtOhZjwdQiw4KvOj+GISnBQx DM55TchQDp0UCO6HWYnTFl+ZXGnDcRrjtmVt0GIZ6JDwUFi3zQCWPJqvetV+/loxv+i8Xr j2g6tkpxmsA9GjI96Xlwcmj7b8qhk98r1/4AJ8laUZSLDcuPqiQtzzWYFJwJFTvGMLU0+o wDPVyJpVfiS+qA3t7qUB8J+SNO8oD1LypdufnktdKKlsw4L4G+iHufJmCfD3Smp7CEl4NP I5nn99mOsDIcVGW53QInVHvg4RHAkhZASyVtxYYV3j/W1Hx/gfPtTgSoLwvEdw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=nq7QnNN4; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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" X-Migadu-Spam-Score: 4.71 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=nq7QnNN4; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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" X-Migadu-Queue-Id: AC0F139490 X-Spam-Score: 4.71 X-Migadu-Scanner: scn0.migadu.com X-TUID: +7JU5+eqad2T On 11/03/2022 01:00, Ignacio Casso wrote: > Max Nikulin writes: > >> On 10/03/2022 19:53, Ignacio Casso wrote: >>> For example, if we call this: >>> (let ((org-capture-templates >>> '(("d" "default" entry >>> (file+headline org-default-notes-file "Tasks") >>> "* %?")))) >>> (org-capture nil "d"))) >>> It produces the error: >>> (error "No capture template referred to by \"d\" keys") >> >> Ignacio, could you, please, try the following? >> >> (custom-set-variables >> '(org-capture-templates >> '(("d" "default" entry >> (file "/tmp/capture-test.org") >> "* %?")))) >> (org-capture nil "d") >> > > That works, of course, but it's not suitable to my use case. The example > I have provided has been reduced from a larger function I wrote that > relies on org-capture functionality to create new entries in an org > file, using a template specific for that function which is not relevant > for any other Elisp code calling org-capture. Thus the function binds > locally and temporarily org-capture-templates, as I've seen other Elisp > code snippets do. If org-capture is already loaded it works just fine, > and I would expect it to work too when it is not and the function > triggers the autoload, but it doesn't. Ignacio, I think, you can add (require 'org-capture) inside your function just before `let' and it would work almost as lazy loading. I am unsure if org-capture is the best approach in your case. Have you considered yasnippet or Org specific functions to transform and to generate content? Even changing arguments of the `org-capture' function or introducing another function that has explicit argument with a template might be better then marking the template list variable for autoloading. I have no particular opinion concerning adding autoload cookie to `org-capture-templates'. Emacs has enough number of them, but Org has no such custom variables. Arguments why autoload should be avoided: info "(elisp) When to Autoload" https://www.gnu.org/software/emacs/manual/html_node/elisp/When-to-Autoload.html > Don’t autoload a user option just so that a user can set it. The following thread related to Emacs core and linked from https://emacs.stackexchange.com/questions/32859/autoloading-defcustoms-good-practice-or-not : Glenn Morris. Re: master f995fbd: * lisp/server.el (server-name): Add autoload cookie. (Bug#23576) Thu, 19 May 2016 12:44:49 -0400 https://lists.gnu.org/archive/html/emacs-devel/2016-05/msg00415.html Org-specific thread: Achim Gratz. missing autoload cookies for defcustom? Sun, 09 Oct 2011 17:20:16 +0200 https://list.orgmode.org/87lisub39r.fsf@Rainer.invalid/T/#u c.buhtz, I am sorry, despite `org-capture-templates' has the :set attribute, this is not a really convincing example why `custom-set-variables' should be used. The setter was added to ensure compatibility with older template format and this example works with `setq' as well.