unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Al Haji-Ali <abdo.haji.ali@gmail.com>
To: John Wiegley <johnw@gnu.org>, Eli Zaretskii <eliz@gnu.org>
Cc: 73609@debbugs.gnu.org
Subject: bug#73609: 29.1; use-package overwrites custom variables in byte-compiled files
Date: Sun, 13 Oct 2024 18:31:39 +0100	[thread overview]
Message-ID: <m25xpvaozo.fsf@gmail.com> (raw)
In-Reply-To: <3BD8C402-58DE-429C-8C90-744471B95007@gnu.org>

Hello,

On 12/10/2024, John Wiegley wrote:

> I don’t fully understand. The purpose of of `:custom (X Y)` is exactly to customize X to the value Y using the value setting functions of the customization framework.
>
> Is the user expecting that byte-compilation would cause the value to be set without loading use-package?

No, the point is that this is already the case, and that is causing a discrepancy between having a compiled file vs not. The original message had the context, but if you've seen that already, here's another crack at explaining. Apologies for the repetition.

The function definition above essentially has the sequence:
1- load a file that uses `use-package` with a `:custom` statement to set a variable. 
2- modify said variable to some other value.
3- require `use-package`.
4- Check value of variable.

If the file is not compiled, then `use-package` is loaded in step 1 in order to expand the `use-package` statement. This means that the third step doesn't do anything, and the value of the variable is set to whatever I had in step 2.

However, if the file is compiled, the first step does not load `use-package`, due to lazy loading and since all `use-package` macro calls are expanded in a compiled file. This means that the loading of `use-package` happens in the third step, after I have modified the variable. The in turns loads `use-package-core` and the 'use-package theme is enabled, which resets the value of all custom variables that were set using `:custom` statements. The final result is that value of the variable in step 4 is the one from step 1, rather than step 2.

I hope this clarifies the issue. I included a potential patch in my original message which fixes the issue, but I am not sure if it would have unintended consequences,

-- Al





  reply	other threads:[~2024-10-13 17:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-03  5:47 bug#73609: 29.1; use-package overwrites custom variables in byte-compiled files Al Haji-Ali
2024-10-03 11:02 ` Eli Zaretskii
2024-10-11 22:25   ` Al Haji-Ali
2024-10-12  8:07     ` Eli Zaretskii
2024-10-12 15:22       ` John Wiegley
2024-10-13 17:31         ` Al Haji-Ali [this message]
2024-10-14 15:10           ` John Wiegley

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.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m25xpvaozo.fsf@gmail.com \
    --to=abdo.haji.ali@gmail.com \
    --cc=73609@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=johnw@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.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).