         verilog-minimum-comment-distance 40
         verilog-indent-begin-after-if    'declarations
         verilog-auto-lineup              '(none))
-  ; can't use :ensure because this package isn't available on package manager
-  )
-
-; Text mode
+  ;; can't use :ensure because this package isn't available on package manager
+  )
+
+;; Text mode
 (setq auto-mode-alist (cons '("README" . text-mode) auto-mode-alist))
 (add-hook 'text-mode-hook 'visual-line-mode)  ; wrap long lines
 (add-hook 'text-mode-hook 'flyspell-mode)     ; spell check
 
-; LaTeX mode
-(add-hook 'latex-mode-hook 'visual-line-mode)
-(add-hook 'latex-mode-hook 'flyspell-mode)
-
-; Todo.txt mode
-; NOTE: The package is "todotxt", but the mode is "todotxt-mode":
-; https://github.com/rpdillon/todotxt.el/blob/master/readme.org
+;; LaTeX mode
+(add-hook 'latex-mode-hook 'visual-line-mode) ; wrap long lines
+(add-hook 'latex-mode-hook 'flyspell-mode)    ; spell check
+
+;; Todo.txt mode
+;; NOTE: The package is "todotxt", but the mode is "todotxt-mode":
+;; https://github.com/rpdillon/todotxt.el/blob/master/readme.org
 (use-package todotxt
   :mode ("todo.txt" . todotxt-mode)
   :mode ("bills.*" . todotxt-mode)

; .emacs
; awdeorio's emacs customizations

; Custom packages go in ~/.emacs.d/elisp
; https://www.emacswiki.org/emacs/LoadPath
(let ((default-directory  "~/.emacs.d/elisp/"))
  (normal-top-level-add-to-load-path '("."))
  (normal-top-level-add-subdirs-to-load-path))

;; Emacs automatically saved information in a separate file
;; https://stackoverflow.com/questions/5052088/what-is-custom-set-variables-and-faces-in-my-emacs
(setq custom-file "~/.emacs.d/custom.el")
(unless (file-exists-p custom-file)
  (write-region "" nil custom-file))

; Custom keyboard shortcuts
(global-set-key "\C-ci"                             'indent-to)
(global-set-key "\C-cl"                             'this-line-to-top-of-window)
(global-set-key "\C-c\C-s"                          'search-forward-regexp)
(global-set-key "\C-c\C-r"                          'search-backward-regexp)
(global-set-key "\C-x\C-b"                          'electric-buffer-list)
(global-set-key "\C-c\C-b"                          'browse-url-at-point)
(global-set-key [(control \')]                      'other-window)

;; No more typing the whole yes or no. Just y or n will do.
(fset 'yes-or-no-p 'y-or-n-p)

; macOS modifier keys
(setq mac-command-modifier 'meta) ; Command == Meta
(setq mac-option-modifier 'super) ; Option == Super

;; Remove scrollbars, menu bars, and toolbars
;; (when (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(when (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(when (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))

; Misc appearance
(setq use-file-dialog                         -1) ; no GTK dialoge boxes
(setq inhibit-startup-message                  t) ; no startup message
(setq ring-bell-function                #'ignore) ; no audible bell
(setq line-number-mode                         t) ; show line numbers
(setq column-number-mode                       t) ; show column numbers
(global-font-lock-mode                         t) ; show syntax highlighting
(setq-default transient-mark-mode              t) ; highlight marked regions
(show-paren-mode                               t) ; parentheses matching
(setq-default truncate-lines                   t) ; truncate long lines
(setq frame-title-format "%b")                    ; Window title = buffer name

; Disable pop-up boxes in the GUI
(defadvice yes-or-no-p (around prevent-dialog activate)
  "Prevent yes-or-no-p from activating a dialog"
  (let ((use-dialog-box nil))
    ad-do-it))
(defadvice y-or-n-p (around prevent-dialog-yorn activate)
  "Prevent y-or-n-p from activating a dialog"
  (let ((use-dialog-box nil))
    ad-do-it))

; Smooth scrolling (one line at a time)
(setq scroll-step 1)

; Update string in the first 8 lines looking like Time-stamp: <> or " "
(add-hook 'write-file-hooks 'time-stamp)

; Tab settings: 2 spaces
(setq-default indent-tabs-mode nil)
(setq default-tab-width 2)
(setq tab-width 2)
(defvaralias 'c-basic-offset 'tab-width)
(defvaralias 'cperl-indent-level 'tab-width)
(defvaralias 'sh-basic-offset 'tab-width)
(defvaralias 'sh-indentation 'tab-width)

; Automatically close parentheses, braces, etc.
(electric-pair-mode 1)

; Default browser
(setq browse-url-generic-program (executable-find "open") ; OSX
      browse-url-browser-function 'browse-url-generic)
; (setq browse-url-generic-program (executable-find "google-chrome") ; Linux
;       browse-url-browser-function 'browse-url-generic)

(setq-default truncate-lines t)

;; Package Management
(require 'package)
(setq package-enable-at-startup nil)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))

(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/"))
(package-initialize)

;; Bootstrap 'use-package' and enable it.  Later, 'use-package- will
;; download and install third-party packages automatically.
;; http://cachestocaches.com/2015/8/getting-started-use-package/
;;
;; EXAMPLE:
;; (use-package foo-mode
;;   :after bar      ; load after bar package
;;   :mode "\\.foo"  ; load and enable foo-mode for *.foo files
;;   :init           ; run this code when init.el is read
;;   :config         ; run this code after loading foo-mode
;;   :ensure t       ; automatically install foo-mode if not present
;;   :defer t        ; defer loading for performance (usually the default)
;; )
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(eval-when-compile
  (require 'use-package))

;; More intuitive undo/redo.  M-_ undo, C-M-_ redo
;; https://www.emacswiki.org/emacs/UndoTree
(use-package undo-tree
  :config
