Xavier de Gaye wrote:

> >> On Wed, May 15, 2013 at 8:51 PM, Bram Moolenaar wrote:
> >> >> >":python os.chdir('/tmp')" makes short buffer names invalid. (Xavier 
> >> >> >de Gaye)
> >> >> >Check directory and call shorten_fnames()?
> >> >>
> >> >> Probably not only the python problem.
> >> >
> >> > I wonder if there is a hook inside Python, so that we can do the
> >> > equivalent of ":cd" in Vim, handling the side effects.
> >>
> >>
> >> Indeed, a hook to chdir can be made with the following code in
> >> a module named vim_hook:
> >>
> >> ########### vim_hook.py ###########
> >> import vim
> >> import os
> >>
> >> _chdir = os.chdir
> >>
> >> def chdir(path):
> >>     _chdir(path)
> >>     vim.command("cd " + path)
> >>
> >> os.chdir = chdir
> >> ###########
> >>
> >> This module is imported on vim startup with:
> >>
> >>     PyRun_SimpleString("import vim_hook");
> >>
> >>
> >> To test that this fixes os.chdir, run the following commands after
> >> having copied the above vim_hook.py file in the current directory:
> >>
> >>     :py3 import sys; sys.path[:1] = ['.']; import vim_hook
> >>     :py3 import os; os.chdir("/tmp")
> >
> > OK, but we want this to work without any commands being used in a
> > script.  It should be done when initalizing Python.
> 
> This is what I meant.
> 
> The attached patch does this.
> 
> A new directory named 'python' is added to the vim runtime files.
> This directory contains at the moment a _vim_python.py file that is
> imported when initalizing Python after the python directory pathname
> has been added to sys.path.
> 
> _vim_python.py is meant to contain (or to import the other components
> of) the python part of the vim-python interface.

Interesting.  So we would have a $VIMRUNTIME/python directory and we can
put Python scripts there that we include with the distribution.

I'm sure it is only a small step that users will ask to have a python
directory in ~/.vim/python.  Or more general, using 'runtimepath'.

Then a plugin does not require to have its Python code in between a
:python << EOF and EOF.  That would be a lot nicer, right?

What do others think?

-- 
BROTHER MAYNARD: Armaments Chapter Two Verses Nine to Twenty One.
ANOTHER MONK:    And St.  Attila raised his hand grenade up on high saying "O
                 Lord bless this thy hand grenade that with it thou mayest
                 blow thine enemies to tiny bits, in thy mercy. "and the Lord
                 did grin and people did feast upon the lambs and sloths and
                 carp and anchovies and orang-utans and breakfast cereals and
                 fruit bats and...
BROTHER MAYNARD: Skip a bit brother ...
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Raspunde prin e-mail lui