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

From: Al Haji-Ali <[email-masked]>
Date: Fri, 11 Oct 2024 23:25:08 +0100

> Can you try this with the latest emacs-30 branch of the Emacs Git
> repository?  I believe some changes were done to use-package there,
> and they might fix your problem as well.

I just tried it on the main branch (version 31.0.50) and saw the same behaviour. I also checked the part of the code that I think is the reason and it remains the same.

Here's how I am able to reproduce the issue:

--8<---------------cut here---------------start------------->8---
;;; 1. Run emacs -Q
;;; 2. Define the following function

(defun bug-73609 (&optional setup)
  (let ((filename (file-name-concat temporary-file-directory "temp.el")))
    (if setup
        (progn (write-region "(use-package org\n:custom\n(org-log-reschedule 'note))"
                             nil filename)
               (require 'use-package)
               (byte-compile-file filename))
      (load (concat filename "c"))
      (message "START value is %S, use-package is%s loaded"
               org-log-reschedule
               (if (featurep 'use-package)
                   ""
                 " NOT"))
      (setq org-log-reschedule t)
      (message "BEFORE value is %S" org-log-reschedule)
      (define-advice enable-theme (:before (theme) enable-theme@debug)
        (message "Loading theme %S" theme))
      (require 'use-package)
      (message "AFTER value is %S" org-log-reschedule))))

;;; 3. Call
(bug-73609 t)

;;; 4. Restart `emacs -Q` and redefine the function above
;;; 5. Run
(bug-73609)

;; The output is
; START value is note, use-package is NOT loaded
; BEFORE value is t
; Loading theme use-package
; Loading theme user
; AFTER value is note
--8<---------------cut here---------------end--------------->8---

I expect the final line to be

; AFTER value is t

as I do not expect that loading `use-package` would change the value of the variable `org-log-reschedule`. 

-- Al