Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol’s function definition is void: auto-dark--check-and-set-dark-mode #70

Closed
mattiasb opened this issue Sep 27, 2024 · 9 comments
Closed

Comments

@mattiasb
Copy link
Contributor

mattiasb commented Sep 27, 2024

With the latest version of auto-dark (0.13.1) I get this message when starting Emacs:

Symbol’s function definition is void: auto-dark--check-and-set-dark-mode

I believe the issue is that the setter for auto-dark-themes will run when
custom-set-variables is run which in turn is very likely to happen before
auto-dark is loaded.

I suspect that if you're bypassing customize and manually write setq / setopt
forms in your init.el you might not experience this.

To reproduce

Add these files:

~/emacs-ad-test/early-init.el:

;; This is just me trying to force Emacs to not add stuff to
;; your `~/.config/emacs/` directory which it otherwise might do.
(defvar user-emacs-cache-directory
  (file-name-concat user-emacs-directory ".cache/"))

(startup-redirect-eln-cache (file-name-concat user-emacs-cache-directory
					      "eln-cache"))
(setopt package-user-dir (file-name-concat user-emacs-cache-directory "elpa"))

~/emacs-ad-test/init.el:

(custom-set-variables
 '(auto-dark-themes '((wombat) (leuven)))
 '(package-archive-priorities
   '(("gnu" . 80)
     ("nongnu" . 40)
     ("melpa-stable" . 20)))
 '(package-archives
   '(("gnu" . "http://elpa.gnu.org/packages/")
     ("nongnu" . "https://elpa.nongnu.org/nongnu/")
     ("melpa-stable" . "http://stable.melpa.org/packages/")))
 '(package-gnupghome-dir (file-name-concat user-emacs-cache-directory "elpa/gnupg/"))
 '(package-selected-packages '(auto-dark-mode))
 '(package-user-dir (file-name-concat user-emacs-cache-directory "elpa")))

(use-package auto-dark
  :ensure t
  :hook (after-init . auto-dark-mode))

Then:

$ emacs --init-directory=~/emacs-ad-test
@mattiasb
Copy link
Contributor Author

mattiasb commented Sep 27, 2024

This is on Emacs 29.4 on Fedora Workstation 40 FWIW.

@threddast
Copy link

I'm having the same issue on Doom Emacs on NixOS unstable, Emacs 29.4

LionyxML added a commit that referenced this issue Sep 27, 2024
Until we run more tests and find out why #69 and #70 causes.
@LionyxML
Copy link
Owner

Thanks, same problem as #69.

And now it happens on Linux also.

I might've tested some cached version or something 🥹

I just reverted it to the last commit on master (while bumping the version to v0.13.2). It should be up on melpa in its next run.

If you @threddast @mattiasb could please test it (the 0.13.2 version), while I try to figure out how we can implement @sellout improvements from #67 in a generic non-breaking way, it would be great 😄

@threddast
Copy link

Fixed for me now, thank you :)

@sellout
Copy link
Contributor

sellout commented Sep 27, 2024

Sorry I keep breaking your project …

I think the solution here is to add :initialize 'custom-initialize-default, so that loading the file doesn’t cause the :set function to be called.

I tested #67 on a Mac, but only an Emacs that already had Auto-Dark loaded 🤦🏼

I’m wondering if you’d also be open to adding a test suite? I tend to use Eldev & buttercup for testing. And my personal project template uses a Nix flake that also adds CI to run the tests across multiple platforms. Here’s a PR against a different project that shows what my template adds (which is likely more than you’d want, but includes the Eldev & Nix flake) mishoo/elisp-reader.el#6.

@LionyxML
Copy link
Owner

Nahhh, breaking is normal @sellout , no hard feelings 😄

Tests already came to mind before, but as the 'core' of the package is basically tweaking the OS for information (and man, OSs changes stuff, lol), I did not went that road.

That said, for stuff like what just happened (breaking in a clean install), tests would've been a nice addition.

I'm kind of short of time for this weekend so I'll probably have the time to play with auto-dark again next week (regarding patching the last commit with :initialize and testing it).

@sellout
Copy link
Contributor

sellout commented Sep 27, 2024

I’ve got a fixed version of #67 now, and tests to show that it works. Not quite ready for a PR, but I’ll try to get it up this weekend.

@mattiasb
Copy link
Contributor Author

Fixed for me now, thank you :)

Yep. I'm on 0.13.2 now and the issue I posted is gone. :)

@LionyxML
Copy link
Owner

LionyxML commented Oct 9, 2024

Thanks for your feedback @mattiasb.

I am closing this, since much related discussionto #67 is also happening on #64.

@LionyxML LionyxML closed this as completed Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants