Indexing My Emacs Init File

Since I keep all my emacs configuration in a single .emacs file and in a hyper organised manner it means I have my init file split into different sections, for example :

  • platform
  • packages
  • mail
  • calendar
  • completion
  • save-desktop
  • keys
  • modes
  • setqs

with each section delimited by a comment of the form:

;;
;; -> platform`
;;

Now I am using occur more often, then why not write a function to produce a nice little Occur buffer containing an index of my init file sections, as thus:

(defun my/index ()
 (interactive)
 (beginning-of-buffer)
 (occur ";;[[:space:]]->"))

I avoided the self index reference by explicitly using the [:space:] variant for the occur regex.

and this gives me the following:

The selection of each item takes me to the relevant section of my emacs configuration and as I have f8 bound to next-error I can easily step through each section if I want to.

comments powered by Disqus