Swiper 0.3.0 is out, with ivy-mode.
22 Apr 2015This release packs more than 90 commits, which is quite a lot for me.
The most important part of this release is ivy-mode, which is a nice alternative to ido-mode or helm-mode.
I've mentioned it already in an earlier post,
I'll just review all the little details, changes and customizations here.
Important: remove the old ivy package
One important change related to MELPA is that the ivy package was merged into swiper package. So if you still have a stand-alone ivy package, you should delete it, or you'll get incompatibility problems.
Video Demo of counsel-git-grep
If you like videos, you can watch the this quick demo
which mostly shows off the new counsel-git-grep function.
Fixes
Add work-around for window-start being not current
From now on, you won't encounter some un-highlighted matches when your window is scrolled.
Make thing-at-point work
C-h v and C-h f should select thing-at-point properly.
Don't try to fontify huge buffers
It's a nice feature of swiper that everything in the minibuffer is fontified. However, this can cause a slowdown for buffers with x10000 lines. So this feature is automatically turned off for these large buffers.
Exclude a few modes from font locking
Some modes just misbehave when font-lock-ensure is called. Excluded:
org-agenda-modedired-mode
New Features
ivy-mode: complete everything with Ivy
ivy-mode uses swiper's approach to completion for almost all completion in Emacs, like:
execute-extended-commandpackage-installfind-file
See the wiki page for the details on the key bindings related to ivy-mode, which are especially important to know for find-file. Also see the intro video.
New Counsel functions
counsel-describe-variable- replacement for C-h v.counsel-describe-function- replacement for C-h f.counsel-info-lookup-symbol- just a wrapper aroundinfo-lookup-symbol, you get the same behavior by just callinginfo-lookup-symbolwithivy-modeon.counsel-unicode-char- replacement forucs-insert.
counsel-git-grep
This is a really cool command for grepping at once all the files in your current git repository. For smaller repositories (<20000) lines, ivy handles the completion by itself. For larger repositories, it defers the work to git grep. It works really well for the Emacs repo with its 3,000,000 lines, especially if you're using Emacs 25 (from emacs-snapshot or self-built).
This function makes use of C-M-n and C-M-p bindings, which switch between candidates without exiting the minibuffer. Also, they highlight the current candidate with the swiper faces. You can think of this command as multi-swiper.
Even for very large repos, it will always display the amount of matches correctly. Also note that swiper-style regex is used here (spaces are wild), and the case is ignored.
The arrows can take numeric arguments
C-n / C-p, C-s / C-r, and C-M-n / C-M-p can all take numeric args, e.g. M-5 or C-u.
Add a recenter binding
C-l will recenter the window in which swiper was called.
Look up Ivy key bindings with C-h m
While in the minibuffer, press C-h m to see the active modes. Ivy also has a paragraph with its bindings.
Use C-v and M-v to scroll
You can use these bindings to speed up your minibuffer scrolling.
Allow C-. to jump-to-definition
For counsel-describe-variable and counsel-describe-function:
- pressing C-m will actually describe the current candidate.
- pressing C-. will instead jump to definition of the the current candidate.
This is very useful for me, I jump to definitions more often that describe.
Bind arrows
The actual arrow keys are also bound to the corresponding Emacs arrows.
Add a way to exit ignoring the candidates
If your current input matches a candidate, C-m and C-j will exit with that candidate. If you want to exit with your exact input instead, press C-u C-j. This is very useful for creating new files and directories.
Use M-q to toggle regexp-quote
This can be useful while completing file names (with a lot of dots). Pressing M-q toggles between regex and non-regex matching.
Customize ivy-re-builders-alist
This is pretty intricate, look up the variable to see the details. In short, you can use this to apply `regexp-quote' for some types of completion if you want.
Customize what to do on DEL error
The standard behavior on a DEL error (usually empty minibuffer) is to exit the minibuffer. I like this behavior, since it's similar to the behavior to fixing wrongly typed chars: only in this case DEL "fixes" a wrongly typed command.
But if you want to customize it, just set ivy-on-del-error-function to something other than minibuffer-keyboard-quit.
Customize ivy-extra-directories
Customize this if you don't want to see ../ and ./ while completing file names.
Customize ivy-sort-functions-alist
Use this variable to customize sorting, depending on what you're completing. For example:
(setq ivy-sort-functions-alist
'((read-file-name-internal . ivy-sort-file-function-default)
(internal-complete-buffer . nil)
(counsel-git-grep-function . nil)
(t . string-lessp)))
Customize ivy-subdir-face
While completing file names, the directories will use ivy-subdir-face.
Outro
Big thanks to all who contributed, especially @tsdh.