views:

185

answers:

1

I usually have to deal with a lot of people sending me Windows files and I'm tired of having to convert them by hand, usually by doing:

 C-x RET f unix RET

Is there any way to add a global hook (for all modes) to automatically do this on saves?

+6  A: 
(defun unix-newline () (set-buffer-file-coding-system 'undecided-unix))
(add-hook 'before-save-hook 'unix-newline)

I also like:

(add-hook 'before-save-hook 'delete-trailing-whitespace)
wrang-wrang