My problem stems from Emacs inserting the coding system headers into source files containing non-ascii characters:
# -*- coding: utf-8 -*-
My coworkers do not like these headers being checked into our repositories. I don't want them inserted into my files because Emacs automatically detects that the file should be UTF-8 regardless so there doesn't seem to be any benefit to anyone.
I would like to simply set Emacs to use UTF-8 automatically for all files, yet it seems to disagree with this idea. In an effort to fix this, I've added the following to my .emacs:
(prefer-coding-system 'utf-8) (setq coding-system-for-read 'utf-8) (setq coding-system-for-write 'utf-8)
This does not seem to solve my problem. Emacs still inserts the coding-system headers into my files. Anyone have any ideas?
EDIT:
I think this problem is specifically related to ruby-mode. I still can't turn it off though.
You can change the encoding to use for the file when saving using 'C-x C-m f' . You can also force this immediately by using 'C-x C-m c <encoding> RET C-x C-w RET' . You can list all available encodings with 'M-x list-coding-systems' . You can force Emacs to read a file in a specific encoding with 'C-x RET c C-x C-f' .
Use coding system coding to save or revisit the file in the current buffer ( set-buffer-file-coding-system ). C-x RET c coding RET. Specify coding system coding for the immediately following command ( universal-coding-system-argument ). C-x RET r coding RET.
This works for me:
(setq ruby-insert-encoding-magic-comment nil)
As suggested here
I believe you're correct that it only happens in ruby-mode. It seems ruby-mode is trying to be helpful by adding the line, which makes Ruby detect the source file encoding automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With