Re: missing setbufline()?
Yegappan Lakshmanan wrote: On 10/23/06, Bram Moolenaar [EMAIL PROTECTED] wrote: 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. I tried to reproduce this problem using the new setbufline() function. The jumplist for the current buffer is not affected while changing the contents of another loaded buffer using the setbufline() function. Is there any specific sequence that needs to be followed to see this problem? The ' and ' marks are probably moved. Manual folds might be moved. I couldn't reproduce the above problems also. The manual folds and the visual area marks for the current buffer are not changed by setbufline(). There may also be redrawing problems. I didn't see any redraw problems. Are you referring to redraw problems in the current buffer or in the buffer that is being changed using setbufline()? The thing is that changes are made to another buffer while using the current window. This may change information in the current window that is wrong for when the buffer originally edited in it has been put back. I can't predict what exactly would go wrong or how to trigger that. The functions that are invoked are appended_lines_mark() and changed_bytes(). You probably need to try with the current buffer having more lines than the buffer being changed. -- Common sense is what tells you that the world is flat. /// 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///
Re: missing setbufline()?
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
Re: missing setbufline()?
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///
Re: missing setbufline()?
Hi Hari, On 10/22/06, Yegappan Lakshmanan [EMAIL PROTECTED] wrote: Hi Hari, 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. With this patch you should not see the above mentioned problems with undo. Let me know if you see any other problems in using the setbufline() function with this patch. If there are no problems, then I will send this to Bram for inclusion in a future Vim release. - Yegappan 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. - Yegappan
Re: missing setbufline()?
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///
missing setbufline()?
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? -- Thank you, Hari __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: missing setbufline()?
Hi Hari, 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
Re: missing setbufline()?
On Sun, 22 Oct 2006 at 6:20pm, Yegappan Lakshmanan wrote: Hi Hari, 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. -- Thanks, Hari __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
Re: missing setbufline()?
Hi Hari, 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. - Yegappan Index: src/eval.c === RCS file: /cvsroot/vim/vim7/src/eval.c,v retrieving revision 1.198 diff -c -p -r1.198 eval.c *** src/eval.c 17 Oct 2006 13:16:39 - 1.198 --- src/eval.c 23 Oct 2006 04:26:57 - *** static void f_getpos __ARGS((typval_T *a *** 531,536 --- 531,537 static void f_getqflist __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getreg __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getregtype __ARGS((typval_T *argvars, typval_T *rettv)); + static void f_gettabvar __ARGS((typval_T *argvars, typval_T *rettv)); static void f_gettabwinvar __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getwinposx __ARGS((typval_T *argvars, typval_T *rettv)); static void f_getwinposy __ARGS((typval_T *argvars, typval_T *rettv)); *** static void f_searchpairpos __ARGS((typv *** 611,616 --- 612,618 static void f_searchpos __ARGS((typval_T *argvars, typval_T *rettv)); static void f_server2client __ARGS((typval_T *argvars, typval_T *rettv)); static void f_serverlist __ARGS((typval_T *argvars, typval_T *rettv)); + static void f_setbufline __ARGS((typval_T *argvars, typval_T *rettv)); static void f_setbufvar __ARGS((typval_T *argvars, typval_T *rettv)); static void f_setcmdpos __ARGS((typval_T *argvars, typval_T *rettv)); static void f_setline __ARGS((typval_T *argvars, typval_T *rettv)); *** static void f_setloclist __ARGS((typval_ *** 618,623 --- 620,626 static void f_setpos __ARGS((typval_T *argvars, typval_T *rettv)); static void f_setqflist __ARGS((typval_T *argvars, typval_T *rettv)); static void f_setreg __ARGS((typval_T *argvars, typval_T *rettv)); + static void f_settabvar __ARGS((typval_T *argvars, typval_T *rettv)); static void f_settabwinvar __ARGS((typval_T *argvars, typval_T *rettv)); static void f_setwinvar __ARGS((typval_T *argvars, typval_T *rettv)); static void f_shellescape __ARGS((typval_T *argvars, typval_T *rettv)); *** static void getwinvar __ARGS((typval_T * *** 740,745 --- 743,749 static int searchpair_cmn __ARGS((typval_T *argvars, pos_T *match_pos)); static int search_cmn __ARGS((typval_T *argvars, pos_T *match_pos, int *flagsp)); static void setwinvar __ARGS((typval_T *argvars, typval_T *rettv, int off)); + static void set_buffer_lines __ARGS((buf_T *buf, linenr_T lnum, char_u *line, list_T *l, typval_T *rettv)); /* Character used as separated in autoload function/variable names. */ #define AUTOLOAD_CHAR '#' *** static struct fst *** 7077,7082 --- 7081,7087 {getqflist, 0, 0, f_getqflist}, {getreg, 0, 2, f_getreg}, {getregtype, 0, 1, f_getregtype}, + {gettabvar, 2, 2, f_gettabvar}, {gettabwinvar, 3, 3, f_gettabwinvar}, {getwinposx, 0, 0, f_getwinposx}, {getwinposy, 0, 0, f_getwinposy}, *** static struct fst *** 7159,7164 --- 7164,7170 {searchpos, 1, 3, f_searchpos}, {server2client, 2, 2, f_server2client}, {serverlist, 0, 0, f_serverlist}, + {setbufline, 3, 3, f_setbufline}, {setbufvar, 3, 3, f_setbufvar}, {setcmdpos, 1, 1, f_setcmdpos}, {setline, 2, 2, f_setline}, *** static struct fst *** 7166,7171 --- 7172,7178 {setpos, 2, 2, f_setpos}, {setqflist, 1, 2, f_setqflist}, {setreg, 2, 3, f_setreg}, + {settabvar, 3, 3, f_settabvar}, {settabwinvar, 4, 4, f_settabwinvar}, {setwinvar, 3, 3, f_setwinvar}, {shellescape, 1, 1, f_shellescape}, *** f_getregtype(argvars,