From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id oDEKLj5jL2L/CAEAgWs5BA (envelope-from ) for ; Mon, 14 Mar 2022 16:46:06 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id wApuKz5jL2Jb4gAA9RJhRA (envelope-from ) for ; Mon, 14 Mar 2022 16:46:06 +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 255DF2A0D4 for ; Mon, 14 Mar 2022 16:46:06 +0100 (CET) Received: from localhost ([::1]:38760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTmtY-00053K-Nw for larch@yhetil.org; Mon, 14 Mar 2022 11:46:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTmt2-00050z-G0 for emacs-orgmode@gnu.org; Mon, 14 Mar 2022 11:45:32 -0400 Received: from mail-oln040092071088.outbound.protection.outlook.com ([40.92.71.88]:42821 helo=EUR03-DB5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTmsz-0007Pc-DT for emacs-orgmode@gnu.org; Mon, 14 Mar 2022 11:45:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mhqjuss/Tt9dSz760PUkymvNPd+awBX3skb5ea5ruEbf/Yq6hTadepcktszdgUJA2ArvpIOgReqLACWGD4j7CpGner9SIyx0h6yIMUzpCompp8CZ2ZaH5F90a63gyo0zfUd55m3WrniftTF+lo+l1ZzNJaobbtt73taIIDr9bFPNoWLhIK0x1Q17/4AXNCWn0mdrkJAMHzNziQfA4bxenb+4ioAmV8wixC7Rkk/T438Cj7+4FsArgFm1NqE1AGKQOmbCVyZPv+sMIPeLifla5U1qGZ5jdnFe0/ebX+/7exopXVKJp6wyHI7pBbXQ8npyxqFy2/zNHg8TwDpQ7nNkvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RQvltzvd1IMhvVk+eMnhOXocb1Gufo1hHjJ7MTEU8M4=; b=KsT34Ubk2NK0In7hXvFhQar7yP054lJnUICtvGCmC/EU/WcPHQtnmN7tp/9rXYjyyCkNlLB8wjhOOGfEYfKAaddjZzUEEMytKokwk70sF/GuNij9MZ1ECjzIAw7YyZGm5+himXTrBi3NMqL2u5QO5rJAPq3BSzhzBzKjpq5uKkHwvTTWxLGat5JnoH1lM2NuiLxQl/ce2q/85nY99pLAO7B/2y1A7RbBqhmMU9yRa7/dGF59vd+F1bgLnwDcwdc3TQE4rHq7NZBxsACdgCcVFAg8rVhFGC5tprckBcm0qnjv7zmhqloXiVrvKjE2SuH/b+6dJMP5aScSNXyjHmd31g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RQvltzvd1IMhvVk+eMnhOXocb1Gufo1hHjJ7MTEU8M4=; b=nJgfioNGmtZZOaFDW8+7W6mOnCOOo5iwj5bi5/YijEQFd5lI0m4HJITCPk2LKNUQfkpxhp5J/ws5ZND70CcIWsE0a47Ci5I/3eWGCntwqzuyqPMOeCR7Q7cN6e1Re8VhsA4QzYSVuG40lnFxAhdM3FfUZOaj/WOD2pCgOF2wPnvNxpk476c58tNG/J0zN0zd0k2uxUFVpifB+3sGoKsXGT9OJFILe98LcSgBBkBV1sjRowuOOHxz7jlnIlVW4dd1iZ5BjikqUrt53ehmt2qrJtC9869YO/zIqb6gJoYrlr/W13uHK5dqCX1ASfDovNovxImxGSH/fhZVgzB0V4r0GQ== Received: from PAXPR06MB7760.eurprd06.prod.outlook.com (2603:10a6:102:155::8) by DB7PR06MB5672.eurprd06.prod.outlook.com (2603:10a6:10:2c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.26; Mon, 14 Mar 2022 15:24:43 +0000 Received: from PAXPR06MB7760.eurprd06.prod.outlook.com ([fe80::e05a:8d81:8648:b10f]) by PAXPR06MB7760.eurprd06.prod.outlook.com ([fe80::e05a:8d81:8648:b10f%9]) with mapi id 15.20.5061.028; Mon, 14 Mar 2022 15:24:42 +0000 References: <87mthw8b74.fsf@gmail.com> User-agent: mu4e 1.6.10; emacs 27.2 From: Ignacio Casso To: Tim Cross Subject: Re: [BUG] org-capture autoload bug? [9.5.2 (9.5.2-gfbff08 @ /home/ignacio/.emacs.d/elpa/org-9.5.2/)] Date: Mon, 14 Mar 2022 11:42:48 +0100 In-reply-to: <87mthw8b74.fsf@gmail.com> Message-ID: Content-Type: text/plain X-TMN: [psfa/pGuHQrUljIVOzFWVFh3IREm+qYT] X-ClientProxiedBy: MR1P264CA0129.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:51::17) To PAXPR06MB7760.eurprd06.prod.outlook.com (2603:10a6:102:155::8) X-Microsoft-Original-Message-ID: <87ee34blqk.fsf@hotmail.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8580a372-8fa2-45af-3cf4-08da05cec319 X-MS-TrafficTypeDiagnostic: DB7PR06MB5672:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zc3uV/JtBlhXQ9Davxq4y+1To8IFFCdt3G3SCy7AeoH3pDHMgGchVKZPvxEaPdBIZet9Lxp1kkr3bjqKj0HjgzjSqiIZXKrCdPRcwzdABdS9t0OgjqulFQbghkhWv1xd1WZSLRce1U7g2iGcx+Tz/jLBYFdUwzU9Cp7oIqG3VNdDP0YBWYaklkND+pPhGdznMQ9SV7Cz5TUZJnLoowA8rJ3RpvFoPsHnAVBT7I2kJUnD9wyC3wKh7WNHGHlQnCV0yde3wOdIaBggkQLkpb20gkU28hyQM0Cq2lYG1m4Lp+zlp2yQPS1QoaygcXB/4+ksBEpsc5RlBm2Rclr7X3B4zbqxZ/qPLBNJ26ZIrS0f8lcrBSnZ8amHL4OBTV64W/X31kfJSPDMDRcqPzP/XqHIRWPP+ORD2qixr0tJMjzhnRwNBnmHNwuM5Zv7oseTgnnAMUDZxVfTwvcwbfPys0wWg//2kokVhKbRLJkY7LlZoHHe4UO4dJlTlSiDVzYhYIydZdglSxSZqS8qUKflVk7DMUgks5odq+5iMb5DRdrG6ikis8tx7YPNMiCK31EmY8d+rBo0eiJXozjWbWEUnFMsXQ== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lzXbfkm1e1Wy6r3PcXPNOWaTcBH+DFVoRmfmwI2S069Mrj86KGDg3EbLdqjj?= =?us-ascii?Q?2xZT++WqtPMdbgARDoD3GydwAIUEWggV9TiTfS3PUHwJ9pMVcnEPgeYi2wHc?= =?us-ascii?Q?osoShKwgk/MK/YeMs4S8eWzjBEIs4q+8laq9h6CniNGyp/hQY/UNL8wmmMaz?= =?us-ascii?Q?gcsDplby4MB5+mUJqWpv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sbKmFLWnz?= =?us-ascii?Q?93qgE0+RMvba3IHs5hX/31e7J1nOew9tuahd3aZRZj7+7NRG/HU10rzc9gdi?= =?us-ascii?Q?7ijWhw/0YWwYjumqfny4KnqS4BAqFDpJlkdLKMBeTufRpENpXl0I5wc=3D?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-6e454.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 8580a372-8fa2-45af-3cf4-08da05cec319 X-MS-Exchange-CrossTenant-AuthSource: PAXPR06MB7760.eurprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2022 15:24:42.7968 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR06MB5672 Received-SPF: pass client-ip=40.92.71.88; envelope-from=ignaciocasso@hotmail.com; helo=EUR03-DB5-obe.outbound.protection.outlook.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_03_06=1.592, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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, Max Nikulin , emacs-orgmode@gnu.org 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=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1647272766; 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=RQvltzvd1IMhvVk+eMnhOXocb1Gufo1hHjJ7MTEU8M4=; b=qiy3Wf8teU2Zdntrd1C+85kSFa1RPFGabxZZwxZZBTxf5tsylp6JybFbCgyz6UX7MvRfmG QZqo0k/wngiBoc0sywjr5xgI41wLf/l1fJmYduRYgndOdpEIVggbcRluMcaWkNURNuhm5d rkZzbVdI4cYSSVpghyUQmv8xVH/A/gLaIJjHwzwAzaWkoHMKfjzT3K5C9PPdh9o86tjokE 1zpU6JIgEkHwjXFVU6EoBTp5yYddkZEj5ngPhd9bPelrkgjoZlxBrQnvPZVP4PJaDsksZJ 1MNQskEPSI+1f2Db2Z8teicTNyqh8Wm20KdEdX1ry6h6ROwxCttYM9v5MAhD8g== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1647272766; a=rsa-sha256; cv=pass; b=F6oewEh9GWNzAF++pODAksWJwxF3uukh1roT/mxGB4nvqCdG3ag4vc0zrTLA7+6ryc99w8 zYbFM1eG7I/bbLe0eRt/sOJYmdNMtl4ob5CPOXQfkVPzTzILB2GZsjyU1/+ycIvDvaCGlj AR9LsZfWxCyGAlVReaa6X2NYE2SbflpLsiiglhzr3AfGkUV3/WjIVxSlXM/sudw4eY17aX wse6UI3TXPeabYSeg75jNeOdukg1/Sq16Z9+tVAcY1pN1bWlwnPJjmFNyvrrAYgCHb3aIE imtRHTCL+xL+hOYplvMNOYQP5DvcLwWM7nJXpqVMHVS1rY5kQKy1TTrtjg8n/A== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=pass header.d=hotmail.com header.s=selector1 header.b=nJgfioNG; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=hotmail.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: -10.47 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=hotmail.com header.s=selector1 header.b=nJgfioNG; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=none) header.from=hotmail.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: 255DF2A0D4 X-Spam-Score: -10.47 X-Migadu-Scanner: scn0.migadu.com X-TUID: yxV0KD3zEb1T > While I don't know if this is a bug, it certainly doesn't seem to be > doing the right thing from an 'intuitive' point of view. I would expect > when a variable is bound to a value inside a let and a function is then > called which uses that variable, the initial let bound value should be > used and the result be the same regardless of whether org-capture has or > has not been loaded. It means there is a hidden side-effect here, which > isn't good and probably needs more analysis. If you had set the value > using setq rather than as a let form, it wouldn't be overridden when > org-capture is loaded, so why does it when it is a let binding? > I've investigated this a little bit further and this is not specific to org-capture. For example if you evaluate (let ((org-agenda-files '("/tmp/foo.org"))) (org-agenda-list)) before org-agenda is laoded, the let-binding of org-agenda-files is ignored too. I think the reason is the following: 1) Loading the file defining those autoload functions runs defcustom for the variable we are using. 2) defcustom calls the function F passed as argument with the :set keyword (set-default by default) to initialize the variable. That function receives as argument the variable and a value. 2.1) If the variable was already initialized (e.g., with setq) with a value V, the value passed to F is V. It it was not, the value passed to F is the value passed as STANDARD argument to defcustom. So far, so good. 2.2) If the variable is let-bound with lexical-binding non-nil, there is an error in Emacs 29, since at the time the variable is let-bound Emacs does not know it is special and thus it uses lexical binding, but when defcustom runs it finds out that it is special and therefore it should have used dynamic binding. In Emacs 27 this check is not done, and the let-binding is considered lexical, so it has no effect for uses of the variable while the let body is being executed, unless they appear textually within that body. In particular, the value passed to F is again the STANDARD argument of defcustom. 2.2.1) An exception to this is when the variable is autoloaded, since Emacs can know that it is special by the time is evaluates let. 2.2.2) But in general this means that the programmer should know whether an autoload function is going to be loaded at that execution point if he is going to do this. 2.3) If the variable is let-bound with lexical-binding nil, things then break completely. First, the value passed to F is again the STANDARD argument of defcustom. This makes sense since F would initialize the variable globally and the let binding was supposed to be local. But it means that again the let binding gets shadowed. But it's worse than that. The initialization of the variable does not work and only has the same scope as the let-binding, so after the let body is finished, the variable is void. Furthermore, since the feature in question is already provided, there is no easy way to leave that state and initialize the variable again. This makes me conclude that let-bindings of variables used by autoloaded functions should be avoided unless we know for sure that the function will be loaded at that point in execution. > Might be worth asking a general question on emacs-devel? Stephan or Eli > can probably provide some clarification here (maybe this is somehow > related to the changes associated with the lexical binding stuff?) Yes, I will email them explaining this, since I think the point 2.3 is a bug. Maybe there is no better way to do this, but I think at least there should be a warning if a misuse of let + autoload can leave Emacs in what I think is a broken state.