Tip of the Day

Although i don’t use it that much, i’ve had the following defun in my emacs config since i remember:

(defun totd ()
  (interactive)
  (random t) ;; seed with time-of-day
  (with-output-to-temp-buffer "*Tip of the day*"
    (let* ((commands (loop for s being the symbols
                           when (commandp s) collect s))
           (command (nth (random (length commands)) commands)))
      (princ
       (concat "Your tip for the day is:\\n"
               "========================\\n\\n"
               (describe-function command)
               "\\n\\nInvoke with:\\n\\n"
               (with-temp-buffer
                 (where-is command t)
                 (buffer-string)))))))

(Actually, i've tracked it down to a gnu.emacs.help thread dated 2001).

I'm sure you've guessed what it does. One possible use is to put the invocation (totd) at the end of your .emacs; but, as i tend to have emacs open for days, if not weeks, in a row, i prefer to just bind it to a keyboard shortcut and press it when i'm idling or thinking of a new post. I can also press the shortcut repeatedly until the random chosen command interests me.

Another possibility (if you don't find it annoying), is to set a timer to get a periodic tip of the day, using something along the lines of:

(defvar jao-totd-timer (run-at-time "12:00am" (* 3600 24) 'totd))
(defun jao-cancel-totd
  (interactive)
  (cancel-timer jao-totd-timer))

Not that bad as a pastime :-)

About these ads
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: