GNU bug report logs - #13815
Wrong mode for files with awkward shebang lines

Previous Next

Package: emacs;

Reported by: Andrew Pennebaker <andrew.pennebaker <at> gmail.com>

Date: Tue, 26 Feb 2013 01:26:01 UTC

Severity: wishlist

Tags: wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Andrew Pennebaker <andrew.pennebaker <at> gmail.com>
To: 13815 <at> debbugs.gnu.org
Subject: bug#13815: Wrong mode for files with awkward shebang lines
Date: Mon, 25 Feb 2013 16:56:03 -0500
[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.