without Org-mode

When I decided to share my limited wisdom, I realized I’d need something better than a 4-year-old, thrown together, init file. The words “init dot org” had briefly crossed my ears through one of Sacha Chua’s previous videos; however, due to 63m of water above my head, internet searches weren’t quite operating at top efficiency.

Without a second thought, and armed with nothing but its name (, I took to writing –I thought at the moment– the simplest way of implementing such a feature.

;;; init.el
(defvar endless/ 3
  "What depth of headers to message at startup.")

  (insert-file "~/.emacs.d/")
  (goto-char (point-min))
  (search-forward "\n* init.el")
  (while (not (eobp))
    (forward-line 1)
     ((looking-at "^\\* ") (goto-char (point-max)))
     ((looking-at (format "\\*\\{1,%s\\} +.*$" endless/
      (message "%s" (match-string-no-properties 0)))
     ((looking-at "^#\\+BEGIN_SRC +emacs-lisp.*$")
      (let ((l (match-end 0)))
        (search-forward "\n#+END_SRC")
        (eval-region l (match-beginning 0)))))))

Once back within the range of cell towers, a quick search revealed it could have been slightly shorter.

(require 'org)
 (expand-file-name ""

Nonetheless, I stuck with my guns and kept the first version. Primarily for stubbornness, but also a few other reasons:

Fine grained control
I can choose exactly what gets evaluated. In this case, anything inside the init.el header. This is important because this blog is my init file, and I don’t want to evaluate everything I post.
Lots of messaging
It calls message on each header it finds (up to a configurable level). Whenever something goes wrong, forget about restarting with --debug-init, the messages buffer tells me exactly where it happened.
It doesn’t (require 'org)
that might seem silly, but that inconspicuous line forms one of the most time-consuming statements you could possibly write. I’d challenge anyone to find a 14-character statement that takes longer than that (other than an empty loop or a sleep command, of course).
About these ads

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s