From: Ignacio Casso <ignaciocasso@hotmail.com>
To: Max Nikulin <manikulin@gmail.com>
Cc: 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: Tue, 15 Mar 2022 13:26:43 +0100 [thread overview]
Message-ID: <PAXPR06MB77607213232118794824B1D5C6109@PAXPR06MB7760.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <t0pvce$11m6$1@ciao.gmane.io>
>>> 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).
Yes, I was wrong about that. Instead of testing it without :set
argument, I had tested it with a :set argument that was just
set-default plus some messages for debugging. I assumed that it was
equivalent since the documentation says that set-default is the default
value for :set. However it turns out that the actual default value that
is used when no argument is passed is set-default-toplevel-value. With
the later it works (with dynamic binding or autoload variable), but with
the former it doesn't. I think I tested once without :set argument, but
I must have used lexical binding so it didn't work anyway, so I
concluded that it didn't work either in that case.
next prev parent reply other threads:[~2022-03-15 12:42 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
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 [this message]
-- 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=PAXPR06MB77607213232118794824B1D5C6109@PAXPR06MB7760.eurprd06.prod.outlook.com \
--to=ignaciocasso@hotmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=manikulin@gmail.com \
/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).