bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13815: Wrong mode for files with awkward shebang lines


From: Andrew Pennebaker
Subject: bug#13815: Wrong mode for files with awkward shebang lines
Date: Mon, 25 Feb 2013 16:56:03 -0500

Some of my Scala code opens as Shell script major mode in Emacs, a problem caused by several factors:

In order to enable dot-slashing for Scala scripts, programmers sometimes start their code as follows:

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

object Hello {
def main(args: Array[String]) {
println("Hello World!")
}
}

This is an awkward shebang line; due to the nature of shebangs, it must be split across three lines of code, starting with #!/bin/sh.

This creates problems for Emacs, as Emacs uses `file` to detect which major mode should be used, and `file` returns 'text/x-shellscript' when a file begins #!/bin/sh, regardless of the file extension or programming language content the file actually contains.

This could be solved a variety of ways, but I think the simplest is to prioritize file extension over mimetype when a file extension is available. We can't trust mimetypes for code that contains these awkward shebangs.

--
Cheers,

Andrew Pennebaker
www.yellosoft.us

reply via email to

[Prev in Thread] Current Thread [Next in Thread]