GNU bug report logs -
#13815
Wrong mode for files with awkward shebang lines
Previous Next
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
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
[Message part 2 (text/html, inline)]
This bug report was last modified 3 years and 268 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.