template reads default python

Bug #827949 reported by Andreas Roehler
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-mode.el
Fix Released
Low
Andreas Roehler

Bug Description

Gennady N. Uraltsev (gennady-uraltsev) wrote 14 hours ago: #6
I think that the actual path of the [pj]ython executable should be parsed.

When reflecting Gennady's proposal, think a template inaugurating an empty Python edit buffer,
could look for and insert a shebang according to the default environment.

Opinions?

Cheers,

Andreas

Changed in python-mode:
importance: Undecided → Low
Revision history for this message
Gennady N. Uraltsev (gennady-uraltsev) wrote :

I think it is a very good idea. First I think we should clean up the shebang detection and parsing functions, so at least the process of generating the template should be invertible. After that it should be easy. I am starting to work on this by adding small snippets. For example the py-shebang-startstring should be set in accordance with the real location of the "env" executable

Revision history for this message
Gennady N. Uraltsev (gennady-uraltsev) wrote :

In the referenced branch I added a runtime detection mechanism for the location of "env".

From the commit message:

>Instead of having hardcoded py-shebang-startstring (used to generate a
>shebang when needed) implemented a simple function to parse shell
>command "which env", in case of failure falling back to the hardcoded
>path. This procedure is used ONLY to determine default value prior to
>customization.

I tested it and it seams to work. py-shebang-startstring is used for generation of shebangs in some improbable circumstances. I think it is right that as a default it should depend on the actual position of the "env" executable in the user's environment. If by any case, in some strange configuration the autodetection with "which" fails it is always possible to customize this variable manually as it is a "(defcustom .. "

Please review this code and tell me what you think of it. I would like very much to work a bit on some functions for parsing and generation of template files (shebangs etc), without touching the actual working code for now.

I also think there is something wrong with the function that determines the version of the currently used interpreter. I will investigate and post a bug report...

Changed in python-mode:
assignee: nobody → Andreas Roehler (a-roehler)
Changed in python-mode:
status: New → Fix Committed
Revision history for this message
Andreas Roehler (a-roehler) wrote :

implemented on base of `type' - command.

Not sure if best solution.

Changed in python-mode:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.