Automatically detect coding system with Enca (by Dmitriyi Paduchikh)
To get this function working, put the file at some place in your load-path, compile, and add something like this into .emacs:
(setenv "ENCAOPT" "-L russian")
(when (load "auto-enca" 'noerror)
(modify-coding-system-alist 'file "" 'enca-detect-coding))