Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Snippet to display a fortune in the mini-buffer
(require 'fortune)
;; Be sure to set the following to your specific fortune files
(setq fortune-dir "~/.fortunes"
fortune-file "~/.fortunes/fortunes")
(defun fortune-message (&optional file)
"Display a fortune cookie to the mini-buffer.
If called with a prefix, it has the same behavior as `fortune'.
Optional FILE is a fortune file from which a cookie will be selected."
(interactive (list (if current-prefix-arg
(message (fortune-generate)))
(defun fortune-generate (&optional file)
"Generate a new fortune and return it as a string.
Without an optional FILE argument it will use the value of `fortune-file'."
(progn (fortune-in-buffer t file)
(with-current-buffer fortune-buffer-name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment