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.
There also have been bugs in this implementation. I don't know if there are any others, it does not appear to be used much. > > 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? OK, so you can. But this doesn't mean it actually works properly, without any undesired side effects. This code is only included optionally. For the main Vim code I'm more careful. -- >From "know your smileys": C=}>;*{)) Drunk, devilish chef with a toupee in an updraft, a mustache, and a double chin /// 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 ///