On Thu, Jul 20, 2006 at 11:07:48AM -0700, John Reese wrote:
> 
> Actually, you can't actually tell that from the import line.  blag
> could also be a package (i.e. directory) containing a module Bok,
> defined in a file called Bok.py.  That's what I had in mind.
> 
> The following is an example of the kind of import line I'm talking
> about, which imports a module from a package:
> 
> >>>from xml.dom import domreg
> >>># effectively the same as 'import xml.dom.domreg as domreg'
> >>># but the from ... import ... form is much more common
> >>>domreg
> <module 'xml.dom.domreg' from '/...'>
> 
> The clause after "from" is the directory (after includeexpr turns the
> dots into slashes), and the clause after "import" is the filename
> (after .py from suffixesadd is added), and I guess all I'm saying is I
> think having directory name and filename be in separate words might
> break assumptions in the *include-search* mechanism.
> 
> I can add the base directory plus **/ to 'path', but that's a lot
> slower than just adding the base directory and configuring the
> include-search mechanism to know how to join up the whole import line
> to get the relative path.
> 
> Anyway, at this point I feel like I should just go off and dink around
> for a while and see if I can get something to work.  Thanks for your
> help.

     Have you read

:help 'include'

carefully?  I think that what you want is something along the lines of

:let &l:include = '^\s*from\s\+\zs'

(untested).  Then, if I read the docs correctly, you should be able to
pass "xml.dom import domreg" to 'includeexpr'.  I suggest using
'includeexpr' to call a function, and putting all the conditionals and
substitute()'s in the function.

     Note that I use :let to avoid the problem of escaping back-slashes
in a :set command.  Then &l: has the same effect as :setlocal .

     If you get this to work, please send it to the maintainer of
ftplugin/python.vim .  I think others would like to use it, too.

HTH                                     --Benji Fisher

Reply via email to