Last active
December 11, 2015 16:10
-
-
Save edcrypt/077dcd917a522dff969e to your computer and use it in GitHub Desktop.
Display a fortune, with commented lines, on the scratch 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
;; Fortune on scratch buffer | |
;; Add this to your ~/.emacs.d/init.el | |
(require 'fortune) | |
(setq fortune-dir "/usr/local/Cellar/fortune/9708/share/games/fortunes/") | |
(setq fortune-file "/usr/local/Cellar/fortune/9708/share/games/fortunes/") | |
(setq fortune-program "/usr/local/bin/fortune") | |
;; next two funcs from http://datko.net/2013/07/08/slight-enhancement-to-fortune-el/ | |
(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))))) | |
(defun fortune-lisp-comments (&optional file) | |
(concat (mapconcat (function (lambda (x) (concat ";; " x))) | |
(delete "" (split-string (fortune-generate file) "\n")) | |
"\n") | |
"\n" | |
)) | |
(setq initial-scratch-message (fortune-lisp-comments)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment