 (load custom-file) ;; Load the emacs `M-x customize` generated file
 
 (require 'benchmark-init)
+(require 'req-package)
 
-;; Stuff that can't be committed publicly on github
-(require 'setup-secret) ;; INSTR_DELETE_THIS_LINE
-;;
+(req-package setup-region-bindings-mode)
+(req-package setup-key-chord)
+(req-package modi-mode)
+(req-package defuns)
+
+(require 'setup-secret nil t) ;; No error if not found
 
 ;; Set up the looks of emacs
-(require 'setup-popwin) ;; require popwin first as packages might depend on it
-(require 'setup-smart-mode-line)
-(require 'setup-visual)
+(req-package setup-popwin) ;; require popwin first as packages might depend on it
+(req-package setup-smart-mode-line)
+(req-package setup-visual)
 
 ;; Set up extensions/packages
-(eval-after-load 'ido '(require 'setup-ido))
-(require 'setup-ace-jump-mode)
-(require 'setup-ace-window)
-(require 'setup-ag)
-(require 'setup-auto-complete)
-(require 'setup-bookmark+)
-(require 'setup-dired)
-(require 'setup-drag-stuff)
-(require 'setup-elisp-slime-nav)
-(require 'setup-expand-region)
-(require 'setup-fci)
-(require 'setup-fiplr)
-(require 'setup-guide-key)
-(require 'setup-hardcore)
-(require 'setup-header2)
-(require 'setup-highlight)
-(require 'setup-hl-line+)
-(require 'setup-hungry-delete)
-(require 'setup-iregister)
-(require 'setup-key-chord)
-;; (require 'setup-linum)
-(require 'setup-magit)
-(require 'setup-manage-minor-mode)
-(require 'setup-multiple-cursors)
-(require 'setup-number)
-(require 'setup-org)
-(require 'setup-page-break-lines)
-(require 'setup-rainbow-delimiters)
-(require 'setup-server)
-(require 'setup-smart-compile)
-(require 'setup-smex)
-(require 'setup-stripe-buffer)
-(require 'setup-undo-tree)
-(require 'setup-visual-regexp)
-(require 'setup-w3m)
-(require 'setup-wrap-region)
-(require 'setup-xkcd)
-(require 'setup-yafolding)
-(require 'setup-yasnippet)
-;; (require 'setup-sublimity) ;; Not required; makes huge code file browsing laggy
-;; (require 'setup-helm) ;; Not required; replaced with swoop
-;; (require 'setup-projectile)
+(req-package setup-ace-jump-mode)
+(req-package setup-ace-window)
+(req-package setup-ag)
+(req-package setup-auto-complete)
+(req-package setup-bookmark+)
+(req-package setup-buffer-move)
+(req-package setup-dired)
+(req-package setup-drag-stuff)
+(req-package setup-elisp-slime-nav)
+(req-package setup-expand-region)
+(req-package setup-fci)
+(req-package setup-fiplr)
+(req-package setup-guide-key)
+(req-package setup-hardcore)
+;; (req-package setup-header2)
+(req-package setup-highlight)
+(req-package setup-hl-line+)
+(req-package setup-hungry-delete)
+(req-package setup-ido)
+(req-package setup-iregister)
+;; (req-package setup-linum)
+(req-package setup-magit)
+(req-package setup-manage-minor-mode)
+(req-package setup-multiple-cursors)
+(req-package setup-number)
+(req-package setup-org)
+(req-package setup-page-break-lines)
+(req-package setup-poporg)
+(req-package setup-rainbow-delimiters)
+(req-package setup-rainbow-mode)
+(req-package setup-server)
+(req-package setup-smart-compile)
+(req-package setup-smex)
+(req-package setup-stripe-buffer)
+(req-package setup-undo-tree)
+(req-package setup-visual-regexp)
+(req-package setup-w3m)
+;; (req-package setup-workgroups2)
+(req-package setup-wrap-region)
+(req-package setup-xkcd)
+(req-package setup-yafolding)
+(req-package setup-yasnippet)
+;; (req-package setup-helm) ;; Not required; replaced with swoop
+;; (req-package setup-projectile)
 
 ;; Languages
-(require 'setup-verilog)
-(require 'setup-perl)
-(require 'setup-python)
-(require 'setup-matlab)
-(require 'setup-markdown)
-(require 'setup-web-mode)
-(require 'setup-yaml-mode)
-(require 'setup-latex)
-(require 'setup-shell)
-(require 'setup-elisp)
-;; (require 'setup-tcl)
-;; (require 'setup-hspice)
+(req-package setup-verilog)
+(req-package setup-perl)
+(req-package setup-python)
+(req-package setup-matlab)
+(req-package setup-markdown)
+(req-package setup-web-mode)
+(req-package setup-yaml-mode)
+(req-package setup-latex)
+(req-package setup-spice)
+;; (req-package setup-tcl)
 
-(require 'setup-sos) ;; INSTR_DELETE_THIS_LINE
-(require 'setup-windows-buffers)
-(require 'setup-registers)
-(require 'setup-navigation)
-(require 'setup-editing)
-(require 'setup-search)
-(require 'setup-print)
-(require 'setup-desktop)
-(require 'setup-gtags)
-(require 'setup-spell)
-(require 'setup-misc)
-;; (require 'setup-ctags)
+(req-package setup-editing)
+(req-package setup-windows-buffers)
+(req-package setup-registers)
+(req-package setup-navigation)
+(req-package setup-search)
+(req-package setup-print)
+(req-package setup-gtags)
+(req-package setup-spell)
+(req-package setup-desktop)
+;; (req-package setup-ctags) ;; Using gtags instead
 
-;; NOTE: Load below ONLY after loading all the packages
-;; region-bindings-mode has bindings for multiple-cursors, visual-regexp, anzu
-(require 'setup-region-bindings-mode)
-(require 'setup-key-bindings)
+(req-package setup-misc) ;; This package must be the last required package
 
+(req-package-finish) ;; Start loading packages in right order
+(global-modi-mode t)
 (funcall default-theme)
 
+(setq emacs-initialized t)
 
-(setq emacs-initialized t)
+;; Write out a message indicating how long it took to process the init script
+(message "init.el loaded in %ds"
+         (destructuring-bind (hi lo ms ps) (current-time)
+           (- (+ hi lo)
+              (+ (first *emacs-load-start*)
+                 (second *emacs-load-start*)))))

    mwe-log-commands ;; for logging commands; useful when demoing emacs
    nlinum ;; reviews say it's better than linum
    number ;; number manipulation
    org ox-reveal htmlize ;; Get the latest org-mode package from MELPA; ox-reveal for HTML slides
    page-break-lines ;; Convert the ^L (form feed) chars to horizontal lines
    popwin ;; Open windows like *Help*, *Completions*, etc in minibuffer
    rainbow-delimiters
    rainbow-mode
    region-bindings-mode ;; complements really well with multiple-cursors
    smart-compile
    smart-mode-line popup
    smex ;; smart M-x
    stripe-buffer
    swoop

    auto-highlight-symbol
    benchmark-init
    bookmark+ ;; able to bookmark desktop sessions
    buffer-move
    cperl-mode
    csv-nav ;; editing csv files
    dired+ dired-single
    drag-stuff
    eimp ;; required by org-show
    elisp-slime-nav ;; tag based code navigation for elisp; works even for compressed code
    expand-region
    fill-column-indicator
