prepending a custom list of paths to counsel-locate results list #373

Closed
drorbemet opened this Issue Jan 31, 2016 · 3 comments

Projects

None yet

2 participants

@drorbemet

I would like to prepend a list of special files to the results of counsel-locate each time just before it is called. So that they are up to date and included and filtered by the entered search pattern and appear at the top if they match.
How would a proper recipe for that look like?

I found something about virtual-buffers here but I am still not sure how to go about this in general.

@abo-abo abo-abo added a commit that closed this issue Feb 1, 2016
@abo-abo Allow to compose static collections with `counsel--async-command'
* ivy.el (ivy--sources-list): New defvar.
(ivy-set-sources): New defun that sets `ivy--sources-list'
(ivy--extra-candidates): New defvar.
(ivy-read): Use `ivy--sources-list' to set `ivy--extra-candidates' - a
list that composes itself with `ivy--all-candidates'.
(ivy--set-candidates): New defun.

Example - stack `recentf' on top of `counsel-locate':

    (defun small-test ()
      (cl-subseq recentf-list 0 10))

    (ivy-set-sources
     'counsel-locate
     '((small-test)
       (original-source)))

Here, (original-source) represents the async candidates of
`counsel-locate'. All extra sources are static - each function is called
once to generate a list of strings, which will be filtered later.

The order matters, so you can have e.g.:

    (ivy-set-sources
     'counsel-locate
     '((original-source)
       (small-test)))

Fixes #373
6817381
@abo-abo abo-abo closed this in 6817381 Feb 1, 2016
@abo-abo
Owner
abo-abo commented Feb 1, 2016

Thanks, have a look at commit msg for description of use.

@drorbemet

Great, this is what I had in mind. Thanks.

@abo-abo
Owner
abo-abo commented Feb 2, 2016

Feel free to add a comment to the wiki if you have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment