 ;; Clean up whitespace
 ;; ============================================================
 
-;; has to go near the end because we need some project/language specific
-;; functions.
-
-(defun preserve-trailing-whitespace-p ()
-  (interactive)
-  (or
-   ;; makefile mode doesn't play well with this
-   (string= major-mode "makefile-mode")
-
-   ;; oomph-lib doesn't stick to no trailing whitespace :(
-   (is-oomph-code)
-
-   ;; Don't do it in non-programming modes (just to be safe)
-   (not (or (derived-mode-p 'prog-mode)
-	    (eq major-mode 'ess-mode)
-            (eq major-mode 'feature-mode)
-            (eq major-mode 'sgml-mode)))))
-
-(defun maybe-delete-trailing-whitespace ()
-  (when (not (preserve-trailing-whitespace-p))
-    (delete-trailing-whitespace)))
-
-(add-hook 'before-save-hook 'maybe-delete-trailing-whitespace)
+;; Automatically clean whitespace in lines that we have touched
+(use-package ws-butler
+  :ensure t
+  :config
+  (ws-butler-global-mode))
 
 (add-to-list 'load-path "~/.emacs.d/aggressive-fill-paragraph-mode")
 (load-library "aggressive-fill-paragraph")

                'org-mode-hook
                'ess-mode-hook))
  )


;; For some stupid reason ess doesn't define this autoload, or this
;; file association!

  (interactive)
  (switch-to-buffer (make-temp-name "scratch"))
  (org-mode))


(global-set-key [home] 'smart-beginning-of-line)
