Updated with useful functions from http://whattheemacsd.com/