From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
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 21:52:09 +0700 [thread overview]
Message-ID: <t0nkqq$gt$1@ciao.gmane.io> (raw)
In-Reply-To: <87mthw8b74.fsf@gmail.com>
On 12/03/2022 02:59, Tim Cross wrote:
> Ignacio Casso writes:
>> (let ((org-capture-templates
>> '(("d" "default" entry
>> (file+headline org-default-notes-file "Tasks")
>> "* %?"))))
>> (org-capture nil "d")))
>>
>> I put an autoload cookie myself and it doesn't fix it, so it's probably
>> not that. It's the first time I manage autoload cookies though, so I may
>> have done something wrong. I only tested that the autoload cookie worked
>> by checking that before loading org-capture, org-capture-templates
>> appears in the completion list for C-h v, and I can evaluate it.
>
> 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?
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. The setter receives nil instead of the let-bound value.
I can not say I understand the tricks with bypassing lexical binding in
`defcustom' and some checks in `custom-declare-variable'. Since emacs-26
something has changed:
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=6309131349
> - ;; Use defvar to set the docstring as well as the special-variable-p flag.
> - ;; FIXME: We should reproduce more of `defvar's behavior, such as the warning
> - ;; when the var is currently let-bound.
> - (if (not (default-boundp symbol))
I am unsure that the setter of `defcustom' should get let-bound value in
the case of autoloading since it might lead to fragile behavior.
I still think that explicit templates argument for `org-capture' is
better than relying on autoloading.
Reading the code I noticed `org-capture-templates-contexts' so I wonder
if it might help for the original use case.
next prev parent reply other threads:[~2022-03-14 14:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 12:53 [BUG] org-capture autoload bug? [9.5.2 (9.5.2-gfbff08 @ /home/ignacio/.emacs.d/elpa/org-9.5.2/)] Ignacio Casso
2022-03-10 16:32 ` Max Nikulin
2022-03-10 18:00 ` Ignacio Casso
2022-03-11 10:07 ` Max Nikulin
2022-03-11 10:38 ` Ignacio Casso
2022-03-11 19:59 ` Tim Cross
2022-03-14 10:42 ` Ignacio Casso
2022-03-14 14:52 ` Max Nikulin [this message]
2022-03-14 18:42 ` Tim Cross
2022-03-14 19:43 ` Ignacio Casso
2022-03-14 22:54 ` Tim Cross
2022-03-15 9:02 ` Ignacio Casso
2022-03-15 15:59 ` Ignacio Casso
2022-03-15 12:04 ` Max Nikulin
2022-03-15 12:26 ` Ignacio Casso
-- strict thread matches above, loose matches on Subject: below --
2022-06-11 7:50 Ignacio Casso
2022-06-11 13:32 ` Ihor Radchenko
2022-06-11 17:25 ` Ignacio Casso
2022-06-14 4:02 ` Ihor Radchenko
2022-06-14 7:49 ` Ignacio Casso
2022-06-14 13:58 ` Ihor Radchenko
2022-06-12 12:36 ` Max Nikulin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='t0nkqq$gt$1@ciao.gmane.io' \
--to=manikulin@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).