SF patch #510288 by Kevin J. Butler, mod'd by Barry.  This provides
better auto-recognition of a Jython file vs. a CPython (or agnostic)
file by looking at the #! line more closely, and inspecting the import
statements in the first 20000 bytes (configurable).  Specifically,

(py-import-check-point-max): New variable, controlling how far into
the buffer it will search for import statements.

(py-jpython-packages): List of package names that are Jython-ish.

(py-shell-alist): List of #! line programs and the modes associated
with them.

(jpython-mode-hook): Extra hook that runs when entering jpython-mode
(what about Jython mode? <20k wink>).

(py-choose-shell-by-shebang, py-choose-shell-by-import,
py-choose-shell): New functions.

(python-mode): Use py-choose-shell.

(jpython-mode): New command.

(py-execute-region): Don't use my previous hacky attempt at doing
this, use the new py-choose-shell function.

One other thing this file now does: it attempts to add the proper
hooks to interpreter-mode-alist and auto-mode-alist if they aren't
already there.  Might help with Emacs users since that editor doesn't
come with python-mode by default.
1 file changed