            (save-excursion
              (goto-char p1)
              (cond
-              ;; lower -> Capitalize
-              ((looking-at "[[:lower:]]")            (put this-command 'next-state "Capitalize"))
-              ;; Capitalize -> UPPER
-              ((looking-at "[[:upper:]][[:lower:]]") (put this-command 'next-state "UPPER"))
-              ;; Default: UPPER -> lower
-              (t                                     (put this-command 'next-state "lower")))))))
+               ;; lower -> Capitalize
+               ((looking-at "[[:lower:]]")            (put this-command 'next-state "Capitalize"))
+               ;; Capitalize -> UPPER
+               ((looking-at "[[:upper:]][[:lower:]]") (put this-command 'next-state "UPPER"))
+               ;; Default: UPPER -> lower
+               (t                                     (put this-command 'next-state "lower")))))))
 
     (cl-case (string-to-char (get this-command 'next-state)) ; `string-to-char' returns first character in string
       (?U (upcase-region p1 p2)

(fset 'modi/convert-dec-to-twos-comp-16-bit-hex
      (lambda (&optional arg) "Keyboard macro." (interactive "p") (kmacro-exec-ring-item (quote ([escape 58 40 114 101 97 100 45 111 110 108 121 45 109 111 100 101 32 45 49 41 return 109 44 19 45 return 67108896 2 97 67108896 40 6 32 40 94 32 50 32 49 54 41 32 5 41 24 109 120 return 24 104 33554435 33554435 40 102 111 114 109 97 116 32 34 37 88 34 5 41 24 109 120 return] 0 "%d")) arg)))

;; How to position the cursor after the end of line; useful for copying/killing
;; rectangles have lines of varying lengths.
;; http://emacs.stackexchange.com/a/3661/115
(use-package rectangle-utils
  :config
  (progn
    (defun modi/extend-rectangle-to-end(beg end)
      "Make `extend-rectangle-to-end' work for read-only buffers too."
      (interactive "r")
      (let* (original-read-only-state buffer-read-only)
        (when original-read-only-state
          (read-only-mode -1)) ; Force the buffer to be writable
        (extend-rectangle-to-end beg end)
        (when original-read-only-state
          (read-only-mode +1)))) ; Revert the buffer back to its read-only state
    (when (featurep 'region-bindings-mode)
      (bind-keys
       :map region-bindings-mode-map
       ("|" . modi/extend-rectangle-to-end)))))

;; http://ergoemacs.org/emacs/modernization_upcase-word.html
(defun xah-cycle-letter-case (arg)

;; zop-to-char
;; Source: https://github.com/thierryvolpiatto/zop-to-char
(use-package zop-to-char
    :load-path "elisp/zop-to-char"
    :config
    (progn
      (bind-keys
       :map modi-mode-map
       ("M-z" . zop-up-to-char)
       ("M-Z" . zop-to-char))))

;; indent-guide
(use-package indent-guide
    :config
  (progn
    (setq indent-guide-recursive t)
    (setq indent-guide-char "|")
