A new Swiper demo on Youtube
19 Mar 2015Youtube video
Today, I've fixed a few bugs in both swiper and ivy
.
Finally, the number of candidates display has also been added. You can see the whole thing in the
one minute video demo.
Here are the bindings that I'm using:
(global-set-key "\C-r" 'swiper)
(global-set-key "\C-s" 'swiper)
Integration tests
I've also added some integration tests,
if you're interested. I didn't know how to do exactly this type of testing before (when there's input from minibuffer).
Turns out, it's pretty easy to do using execute-kbd-macro
:
(require 'ert)
(defvar ivy-expr nil
"Holds a test expression to evaluate with `ivy-eval'.")
(defvar ivy-result nil
"Holds the eval result of `ivy-expr' by `ivy-eval'.")
(defun ivy-eval ()
"Evaluate `ivy-expr'."
(interactive)
(setq ivy-result (eval ivy-expr)))
(global-set-key (kbd "C-c e") 'ivy-eval)
(defun ivy-with (expr keys)
"Evaluate EXPR followed by KEYS."
(let ((ivy-expr expr))
(execute-kbd-macro
(vconcat (kbd "C-c e")
(kbd keys)))
ivy-result))
(ert-deftest ivy-read ()
(should (equal
(ivy-read "pattern: " nil)
nil))
(should (equal
(ivy-read "pattern: " '("42"))
"42"))
(should (equal
(ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
"C-m")
"blue"))
(should (equal
(ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
"y C-m")
"yellow"))
(should (equal
(ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
"y DEL b C-m")
"blue"))
(should (equal
(ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
"z C-m")
nil)))
Outro
Give the package a try, if you haven't yet. You can get it from MELPA.