When working under windows I like to make use of cygwin tools. Its a great project that brings gnu tools to windows. Despite other features it offers a terminal window with a bash shell. While cygwin even offers an X-Server and and an Emacs that runs on this X-Server I do prefer an native windows Emacs. I prefer to have one emacs instance running and have it in server-mode so that i can integrate emacsclient into the cygwins‘ bash. In general this works pretty well – however „problems“ arise when emacs saves files with windows line-endings. When I edit shell scripts for cygwin and further dare to execute the script under cygwins‘ bash the shell does not really get along very well with windows line endings. To change character encoding in emacs I than follow these guidelines:
Dos to unix
M-x set-buffer-file-coding-system RET undecided-unix
save the file (C-x C-s)
C-x RET f undecided-unix
I bet there is a smarter way – like telling emacs to use unix character-encoding whenever editing files in my cygwin home-directory. And there really is: modify-coding-system-alist! This handy defun lets me define that any file residing below c:/cygwin/“ should really be encoded with utf-8-unix. No more live switching coding systems!