 (setq-default indent-tabs-mode nil)
 (setq-default tab-always-indent nil)
 (setq-default tab-width my-indent)
-(global-set-key (kbd "TAB") 'tab-to-tab-stop)
 (defvaralias 'c-basic-offset 'my-indent)
 (defvaralias 'cperl-indent-level 'my-indent)
-;(setq-default c-hungry-delete-key t)
 
 (electric-indent-mode -1)
 (setq-default electric-indent-inhibit t)
 
+(global-set-key (kbd "TAB") 'tab-to-tab-stop)
+
+; Retains indent level on newline
 (defun newline-preserve-indent ()
     "Insert a newline after point with the same indentation as the current line."
     (interactive)

(package-initialize)

;;
;; whitespace stuff
;;

(defvar my-indent 4 "My indentation offset.")

)
(global-set-key (kbd "RET") 'newline-preserve-indent)

; Deletes groups of spaces if on a tabstop
(defun smart-del ()
    "Deletes 4 spaces back when on a tabstop, or just the last character."
    (interactive)
    (if (or (bolp) (/= 0 (% (current-column) my-indent)))
        (delete-backward-char 1)
    ;else
        (setq last-tabstop (- (current-column) my-indent))
        (if (and (string-match "[ \t]*" (thing-at-point 'line t) last-tabstop) 
                 (>= (match-end 0) (current-column))
            )
            (delete-backward-char (- (current-column) last-tabstop))
        ; else
            (delete-backward-char 1)
        )
    )
)
