Skip to content

Instantly share code, notes, and snippets.

@nfunato
Created October 20, 2012 18:42
Show Gist options
  • Save nfunato/3924312 to your computer and use it in GitHub Desktop.
Save nfunato/3924312 to your computer and use it in GitHub Desktop.
whitespace busters for Emacs
(defvar undesirable-ws-cleanup-wo-choice-modes
'(lisp-mode))
(defvar undesirable-ws-cleanup-w-check-modes
'(org-mode))
(defun undesirable-ws-cleanup ()
(interactive)
(save-excursion
(when (or (member major-mode undesirable-ws-cleanup-wo-choice-modes)
(and (member major-mode undesirable-ws-cleanup-w-check-modes)
(y-or-n-p "Really untabify/delete-trailing-whitespace ? ")))
(untabify (point-min) (point-max))
(delete-trailing-whitespace (point-min) (point-max))))
nil)
(add-hook 'before-save-hook 'undesirable-ws-cleanup)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment