unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Elisp newbie string to symbol help
@ 2019-03-07 16:36 Thomas Ingram
  2019-03-07 17:08 ` Michael Heerdegen
  2019-03-08  5:40 ` Stefan Monnier
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Ingram @ 2019-03-07 16:36 UTC (permalink / raw)
  To: help-gnu-emacs

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."
   (interactive)
   (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.

Thanks,

Thomas Ingram




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-03-08  5:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-07 16:36 Elisp newbie string to symbol help Thomas Ingram
2019-03-07 17:08 ` Michael Heerdegen
2019-03-07 17:22   ` Thomas Ingram
2019-03-08  5:40 ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).