Ramel Eshed wrote:

> Hi All,
> 
> Thanks to Bram and his recent work on channels, I have a preliminary
> version of an asynchronous grep plugin which lets you work with the
> available results while grep is still running. I would like to take
> advantage of this relatively short script to raise some issues and
> thoughts I have. The plugin can be found at
> https://github.com/ramele/agrep.
> 
> My original idea was to use the quickfix list and add each match to it
> from the out callback. I had some issues with it, so temporarily (I
> hope..) I’m using my own window to display the results (“agrep
> window”). This is the default now and it should demonstrate what this
> plugin should do eventually. In order to reproduce the quickfix
> issues, you'll need to tell agrep to use quickfix list instead of
> agrep window (:let qgrep_use_qf=1). You can install the plugin as is
> or load it with $vim -u NONE -N -S <path to agrep.vim>

Several of the problems have been fixed.  Especially appending to the
quickfix list should now be much faster.

Let us know if you still encounter problems.

> 3. Changing other buffers:
> As far as I know, there is no nice way to change buffers other than
> the current one. There is the getbufline() function, but the symmetry
> is broken since there is no setbufline(). I found a discussion about
> this from 10 years ago
> (http://vim.1045645.n5.nabble.com/missing-setbufline-td1155970.html)
> but I'm not sure if Bram added it to his TODO list or not. In this
> script I'm using the move_to_buf() and back_from_buf() functions. The
> problems with this approach are:
> 
> - It is ugly.
> - Poor performance (it is slow, you can see the cursor jumping between
> windows, it can cause Vim to hang).
> - Difficult to change hidden buffers or buffers in other tab pages.
> - Is has side effects - It seems to break my undo tree and I'm sure
> that there are more.

This is actually difficult to do.  The internals of Vim only expect a
buffer to change when it's in a window.  Also when invoking
autocommands, which expect a valid buffer and window.  And undo expects
the buffer to be the current buffer.  This would be a lot of work to
change, and it's likely to introduce a few bugs.

> I'm not very much experienced with external plugins (like Python)
> which can change any buffer, but it seems that when using a channel
> with "out_io": "buffer" the performance is much better. Is it possible
> to implement such a function based on how it's done there?

Python uses switch_to_win_for_buf().  It doesn't work perfectly though.
Marks may be wrong and it may redraw the current window even though it
didn't change.


-- 
Micro$oft: where do you want to go today?
    Linux: where do you want to go tomorrow?
  FreeBSD: are you guys coming, or what?

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui