Skip to content

Instantly share code, notes, and snippets.

@jbdatko
Created July 9, 2013 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbdatko/5954588 to your computer and use it in GitHub Desktop.
Save jbdatko/5954588 to your computer and use it in GitHub Desktop.
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
(fortune-ask-file)
fortune-file)))
(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'."
(save-excursion
(progn (fortune-in-buffer t file)
(with-current-buffer fortune-buffer-name
(buffer-string)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment