rougier / nano-emacs

GNU Emacs / N Λ N O - Emacs made simple
GNU General Public License v3.0
2.52k stars 194 forks source link

On the fly theme switcing and refreshing #81

Closed tefkah closed 1 year ago

tefkah commented 3 years ago

Fixes #26.

Adds two new functions: (nano-refresh-theme) and (nano-toggle-theme), and one new variable nano-theme-var.

Calling nano-toggle-theme will switch the theme from light to dark, and vice versa. This does require you to also require both themes separately, otherwise the function fails. I put this in the docstring, but is probably a better way to do this, maybe adding the themes back into nano-theme?

rougier commented 3 years ago

Thanks. What is the use-case of refresh-theme exactly?

tefkah commented 3 years ago

Refresh theme can be useful when changing the font(-size) for instance, avoids having to manually call (nano-faces) and (nano-theme). Not strictly necessary of course, but when testing things out I found myself calling these quite often, and I thought other people might find it useful.

rougier commented 3 years ago

I think the nano-theme might make theme switch much easier now and the plan os to remove the theme files from this repository. I still need to add a settings to enforce fonts or not.

Kabouik commented 1 year ago

Is there anything blocking this PR? I have reproduced the changes here on nano-emacs master and that seems to work fine.

I would really love to be able to load these two themes just like other themes with load-theme because then they could be cycled with other themes from ELPA/MELPA in a single command. For instance, this is what I was using before trying nano-emacs for the first time today:

;; Cycle between some themes
(defun toggle-theme ()
  (interactive)
  (cond ((eq (car custom-enabled-themes) 'doom-palenight)
      (mapc #'disable-theme custom-enabled-themes)
          (load-theme 'doom-nord-light))
        ((eq (car custom-enabled-themes) 'doom-nord-light)
      (mapc #'disable-theme custom-enabled-themes)
      (load-theme 'doom-Iosvkem))
        ((eq (car custom-enabled-themes) 'doom-Iosvkem)
      (mapc #'disable-theme custom-enabled-themes)
      (load-theme 'doom-palenight))))
(global-set-key (kbd "C-c t") 'toggle-theme)

Unfortunately I wouldn't know how to make nano-theme-dark and nano-theme-light compatible with that workflow.

rougier commented 1 year ago

Sorry for late reply and many thanks for the PR.