emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ignacio Casso <ignaciocasso@hotmail.com>
To: Tim Cross <theophilusx@gmail.com>
Cc: Max Nikulin <manikulin@gmail.com>, 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 10:02:51 +0100	[thread overview]
Message-ID: <PAXPR06MB7760A19D1724C4B0D5BD70A1C6109@PAXPR06MB7760.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <87pmmom9br.fsf@gmail.com>

>>> My recommendation would be to come up
>>> with a non-org specific example which reproduces the behaviour and then
>>> ask on emacs-devel, using the example to demonstrate the issue.
>>
>> I agree. I'm on it.

After trying to build a simple example I have realized a part of my
analysis was wrong.

> Not really, all defcustoms have a :set attribute, be it passed
> explicitly as a parameter or the default value, set-default.

I was wrong about this: set-default is not the default setter for
defcustoms without one, it's actually set-default-toplevel-value
(although everywhere in the documentation and comments it says it is
set-default). set-default-toplevel-value works well with let bindings,
but set-default does not.

> 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.

So this is only true for defcustoms without explicit :set argument if
the let form is evaluated with lexical binding enabled.

The following table shows all the cases and what works and doesn't:

- Lexical Binding and no autoload for the variable -> The let binding is
  ignored in Emacs 27 (or more accurately, it's considered lexical), and
  an error occurs in Emacs 29

- Dynamic binding or autoload for the variable:

  - No setter (or the actual default, set-default-toplevel-value) ->
    Everything works as expected

  - Setter with set or set-default (the suggested value in the
    documentation) -> Everything breaks as discussed in previous emails

So if we remove the setter for org-capture-templates, which is not
actually needed as discussed, or use set-default-toplevel-value instead
of set, it would fix the problem when dynamic binding is used, and in
Emacs 29 it would at least produce an error with lexical binding. If an
autoload cookie was also added, it would fix the problem also when
lexical binding is used, but I understand that may come with its own
disadvantages. I'll leave that decision to you, for me this is no longer
a problem since I just require org-capture now before doing this.

I'll write now the email to emacs-devel with all these issues and
mention in this thread the corresponding debbugs thread in case anyone
wants to follow it.

Regards,

Ignacio


  reply	other threads:[~2022-03-15 15:21 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 [this message]
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=PAXPR06MB7760A19D1724C4B0D5BD70A1C6109@PAXPR06MB7760.eurprd06.prod.outlook.com \
    --to=ignaciocasso@hotmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    --cc=theophilusx@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).