Hi,

2013/6/1 Sat 3:49:45 UTC+9 Bram Moolenaar wrote:
> Marc Weber wrote:
> 
> > There are two important problems with python support:
> > 1) you still have to use .viml in order to load python
> > 2) when using python its you having to remember which python to use despite
> >   most codes may work with python and python3 interpreter.
> >   Using the same (only one) interpreter is very important, because
> >   many vims will only support one, and loading both is slower
> > 
> > So this patch
> > - introduces the the option loadpyplugins, which is disabled by default
> >   like loadplugins it tells vim to load plugin/*.py files
> > - Special commands like "# requires python 2.x" can be used to force Vim 
> > using
> >   pyfile or py3file. If such a comment is missing the pythonx python 
> > version setting
> >   is used to decide upon which interpreter to use. Obviously this setting
> >   should be set early in your .vimrc and not be touched again
> >   Likewise there are :pyxfile :pydo :pythonx :pyx pyxeval() to run python 
> > code
> >   depending on 'pythonx' setting.
> > - adds some of the commands to python.vim syntax file
> 
> I think it's a good idea to help people write portable Python plugins.
> We want to avoid that every plugin has to be written twice.
> 
> Not everything is compatible between Python 2 and 3 though.  Is there a
> way to do:
> 
>       if python3:
>           do-it-this-way
>       else:
>           do-it-that-way
> 
> Then :pyx would really work.  Is that possible without getting errors
> for some code that works only in one versin?
> 
> In the patch the docs have the section "Python 3" twice.
> 
> The default for 'pythonx' should be zero when build with both Python 2
> and 3.  Then the first Python command sets it.
> 
> Should be called 'pythonversion' actually.

Three years has past from this discussion but still I think that the pyx*
commands and functions are useful.  So I have updated Marc's patch for Vim 8.0.
Changes from the original patch are:

* Update for the latest code base.
* Update documents.
* Fix coding style.
* Add has('pythonx').
* Rename the 'pythonx' option to 'pythonxversion'.
* Make Python 3 as the default when build with both Python 2 and 3.
  Ubuntu 16.04 and some other distributions already make Python 3 as the
  default. It's good time to set Python 3 as the default.
* Support shebangs with :pyxfile.
* Respects the 'modelines' option when checking pythonx special comments with
  :pyxfile.
* Remove the 'loadpyplugins' option.
  There was no consensus about this option.
* Add checking when setting the 'pythonxversion' option.
  Accept only 2 and 3.

Please check this:
https://bitbucket.org/k_takata/vim-ktakata-mq/src/c861d978882ce218b9d8292797ffd0569a60094a/pythonx.patch?fileviewer=file-view-default
(Tests are not available yet.)

This would be most useful when used with pythonx-directory.
(:help pythonx-directory)

Regards,
Ken Takata

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui