Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible new feature: append candidates periodically #340

Closed
justbur opened this issue Jan 7, 2016 · 5 comments
Closed

possible new feature: append candidates periodically #340

justbur opened this issue Jan 7, 2016 · 5 comments

Comments

@justbur
Copy link
Contributor

justbur commented Jan 7, 2016

Using counsel-ag, if I type a string that's pretty common (~5k-10k candidates maybe) I see the collected notice at the bottom for a few seconds and then the minibuffer fills with candidates when the process is done. Obviously, I need to refine my search. I know that I need to refine it once that counter starts getting large, but I think it would be helpful to see the types of matches I'm getting right away.

So what I was thinking is what if you could configure ivy-read to collect all of the candidates but to start showing them as soon as you reach some number (I don't know 500 or so). That way you get visual feedback right away showing all of the bad matches you're getting and you can start thinking about how you want to refine the search immediately.

This question is inspired by how helm-ag works. Somehow helm-ag shows matches immediately, but keeps collecting remaining ones in the background.

@myrjola
Copy link

myrjola commented Jan 10, 2016

I second this proposal. ag can take quite a while to search larger projects e.g. the Linux kernel, so showing some intermediate results would be very helpful.

@zilongshanren
Copy link

+1 for the proposal

@abo-abo
Copy link
Owner

abo-abo commented Jan 12, 2016

Please check. The candidate list should refresh every 0.5s and display ++ next to the number of candidates.

@myrjola
Copy link

myrjola commented Jan 12, 2016

Wonderful work @abo-abo! Works like a charm.

@justbur
Copy link
Contributor Author

justbur commented Jan 12, 2016

Thanks @abo-abo I haven't played with it too much, but it's not as smooth as I would have hoped on my computer.

My first thought for an alternative was something like this.

(defvar counsel--async-lines 0)
(defvar counsel--async-line-threshold 1000)

(defun counsel--async-filter (process str)
  "Receive from PROCESS the output STR."
  (when (< counsel--async-lines counsel--async-line-threshold)
    (with-current-buffer (process-buffer process)
      (insert str)
      (setq counsel--async-lines
            (count-matches "\n" (point-min) (point-max)))
      (when (< counsel--async-lines counsel--async-line-threshold)
        (goto-char (point-min))
        (setq ivy--all-candidates
              (split-string (buffer-string) "\n" t))))
    (let ((ivy--prompt (format "%d++ ag:" counsel--async-lines)))
      (ivy--insert-minibuffer
       (ivy--format ivy--all-candidates)))))

I know I need to do the paperwork now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants