Today might not be the best day in terms of productivity. However, tonight I was able to do my first lisp function for my emacs config. Nothing fancy, just allow me to switch between two themes: one dark and one light. Off course, I bind it. There was already a package to do something similar (https://libraries.io/emacs/cycle-themes), but I wanted to cycle between tsdh-dark and original theme. So this is mine:

(setq cur-theme nil)
(defun cycle-theme ()
  "Cycle between dark theme and light theme"
  (interactive)
  (if cur-theme
      (progn
    (disable-theme 'tsdh-dark)
    (setq cur-theme nil)
    )
    (progn
      (load-theme 'tsdh-dark t)
      (setq cur-theme t)
      )
    )
  )
;; Bind this to C-x t
(global-set-key (kbd "C-x t") 'cycle-theme)

So good !


Comments

comments powered by Disqus