I like to step up the solution to these problems gradually. If you just want to try my answer, skip to the code block defunat the end. I go to the buffer *scratch*in lisp-interaction-modeto try these snippets of code. You can enter C-jafter the expression, and Emacs will run it and enter the results into the buffer.
The aproposfunction searches for characters matching a certain pattern, including regular expressions. Thus, we can find all the characters starting with "inspiration" as follows:
(apropos "^inspiration-\*" t)
But this result has a list for each character with some other information. We can discard this and simply take the symbol name that will be first using the function first:
(mapcar #'first (apropos "^inspiration-\*" t))
, , functionp:
(let ((symbols (mapcar #'first (apropos "^inspiration-\*" t))))
(remove-if-not #'functionp symbols))
. let let*, let* , . symbols functions.
(let* ((symbols (mapcar
(functions (remove-if-not
(number (random (length functions))))
(nth number functions))
lisp ( inspiration-). interactive, M-x use-random-inspiration elisp. funcall :
(defun use-random-inspiration ()
(interactive)
(let* ((symbols (mapcar
(functions (remove-if-not
(number (random (length functions))))
(funcall (nth number functions))))
$HOME/.emacs .
: Apropos
(defun use-random-inspiration ()
(interactive)
(let* ((pop-up-windows nil)
(symbols (mapcar
(functions (remove-if-not
(number (random (length functions))))
(funcall (nth number functions)))
(kill-buffer (get-buffer "*Apropos*")))