How can I specify the shell variant for a file in that file's Emacs local variables, when the file is not a standalone program?
Emacs allows me to specify that a shell include file should be opened in
sh mode, by setting a local variable in the editor hints:
# Local variables: # coding: utf-8 # mode: sh # End: # vim: fileencoding=utf-8 filetype=bash :
I can specify to Vim that the file's shell variant is specifically Bash, and it obeys the editor hint to present specific Bash syntax highlighting. But Emacs has
sh mode which covers all shell variants.
Emacs will properly interpret such a file if it has a shebang line (e.g.
#! /bin/bash). But some files are not stand-alone programs, so I do not want those to have a shebang line.
sh mode treats those files as Posix shell syntax, which they are not.
sh mode has the concept of “variant” of shell syntax; but I'm unable to find out how to specify, in the file's editor hints, which variant to use for the file.
How can I set the editor hints in the file to tell Emacs that its syntax is Bash?
Update 2014-04-24: I have reported Emacs bug#17333 for this missing behaviour.