Created
July 9, 2013 03:55
-
-
Save jbdatko/5954588 to your computer and use it in GitHub Desktop.
Snippet to display a fortune in the mini-buffer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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