Nico Raffo wrote:

> Due to a syntax change between python 2 and python 3, there is no way
> to insert a new line at an arbitrary line number into a buffer using
> the python interface without using undocumented parameters in the
> buffer.append() method.
> 
> In the existing python 2 interface, the way to insert a line according
> to the documentation is:
> 
> :py b[n:n] = ["a new line at line number n"]
> 
> In python 3 you are no longer allowed to assign to a slice, so this
> doesn't work anymore.
> 
> There is an undocumented second parameter to buffer.append() which
> allows you to add a line number where the new line should be added.
> However this diverges from the standard set of python list methods. If
> the vim module wants to emulate a python list, it should have
> buffer.insert(n, "new line at n"). Otherwise the extra param in
> append() should be documented.
> 
> I'll throw in a patch for the new buffer.insert() method if people
> think it's a good idea.

Why not document the extra argument to append()?

        :py vim.current.buffer.append(["foobar"], 239)

Seems to work as expected.

-- 
A special law prohibits unmarried women from parachuting on Sunday or she
shall risk arrest, fine, and/or jailing.
                [real standing law in Florida, United States of America]

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.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

Raspunde prin e-mail lui