public
Last active

cleanup-buffer.el

  • Download Gist
gistfile1.el
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
(defun cleanup-buffer-safe ()
"Perform a bunch of safe operations on the whitespace content of a buffer.
Does not indent buffer, because it is used for a before-save-hook, and that
might be bad."
(interactive)
(untabify-buffer)
(delete-trailing-whitespace)
(set-buffer-file-coding-system 'utf-8))
 
(defun cleanup-buffer ()
"Perform a bunch of operations on the whitespace content of a buffer.
Including indent-buffer, which should not be called automatically on save."
(interactive)
(cleanup-buffer-safe)
(indent-buffer))
 
(global-set-key (kbd "C-c n") 'cleanup-buffer)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.