unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13815: Wrong mode for files with awkward shebang lines
@ 2013-02-25 21:56 Andrew Pennebaker
  2013-02-26  2:59 ` Stefan Monnier
  2013-02-26  3:02 ` Glenn Morris
  0 siblings, 2 replies; 9+ messages in thread
From: Andrew Pennebaker @ 2013-02-25 21:56 UTC (permalink / raw)
  To: 13815

[-- Attachment #1: Type: text/plain, Size: 981 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 1569 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-08-31  1:54 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-25 21:56 bug#13815: Wrong mode for files with awkward shebang lines Andrew Pennebaker
2013-02-26  2:59 ` Stefan Monnier
2013-02-26  8:12   ` Glenn Morris
2013-02-26  3:02 ` Glenn Morris
2021-08-23  1:13   ` Lars Ingebrigtsen
2021-08-23 15:06     ` Glenn Morris
2021-08-23 15:10       ` Lars Ingebrigtsen
2021-08-30 15:11         ` Glenn Morris
2021-08-31  1:54           ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).