You put the -*- mode: python -*-
in the second line (special exception, added specifically for the shebang thingies).
Recognize a file with a shebang and no extension
سؤال
I know that emacs can recognize a file by the extension, a -*- mode -*-
first line, and even by the shebang line, but what do I do if I want to override the shebang?
For example, a script that starts with
#!/usr/bin/env python2.7
...
won't be recognized by the shebang line alone. I also can't add in a -*-python-*-
line, because then the shell tries to parse it. How do I deal with this?
المحلول
نصائح أخرى
You can try putting something like
(add-to-list 'interpreter-mode-alist '("python2.7" . python-mode))
in your .emacs
. See “Choosing File Modes” for more info.
Like this:
#!/usr/bin/env python2.7
print "test"
# Local Variables:
# mode: python
# End:
This information comes from Specifying File Variables
node of info
.
- Use f1 i to enter info.
- Use g
(emacs)
to jump to emacs info. - Use g
Specifying File Variables
to jump to the page. You can use tab to complete node names.
لا تنتمي إلى StackOverflow