cycle-themes.el icon indicating copy to clipboard operation
cycle-themes.el copied to clipboard

"No valid themes in cycle-themes-theme-list"

Open mtekman opened this issue 6 years ago • 3 comments

I traced the culprit down to this line:

https://github.com/toroidal-code/cycle-themes.el/blob/6e125d11fdbc6b78fc9f219eb2609a5e29815898/cycle-themes.el#L102

Change (not (custom-theme-p current-theme)) to (custom-theme-p current-theme) and it works fine.

I don't understand the significance of skipping custom-themes or why it evaluates my leuven, monokai, and nyx as custom, but this line change fixes the problem for me.

mtekman avatar Sep 26 '19 20:09 mtekman

The problem here is that once you do this, it gets stuck at the end of the cycle list (I'm unable to cycle back to the start). I'm not sure this is just an issue separately as I couldn't get it working from the start.

humanfactors avatar Nov 14 '19 06:11 humanfactors

Yeah, I think it only worked for a little while, and then failed after that. I have since moved to writing my own little function which works well for me:

;; -- Rotate-themes --
(setq theme-index 0)
(defun rotate-themes ()
    (interactive)
    (let* ((theme-list '(leuven monokai misterioso nyx nil))
        (next-index (mod (+ theme-index 1) (length theme-list)))
        (current-theme (nth theme-index theme-list))
        (next-theme (nth next-index theme-list)))
        (setq theme-index next-index) ;; set next index
        (disable-theme current-theme) 
        (load-theme next-theme)))
(global-set-key (kbd "C-c c") 'rotate-themes)

mtekman avatar Nov 14 '19 07:11 mtekman

There's probably a reason for the way the code is written, but wouldn't this be fine as a rewrite of cycle-themes-get-next-valid-theme?

(defun cycle-themes-get-next-valid-theme ()
  (nth (mod (1+ (cl-position (first custom-enabled-themes) cycle-themes-theme-list))
            (length cycle-themes-theme-list))
       cycle-themes-theme-list))

Haven't tested it for more than 5 minutes, but it should work...

runejuhl avatar Sep 21 '21 07:09 runejuhl