Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1038375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:58:04+00:00 2026-05-16T14:58:04+00:00

So, I’ve been having fun with this web site that creates random themes for

  • 0

So, I’ve been having fun with this web site that creates random themes for Emacs. I’ve been saving the resultant .el files and loading them when starting Emacs. Each color theme can be started by evaluating an elisp expression prefixed with inspiration-.

Unfortunately, I don’t know elisp. Can someone help me figure out how I might write a function that looks at what “inspiration-” prefixed functions are available, and randomly evaluate one of them?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:58:04+00:00Added an answer on May 16, 2026 at 2:58 pm

    I like to build up a solution to these problems incrementally. If you just want to try my answer, skip to the defun block of code at the end. I go to the *scratch* buffer, in lisp-interaction-mode to try these code snippets out. You can type C-j after an expression and Emacs will run it and insert the results in the buffer.

    The apropos function searches for symbols matching some pattern, including regular expressions. So we can find all symbols starting with “inspiration-” like so:

    (apropos "^inspiration-\*" t)
    

    But that result has a list for each symbol with some other information. We can discard that and just take the symbol name, which comes first, using the first function:

    (mapcar #'first (apropos "^inspiration-\*" t))
    

    Some of those aren’t functions, so let’s remove any that fail the functionp test:

    (let ((symbols (mapcar #'first (apropos "^inspiration-\*" t))))
      (remove-if-not #'functionp symbols))
    

    Now let’s randomly choose one of those. I’m switching from let to let* because let* allows me to reference earlier definitions in the same initialization, e.g. using symbols when defining functions.

    (let* ((symbols (mapcar #'first (apropos "^inspiration-\*" t)))
           (functions (remove-if-not #'functionp symbols))
           (number (random (length functions))))
      (nth number functions))
    

    Now let’s turn that into a new lisp function (and let’s not have the name start with inspiration-). I’ll mark it as interactive so that you can run it via M-x use-random-inspiration in addition to using it in other elisp code. The other big change is to use funcall to actually run the randomly selected function:

    (defun use-random-inspiration ()
      (interactive)
      (let* ((symbols (mapcar #'first (apropos "^inspiration-\*" t)))
             (functions (remove-if-not #'functionp symbols))
             (number (random (length functions))))
        (funcall (nth number functions))))
    

    So add that to your $HOME/.emacs file and try it out.

    EDIT: Avoid the Apropos buffer popup

    (defun use-random-inspiration ()
      (interactive)
      (let* ((pop-up-windows nil)
             (symbols (mapcar #'first (apropos "^inspiration-\*" t)))
             (functions (remove-if-not #'functionp symbols))
             (number (random (length functions))))
        (funcall (nth number functions)))
      (kill-buffer (get-buffer "*Apropos*")))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm looking for suggestions for debugging... If you view this site in Firefox or
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.