[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Elisp newbie string to symbol help

From: Thomas Ingram
Subject: Elisp newbie string to symbol help
Date: Thu, 7 Mar 2019 11:36:57 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1

I'm looking for some help with a simple function I am trying to write. I'm a long time Emacs user but I have little experience with Emacs lisp. The issue I am having is with the load-theme lines.

(defun my/theme-toggle ()
  "Toggle between light to dark theme."
  (require 'custom)
  (let* ((current-theme (symbol-name (car custom-enabled-themes)))
     (theme (substring current-theme 0
               (- (length current-theme)
                  ; Probably a better way to do this with regex?
                  (if (string-suffix-p "dark" current-theme)
                  (length "-dark")
                (length "-light"))))))
  (if (string-suffix-p "dark" current-theme)
      (load-theme (concat theme "-light"))
    (load-theme (concat theme "-dark"))))
  ;; (spaceline-emacs-theme)
  (start-process "toggle Gtk theme" nil "~/bin/change-theme" "toggle"))

I get the message "load-theme: Invalid theme name ‘spacemacs-dark’" which doesn't make sense as that is a theme I have installed.  I've tried quoting those lines but then it doesn't evaluate. How can I properly pass this concatenated string to load-theme?

I vaguely understand that it is expecting a symbol not a string and I've tried passing the string to make-symbol but that just changed the error to "Undefined Custom theme spacemacs-dark"

Any help is appreciated.


Thomas Ingram

reply via email to

[Prev in Thread] Current Thread [Next in Thread]