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.

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

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.

-- 
The primary purpose of the DATA statement is to give names to constants;
instead of referring to pi as 3.141592653589793 at every appearance, the
variable PI can be given that value with a DATA statement and used instead
of the longer form of the constant.  This also simplifies modifying the
program, should the value of pi change.
        -- FORTRAN manual for Xerox Computers

 /// 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    ///

Reply via email to