Complete stuff with Counsel
09 Apr 2015Intro
If you like my package swiper, I'm sure you'll also like counsel. It lives in the same repository, but you can install it separately from MELPA.
Counsel uses ivy
- the same method as swiper
to:
- Complete Elisp at point with
counsel-el
. - Complete Clojure at point with
counsel-clj
. - Open a git-managed file with
counsel-git
. - Describe an Elisp variable with
counsel-describe-variable
. - Describe an Elisp function with
counsel-describe-function
. - Look up an Elisp symbol in the info with
counsel-info-lookup-symbol
. - Insert a Unicode character at point with
counsel-unicode-char
.
Below, I'll describe the functions that I added just today.
counsel-describe-function
This is just a replacement for describe-function
:
As you can see, regular expressions work here as well. The
space-splitting behavior is the same as in swiper
, so don't expect
to be able to match a single space: spaces are wild.
counsel-describe-variable
This is just a replacement for describe-variable
:
Well, actually I've used ido-mode
with flx
matching for these two
functions before. In my experience, ivy
handles much better:
- you are in charge of which regex you're searching for
- you see the candidate count
- no crazy wrap-around candidate cycling
And it works faster, too.
Here are my bindings:
(global-set-key (kbd "<f1> f") 'counsel-describe-function)
(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
counsel-info-lookup-symbol
I don't use this one too often, but it's nice to have the option:
(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
counsel-unicode-char
At around 40000 candidates, ivy
starts to feel clunky (around 0.1s
display delay). Unfortunately, I don't really see a way around this,
except using tricks like while-no-input
, which didn't work right
when I tried it earlier. It would be really cool to do the completion
in another thread, but alas.
Outro
Give the new functions a try. I think ivy
can become a viable ido
replacement, at least it has done so for me: the only ido
functions
that I'm still using are ido-switch-buffer
and ido-find-file
.
Also, if you're using projectile
, you can use ivy
completion for it:
(setq projectile-completion-system 'ivy)