myTerminal
myTerminal

Reputation: 1646

How do I get a list of available themes in Emacs 24?

I know that you can do

M-x load-theme RET

and get a list of available themes for auto-complete, of which you could select one.

What I'm looking for, is a way to get this list of themes through Emacs LISP, so that I can cycle through it with a custom key-binding, without having to look at all the available themes and switch to one manually.

Upvotes: 2

Views: 5029

Answers (1)

Chris Johnsen
Chris Johnsen

Reputation: 224691

The function custom-available-themes should give you the list of themes.


I did not know this “off the top of my head”, but Emacs is a fairly discoverable system once one is comfortable digging about in the Emacs Lisp code. Here is how I found this answer:

  1. Started a non-customized instance of Emacs:

    % emacs -q
    

    I wanted to make sure none of my normal customizations (installed packages, et cetera) would interfere with my investigation.

  2. Since the list is available during autocomplete after M-x load-theme RET, I started with that function:

    C-h f load-theme RET
    
  3. Switched to the *Help* buffer and hit Enter on the link to the definition of load-theme in custom.el.

  4. Scanned the definition of load-theme to see if it was arranging a custom completion handler. Its (interactive …) form uses the function completing-read, giving it the output of this form:

    (mapcar 'symbol-name (custom-available-themes))
    
  5. A quick C-h f RET on custom-availabe-themes verified that this is the source of the list of available themes.

Upvotes: 7

Related Questions