- (let* ((dummy-insert-op (list 'insert-file-contents (buffer-file-name)))
- (coding-system-pair
- (find-buffer-file-type-coding-system dummy-insert-op)))
- (setq buffer-file-coding-system (car coding-system-pair))
+ (let ((coding buffer-file-coding-system))
+ ;; buffer-file-coding-system is already set by
+ ;; find-operation-coding-system, which was called from
+ ;; insert-file-contents. All that's left is to change
+ ;; the EOL conversion, if required by the user.
+ (when (and (null coding-system-for-read)
+ (or inhibit-eol-conversion
+ (untranslated-file-p (buffer-file-name))))
+ (setq coding (coding-system-change-eol-conversion coding 0))
+ (setq buffer-file-coding-system coding))