                        (region-end))
       ;; Are we at the end of a word?
       (if (looking-at "\\_>")
-          (if (long-enough-p)
-              (dabbrev-expand nil)
-            (if (override-p)
-                (progn
-                  (dabbrev--reset-global-variables)
-                  (dabbrev-expand nil))
-              nil))
+          (progn
+            (if smart-tab-always-indent
+                (indent-for-tab-command) nil)
+            (if (long-enough-p)
+                (dabbrev-expand nil)
+              (if (override-p)
+                  (progn
+                    (dabbrev--reset-global-variables)
+                    (dabbrev-expand nil)
+                    (indent-for-tab-command)))))
         (indent-for-tab-command)))))
 ;; Make dabbrev-replace case insensitive.
+;; insensitive.
 (setq dabbrev-case-replace nil)
 ;; Replace dabbrev-expand with hippie-expand.
-;; (global-set-key (kbd "M-/") 'hippie-expand)
+(global-set-key (kbd "M-/") 'hippie-expand)
 ;; Bind to tab.
 (global-set-key (kbd "C-i") 'smart-tab)
 ;; Function to enable autosave.


(defun long-enough-p ()
  "Is this word long enough to expand?"
  (> (- (point) (car (bounds-of-thing-at-point 'word))) 2))
(defun override-p ()
  "Did we manually override the length limit?"
  (eq this-command last-command))

;; Modified from http://emacswiki.org/emacs/TabCompletion
(defun smart-tab ()
  "Smart tab does the following:
    In the mini-buffer: expand the word.

    If mark is active: indent the region.

    If we are at the end of the word or call twice: expand the word.

    Otherwise: indent the current line."
  (interactive)
  ;; Always expend in the buffer.
  (if (minibufferp)

  (interactive)
  (if (and (buffer-file-name) (buffer-modified-p))
      (save-some-buffers t)))

;; Rectangles :)
(cua-selection-mode t)
;; (kbd "C-j") is Ctrl + Enter
(global-set-key (kbd "C-j") 'cua-set-rectangle-mark)
