 (add-to-list 'compilation-error-regexp-alist-alist '(jshint "^\\(.*\\): line \\([0-9]+\\), col \\([0-9]+\\), " 1 2 3))
 (add-to-list 'compilation-error-regexp-alist 'jshint)
 
-;; always clean whitespace in javascript mode
-(defun remap-save-clean-whitespace ()
-  (interactive)
-  (local-set-key [remap save-buffer] 'clean-whitespace-and-save))
-(add-hook 'js-mode-hook 'remap-save-clean-whitespace)
-
 ;; set up tab key
 (add-hook 'js-mode-hook 'set-tab)
 

;; 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)

(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!
