hvesalai / emacs-scala-mode

The definitive scala-mode for emacs
http://ensime.org
GNU General Public License v3.0
361 stars 68 forks source link

Emacs treats .scala files as .sh shell script files #47

Closed mcandre closed 11 years ago

mcandre commented 11 years ago

I installed scala-mode2 and added (require 'scala-mode2) to ~/.emacs, but Emacs still treats .scala files as .sh shell scripts.

hvesalai commented 11 years ago

I'm sorry to hear you are having problems. I bet it is something pretty trivial that you need to tweak.

Please check the following:

To make sure you have scala-mode properly installed, open a .scala file and type in M-x scala-mode. This should turn the scala-mode on and you should see the text "(Scala)" on the status row.

If this fails, please include a link to your emacs file here. Use gist, pastebin or other similar service.

mcandre commented 11 years ago

Turns out mimetypes :( Emacs is doing the right thing, noticing my .scala files have the text/x-shellscript mimetype and opening them in shell script mode.

Mac is using the wrong mimetype, and there's no easy way to correct it.

http://superuser.com/questions/557281/how-can-i-set-a-files-mimetype-in-mac-os-x

hvesalai commented 11 years ago

I bet there are many other mac users (but I am not). Join the #scala irc channel and ask there for advice.

hvesalai commented 11 years ago

Or is Mac is anything like other unixes, then there might be a /etc/mime.types file that you can edit.

mcandre commented 11 years ago

It turns out scala-mode2 is doing everything right. My shebang line is to blame:

#!/bin/sh
exec scala "$0" "$@"
!#

Because file uses shebang lines to detect mimetypes, and Emacs uses mimetypes to assign major modes. So #!/bin/sh maps to 'text/x-shellscript' maps to Sh mode.

Do you happen to know a good shebang for Scala code that doesn't corrupt the mimetype?

hvesalai commented 11 years ago

http://stackoverflow.com/questions/15077341/whats-a-shebang-line-for-scala-that-doesnt-corrupt-mimetype