When I was learning
LISP, I used slime in emacs. One of the neat little features I liked was the motivational message it showed on startup. It wasn't really that important, but it was one of those little features that when you notice, brightens your day a little. I use emacs so much, I decided why not add a feature for emacs. (This was a few months ago, when I wanted to learn dome elisp for the first time.)
So first, I created a file
~/Dropbox/wisdom.txt and on each line, I put a quote or a motivational message. Put whatever you want to see on startup in it.
Next we need to read each of the lines into a list, so I use a simple python style
1: (defun read-lines (file) 2: "Return a list of lines in FILE." 3: (with-temp-buffer 4: (insert-file-contents file) 5: (split-string 6: (buffer-string) "\n" t))) 7:
Then I load
wisdom.txt into a variable named wisdom. I remove any line starting with =";;"= so that I can comment out lines if I wish to.
1: (setq wisdom (remove-if (lambda (s) (string= (substring s 0 2) ";;")) 2: (read-lines "~/Dropbox/wisdom.txt"))) 3:
Next, I choose a random element from the list
wisdom and show it in the minibuffer.
1: (defun motivational-message (&rest rest) 2: (interactive) 3: (message (elt wisdom (random (length wisdom))))) 4:
Then, I just override it so that it shows at startup. This intentionally goes strait to
*scratch*, I use emacs so much that I prefer to go straight scratch.
1: (defun display-startup-echo-area-message () 2: "If it wasn't for this you'd be GNU/Spammed by now" 3: (motivational-message)) 4:
What do you think? Not too painful.Posted on 31 October 2010 in emacs customizations