init.el in org-mode

I've been learning a little bit about Emacs each day over the last month. My latest attempt was re-doing my init.el in org-mode.

My primary goal was better organization. My init.el was several hundred lines long and was totally disorganized. I've been adding to the end of it randomly as I've learned. I wanted a better way to understand my configuration so that I could improve it.

My secondary goal was to switch to using use-package for all my packages.


I replaced ~/.emacs.d/init.el with this:

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

I then created ~/.emacs.d/ and put everything from my old init.el into a giant BEGIN_SRC block:

#+BEGIN_SRC emacs-lisp
; original code goes here
#+END_SRC emacs-lisp

building an organizational structure

  • Emacs environment
    • Directories/path setup
    • Package setup
      • Repositories
    • Customize
    • use-package
    • Subprocesses
    • Helm
    • Startup
    • Backup file names
    • Ask before closing
    • Nuke buffers
    • Global revert
  • Display and movement preferences
    • No easy keys
    • Subword mode
    • Only one space after period
    • dired sort directories at top
    • M-o to open previous line
    • save-place-mode
  • Modules
    • Snippets
    • Flymake
    • Git
    • Python development
      • Python-related modes
    • Django setup
      • Python flymake rules
    • Editing modes
    • org-mode
      • org-mode modules
      • org-mode link type jekyll-post
    • Email
  • Custom emacs functions
    • random numbers
  • Overrides
    • OS-specific overrides
    • System-specific overrides
    • Username-specific overrides
    • local.el overrides

Trying out use-package

I don't know much about use-package still. that said, I started to figure out a few of the options:

(use-package helm
    (require 'helm-config)
  :bind (("C-x C-f" . helm-find-files)
         ("M-x" . helm-M-x)
         ("C-x r b" . helm-filtered-bookmarks)
         ("C-x b" . 'helm-mini))
  :config (progn
            (helm-mode 1)))

Testing out the new configuration

After I got things sort of working, I closed Emacs and deleted my elpa repository. This made Emacs re-download all packages, which also showed me a bunch of errors. For example, I didn't have this set up properly:

(require 'use-package-ensure)           ;install packages by default
(setq use-package-always-ensure t)

These add :ensure t to every use-package statement; I left off the setq so no packages actually got downloaded.

Initial lessons learned

I had a fair bit of duplicate code, e.g. repeated imports of the same module. I also learned more about org-mode's dependencies and how some things aren't really modules. For example I'm using org-plus-contrib, which apparently also gives me org-checklist.

PS Eventually I'll post my .emacs.d.