Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i prevent emacs from adding coding information in the first line?

Tags:

emacs

encoding

In some files, especially .rb I have a problem where emacs forces me to have the following encoding line.

# -*- coding: utf-8 -*-

Even if I delete the line it will get written again once I save my file.

Is it possible to disable this feature?

like image 731
ayckoster Avatar asked Jun 23 '11 12:06

ayckoster


1 Answers

It looks like this is part of the ruby-mode in emacs.

I found a link to an article that shows how to edit the ruby-mode.el file. Not sure if it works, but there is also a comment on that article that may work better:

(setq ruby-insert-encoding-magic-comment nil)

If instead of using ruby-mode your are using enh-ruby-mode you should set this variable:

(setq enh-ruby-add-encoding-comment-on-save nil)

Links:

Fix: Emacs/Aquamacs keeps adding encoding comments to my files

Also, semi-related question but pertinent answer by Michael Kohl: How can I avoid putting the magic encoding comment on top of every UTF-8 file in Ruby 1.9?

Enh-ruby-mode comment encoding line

like image 120
crashmstr Avatar answered Nov 15 '22 22:11

crashmstr