Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Emacs is treating my Scala code as shell scripts due to an incorrect mimetype being set:

file -I Hello.scala
Hello.scala: text/x-shellscript; charset=us-ascii

I tried changing the Open with... information for the file, but Mac still uses the wrong mimetype. How can I fix the mimetype, preferably with a command?

share|improve this question
cp and cat both copy over the source mimetype, so it's not easy to get around this issue by making a new file and copying the source into it. – mcandre Feb 25 '13 at 20:49
Is the problem that you want Emacs to know what type it is (in which case you want auto-mode-alist), that you want the Mac's "open with..." to know what the file type is (in which case you might want Universal Type Identifiers), or that you want the file command to know what type the file is (which uses files in the /usr/share/file/magic directory)? Since each uses a different method, the route to fixing it will depend on what you're trying to do. Let us know and I think I can tell you how to fix it. – Alan Shutko Feb 25 '13 at 22:44
up vote 0 down vote accepted

Turns out shebang lines are to blame.

exec scala "$0" "$@"

These are necessary in order to dot-slash Scala programs, but they are also used to determine a file's mimetype, albeit incorrectly so.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .