Hi Bram,

On 10/23/06, Bram Moolenaar <[EMAIL PROTECTED]> wrote:

Yegappan Lakshmanan wrote:

> On 10/22/06, Hari Krishna Dara <[EMAIL PROTECTED]> wrote:
> > > On 10/22/06, Hari Krishna Dara <[EMAIL PROTECTED]> wrote:
> > > >
> > > > I see functions for creating new unlisted buffers (bufnr() with {create}
> > > > option), and for reading the lines from the buffer using getbufline(),
> > > > all without having to change the current buffer, but I don't see a
> > > > setbufline() so there is no way to set the lines without having to
> > > > switch to it. Is there a reason to leave this circle incomplete?
> > > >
> > >
> > > Yes. I had a patch for the setbufline() function last year. There were
> > > several problems with it. So it was not included in Vim7 and only
> > > the getbufline() function was included.
> > >
> > > The setbufline() function worked only for loaded buffers. The undo
> > > history was not updated correctly.
> > >
> > > But I agree that it will be good to have the setbufline() function.
> > >
> > > - Yegappan
> >
> > Nice, so it will be included at some point after resolving these issues.
> >
>
> You can try the attached patch against the latest Vim7 sources.
> The syntax of the new function is:
>
>             setbufline({expr}, {lnum}, {line})
>
> where, {expr} specifies the loaded buffer name/number, {lnum} specifies
> a valid line number in that buffer and {line} is either a single line
> or a List of lines.
>
> Note. The patch also includes the new gettabvar() and settabvar()
> functions.

It looks like after this patch, if you change lines in another buffer
some marks in the current window will be moved.  Especially the
jumplist, perhaps setting cmdmod.lockmarks would help.  The '< and '>
marks are probably moved.  Manual folds might be moved.  There may also
be redrawing problems.


The setbufline() implementation is similar to the one used in
if_perl.xs (Set) , if_python.c (SetBufferLine), if_ruby.c (set_buffer_line)
if_mzsch.c (set_buffer_line_list) and if_tcl.c (BUF_SET) interface
files. These problems should also be seen with those
interfaces also.


This needs a test in src/testdir.  And documentation, of course.


Will add the doc updates.


I'm very careful with including something like this.  Currently there is
no code that changes another buffer.  It could break more than you
expect.


You can't change the buffer contents with the Perl/Python/Tcl/Ruby
interfaces?

- Yegappan

Reply via email to