Skip to content

Commit

Permalink
Add highlighting of trailing whitespace and tabs.
Browse files Browse the repository at this point in the history
- Also disabled removal of tabs and trailing whitespace on save. It
  was causing too many unexpected changes during checkin. Cleanup of
  whitespace can be done manually with `C-x t`.
  • Loading branch information
candera committed Nov 29, 2011
1 parent 5acbb1c commit 95a1d9f
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions init.el
Expand Up @@ -233,7 +233,7 @@

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Whitespace cleanup
;; Whitespace cleanup and display
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Expand Down Expand Up @@ -261,8 +261,9 @@
(when (member major-mode delete-trailing-whitespace-modes)
(delete-trailing-whitespace)))

(add-hook 'before-save-hook 'mode-aware-detabify)
(add-hook 'before-save-hook 'mode-aware-trailing-whitespace-cleanup)
;; Removing these in favor of doing it manually
; (add-hook 'before-save-hook 'mode-aware-detabify)
; (add-hook 'before-save-hook 'mode-aware-trailing-whitespace-cleanup)

(defun clean-up-whitespace ()
"Calls untabify and delete-trailing-whitespace on the current buffer."
Expand All @@ -272,6 +273,22 @@

(global-set-key (kbd "C-x t") 'clean-up-whitespace)

(defface extra-whitespace-face
'((t (:background "pale green")))
"Used for tabs and such.")

(defvar extra-whitespace-keywords
'(("\t" . 'extra-whitespace-face)))

(defun setup-highlight-whitespace ()
(font-lock-add-keywords nil extra-whitespace-keywords)
(setq show-trailing-whitespace t))

(add-hook 'emacs-lisp-mode-hook 'setup-highlight-whitespace)
(add-hook 'text-mode-hook 'setup-highlight-whitespace)
(add-hook 'lisp-mode-hook 'setup-highlight-whitespace)
(add-hook 'ruby-mode 'setup-highlight-whitespace)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Work around a bug in Ubuntu 10.10
Expand Down

0 comments on commit 95a1d9f

Please sign in to comment.