|
From: | Max Nikulin |
Subject: | Re: [BUG] org-capture autoload bug? [9.5.2 (9.5.2-gfbff08 @ /home/ignacio/.emacs.d/elpa/org-9.5.2/)] |
Date: | Tue, 15 Mar 2022 19:04:29 +0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 |
On 15/03/2022 02:43, Ignacio Casso wrote:
I've also investigated the issue a little bit further and wrote and email with my conclusions about the same time Max wrote his. I comment inline about a few of your thoughts:For `defcustom' autoload generates no more than (defvar org-capture-templates nil "...") It seems, behavior depends on whether `org-capture-templates' has the :set attribute.Not really, all defcustoms have a :set attribute, be it passed explicitly as a parameter or the default value, set-default. This issue happens with all autoload functions that use a custom variable: if they are called inside a let form binding that variable and the feature was not loaded yet, the let-binding will have no effect.
To avoid misunderstanding. I was testing with Emacs-26.3 (Ubuntu-20.04 focal LTS system package) and did not explicitly set lexical binding cookie in an .el file. However defcustom autoloading was assumed.
;; simulate effect of ;;;###autoload (defvar org-capture-templates nil) (defun print-org-capture-templates () (message "print-org-capture-templates") (pp org-capture-templates) (message "-----")) (let ((org-capture-templates '(("d" "default" entry (file "/tmp/capture-test.org") "* %?")))) (print-org-capture-templates) (require 'org-capture) (print-org-capture-templates))Second call of print-org-capture templates prints nil with original definition of `org-capture-templates' but it prints locally let-bound value if I comment out the :set attribute.
I am not disputing any observation from your thorough study mid:PAXPR06MB7760A3031924BA897FD082E4C60F9@PAXPR06MB7760.eurprd06.prod.outlook.com(it seems message delivery took several hours, so I noticed it after I sent my message).
Maybe it is reasonable to expect that let-binding should work with autoloading. I believe that loading of a file should be performed inside top-level scope, so it should ignore let-bound values. It is fragile when let-binding may affect global value of defcustom. However following call of just loaded function should be performed with regular stack of dynamic scopes. I am unsure if such behavior is feasible with elisp implementation.
[Prev in Thread] | Current Thread | [Next in Thread] |