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

ef-themes-select empty until themes are loaded #2

Closed
iris-garcia opened this issue Aug 18, 2022 · 12 comments
Closed

ef-themes-select empty until themes are loaded #2

iris-garcia opened this issue Aug 18, 2022 · 12 comments

Comments

@iris-garcia
Copy link

Hi Prot,

First of all thank you for this amazing package, I love it.

The question I have is the following, if I just load the ef-themes like this:

(add-to-list 'load-path "~/.emacs.d/.local/straight/repos/ef-themes")
(require 'ef-themes)

When I call ef-themes-select there are no candidates, is this the intention?

If so, what is the best way to populate that list without having to load each theme during initialization?

Thank you.

@protesilaos
Copy link
Owner

Hello @iris-garcia!

This is not intended behaviour. I will see to it now and report back to you.

@theherk
Copy link

theherk commented Aug 18, 2022

I notice they are all present if I use load-theme, then afterwards, they are available in ef-themes-select.

@iris-garcia
Copy link
Author

@theherk
First call to load-theme:
image
Then a call to ef-themes-select
image

I think the themes are not added until they are actually loaded.

protesilaos added a commit that referenced this issue Aug 18, 2022
Thanks to Iris Garcia for informing me that the were not registered as
"known" before.  This was done in issue 2 on the GitHub mirror:
<#2>.

The code I am adding here needs to be reviewed to simplify all the
internal functions.  Thought it has been a very long day (again), so I
will do that tomorrow.
@protesilaos
Copy link
Owner

@iris-garcia I just pushed the change. Yes, @theherk is correct in that load-theme would always recognise them, but the ef-themes-select didn't do that.

I have changed it now. I believe it works properly. Please give it a try.

I still plan to refine some of the internal functions in the interest of simplicity/correctness. Though that will have to wait until tomorrow morning.

@iris-garcia
Copy link
Author

Thank you for the quick response @protesilaos, I think the logic is good, but maybe you placed the enabling of themes function in the wrong place, I still don't see the candidates (It can also be an issue in my environment).

protesilaos added a commit that referenced this issue Aug 18, 2022
Thanks to Iris Garcia for pointing it out in issue 2 over at the GitHub
mirror: <#2>.
@protesilaos
Copy link
Owner

Mea culpa! I only added it to one command, but not the other. I pushed a change now.

@iris-garcia
Copy link
Author

I have a suggestion, can I open a PR?

@protesilaos
Copy link
Owner

Yes, sure. Though, if possible, keep the change below 15 lines. Otherwise you need to assign copyright to the Free Software Foundation.

@iris-garcia
Copy link
Author

iris-garcia commented Aug 18, 2022

I can confirm that this issue is fixed, happy to close it, however I see a new one with ef-themes-load-random which may be related to this one.

@protesilaos
Copy link
Owner

I just pushed commit 50be213 which should properly fix this issue. Please let me know if this is the case.

Here is what I am loading at startup and both ef-themes-load-random and ef-themes-select do the right thing:

(require 'ef-themes)

;; The `ef-themes' provide lots of themes.  I want to pick one at
;; random when I start Emacs: the `ef-themes-load-random' does just
;; that (it can be called interactively as well).  I just check with
;; GNOME to determine if the choice should be about a light or a dark
;; theme.
(if (string-match-p
     "dark"
     (shell-command-to-string "gsettings get org.gnome.desktop.interface color-scheme"))
    (ef-themes-load-random 'dark)
  (ef-themes-load-random 'light))

(define-key global-map (kbd "<f5>") #'ef-themes-select)

Simplified:

(require 'ef-themes)

(ef-themes-load-random 'dark) ;; OR (ef-themes-load-random 'light)

(define-key global-map (kbd "<f5>") #'ef-themes-select)

@iris-garcia
Copy link
Author

It works perfect now! Thank you @protesilaos, also for the suggestion on reading the current color-scheme of the DE to load dark or light themes.

@protesilaos
Copy link
Owner

Great!

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

3 participants