all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.