Subject: bug#73609: 29.1; use-package overwrites custom variables in byte-compiled files

From: Al Haji-Ali <[email-masked]>
Date: Sun, 13 Oct 2024 18:31:39 +0100

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