emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/swiper 6c9285d: Rename swiper -> ivy


From: Stefan Monnier
Subject: [elpa] externals/swiper 6c9285d: Rename swiper -> ivy
Date: Sun, 29 Nov 2020 23:12:06 -0500 (EST)

branch: externals/swiper
commit 6c9285d09bca92a00c7ac8e669affad1760c1fc2
Author: Oleh Krehel <ohwoeowho@gmail.com>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Rename swiper -> ivy
---
 .travis.yml       |   12 -
 Makefile          |   16 -
 README.md         |   51 --
 colir.el          |  102 ---
 counsel.el        | 1301 ----------------------------
 doc/Changelog.org |  616 --------------
 doc/ivy.org       |  476 -----------
 doc/ivy.texi      |  591 -------------
 doc/style.css     |  107 ---
 ivy-hydra.el      |   90 --
 ivy-test.el       |  140 ---
 ivy.el            | 2445 -----------------------------------------------------
 12 files changed, 5947 deletions(-)

diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 1f5dbc7..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-language: emacs-lisp
-env:
-  matrix:
-    - EMACS=emacs24
-
-before_install:
-  - sudo add-apt-repository -y ppa:cassou/emacs
-  - sudo apt-get update -qq
-  - sudo apt-get install -qq $EMACS
-
-script:
-  - make test
diff --git a/Makefile b/Makefile
deleted file mode 100644
index b3857c9..0000000
--- a/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-emacs ?= emacs
-
-LOAD = -l colir.el -l ivy.el -l swiper.el
-
-.PHONY: all compile clean
-
-all: test
-
-test:
-       $(emacs) -batch $(LOAD) -l ivy-test.el -f ert-run-tests-batch-and-exit
-
-compile:
-       $(emacs) -batch $(LOAD) --eval "(mapc #'byte-compile-file '(\"ivy.el\" 
\"swiper.el\" \"counsel.el\"))"
-
-clean:
-       rm -f *.elc
diff --git a/README.md b/README.md
deleted file mode 100644
index 0d80f8d..0000000
--- a/README.md
+++ /dev/null
@@ -1,51 +0,0 @@
-[![Build 
Status](https://travis-ci.org/abo-abo/swiper.svg?branch=master)](https://travis-ci.org/abo-abo/swiper)
-
-## Swiper
-
-Package for GNU Emacs that gives you an overview as you search for a regex
-
-![swiper.png](http://oremacs.com/download/swiper.png)
-
-The package uses the `ivy` back end for the overview, see also
-[swiper-helm](https://github.com/abo-abo/swiper-helm).
-
-## Screenshots
-
-![ivy-swiper-1.png](http://oremacs.com/download/ivy-swiper-1.png)
-
-There's also a ten minute [video 
demo](https://www.youtube.com/watch?v=VvnJQpTFVDc).
-
-## Ivy
-
-Ivy is a generic completion method for Emacs, similar to
-`icomplete-mode`. It aims to be more efficient, more simple, and more
-pleasant to use than the alternatives. It's also highly customizable
-and very small.
-
-To try it, just call <kbd>M-x</kbd> `ivy-mode`, and all generic
-completion, including file and buffer names, will be done with Ivy.
-
-## Installation
-
-You can install the package from MELPA / GNU ELPA.
-Here is some typical configuration:
-
-```elisp
-(ivy-mode 1)
-(setq ivy-use-virtual-buffers t)
-(global-set-key "\C-s" 'swiper)
-(global-set-key (kbd "C-c C-r") 'ivy-resume)
-(global-set-key (kbd "<f6>") 'ivy-resume)
-(global-set-key (kbd "M-x") 'counsel-M-x)
-(global-set-key (kbd "C-x C-f") 'counsel-find-file)
-(global-set-key (kbd "<f1> f") 'counsel-describe-function)
-(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
-(global-set-key (kbd "<f1> l") 'counsel-load-library)
-(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
-(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
-(global-set-key (kbd "C-c g") 'counsel-git)
-(global-set-key (kbd "C-c j") 'counsel-git-grep)
-(global-set-key (kbd "C-c k") 'counsel-ag)
-(global-set-key (kbd "C-x l") 'counsel-locate)
-(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
-```
diff --git a/colir.el b/colir.el
deleted file mode 100644
index e11ef7d..0000000
--- a/colir.el
+++ /dev/null
@@ -1,102 +0,0 @@
-;;; colir.el --- Color blending library -*- lexical-binding: t -*-
-
-;; Copyright (C) 2015  Free Software Foundation, Inc.
-
-;; Author: Oleh Krehel <ohwoeowho@gmail.com>
-
-;; This file is part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; For a full copy of the GNU General Public License
-;; see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; This package solves the problem of adding a face with a background
-;; to text which may already have a background.  In all conflicting
-;; areas, instead of choosing either the original or the new
-;; background face, their blended sum is used.
-;;
-;; The blend mode functions are taken from 
http://en.wikipedia.org/wiki/Blend_modes.
-
-;;; Code:
-
-(require 'color)
-
-(defcustom colir-compose-method 'colir-compose-alpha
-  "Select a method to compose two color channels."
-  :type '(choice
-          (const colir-compose-alpha)
-          (const colir-compose-overlay)
-          (const colir-compose-soft-light))
-  :group 'ivy)
-
-(defun colir-compose-soft-light (a b)
-  "Compose A and B channels."
-  (if (< b 0.5)
-      (+ (* 2 a b) (* a a (- 1 b b)))
-    (+ (* 2 a (- 1 b)) (* (sqrt a) (- (* 2 b) 1)))))
-
-(defun colir-compose-overlay (a b)
-  "Compose A and B channels."
-  (if (< a 0.5)
-      (* 2 a b)
-    (- 1 (* 2 (- 1 a) (- 1 b)))))
-
-(defun colir-compose-alpha (a b &optional alpha gamma)
-  "Compose A and B channels."
-  (setq alpha (or alpha 0.5))
-  (setq gamma (or gamma 2.2))
-  (+ (* (expt a gamma) alpha) (* (expt b gamma) (- 1 alpha))))
-
-(defun colir-blend (c1 c2)
-  "Blend the two colors C1 and C2 using `colir-compose-method'.
-C1 and C2 are triples of floats in [0.0 1.0] range."
-  (apply #'color-rgb-to-hex
-         (cl-mapcar
-          (if (eq (frame-parameter nil 'background-mode) 'dark)
-              ;; this method works nicely for dark themes
-              'colir-compose-soft-light
-            colir-compose-method)
-          c1 c2)))
-
-(defun colir-blend-face-background (start end face &optional object)
-  "Append to the face property of the text from START to END the face FACE.
-When the text already has a face with a non-plain background,
-blend it with the background of FACE.
-Optional argument OBJECT is the string or buffer containing the text.
-See also `font-lock-append-text-property'."
-  (let (next prev)
-    (while (/= start end)
-      (setq next (next-single-property-change start 'face object end)
-            prev (get-text-property start 'face object))
-      (when (listp prev)
-        (setq prev (cl-find-if #'atom prev)))
-      (if prev
-          (let ((background-prev (face-background prev)))
-            (progn
-              (put-text-property
-               start next 'face
-               (if background-prev
-                   (cons `(background-color
-                           . ,(colir-blend
-                               (color-name-to-rgb background-prev)
-                               (color-name-to-rgb (face-background face nil 
t))))
-                         prev)
-                 (list face prev))
-               object)))
-        (put-text-property start next 'face face object))
-      (setq start next))))
-
-(provide 'colir)
-
-;;; colir.el ends here
diff --git a/counsel.el b/counsel.el
deleted file mode 100644
index 9c86ec0..0000000
--- a/counsel.el
+++ /dev/null
@@ -1,1301 +0,0 @@
-;;; counsel.el --- Various completion functions using Ivy -*- lexical-binding: 
t -*-
-
-;; Copyright (C) 2015  Free Software Foundation, Inc.
-
-;; Author: Oleh Krehel <ohwoeowho@gmail.com>
-;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.1.0
-;; Package-Requires: ((emacs "24.1") (swiper "0.4.0"))
-;; Keywords: completion, matching
-
-;; This file is part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; For a full copy of the GNU General Public License
-;; see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; Just call one of the interactive functions in this file to complete
-;; the corresponding thing using `ivy'.
-;;
-;; Currently available: Elisp symbols, Clojure symbols, Git files.
-
-;;; Code:
-
-(require 'swiper)
-(require 'etags)
-
-(defvar counsel-completion-beg nil
-  "Completion bounds start.")
-
-(defvar counsel-completion-end nil
-  "Completion bounds end.")
-
-;;;###autoload
-(defun counsel-el ()
-  "Elisp completion at point."
-  (interactive)
-  (let* ((bnd (unless (and (looking-at ")")
-                           (eq (char-before) ?\())
-                (bounds-of-thing-at-point
-                 'symbol)))
-         (str (if bnd
-                  (buffer-substring-no-properties
-                   (car bnd)
-                   (cdr bnd))
-                ""))
-         (ivy-height 7)
-         (funp (eq (char-before (car bnd)) ?\())
-         symbol-names)
-    (if bnd
-        (progn
-          (setq counsel-completion-beg
-                (move-marker (make-marker) (car bnd)))
-          (setq counsel-completion-end
-                (move-marker (make-marker) (cdr bnd))))
-      (setq counsel-completion-beg nil)
-      (setq counsel-completion-end nil))
-    (if (string= str "")
-        (mapatoms
-         (lambda (x)
-           (when (symbolp x)
-             (push (symbol-name x) symbol-names))))
-      (setq symbol-names
-            (all-completions str obarray
-                             (and funp
-                                  (lambda (x)
-                                    (or (functionp x)
-                                        (macrop x)
-                                        (special-form-p x)))))))
-    (ivy-read "Symbol name: " symbol-names
-              :predicate (and funp #'functionp)
-              :initial-input str
-              :action #'counsel--el-action)))
-
-(declare-function slime-symbol-start-pos "ext:slime")
-(declare-function slime-symbol-end-pos "ext:slime")
-(declare-function slime-contextual-completions "ext:slime-c-p-c")
-
-;;;###autoload
-(defun counsel-cl ()
-  "Common Lisp completion at point."
-  (interactive)
-  (setq counsel-completion-beg (slime-symbol-start-pos))
-  (setq counsel-completion-end (slime-symbol-end-pos))
-  (ivy-read "Symbol name: "
-            (car (slime-contextual-completions
-                  counsel-completion-beg
-                  counsel-completion-end))
-            :action #'counsel--el-action))
-
-(defun counsel--el-action (symbol)
-  "Insert SYMBOL, erasing the previous one."
-  (when (stringp symbol)
-    (with-ivy-window
-      (when counsel-completion-beg
-        (delete-region
-         counsel-completion-beg
-         counsel-completion-end))
-      (setq counsel-completion-beg
-            (move-marker (make-marker) (point)))
-      (insert symbol)
-      (setq counsel-completion-end
-            (move-marker (make-marker) (point))))))
-
-(declare-function deferred:sync! "ext:deferred")
-(declare-function jedi:complete-request "ext:jedi-core")
-(declare-function jedi:ac-direct-matches "ext:jedi")
-
-(defun counsel-jedi ()
-  "Python completion at point."
-  (interactive)
-  (let ((bnd (bounds-of-thing-at-point 'symbol)))
-    (if bnd
-        (progn
-          (setq counsel-completion-beg (car bnd))
-          (setq counsel-completion-end (cdr bnd)))
-      (setq counsel-completion-beg nil)
-      (setq counsel-completion-end nil)))
-  (deferred:sync!
-   (jedi:complete-request))
-  (ivy-read "Symbol name: " (jedi:ac-direct-matches)
-            :action #'counsel--py-action))
-
-(defun counsel--py-action (symbol)
-  "Insert SYMBOL, erasing the previous one."
-  (when (stringp symbol)
-    (with-ivy-window
-      (when counsel-completion-beg
-        (delete-region
-         counsel-completion-beg
-         counsel-completion-end))
-      (setq counsel-completion-beg
-            (move-marker (make-marker) (point)))
-      (insert symbol)
-      (setq counsel-completion-end
-            (move-marker (make-marker) (point)))
-      (when (equal (get-text-property 0 'symbol symbol) "f")
-        (insert "()")
-        (setq counsel-completion-end
-              (move-marker (make-marker) (point)))
-        (backward-char 1)))))
-
-(defvar counsel-describe-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-.") #'counsel-find-symbol)
-    (define-key map (kbd "C-,") #'counsel--info-lookup-symbol)
-    map))
-
-(defun counsel-find-symbol ()
-  "Jump to the definition of the current symbol."
-  (interactive)
-  (ivy-exit-with-action #'counsel--find-symbol))
-
-(defun counsel--info-lookup-symbol ()
-  "Lookup the current symbol in the info docs."
-  (interactive)
-  (ivy-exit-with-action #'counsel-info-lookup-symbol))
-
-(defun counsel--find-symbol (x)
-  "Find symbol definition that corresponds to string X."
-  (with-no-warnings
-    (ring-insert find-tag-marker-ring (point-marker)))
-  (let ((full-name (get-text-property 0 'full-name x)))
-    (if full-name
-        (find-library full-name)
-      (let ((sym (read x)))
-        (cond ((and (eq (ivy-state-caller ivy-last)
-                        'counsel-describe-variable)
-                    (boundp sym))
-               (find-variable sym))
-              ((fboundp sym)
-               (find-function sym))
-              ((boundp sym)
-               (find-variable sym))
-              ((or (featurep sym)
-                   (locate-library
-                    (prin1-to-string sym)))
-               (find-library
-                (prin1-to-string sym)))
-              (t
-               (error "Couldn't fild definition of %s"
-                      sym)))))))
-
-(defvar counsel-describe-symbol-history nil
-  "History for `counsel-describe-variable' and `counsel-describe-function'.")
-
-(defun counsel-symbol-at-point ()
-  "Return current symbol at point as a string."
-  (let ((s (thing-at-point 'symbol)))
-    (and (stringp s)
-         (if (string-match "\\`[`']?\\(.*?\\)'?\\'" s)
-             (match-string 1 s)
-           s))))
-
-(defun counsel-variable-list ()
-  "Return the list of all currently bound variables."
-  (let (cands)
-    (mapatoms
-     (lambda (vv)
-       (when (or (get vv 'variable-documentation)
-                 (and (boundp vv) (not (keywordp vv))))
-         (push (symbol-name vv) cands))))
-    cands))
-
-;;;###autoload
-(defun counsel-describe-variable ()
-  "Forward to `describe-variable'."
-  (interactive)
-  (let ((enable-recursive-minibuffers t))
-    (ivy-read
-     "Describe variable: "
-     (counsel-variable-list)
-     :keymap counsel-describe-map
-     :preselect (counsel-symbol-at-point)
-     :history 'counsel-describe-symbol-history
-     :require-match t
-     :sort t
-     :action (lambda (x)
-               (describe-variable
-                (intern x)))
-     :caller 'counsel-describe-variable)))
-
-(ivy-set-actions
- 'counsel-describe-variable
- '(("i" counsel-info-lookup-symbol "info")
-   ("d" counsel--find-symbol "definition")))
-
-(ivy-set-actions
- 'counsel-describe-function
- '(("i" counsel-info-lookup-symbol "info")
-   ("d" counsel--find-symbol "definition")))
-
-(ivy-set-actions
- 'counsel-M-x
- '(("d" counsel--find-symbol "definition")))
-
-;;;###autoload
-(defun counsel-describe-function ()
-  "Forward to `describe-function'."
-  (interactive)
-  (let ((enable-recursive-minibuffers t))
-    (ivy-read "Describe function: "
-              (let (cands)
-                (mapatoms
-                 (lambda (x)
-                   (when (fboundp x)
-                     (push (symbol-name x) cands))))
-                cands)
-              :keymap counsel-describe-map
-              :preselect (counsel-symbol-at-point)
-              :history 'counsel-describe-symbol-history
-              :require-match t
-              :sort t
-              :action (lambda (x)
-                        (describe-function
-                         (intern x)))
-              :caller 'counsel-describe-function)))
-
-(defvar info-lookup-mode)
-(declare-function info-lookup->completions "info-look")
-(declare-function info-lookup->mode-value "info-look")
-(declare-function info-lookup-select-mode "info-look")
-(declare-function info-lookup-change-mode "info-look")
-(declare-function info-lookup "info-look")
-
-;;;###autoload
-(defun counsel-info-lookup-symbol (symbol &optional mode)
-  "Forward to (`info-describe-symbol' SYMBOL MODE) with ivy completion."
-  (interactive
-   (progn
-     (require 'info-look)
-     (let* ((topic 'symbol)
-            (mode (cond (current-prefix-arg
-                         (info-lookup-change-mode topic))
-                        ((info-lookup->mode-value
-                          topic (info-lookup-select-mode))
-                         info-lookup-mode)
-                        ((info-lookup-change-mode topic))))
-            (completions (info-lookup->completions topic mode))
-            (enable-recursive-minibuffers t)
-            (value (ivy-read
-                    "Describe symbol: "
-                    (mapcar #'car completions)
-                    :sort t)))
-       (list value info-lookup-mode))))
-  (require 'info-look)
-  (info-lookup 'symbol symbol mode))
-
-(defvar counsel-unicode-char-history nil
-  "History for `counsel-unicode-char'.")
-
-;;;###autoload
-(defun counsel-unicode-char ()
-  "Insert a Unicode character at point."
-  (interactive)
-  (let ((minibuffer-allow-text-properties t))
-    (setq counsel-completion-beg (point))
-    (setq counsel-completion-end (point))
-    (ivy-read "Unicode name: "
-              (mapcar (lambda (x)
-                        (propertize
-                         (format "% -60s%c" (car x) (cdr x))
-                         'result (cdr x)))
-                      (ucs-names))
-              :action (lambda (char)
-                        (with-ivy-window
-                          (delete-region counsel-completion-beg 
counsel-completion-end)
-                          (setq counsel-completion-beg (point))
-                          (insert-char (get-text-property 0 'result char))
-                          (setq counsel-completion-end (point))))
-              :history 'counsel-unicode-char-history)))
-
-(declare-function cider-sync-request:complete "ext:cider-client")
-;;;###autoload
-(defun counsel-clj ()
-  "Clojure completion at point."
-  (interactive)
-  (counsel--generic
-   (lambda (str)
-     (mapcar
-      #'cl-caddr
-      (cider-sync-request:complete str ":same")))))
-
-;;;###autoload
-(defun counsel-git ()
-  "Find file in the current Git repository."
-  (interactive)
-  (let* ((default-directory (locate-dominating-file
-                             default-directory ".git"))
-         (cands (split-string
-                 (shell-command-to-string
-                  "git ls-files --full-name --")
-                 "\n"
-                 t))
-         (action `(lambda (x)
-                    (let ((default-directory ,default-directory))
-                      (find-file x)))))
-    (ivy-read "Find file: " cands
-              :action action)))
-
-(defvar counsel--git-grep-dir nil
-  "Store the base git directory.")
-
-(defvar counsel--git-grep-count nil
-  "Store the line count in current repository.")
-
-(defun counsel-more-chars (n)
-  "Return two fake candidates prompting for at least N input."
-  (list ""
-        (format "%d chars more" (- n (length ivy-text)))))
-
-(defvar counsel-git-grep-cmd "git --no-pager grep --full-name -n --no-color -i 
-e %S"
-  "Store the command for `counsel-git-grep'.")
-
-(defun counsel-git-grep-function (string &optional _pred &rest _unused)
-  "Grep in the current git repository for STRING."
-  (if (and (> counsel--git-grep-count 20000)
-           (< (length string) 3))
-      (counsel-more-chars 3)
-    (let* ((default-directory counsel--git-grep-dir)
-           (cmd (format counsel-git-grep-cmd
-                        (setq ivy--old-re (ivy--regex string t)))))
-      (if (<= counsel--git-grep-count 20000)
-          (split-string (shell-command-to-string cmd) "\n" t)
-        (counsel--gg-candidates (ivy--regex string))
-        nil))))
-
-(defvar counsel-git-grep-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-l") 'counsel-git-grep-recenter)
-    (define-key map (kbd "M-q") 'counsel-git-grep-query-replace)
-    map))
-
-(defun counsel-git-grep-query-replace ()
-  "Start `query-replace' with string to replace from last search string."
-  (interactive)
-  (if (null (window-minibuffer-p))
-      (user-error
-       "Should only be called in the minibuffer through 
`counsel-git-grep-map'")
-    (let* ((enable-recursive-minibuffers t)
-           (from (ivy--regex ivy-text))
-           (to (query-replace-read-to from "Query replace" t)))
-      (ivy-exit-with-action
-       (lambda (_)
-         (let (done-buffers)
-           (dolist (cand ivy--old-cands)
-             (when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" cand)
-               (with-ivy-window
-                 (let ((file-name (match-string-no-properties 1 cand)))
-                   (setq file-name (expand-file-name file-name 
counsel--git-grep-dir))
-                   (unless (member file-name done-buffers)
-                     (push file-name done-buffers)
-                     (find-file file-name)
-                     (goto-char (point-min)))
-                   (perform-replace from to t t nil)))))))))))
-
-(defun counsel-git-grep-recenter ()
-  (interactive)
-  (with-ivy-window
-    (counsel-git-grep-action ivy--current)
-    (recenter-top-bottom)))
-
-(defun counsel-git-grep-action (x)
-  (when (string-match "\\`\\(.*?\\):\\([0-9]+\\):\\(.*\\)\\'" x)
-    (with-ivy-window
-      (let ((file-name (match-string-no-properties 1 x))
-            (line-number (match-string-no-properties 2 x)))
-        (find-file (expand-file-name file-name counsel--git-grep-dir))
-        (goto-char (point-min))
-        (forward-line (1- (string-to-number line-number)))
-        (re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
-        (unless (eq ivy-exit 'done)
-          (swiper--cleanup)
-          (swiper--add-overlays (ivy--regex ivy-text)))))))
-
-(defvar counsel-git-grep-history nil
-  "History for `counsel-git-grep'.")
-
-(defvar counsel-git-grep-cmd-history
-  '("git --no-pager grep --full-name -n --no-color -i -e %S")
-  "History for `counsel-git-grep' shell commands.")
-
-;;;###autoload
-(defun counsel-git-grep (&optional cmd initial-input)
-  "Grep for a string in the current git repository.
-When CMD is a string, use it as a \"git grep\" command.
-When CMD is non-nil, prompt for a specific \"git grep\" command.
-INITIAL-INPUT can be given as the initial minibuffer input."
-  (interactive "P")
-  (cond
-    ((stringp cmd)
-     (setq counsel-git-grep-cmd cmd))
-    (cmd
-     (setq counsel-git-grep-cmd
-           (ivy-read "cmd: " counsel-git-grep-cmd-history
-                     :history 'counsel-git-grep-cmd-history))
-     (setq counsel-git-grep-cmd-history
-           (delete-dups counsel-git-grep-cmd-history)))
-    (t
-     (setq counsel-git-grep-cmd "git --no-pager grep --full-name -n --no-color 
-i -e %S")))
-  (setq counsel--git-grep-dir
-        (locate-dominating-file default-directory ".git"))
-  (if (null counsel--git-grep-dir)
-      (error "Not in a git repository")
-    (setq counsel--git-grep-count (counsel--gg-count "" t))
-    (ivy-read "git grep: " 'counsel-git-grep-function
-              :initial-input initial-input
-              :matcher #'counsel-git-grep-matcher
-              :dynamic-collection (> counsel--git-grep-count 20000)
-              :keymap counsel-git-grep-map
-              :action #'counsel-git-grep-action
-              :unwind #'swiper--cleanup
-              :history 'counsel-git-grep-history
-              :caller 'counsel-git-grep)))
-
-(defcustom counsel-find-file-at-point nil
-  "When non-nil, add file-at-point to the list of candidates."
-  :type 'boolean
-  :group 'ivy)
-
-(declare-function ffap-guesser "ffap")
-
-(defvar counsel-find-file-map (make-sparse-keymap))
-
-;;;###autoload
-(defun counsel-find-file ()
-  "Forward to `find-file'."
-  (interactive)
-  (ivy-read "Find file: " 'read-file-name-internal
-            :matcher #'counsel--find-file-matcher
-            :action
-            (lambda (x)
-              (with-ivy-window
-                (find-file (expand-file-name x ivy--directory))))
-            :preselect (when counsel-find-file-at-point
-                         (require 'ffap)
-                         (ffap-guesser))
-            :require-match 'confirm-after-completion
-            :history 'file-name-history
-            :keymap counsel-find-file-map))
-
-(defcustom counsel-find-file-ignore-regexp nil
-  "A regexp of files to ignore while in `counsel-find-file'.
-These files are un-ignored if `ivy-text' matches them.
-The common way to show all files is to start `ivy-text' with a dot.
-Possible value: \"\\(?:\\`[#.]\\)\\|\\(?:[#~]\\'\\)\"."
-  :group 'ivy)
-
-(defun counsel--find-file-matcher (regexp candidates)
-  "Return REGEXP-matching CANDIDATES.
-Skip some dotfiles unless `ivy-text' requires them."
-  (let ((res (cl-remove-if-not
-              (lambda (x)
-                (string-match regexp x))
-              candidates)))
-    (if (or (null counsel-find-file-ignore-regexp)
-            (string-match counsel-find-file-ignore-regexp ivy-text))
-        res
-      (cl-remove-if
-       (lambda (x)
-         (string-match counsel-find-file-ignore-regexp x))
-       res))))
-
-(defun counsel-git-grep-matcher (regexp candidates)
-  (or (and (equal regexp ivy--old-re)
-           ivy--old-cands)
-      (prog1
-          (setq ivy--old-cands
-                (cl-remove-if-not
-                 (lambda (x)
-                   (ignore-errors
-                     (when (string-match "^[^:]+:[^:]+:" x)
-                       (setq x (substring x (match-end 0)))
-                       (if (stringp regexp)
-                           (string-match regexp x)
-                         (let ((res t))
-                           (dolist (re regexp)
-                             (setq res
-                                   (and res
-                                        (ignore-errors
-                                          (if (cdr re)
-                                              (string-match (car re) x)
-                                            (not (string-match (car re) 
x)))))))
-                           res)))))
-                 candidates))
-        (setq ivy--old-re regexp))))
-
-(defvar counsel--async-time nil
-  "Store the time when a new process was started.
-Or the time of the last minibuffer update.")
-
-(defun counsel--async-command (cmd)
-  (let* ((counsel--process " *counsel*")
-         (proc (get-process counsel--process))
-         (buff (get-buffer counsel--process)))
-    (when proc
-      (delete-process proc))
-    (when buff
-      (kill-buffer buff))
-    (setq proc (start-process-shell-command
-                counsel--process
-                counsel--process
-                cmd))
-    (setq counsel--async-time (current-time))
-    (set-process-sentinel proc #'counsel--async-sentinel)
-    (set-process-filter proc #'counsel--async-filter)))
-
-(defun counsel--async-sentinel (process event)
-  (if (string= event "finished\n")
-      (progn
-        (with-current-buffer (process-buffer process)
-          (setq ivy--all-candidates
-                (ivy--sort-maybe
-                 (split-string (buffer-string) "\n" t)))
-          (if (null ivy--old-cands)
-              (setq ivy--index
-                    (or (ivy--preselect-index
-                         (ivy-state-preselect ivy-last)
-                         ivy--all-candidates)
-                        0))
-            (ivy--recompute-index
-             ivy-text
-             (funcall ivy--regex-function ivy-text)
-             ivy--all-candidates))
-          (setq ivy--old-cands ivy--all-candidates))
-        (ivy--exhibit))
-    (if (string= event "exited abnormally with code 1\n")
-        (progn
-          (setq ivy--all-candidates '("Error"))
-          (setq ivy--old-cands ivy--all-candidates)
-          (ivy--exhibit)))))
-
-(defun counsel--async-filter (process str)
-  "Receive from PROCESS the output STR.
-Update the minibuffer with the amount of lines collected every
-0.5 seconds since the last update."
-  (with-current-buffer (process-buffer process)
-    (insert str))
-  (let (size)
-    (when (time-less-p
-           ;; 0.5s
-           '(0 0 500000 0)
-           (time-since counsel--async-time))
-      (with-current-buffer (process-buffer process)
-        (goto-char (point-min))
-        (setq size (- (buffer-size) (forward-line (buffer-size)))))
-      (ivy--insert-minibuffer
-       (format "\ncollected: %d" size))
-      (setq counsel--async-time (current-time)))))
-
-(defun counsel-locate-action-extern (x)
-  "Use xdg-open shell command on X."
-  (call-process shell-file-name nil
-                nil nil
-                shell-command-switch
-                (format "%s %s"
-                        (if (eq system-type 'darwin)
-                                    "open"
-                                  "xdg-open")
-                        (shell-quote-argument x))))
-
-(declare-function dired-jump "dired-x")
-(defun counsel-locate-action-dired (x)
-  "Use `dired-jump' on X."
-  (dired-jump nil x))
-
-(defvar counsel-locate-history nil
-  "History for `counsel-locate'.")
-
-(defcustom counsel-locate-options (if (eq system-type 'darwin)
-                                      '("-i")
-                                    '("-i" "--regex"))
-  "Command line options for `locate`."
-  :group 'ivy
-  :type  '(repeat string))
-
-(ivy-set-actions
- 'counsel-locate
- '(("x" counsel-locate-action-extern "xdg-open")
-   ("d" counsel-locate-action-dired "dired")))
-
-(defun counsel-unquote-regex-parens (str)
-  (replace-regexp-in-string
-   "\\\\)" ")"
-   (replace-regexp-in-string
-    "\\\\(" "("
-    str)))
-
-(defun counsel-locate-function (str &rest _u)
-  (if (< (length str) 3)
-      (counsel-more-chars 3)
-    (counsel--async-command
-     (format "locate %s '%s'"
-             (mapconcat #'identity counsel-locate-options " ")
-             (counsel-unquote-regex-parens
-              (ivy--regex str))))
-    '("" "working...")))
-
-(defun counsel-delete-process ()
-  (let ((process (get-process " *counsel*")))
-    (when process
-      (delete-process process))))
-
-;;;###autoload
-(defun counsel-locate (&optional initial-input)
-  "Call the \"locate\" shell command.
-INITIAL-INPUT can be given as the initial minibuffer input."
-  (interactive)
-  (ivy-read "Locate: " #'counsel-locate-function
-            :initial-input initial-input
-            :dynamic-collection t
-            :history 'counsel-locate-history
-            :action (lambda (file)
-                      (with-ivy-window
-                        (when file
-                          (find-file file))))
-            :unwind #'counsel-delete-process))
-
-(defun counsel--generic (completion-fn)
-  "Complete thing at point with COMPLETION-FN."
-  (let* ((bnd (bounds-of-thing-at-point 'symbol))
-         (str (if bnd
-                  (buffer-substring-no-properties
-                   (car bnd) (cdr bnd))
-                ""))
-         (candidates (funcall completion-fn str))
-         (ivy-height 7)
-         (res (ivy-read (format "pattern (%s): " str)
-                        candidates)))
-    (when (stringp res)
-      (when bnd
-        (delete-region (car bnd) (cdr bnd)))
-      (insert res))))
-
-(defun counsel-directory-parent (dir)
-  "Return the directory parent of directory DIR."
-  (concat (file-name-nondirectory
-           (directory-file-name dir)) "/"))
-
-(defun counsel-string-compose (prefix str)
-  "Make PREFIX the display prefix of STR though text properties."
-  (let ((str (copy-sequence str)))
-    (put-text-property
-     0 1 'display
-     (concat prefix (substring str 0 1))
-     str)
-    str))
-
-;;;###autoload
-(defun counsel-load-library ()
-  "Load a selected the Emacs Lisp library.
-The libraries are offered from `load-path'."
-  (interactive)
-  (let ((dirs load-path)
-        (suffix (concat (regexp-opt '(".el" ".el.gz") t) "\\'"))
-        (cands (make-hash-table :test #'equal))
-        short-name
-        old-val
-        dir-parent
-        res)
-    (dolist (dir dirs)
-      (when (file-directory-p dir)
-        (dolist (file (file-name-all-completions "" dir))
-          (when (string-match suffix file)
-            (unless (string-match "pkg.elc?$" file)
-              (setq short-name (substring file 0 (match-beginning 0)))
-              (if (setq old-val (gethash short-name cands))
-                  (progn
-                    ;; assume going up directory once will resolve name clash
-                    (setq dir-parent (counsel-directory-parent (cdr old-val)))
-                    (puthash short-name
-                             (cons
-                              (counsel-string-compose dir-parent (car old-val))
-                              (cdr old-val))
-                             cands)
-                    (setq dir-parent (counsel-directory-parent dir))
-                    (puthash (concat dir-parent short-name)
-                             (cons
-                              (propertize
-                               (counsel-string-compose
-                                dir-parent short-name)
-                               'full-name (expand-file-name file dir))
-                              dir)
-                             cands))
-                (puthash short-name
-                         (cons (propertize
-                                short-name
-                                'full-name (expand-file-name file dir))
-                               dir) cands)))))))
-    (maphash (lambda (_k v) (push (car v) res)) cands)
-    (ivy-read "Load library: " (nreverse res)
-              :action (lambda (x)
-                        (load-library
-                         (get-text-property 0 'full-name x)))
-              :keymap counsel-describe-map)))
-
-(defvar counsel-gg-state nil
-  "The current state of candidates / count sync.")
-
-(defun counsel--gg-candidates (regex)
-  "Return git grep candidates for REGEX."
-  (setq counsel-gg-state -2)
-  (counsel--gg-count regex)
-  (let* ((default-directory counsel--git-grep-dir)
-         (counsel-gg-process " *counsel-gg*")
-         (proc (get-process counsel-gg-process))
-         (buff (get-buffer counsel-gg-process)))
-    (when proc
-      (delete-process proc))
-    (when buff
-      (kill-buffer buff))
-    (setq proc (start-process-shell-command
-                counsel-gg-process
-                counsel-gg-process
-                (concat
-                 (format counsel-git-grep-cmd regex)
-                 " | head -n 200")))
-    (set-process-sentinel
-     proc
-     #'counsel--gg-sentinel)))
-
-(defun counsel--gg-sentinel (process event)
-  (if (string= event "finished\n")
-      (progn
-        (with-current-buffer (process-buffer process)
-          (setq ivy--all-candidates
-                (or (split-string (buffer-string) "\n" t)
-                    '("")))
-          (setq ivy--old-cands ivy--all-candidates))
-        (when (= 0 (cl-incf counsel-gg-state))
-          (ivy--exhibit)))
-    (if (string= event "exited abnormally with code 1\n")
-        (progn
-          (setq ivy--all-candidates '("Error"))
-          (setq ivy--old-cands ivy--all-candidates)
-          (ivy--exhibit)))))
-
-(defun counsel--gg-count (regex &optional no-async)
-  "Quickly and asynchronously count the amount of git grep REGEX matches.
-When NO-ASYNC is non-nil, do it synchronously."
-  (let ((default-directory counsel--git-grep-dir)
-        (cmd
-         (concat
-          (format
-           (replace-regexp-in-string
-            "--full-name" "-c"
-            counsel-git-grep-cmd)
-           ;; "git grep -i -c '%s'"
-           (replace-regexp-in-string
-            "-" "\\\\-"
-            (replace-regexp-in-string "'" "''" regex)))
-          " | sed 's/.*:\\(.*\\)/\\1/g' | awk '{s+=$1} END {print s}'"))
-        (counsel-ggc-process " *counsel-gg-count*"))
-    (if no-async
-        (string-to-number (shell-command-to-string cmd))
-      (let ((proc (get-process counsel-ggc-process))
-            (buff (get-buffer counsel-ggc-process)))
-        (when proc
-          (delete-process proc))
-        (when buff
-          (kill-buffer buff))
-        (setq proc (start-process-shell-command
-                    counsel-ggc-process
-                    counsel-ggc-process
-                    cmd))
-        (set-process-sentinel
-         proc
-         #'(lambda (process event)
-             (when (string= event "finished\n")
-               (with-current-buffer (process-buffer process)
-                 (setq ivy--full-length (string-to-number (buffer-string))))
-               (when (= 0 (cl-incf counsel-gg-state))
-                 (ivy--exhibit)))))))))
-
-(defun counsel--M-x-transformer (cand-pair)
-  "Add a binding to CAND-PAIR cdr if the car is bound in the current window.
-CAND-PAIR is (command-name . extra-info)."
-  (let* ((command-name (car cand-pair))
-         (extra-info (cdr cand-pair))
-         (binding (substitute-command-keys (format "\\[%s]" command-name))))
-    (setq binding (replace-regexp-in-string "C-x 6" "<f2>" binding))
-    (if (string-match "^M-x" binding)
-        cand-pair
-      (cons command-name
-            (if extra-info
-                (format " %s (%s)" extra-info (propertize binding 'face 
'font-lock-keyword-face))
-              (format " (%s)" (propertize binding 'face 
'font-lock-keyword-face)))))))
-
-(defvar smex-initialized-p)
-(defvar smex-ido-cache)
-(declare-function smex-initialize "ext:smex")
-(declare-function smex-detect-new-commands "ext:smex")
-(declare-function smex-update "ext:smex")
-(declare-function smex-rank "ext:smex")
-
-(defun counsel--M-x-prompt ()
-  "M-x plus the string representation of `current-prefix-arg'."
-  (if (not current-prefix-arg)
-      "M-x "
-    (concat
-     (if (eq current-prefix-arg '-)
-         "- "
-       (if (integerp current-prefix-arg)
-           (format "%d " current-prefix-arg)
-         (if (= (car current-prefix-arg) 4)
-             "C-u "
-           (format "%d " (car current-prefix-arg)))))
-     "M-x ")))
-
-;;;###autoload
-(defun counsel-M-x (&optional initial-input)
-  "Ivy version of `execute-extended-command'.
-Optional INITIAL-INPUT is the initial input in the minibuffer."
-  (interactive)
-  (unless initial-input
-    (setq initial-input (cdr (assoc this-command
-                                    ivy-initial-inputs-alist))))
-  (let* ((store ivy-format-function)
-         (ivy-format-function
-          (lambda (cand-pairs)
-            (funcall
-             store
-             (with-ivy-window
-               (mapcar #'counsel--M-x-transformer cand-pairs)))))
-         (cands obarray)
-         (pred 'commandp)
-         (sort t))
-    (when (require 'smex nil 'noerror)
-      (unless smex-initialized-p
-        (smex-initialize))
-      (smex-detect-new-commands)
-      (smex-update)
-      (setq cands smex-ido-cache)
-      (setq pred nil)
-      (setq sort nil))
-    (ivy-read (counsel--M-x-prompt) cands
-              :predicate pred
-              :require-match t
-              :history 'extended-command-history
-              :action
-              (lambda (cmd)
-                (when (featurep 'smex)
-                  (smex-rank (intern cmd)))
-                (let ((prefix-arg current-prefix-arg)
-                      (ivy-format-function store))
-                  (command-execute (intern cmd) 'record)))
-              :sort sort
-              :keymap counsel-describe-map
-              :initial-input initial-input
-              :caller 'counsel-M-x)))
-
-(declare-function powerline-reset "ext:powerline")
-
-(defun counsel--load-theme-action (x)
-  "Disable current themes and load theme X."
-  (condition-case nil
-      (progn
-        (mapc #'disable-theme custom-enabled-themes)
-        (load-theme (intern x))
-        (when (fboundp 'powerline-reset)
-          (powerline-reset)))
-    (error "Problem loading theme %s" x)))
-
-;;;###autoload
-(defun counsel-load-theme ()
-  "Forward to `load-theme'.
-Usable with `ivy-resume', `ivy-next-line-and-call' and
-`ivy-previous-line-and-call'."
-  (interactive)
-  (ivy-read "Load custom theme: "
-            (mapcar 'symbol-name
-                    (custom-available-themes))
-            :action #'counsel--load-theme-action))
-
-(defvar rhythmbox-library)
-(declare-function rhythmbox-load-library "ext:helm-rhythmbox")
-(declare-function dbus-call-method "dbus")
-(declare-function rhythmbox-song-uri "ext:helm-rhythmbox")
-(declare-function helm-rhythmbox-candidates "ext:helm-rhythmbox")
-
-(defun counsel-rhythmbox-enqueue-song (song)
-  "Let Rhythmbox enqueue SONG."
-  (let ((service "org.gnome.Rhythmbox3")
-        (path "/org/gnome/Rhythmbox3/PlayQueue")
-        (interface "org.gnome.Rhythmbox3.PlayQueue"))
-    (dbus-call-method :session service path interface
-                      "AddToQueue" (rhythmbox-song-uri song))))
-
-(defvar counsel-rhythmbox-history nil
-  "History for `counsel-rhythmbox'.")
-
-;;;###autoload
-(defun counsel-rhythmbox ()
-  "Choose a song from the Rhythmbox library to play or enqueue."
-  (interactive)
-  (unless (require 'helm-rhythmbox nil t)
-    (error "Please install `helm-rhythmbox'"))
-  (unless rhythmbox-library
-    (rhythmbox-load-library)
-    (while (null rhythmbox-library)
-      (sit-for 0.1)))
-  (ivy-read "Rhythmbox: "
-            (helm-rhythmbox-candidates)
-            :history 'counsel-rhythmbox-history
-            :action
-            '(1
-              ("p" helm-rhythmbox-play-song "Play song")
-              ("e" counsel-rhythmbox-enqueue-song "Enqueue song"))
-            :caller 'counsel-rhythmbox))
-
-(defvar counsel-org-tags nil
-  "Store the current list of tags.")
-
-(defvar org-outline-regexp)
-(defvar org-indent-mode)
-(defvar org-indent-indentation-per-level)
-(defvar org-tags-column)
-(declare-function org-get-tags-string "org")
-(declare-function org-move-to-column "org-compat")
-
-(defun counsel-org-change-tags (tags)
-  (let ((current (org-get-tags-string))
-        (col (current-column))
-        level)
-    ;; Insert new tags at the correct column
-    (beginning-of-line 1)
-    (setq level (or (and (looking-at org-outline-regexp)
-                         (- (match-end 0) (point) 1))
-                    1))
-    (cond
-      ((and (equal current "") (equal tags "")))
-      ((re-search-forward
-        (concat "\\([ \t]*" (regexp-quote current) "\\)[ \t]*$")
-        (point-at-eol) t)
-       (if (equal tags "")
-           (delete-region
-            (match-beginning 0)
-            (match-end 0))
-         (goto-char (match-beginning 0))
-         (let* ((c0 (current-column))
-                ;; compute offset for the case of org-indent-mode active
-                (di (if (bound-and-true-p org-indent-mode)
-                        (* (1- org-indent-indentation-per-level) (1- level))
-                      0))
-                (p0 (if (equal (char-before) ?*) (1+ (point)) (point)))
-                (tc (+ org-tags-column (if (> org-tags-column 0) (- di) di)))
-                (c1 (max (1+ c0) (if (> tc 0) tc (- (- tc) (string-width 
tags)))))
-                (rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags)))
-           (replace-match rpl t t)
-           (and c0 indent-tabs-mode (tabify p0 (point)))
-           tags)))
-      (t (error "Tags alignment failed")))
-    (org-move-to-column col)))
-
-(defun counsel-org--set-tags ()
-  (counsel-org-change-tags
-   (if counsel-org-tags
-       (format ":%s:"
-               (mapconcat #'identity counsel-org-tags ":"))
-     "")))
-
-(defvar org-agenda-bulk-marked-entries)
-
-(declare-function org-get-at-bol "org")
-(declare-function org-agenda-error "org-agenda")
-
-(defun counsel-org-tag-action (x)
-  (if (member x counsel-org-tags)
-      (progn
-        (setq counsel-org-tags (delete x counsel-org-tags)))
-    (unless (equal x "")
-      (setq counsel-org-tags (append counsel-org-tags (list x)))
-      (unless (member x ivy--all-candidates)
-        (setq ivy--all-candidates (append ivy--all-candidates (list x))))))
-  (let ((prompt (counsel-org-tag-prompt)))
-    (setf (ivy-state-prompt ivy-last) prompt)
-    (setq ivy--prompt (concat "%-4d " prompt)))
-  (cond ((memq this-command '(ivy-done
-                              ivy-alt-done
-                              ivy-immediate-done))
-         (if (eq major-mode 'org-agenda-mode)
-             (if (null org-agenda-bulk-marked-entries)
-                 (let ((hdmarker (or (org-get-at-bol 'org-hd-marker)
-                                     (org-agenda-error))))
-                   (with-current-buffer (marker-buffer hdmarker)
-                     (goto-char hdmarker)
-                     (counsel-org--set-tags)))
-               (let ((add-tags (copy-sequence counsel-org-tags)))
-                 (dolist (m org-agenda-bulk-marked-entries)
-                   (with-current-buffer (marker-buffer m)
-                     (save-excursion
-                       (goto-char m)
-                       (setq counsel-org-tags
-                             (delete-dups
-                              (append (split-string (org-get-tags-string) ":" 
t)
-                                      add-tags)))
-                       (counsel-org--set-tags))))))
-           (counsel-org--set-tags)))
-        ((eq this-command 'ivy-call)
-         (delete-minibuffer-contents))))
-
-(defun counsel-org-tag-prompt ()
-  (format "Tags (%s): "
-          (mapconcat #'identity counsel-org-tags ", ")))
-
-(defvar org-setting-tags)
-(defvar org-last-tags-completion-table)
-(defvar org-tag-persistent-alist)
-(defvar org-tag-alist)
-(defvar org-complete-tags-always-offer-all-agenda-tags)
-
-(declare-function org-at-heading-p "org")
-(declare-function org-back-to-heading "org")
-(declare-function org-get-buffer-tags "org")
-(declare-function org-global-tags-completion-table "org")
-(declare-function org-agenda-files "org")
-(declare-function org-agenda-set-tags "org-agenda")
-
-;;;###autoload
-(defun counsel-org-tag ()
-  "Add or remove tags in org-mode."
-  (interactive)
-  (save-excursion
-    (if (eq major-mode 'org-agenda-mode)
-        (if org-agenda-bulk-marked-entries
-            (setq counsel-org-tags nil)
-          (let ((hdmarker (or (org-get-at-bol 'org-hd-marker)
-                              (org-agenda-error))))
-            (with-current-buffer (marker-buffer hdmarker)
-              (goto-char hdmarker)
-              (setq counsel-org-tags
-                    (split-string (org-get-tags-string) ":" t)))))
-      (unless (org-at-heading-p)
-        (org-back-to-heading t))
-      (setq counsel-org-tags (split-string (org-get-tags-string) ":" t)))
-    (let ((org-setting-tags t)
-          (org-last-tags-completion-table
-           (append org-tag-persistent-alist
-                   (or org-tag-alist (org-get-buffer-tags))
-                   (and
-                    (or org-complete-tags-always-offer-all-agenda-tags
-                        (eq major-mode 'org-agenda-mode))
-                    (org-global-tags-completion-table
-                     (org-agenda-files))))))
-      (ivy-read (counsel-org-tag-prompt)
-                (lambda (str &rest _unused)
-                  (delete-dups
-                   (all-completions str 'org-tags-completion-function)))
-                :history 'org-tags-history
-                :action 'counsel-org-tag-action))))
-
-;;;###autoload
-(defun counsel-org-tag-agenda ()
-  "Set tags for the current agenda item."
-  (interactive)
-  (let ((store (symbol-function 'org-set-tags)))
-    (unwind-protect
-         (progn
-           (fset 'org-set-tags
-                 (symbol-function 'counsel-org-tag))
-           (org-agenda-set-tags nil nil))
-      (fset 'org-set-tags store))))
-
-(defun counsel-ag-function (string &optional _pred &rest _unused)
-  "Grep in the current directory for STRING."
-  (if (< (length string) 3)
-      (counsel-more-chars 3)
-    (let ((default-directory counsel--git-grep-dir)
-          (regex (counsel-unquote-regex-parens
-                  (setq ivy--old-re
-                        (ivy--regex string)))))
-      (counsel--async-command
-       (format "ag --vimgrep %S" regex))
-      nil)))
-
-;;;###autoload
-(defun counsel-ag (&optional initial-input initial-directory)
-  "Grep for a string in the current directory using ag.
-INITIAL-INPUT can be given as the initial minibuffer input."
-  (interactive)
-  (setq counsel--git-grep-dir (or initial-directory default-directory))
-  (ivy-read "ag: " 'counsel-ag-function
-            :initial-input initial-input
-            :dynamic-collection t
-            :history 'counsel-git-grep-history
-            :action #'counsel-git-grep-action
-            :unwind (lambda ()
-                      (counsel-delete-process)
-                      (swiper--cleanup))))
-
-;;;###autoload
-(defun counsel-grep ()
-  "Grep for a string in the current file."
-  (interactive)
-  (setq counsel--git-grep-dir (buffer-file-name))
-  (ivy-read "grep: " 'counsel-grep-function
-            :dynamic-collection t
-            :preselect (format "%d:%s"
-                               (line-number-at-pos)
-                               (buffer-substring-no-properties
-                                (line-beginning-position)
-                                (line-end-position)))
-            :history 'counsel-git-grep-history
-            :update-fn (lambda ()
-                         (counsel-grep-action ivy--current))
-            :action #'counsel-grep-action
-            :unwind (lambda ()
-                      (counsel-delete-process)
-                      (swiper--cleanup))
-            :caller 'counsel-grep))
-
-(defun counsel-grep-function (string &optional _pred &rest _unused)
-  "Grep in the current directory for STRING."
-  (if (< (length string) 3)
-      (counsel-more-chars 3)
-    (let ((regex (counsel-unquote-regex-parens
-                  (setq ivy--old-re
-                        (ivy--regex string)))))
-      (counsel--async-command
-       (format "grep -nP --ignore-case '%s' %s" regex counsel--git-grep-dir))
-      nil)))
-
-(defun counsel-grep-action (x)
-  (when (string-match "\\`\\([0-9]+\\):\\(.*\\)\\'" x)
-    (with-ivy-window
-      (let ((file-name counsel--git-grep-dir)
-            (line-number (match-string-no-properties 1 x)))
-        (find-file file-name)
-        (goto-char (point-min))
-        (forward-line (1- (string-to-number line-number)))
-        (re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
-        (unless (eq ivy-exit 'done)
-          (swiper--cleanup)
-          (swiper--add-overlays (ivy--regex ivy-text)))))))
-
-(defun counsel-recoll-function (string &optional _pred &rest _unused)
-  "Grep in the current directory for STRING."
-  (if (< (length string) 3)
-      (counsel-more-chars 3)
-    (counsel--async-command
-     (format "recoll -t -b '%s'" string))
-    nil))
-
-;; This command uses the recollq command line tool that comes together
-;; with the recoll (the document indexing database) source:
-;;     http://www.lesbonscomptes.com/recoll/download.html
-;; You need to build it yourself (together with recoll):
-;;     cd ./query && make && sudo cp recollq /usr/local/bin
-;; You can try the GUI version of recoll with:
-;;     sudo apt-get install recoll
-;; Unfortunately, that does not install recollq.
-(defun counsel-recoll (&optional initial-input)
-  "Search for a string in the recoll database.
-You'll be given a list of files that match.
-Selecting a file will launch `swiper' for that file.
-INITIAL-INPUT can be given as the initial minibuffer input."
-  (interactive)
-  (ivy-read "recoll: " 'counsel-recoll-function
-            :initial-input initial-input
-            :dynamic-collection t
-            :history 'counsel-git-grep-history
-            :action (lambda (x)
-                      (when (string-match "file://\\(.*\\)\\'" x)
-                        (let ((file-name (match-string 1 x)))
-                          (find-file file-name)
-                          (unless (string-match "pdf$" x)
-                            (swiper ivy-text)))))))
-
-(defvar tmm-km-list nil)
-(declare-function tmm-get-keymap "tmm")
-(declare-function tmm--completion-table "tmm")
-(declare-function tmm-get-keybind "tmm")
-
-(defun counsel-tmm-prompt (menu)
-  "Select and call an item from the MENU keymap."
-  (let (out
-        choice
-        chosen-string)
-    (setq tmm-km-list nil)
-    (map-keymap (lambda (k v) (tmm-get-keymap (cons k v))) menu)
-    (setq tmm-km-list (nreverse tmm-km-list))
-    (setq out (ivy-read "Menu bar: " (tmm--completion-table tmm-km-list)
-                        :require-match t
-                        :sort nil))
-    (setq choice (cdr (assoc out tmm-km-list)))
-    (setq chosen-string (car choice))
-    (setq choice (cdr choice))
-    (cond ((keymapp choice)
-           (counsel-tmm-prompt choice))
-          ((and choice chosen-string)
-           (setq last-command-event chosen-string)
-           (call-interactively choice)))))
-
-(defun counsel-tmm ()
-  "Text-mode emulation of looking and choosing from a menubar."
-  (interactive)
-  (require 'tmm)
-  (run-hooks 'menu-bar-update-hook)
-  (counsel-tmm-prompt (tmm-get-keybind [menu-bar])))
-
-(defcustom counsel-yank-pop-truncate nil
-  "When non-nil, truncate the display of long strings."
-  :group 'ivy)
-
-;;;###autoload
-(defun counsel-yank-pop ()
-  "Ivy replacement for `yank-pop'."
-  (interactive)
-  (if (eq last-command 'yank)
-      (progn
-        (setq counsel-completion-end (point))
-        (setq counsel-completion-beg
-              (save-excursion
-                (search-backward (car kill-ring))
-                (point))))
-    (setq counsel-completion-beg (point))
-    (setq counsel-completion-end (point)))
-  (let ((candidates (cl-remove-if
-                     (lambda (s)
-                       (or (< (length s) 3)
-                           (string-match "\\`[\n[:blank:]]+\\'" s)))
-                     (delete-dups kill-ring))))
-    (when counsel-yank-pop-truncate
-      (setq candidates
-            (mapcar (lambda (s)
-                      (if (string-match "\\`\\(.*\n.*\n.*\n.*\\)\n" s)
-                          (progn
-                            (let ((s (copy-sequence s)))
-                              (put-text-property
-                               (match-end 1)
-                               (length s)
-                               'display
-                               " [...]"
-                               s)
-                              s))
-                        s))
-                    candidates)))
-    (ivy-read "kill-ring: " candidates
-              :action 'counsel-yank-pop-action)))
-
-(defun counsel-yank-pop-action (s)
-  "Insert S into the buffer, overwriting the previous yank."
-  (with-ivy-window
-    (delete-region counsel-completion-beg
-                   counsel-completion-end)
-    (insert (substring-no-properties s))
-    (setq counsel-completion-end (point))))
-
-(provide 'counsel)
-
-;;; counsel.el ends here
diff --git a/doc/Changelog.org b/doc/Changelog.org
deleted file mode 100644
index 21076de..0000000
--- a/doc/Changelog.org
+++ /dev/null
@@ -1,616 +0,0 @@
-#+OPTIONS: toc:nil
-* 0.6.0
-** Fixes
-*** =swiper-avy= should use only the current window
-Not all windows. See [[https://github.com/abo-abo/swiper/issues/117][#117]].
-*** fix wrap-around for =ivy-next-line=
-See [[https://github.com/abo-abo/swiper/issues/118][#118]].
-*** =swiper-avy= should do nothing for empty input
-See [[https://github.com/abo-abo/avy/issues/50][#50]].
-*** =ivy-alt-done= should require TRAMP if necessary
-See [[https://github.com/abo-abo/swiper/pull/145][#145]].
-*** =swiper-query-replace= shouldn't miss the first occurrence
-See [[https://github.com/abo-abo/swiper/pull/144][#144]].
-*** =swiper= should not deactivate mark
-*** =ivy-mode= should not switch to TRAMP for certain input
-See [[https://github.com/abo-abo/swiper/pull/145][#145]].
-*** =counsel-find-file= should work better with TRAMP
-"/ssh:foo" should not be cut off
-See [[https://github.com/abo-abo/swiper/pull/145][#145]].
-*** =counsel-find-file= supports Windows drive letters
-See [[https://github.com/abo-abo/swiper/pull/155][#155]].
-*** =counsel-file-file= should work better with files that contain "~"
-See [[https://github.com/abo-abo/swiper/pull/157][#157]].
-*** =counsel-M-x= should respect =ivy-format-function=
-See [[https://github.com/abo-abo/swiper/pull/150][#150]].
-*** =counsel-git-grep= should position better on exit
-See [[https://github.com/abo-abo/swiper/pull/153][#153]].
-*** =ivy-mode= should re-scale text to minibuffer height
-See [[https://github.com/abo-abo/swiper/pull/151][#151]].
-*** =counsel-unicode-char= should use action-style call
-See [[https://github.com/abo-abo/swiper/pull/160][#160]].
-*** =ivy-read= should allow % in prompt string
-See [[https://github.com/abo-abo/swiper/pull/171][#171]].
-*** =ivy-call= should execute in proper window
-See [[https://github.com/abo-abo/swiper/pull/176][#176]].
-** New Features
-*** =ivy-mode=
-**** Open an Info file on the file system
-When in =Info-mode=, press ~g~ and select either "(./)" or "(../)" to
-switch to file name completion. That file will be opened with Info.
-**** Account for =minibuffer-depth-indication-mode=
-If you have =minibuffer-depth-indication-mode= on, the minibuffer
-prompt will indicate the current depth.
-See [[https://github.com/abo-abo/swiper/pull/134][#134]].
-**** Add fuzzy matching function
-To enable fuzzy matching, set your =ivy-re-builders-alist= accordingly:
-#+begin_src elisp
-(setq ivy-re-builders-alist
-      '((t . ivy--regex-fuzzy)))
-#+end_src
-See [[https://github.com/abo-abo/swiper/pull/136][#136]].
-
-See also [[https://github.com/abo-abo/swiper/pull/142][#142]] for toggling 
fuzzy matching with ~C-o m~.
-**** =case-fold-search= optimization
-Bind case-fold-search to t when the input is all lower-case:
-
-- input "the" matches both "the" and "The".
-- input "The" matches only "The".
-
-See [[https://github.com/abo-abo/swiper/pull/166][#166]].
-**** Allow to see the candidate index a la =anzu= via =ivy-count-format=
-To have this feature, use something like this:
-#+begin_src elisp
-(setq ivy-count-format "(%d/%d) ")
-#+end_src
-See [[https://github.com/abo-abo/swiper/pull/167][#167]].
-
-You can also set this to "", if you don't want any count, see 
[[https://github.com/abo-abo/swiper/pull/188][#188]].
-**** Allow to add additional exit points for any command
-Example for =ivy-switch-to-buffer=:
-#+begin_src elisp
-(ivy-set-actions
- 'ivy-switch-buffer
- '(("k"
-    (lambda (x)
-      (kill-buffer x)
-      (ivy--reset-state ivy-last))
-    "kill")
-   ("j"
-    ivy--switch-buffer-other-window-action
-    "other")))
-#+end_src
-
-After this:
-
-- use ~M-o k~ to kill a buffer
-- use ~M-o j~ to switch to a buffer in other window
-
-You can always use ~M-o o~ to access the default action. When there is
-only one action, ~M-o~ does the same as ~C-m~.
-
-See [[https://github.com/abo-abo/swiper/pull/164][#164]].
-
-
-
-
-
-
-
-
-*** =counsel-describe-function= and =counsel-decribe-variable=
-**** Add a binding to look up the symbol in info
-Press ~C-,~ to look up the symbol in info, instead of the default
-describe action.
-See [[https://github.com/abo-abo/swiper/pull/121][#121]].
-**** Handle symbol-at-point better in non-Elisp buffers
-See [[https://github.com/abo-abo/swiper/pull/126][#126]].
-*** =ivy-switch-buffer=
-**** New face =ivy-virtual=
-See [[https://github.com/abo-abo/swiper/pull/129][#129]].
-**** Deal better with invisible buffers
-See [[https://github.com/abo-abo/swiper/pull/135][#135]].
-**** Add custom keymap
-You can customize =ivy-switch-buffer-map=.
-
-See [[https://github.com/abo-abo/swiper/pull/164][#164]].
-**** Add extra actions
-Add a =kill-buffer= action, and =switch-to-buffer-other-window= action.
-*** =counsel-git-grep=
-**** Add Async
-Make it fully async: the process =git grep= will be killed and
-restarted on new input. This results in almost no keyboard delay.
-**** Own history variable
-*** =swiper=
-**** Own history variable
-Having own history variable allows to get more use of ~M-p~, ~M-n~ and ~C-r~.
-*** =counsel-el=
-**** Switch to action-style call
-This allows to make use of ~C-M-n~ and ~C-M-p~.
-*** =counsel-locate=
-**** Add Async
-**** Add extra actions
-In addition to the default action of opening a file add:
-
-- =xdg-open= action
-- =dired= action
-
-Press ~M-o~ or ~C-o~ to access these actions.
-**** Add own history
-
-*** API
-**** Add :matcher
-A matcher is a function that accepts a regexp and a list of candidates
-and returns the filtered list of candidates.
-
-The default matcher is basically =cl-remove-if-not= + =string-match=.
-If you'd like to customize this, pass your own matcher.
-
-See =counsel-git-grep-matcher= for an example.
-**** Allow to customize the initial input for all commands
-Customize =ivy-initial-inputs-alist= for this.
-See [[https://github.com/abo-abo/swiper/pull/140][#140]].
-**** =ivy-sort-functions-alist= should also examine =this-command=
-**** :dynamic-collection is now a boolean
-Pass the collection function as the second var instead.
-
-** New Commands
-*** =ivy-call=
-Execute the current action for the current candidate without exiting
-the minibuffer.  Bound to ~C-M-m~ or ~M-RET~ or ~C-o g~.
-
-
-*** =counsel-find-file=
-Forward to =find-file= with Ivy completion.
-
-=ivy-next-line-and-call= as well as =ivy-resume= should work for this command.
-
-The variable =counsel-find-file-ignore-regexp= allows to ignore
-certain files, like dot files.  Input a leading dot to see all files.
-
-The variable =counsel-find-file-at-point= allows to automatically use
-=ffap=.  You also can do it manually with ~M-n~ when the point is on a file 
name.
-
-The variable =counsel-find-file-map= allows to customize the
-minibuffer key bindings for this command.
-
-Recommended binding:
-
-#+begin_src elisp
-(global-set-key (kbd "C-x C-f") 'counsel-find-file)
-#+end_src
-
-You can peek at files with ~C-M-n~ and ~C-M-p~.
-
-See [[https://github.com/abo-abo/swiper/issues/122][#122]] and 
[[https://github.com/abo-abo/swiper/issues/123][#123]].
-
-See [[https://github.com/abo-abo/swiper/pull/152][#152]] about ~M-n~, ~M-p~ 
and ~M-i~ switching directories when necessary.
-
-*** =ivy-recentf=
-Find a file on =recentf-list=.
-
-Note that if your set =ivy-use-virtual-buffers=, =recentf-list= is
-merged into candidates list for =ivy-switch-buffer=. But if you want
-it separately, you can use this command.
-
-See [[https://github.com/abo-abo/swiper/issues/124][#124]].
-*** =ivy-yank-word=
-Add word at point to minibuffer input.
-
-This is similar to what ~C-w~ does for =isearch=.  However it's bound
-to ~M-j~ instead of ~C-w~, since ~C-w~ is bound to =kill-region= - a
-useful command.
-
-See [[https://github.com/abo-abo/swiper/issues/125][#125]].
-*** =counsel-M-x=
-Forward to =execute-extended-command= with Ivy completion.
-The candidate list will also display the key binding for each bound command.
-
-This command will piggyback on =smex= for sorting, if =smex= is installed.
-
-Use =counsel-M-x-initial-input= to customize the initial input for
-this command.  By default, it's "^" - the regex character that
-indicates beginning of string.  This results in much faster matching,
-since you usually type the command name from the start.
-
-See [[https://github.com/abo-abo/swiper/pull/136][#136]] and 
[[https://github.com/abo-abo/swiper/pull/138][#138]].
-
-*** =hydra-ivy=
-Press ~C-o~ to toggle the Hydra for Ivy.
-It gives access to shorter bindings and many customizable options.
-
-Use ~C-o >~ to grow the minibuffer.
-Use ~C-o <~ to shrink the minibuffer.
-
-See [[https://github.com/abo-abo/swiper/pull/151][#151]].
-
-*** =ivy-toggle-calling=
-Toggle executing the current action each time a new candidate is selected.
-
-This command is bound to ~C-o c~.
-
-To explain how this is useful: ~C-M-m C-M-f C-M-f C-M-f~  is equivalent to 
~C-o cjjj~.
-
-*** =ivy-insert-current=
-Inserts the current candidate into the minibuffer.
-
-Press ~M-i~ if you want something close to the current candidate. You
-can follow up with an edit and select.
-
-I find this very useful when creating new files with a similar name to
-the existing file: ~C-x C-f M-i~ + a bit of editing is very fast.
-
-See [[https://github.com/abo-abo/swiper/pull/141][#141]].
-
-*** =counsel-load-theme=
-Forward to =load-theme= with Ivy completion. Allows to rapidly try themes 
(e.g. with ~C-M-n~).
-
-*** =ivy-reverse-i-search=
-Allow to recursively match history with ~C-r~.
-
-I like this command from bash shell. The usual way to search through
-history is with ~M-p~ and ~M-n~.  Using =ivy-reverse-i-search= will
-open a recursive completion session with the current history as the
-candidates.
-*** =counsel-rhythmbox=
-[[http://oremacs.com/2015/07/09/counsel-rhythmbox/][Control Rhythmbox from 
Emacs.]]
-*** =ivy-dispatching-done=
-Select an action for the current candidate and execute it. Bound to ~M-o~.
-
-Some commands that support ~M-o~:
-
-- =counsel-rhythmbox=
-- =counsel-describe-function=
-- =counsel-describe-variable=
-- =ivy-switch-buffer=
-- =counsel-locate=
-
-*** =counsel-org-tag=
-Forward to =org-set-tags= with Ivy completion.
-
-Selecting any tag each time will toggle it on/off.
-The current list of selected tags will be displayed in the prompt.
-
-See [[https://github.com/abo-abo/swiper/pull/177][#177]] and 
[[https://github.com/abo-abo/swiper/pull/91][#91]].
-
-*** =counsel-org-tag-agenda=
-Forward to =org-agenda-set-tags= with Ivy completion.
-See [[https://github.com/abo-abo/swiper/pull/177][#177]].
-
-*** =counsel-ag=
-Interactively =ag= using Ivy completion.
-
-*** =counsel-recoll=
-Use =recoll= with Ivy completion.
-See [[http://oremacs.com/2015/07/27/counsel-recoll/][Using Recoll desktop 
search database with Emacs]].
-
-Install recoll with =sudo apt-get install recoll=.
-
-*** =swiper-from-isearch=
-Start =swiper= from the current =isearch= input.
-
-*** =ivy-immediate-done=
-Use this command to exit the minibuffer choosing not the current
-candidate, but the current text.  Bound to ~C-M-j~ or ~C-u C-j~.
-
-See [[https://github.com/abo-abo/swiper/pull/183][#183]].
-
-* 0.7.0
-** Fixes
-*** Fix :dynamic-collection not being sorted
-*** When :initial-input contains a plus, escape it
-See [[https://github.com/abo-abo/swiper/issues/195][#195]].
-*** Set line-spacing to 0 in the minibuffer
-See [[https://github.com/abo-abo/swiper/issues/198][#198]].
-*** Enlarge the minibuffer window if the candidate list doesn't fit
-See [[https://github.com/abo-abo/swiper/issues/198][#198]] and 
[[https://github.com/abo-abo/swiper/issues/161][#161]] and 
[[https://github.com/abo-abo/swiper/issues/220][#220]].
-*** Fix minibuffer collapsing to one line
-See [[https://github.com/abo-abo/swiper/issues/237][#237]], 
[[https://github.com/abo-abo/swiper/issues/229][#229]] and 
[[https://github.com/abo-abo/swiper/issues/77][#77]].
-*** Use minibuffer-allow-text-properties
-Allows =ivy-read= to return a propertized string.
-*** Improve ~C-g~ out of a long-running async process
-Use =counsel-delete-process= as =:unwind=.
-*** Don't regexp-quote :preselect
-See [[https://github.com/abo-abo/swiper/issues/245][#245]].
-*** Fix ivy-partial for fuzzy completion
-See [[https://github.com/abo-abo/swiper/issues/266][#266]].
-*** ivy-resume should pass :caller
-See [[https://github.com/abo-abo/swiper/issues/245][#245]].
-*** Fix the regression in perfect match logic
-See [[https://github.com/abo-abo/swiper/issues/270][#270]].
-*** Fix pasting file paths on Windows
-*** ~C-j~ should no stop completion for a pasted file path
-*** ~C-M-j~ should use =ivy--directory=
-When completing file names, expand the file name properly.
-See [[https://github.com/abo-abo/swiper/issues/275][#275]].
-*** Use a specific blend method for dark themes
-See [[https://github.com/abo-abo/swiper/issues/278][#278]].
-*** Fix one-off bug in =ivy-scroll-up-command= and =ivy-scroll-down-command=
-*** ~M-o~ shouldn't set the action permanently
-So now it's possible to e.g. =counsel-describe-function= -> ~M-o d~ ->
-=ivy-resume= -> ~M-o o~ -> =ivy-resume= -> ~M-o i~.
-*** Fix swiper preselect issue with similar or identical lines
-See [[https://github.com/abo-abo/swiper/issues/290][#290]].
-*** Make ivy-completing-read handle history as cons
-See [[https://github.com/abo-abo/swiper/issues/295][#295]].
-*** Perform string-match in the original buffer
-The syntax for whitespace, separators etc. is different for modes.  See 
[[https://github.com/abo-abo/swiper/issues/298][#298]].
-** New Features
-*** =swiper=
-**** Make line numbers into display properties
-Each candidate is now a single space plus the original string.  The
-display property of the single space holds the line number. This means
-that it's no longer possible to match line numbers in queries, which
-is a good thing if you're searching for numbers.
-**** Extend =swiper-font-lock-ensure=
-Add =mu4e-view-mode=, =mu4e-headers-mode=, =help-mode=,
-=elfeed-show-mode=, =emms-stream-mode=, =debbugs-gnu-mode=,
-=occur-mode=, =occur-edit-mode=, =bongo-mode=, =eww-mode=, =vc-dir-mode=.
-**** Add support for =evil-jumper/backward=
-See [[https://github.com/abo-abo/swiper/issues/268][#268]].
-**** Make compatible with =visual-line-mode=
-=swiper= will split the lines when =visual-line-mode= is on.  This is
-convenient for small buffers. For large buffers, it can be very slow,
-since =visual-line-mode= is slow.
-See [[https://github.com/abo-abo/swiper/issues/227][#227]].
-**** Add =swiper-toggle-face-matching=
-Bound to ~C-c C-f~.
-At each start of =swiper=, the face at point will be stored.
-Use this command to toggle matching only the candidates with that face.
-See [[https://github.com/abo-abo/swiper/issues/288][#288]].
-**** =push-mark= only if exited the minibuffer
-~C-M-n~ and ~C-M-p~ will no longer push mark and annoy with messages.
-**** =ivy-resume= should restore the buffer for =swiper=
-See [[https://github.com/abo-abo/swiper/issues/302][#302]].
-**** Enable recursive =swiper= calls
-While you =swiper= buffer-1, you can switch out of the minibuffer into
-buffer-2 and call =swiper= again.  Exiting the second minibuffer will
-restore the first minibuffer.
-
-To use this, you need to enable recursive minibuffers.
-#+begin_src elisp
-(setq enable-recursive-minibuffers t)
-#+end_src
-
-It's also useful to indicate the current depth:
-
-#+begin_src elisp
-(minibuffer-depth-indicate-mode 1)
-#+end_src
-
-See [[https://github.com/abo-abo/swiper/issues/309][#309]].
-**** Fix for =twittering-mode=
-The =field= text property is now removed before inserting text into
-the minibuffer. This fixes the =swiper= problems with
-=twittering-mode=. See [[https://github.com/abo-abo/swiper/issues/310][#310]].
-
-
-
-
-*** =ivy=
-**** Add manual
-In the current state, the manual covers the most basic topics, like
-the minibuffer key bindings and the regexp builders.
-**** Make <left> and <right> behave as in fundamental-mode
-**** Truncate minibuffer prompts longer than window-width
-See [[https://github.com/abo-abo/swiper/issues/240][#240]].
-**** ~C-M-n~ should not leave the minibuffer
-Make sure that the minibuffer window remains selected as long as the
-completion hasn't finished.  For example, ~<f1> f~ to call
-=counsel-describe-function=, input "forward" and spam ~C-M-n~ to read
-the doc for each function that starts with "forward". The =*Help*=
-window popup would move the window focus, but this change moves it
-back to the minibuffer.
-**** Add =flx= sorting
-See [[https://github.com/abo-abo/swiper/issues/207][#207]].
-Since flx is costly, move the caching to an earlier point. This means
-immediate return for when the input hasn't changed, i.e. for ~C-n~ or
-~C-p~. When =flx= is installed, and =(eq ivy--regex-function 
'ivy--regex-fuzzy)=
-for current function (through =ivy-re-builders-alist=), then sort the final 
candidates with
-=ivy--flx-sort=.
-
-In the worst case, when some error pops up, return the same list. In
-the best case sort the =cands= that all match =name= by closeness to
-=name=.
-
-How to use:
-1. Have =flx= installed - =(require 'flx)= should succeed.
-2. Configure =ivy-re-builders-alist= appropriately to use =ivy--regex-fuzzy=.
-
-For example:
-
-#+begin_src elisp
-(setq ivy-re-builders-alist
-      '((t . ivy--regex-fuzzy)))
-#+end_src
-**** Support hash tables
-Since =all-completions= also works for hash tables, no reason not to support 
them.
-**** Improve documentation of =ivy-count-format=
-Now possible to set it with Customize.
-**** Add =ivy-index-functions-alist=
-Customize this to decide how the index, i.e. the currently selected
-candidate, is updated with new input.
-For example, one strategy is not reset it to 0 after each change.
-
-Another strategy, used for =swiper=, is to try to select the first
-appropriate candidate after (inclusive) the first previously selected
-candidate. This way, if you're typing something that matches what is
-currently selected, the selection won't change.
-
-See [[https://github.com/abo-abo/swiper/issues/253][#253]].
-**** Add =ivy-virtual-abbreviate=
-The mode of abbreviation for virtual buffer names.
-**** Add =ivy-case-fold-search=
-Used to override =case-fold-search=. See 
[[https://github.com/abo-abo/swiper/issues/259][#259]].
-**** Add feedback for long-running async processes
-Each time 0.5s pass after the last input, if the external process
-hasn't finished yet, update minibuffer with the amount of candidates
-collected so far. This is useful to see that long running commands
-like =counsel-locate= or =counsel-ag= (when in a very large directory)
-aren't stuck.
-**** Promote =ivy-extra-directories= to defcustom
-**** Promote =ivy-sort-function-alist= to defcustom
-**** ~M-n~ should prefer url at point to symbol at point
-**** ~C-x C-f M-n~ calls =ffap-url-fetcher= when at URL
-**** Highlight modified file buffers with =ivy-modified-buffer= face
-This new face is blank by default, but you can use e.g.:
-#+begin_src elisp
-(custom-set-faces
- '(ivy-modified-buffer ((t (:background "#ff7777")))))
-#+end_src
-**** Work with =enable-recursive-minibuffers=
-Store the old =ivy-last= in case =ivy-read= is called while inside the
-minibuffer.  Restore it after =ivy-call=.
-**** Allow user-specified matched candidate sorting
-New defcustom =ivy-sort-matches-functions-alist=.
-See [[https://github.com/abo-abo/swiper/issues/269][#269]] 
[[https://github.com/abo-abo/swiper/issues/265][#265]] 
[[https://github.com/abo-abo/swiper/issues/213][#213]].
-
-By default, Ivy doesn't sort the matched candidates, they remain in
-the same order as in the original collection. This option is the
-default, since it's fast and simple.
-
-A small problem with this approach is that we usually want prefix
-matches to be displayed first. One solution to this is to input "^" to
-see only the prefix matches.
-
-Now, another solution is to can set:
-#+begin_src elisp
-(setq ivy-sort-matches-functions-alist
-      '((t . ivy--prefix-sort)))
-#+end_src
-
-Here's another example of using this defcustom:
-#+begin_src elisp
-(add-to-list
-     'ivy-sort-matches-functions-alist
-     '(read-file-name-internal . ivy--sort-files-by-date))
-#+end_src
-
-After this, during file name completion, most recently changed files
-will be ahead.
-**** =ivy-display-style=
-Adds fancy highlighting to the minibuffer.
-See [[https://github.com/abo-abo/swiper/issues/212][#212]], 
[[https://github.com/abo-abo/swiper/issues/217][#217]], .
-*** =ivy-hydra=
-**** Bind ~t~ to =toggle-truncate-lines=
-See [[https://github.com/abo-abo/swiper/issues/214][#214]].
-**** Bind ~a~ to =ivy-read-action=
-*** =ivy-switch-buffer=
-**** Make ~M-o r~ rename the buffer instead of switching.
-See [[https://github.com/abo-abo/swiper/issues/233][#233]].
-*** =counsel-locate=
-**** Allow customizing locate options
-See =counsel-locate-options=.
-The current setting is:
-#+begin_src elisp
-(setq counsel-locate-options '("-i" "--regex"))
-#+end_src
-**** Support OSX
-Use =open= instead of =xdg-open=.  Modify =counsel-locate-options= for
-OSX, since there =locate= doesn't support =--regex=.
-**** Use single quotes for the regex
-See [[https://github.com/abo-abo/swiper/issues/194][#194]].
-**** Add initial-input argument
-See [[https://github.com/abo-abo/swiper/issues/289][#289]].
-*** =counsel-org-tag=
-**** Now works in agenda
-See [[https://github.com/abo-abo/swiper/issues/200][#200]].
-*** =counsel-unicode-char=
-**** Add own history
-*** =counsel-M-x=
-**** Add "definition" action
-Use ~M-o d~ to jump to definition.
-**** Show =current-prefix-arg= in the prompt
-See [[https://github.com/abo-abo/swiper/issues/287][#287]].
-*** =counsel-find-file=
-**** Input '/sudo::' goes to current directory instead of root's home
-See [[https://github.com/abo-abo/swiper/issues/283][#283]].
-**** Fix directory validity check
-See [[https://github.com/abo-abo/swiper/issues/283][#283]] 
[[https://github.com/abo-abo/swiper/issues/284][#284]].
-**** Improve TRAMP support
-Selecting items after ~//~ now works properly.
-*** =counsel-git-grep=
-**** Use prefix arg to specify the shell command.
-Remember to use ~M-i~ to insert the current candidate into the
-minibuffer.
-
-See [[https://github.com/abo-abo/swiper/issues/244][#244]].
-**** Allow =counsel-git-grep= -> =ivy-occur= -> =wgrep=
-Using ~C-c C-o~ (=ivy-occur=) while in =counsel-git-grep= will produce
-a =wgrep=-compatible buffer.
-**** =ivy-occur= gives full candidates
-This means that the =" | head -n 200"= speed-up isn't used and full
-candidates are returned.
-*** =counsel--find-symbol=
-**** Allow to jump back with pop-tag-mark
-Using ~C-.~ in:
-
-- =counsel-describe-function=
-- =counsel-describe-variable=
-- =counsel-load-library=
-
-will change the current buffer. The buffer and point can be restored
-with ~M-*~ (=pop-tag-mark=).
-
-I also recommend this binding:
-
-#+begin_src elisp
-(global-set-key (kbd "M-,") 'pop-tag-mark)
-#+end_src
-**** Resolve the name clash better
-When the symbol is both bound and fbound, prefer the fbound one,
-unless the =:caller= is =counsel-describe-variable=.
-*** =counsel-ag=
-**** Add =initial-directory=
-Support alternative initial directory which helps other packages call
-this function with their unique starting directory.
-**** Fix on Windows
-Using the "--vimgrep" argument improves things.
-** New Commands
-*** =ivy-occur=
-Bound to ~C-c C-o~. Store the current completion session to its own
-buffer.  You can have an unlimited amount of these buffers.
-*** =ivy-avy=
-Bound to ~C-'~.
-
-Speeds up selecting a candidate that's currently visible in the minibuffer.
-*** =ivy-kill-ring-save=
-Bound to ~M-w~.
-
-When the region is active, call =kill-ring-save=.  Otherwise, store
-all selected candidates to the kill ring.
-*** =ivy-dispatching-call=
-Bound to ~C-M-o~.
-
-This is a non-exiting version of ~M-o~ (=ivy-dispatching-done=).
-*** =ivy-read-action=
-Bound to ~C-M-a~. Select the current action. Don't call it yet.
-*** =swiper-multi=
-Use =swiper= in multiple buffers.
-See [[https://github.com/abo-abo/swiper/issues/182][#182]].
-
-Basic usage tips for selecting multiple buffers:
-
-- Use ~C-M-m~ (=ivy-call=) to add or remove one more buffer without exiting.
-- Use ~C-m~ (=ivy-done=) to add one last buffer.
-- Or use ~C-M-j~ (=ivy-immediate-done=) to finish without adding more buffers.
-- Hold ~C-M-n~ (=ivy-next-line-and-call=) to add a lot of buffers at once.
-*** =swiper-mc=
-Open multiple cursors at all selected candidates.
-*** =swiper-all=
-New command to launch =swiper= for all open file buffers.  Note that
-this can be excruciatingly slow if you don't clean up your buffer list
-often.
-*** =counsel-grep=
-This is essentially =swiper= for huge files. It's not as smooth as
-=swiper= for small files, but has a faster startup and faster matching
-for files that measure in megabytes.
-*** =counsel-git-grep-query-replace=
-Bound to ~M-q~. Perform =query-replace= on all matches in all buffers.
-*** =counsel-jedi=
-Complete Python symbols using Jedi.
-*** =counsel-cl=
-Complete Common Lisp symbols using SLIME.
-*** =counsel-yank-pop=
-Give completion for inserting from the kill ring.
-See =counsel-yank-pop-truncate= defcustom and 
[[https://github.com/abo-abo/swiper/issues/218][#218]].
diff --git a/doc/ivy.org b/doc/ivy.org
deleted file mode 100644
index b26b00e..0000000
--- a/doc/ivy.org
+++ /dev/null
@@ -1,476 +0,0 @@
-#+TITLE: Ivy User Manual
-#+AUTHOR: Oleh Krehel
-#+EMAIL: ohwoeowho@gmail.com
-#+DATE: 2015
-#+LANGUAGE: en
-
-#+TEXINFO_DIR_CATEGORY: Emacs
-#+TEXINFO_DIR_TITLE: Ivy: (ivy).
-#+TEXINFO_DIR_DESC: Using Ivy for completion.
-#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style.css"/>
-
-#+OPTIONS: H:6 num:6 toc:4
-#+STARTUP: indent
-* Macros                                                                       
       :noexport:
-#+MACRO: defopt #+TEXINFO: @defopt $1
-#+MACRO: endopt #+TEXINFO: @end defopt
-* Copying
-:PROPERTIES:
-:COPYING:  t
-:END:
-
-#+BEGIN_TEXINFO
-@ifnottex
-Ivy manual, version 0.7.0
-
-Ivy is an interactive interface for completion in Emacs. Emacs uses
-completion mechanism in a variety of contexts: code, menus, commands,
-variables, functions, etc. Completion entails listing, sorting,
-filtering, previewing, and applying actions on selected items. When
-active, @code{ivy-mode} completes the selection process by narrowing
-available choices while previewing in the minibuffer. Selecting the
-final candidate is either through simple keyboard character inputs or
-through powerful regular expressions. @end ifnottex
-
-Copyright @copyright{} 2015 Free Software Foundation, Inc.
-
-@quotation
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.3 or
-any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
-and with the Back-Cover Texts as in (a) below.  A copy of the license
-is included in the section entitled ``GNU Free Documentation License.''
-
-(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
-modify this GNU manual.''
-@end quotation
-#+END_TEXINFO
-
-* Introduction
-Ivy is for quick and easy selection from a list. When Emacs prompts
-for a string from a list of several possible choices, Ivy springs into
-action to assist in narrowing and picking the right string from a vast
-number of choices.
-
-Ivy strives for minimalism, simplicity, customizability and
-discoverability.
-
-#+BEGIN_TEXINFO
-@subsubheading Minimalism
-#+END_TEXINFO
-Uncluttered minibuffer is minimalism. Ivy shows the completion
-defaults, the number of matches, and 10 candidate matches below the
-input line. Customize =ivy-length= to adjust the number of candidate
-matches displayed in the minibuffer.
-
-#+BEGIN_TEXINFO
-@subsubheading Simplicity
-#+END_TEXINFO
-Simplicity is about Ivy's behavior in the minibuffer. It is also about
-the code interface to extend Ivy's functionality. The minibuffer area
-behaves as close to =fundamental-mode= as possible. ~SPC~ inserts a
-space, for example, instead of being bound to the more complex
-=minibuffer-complete-word=. Ivy's code uses easy-to-examine global
-variables; avoids needless complications with branch-introducing
-custom macros.
-
-#+BEGIN_TEXINFO
-@subsubheading Customizability
-#+END_TEXINFO
-Customizability is about being able to use different methods and
-interfaces of completion to tailor the selection process. For example,
-adding a custom display function that points to a selected candidate
-with =->=, instead of highlighting the selected candidate with the
-=ivy-current-match= face. Or take the customization of actions, say
-after the candidate function is selected. ~RET~ uses
-=counsel-describe-function= to describe the function, whereas ~M-o d~
-jumps to that function's definition in the code. The ~M-o~ prefix can
-be uniformly used with characters like ~d~ to group similar actions.
-
-#+BEGIN_TEXINFO
-@subsubheading Discoverability
-#+END_TEXINFO
-Ivy displays easily discoverable commands through the hydra facility.
-~C-o~ in the minibuffer displays a hydra menu. It opens up within an
-expanded minibuffer area. Each menu item comes with short
-documentation strings and highlighted one-key completions. So
-discovering even seldom used keys is simply a matter of ~C-o~ in the
-minibuffer while in the midst of the Ivy interaction. This
-discoverability minimizes exiting Ivy interface for documentation
-look-ups.
-
-* Installation
-
-Install Ivy automatically through Emacs's package manager, or manually
-from Ivy's development repository.
-
-** Installing from Emacs Package Manager
-
-~M-x~ =package-install= ~RET~ =swiper= ~RET~
-
-Ivy is installed as part of =swiper= package. =swiper= is available
-from two different package archives, GNU ELPA and MELPA. For the
-latest stable version, use the GNU ELPA archives using the above M-x
-command.
-
-For current hourly builds, use the MELPA archives. See the code below
-for adding MELPA to the list of package archives:
-
-#+begin_src elisp
-(require 'package)
-(add-to-list 'package-archives
-             '("melpa" . "http://melpa.org/packages/";))
-#+end_src
-
-After this do ~M-x~ =package-refresh-contents= ~RET~, followed by
-~M-x~ =package-install= ~RET~ =swiper= ~RET~.
-
-For package manager details, see [[info:emacs#Packages]].
-
-** Installing from the Git repository
-
-Why install from Git?
-
-- No need to wait for MELPA's hourly builds
-- Easy to revert to previous versions
-- Contribute to Ivy's development; send patches; pull requests
-
-*Configuration steps*
-
-First clone the Swiper repository:
-#+begin_src sh
-cd ~/git && git clone https://github.com/abo-abo/swiper
-cd swiper && make compile
-#+end_src
-
-Then add this to Emacs init:
-#+begin_src elisp
-(add-to-list 'load-path "~/git/swiper/")
-(require 'ivy)
-#+end_src
-
-To update the code:
-#+begin_src sh
-git pull
-make
-#+end_src
-
-* Getting started
-
-First enable Ivy completion everywhere:
-
-#+begin_src elisp
-(ivy-mode 1)
-#+end_src
-
-Note: =ivy-mode= can be toggled on and off with ~M-x~ =ivy-mode=.
-** Basic customization
-Here are some basic settings particularly useful for new Ivy
-users:
-#+begin_src elisp
-(setq ivy-use-virtual-buffers t)
-(setq ivy-height 10)
-(setq ivy-display-style 'fancy)
-(setq ivy-count-format "(%d/%d) ")
-#+end_src
-
-For additional customizations, refer to =M-x describe-variable=
-documentation.
-
-* Key bindings
-** Global key bindings
-
-Recommended key bindings are:
-#+BEGIN_TEXINFO
-@subsubheading Ivy-based interface to standard commands
-#+END_TEXINFO
-#+begin_src elisp
-(global-set-key (kbd "C-s") 'swiper)
-(global-set-key (kbd "M-x") 'counsel-M-x)
-(global-set-key (kbd "C-x C-f") 'counsel-find-file)
-(global-set-key (kbd "<f1> f") 'counsel-describe-function)
-(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
-(global-set-key (kbd "<f1> l") 'counsel-load-library)
-(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
-(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
-#+end_src
-#+BEGIN_TEXINFO
-@subsubheading Ivy-based interface to shell and system tools
-#+END_TEXINFO
-#+begin_src elisp
-(global-set-key (kbd "C-c g") 'counsel-git)
-(global-set-key (kbd "C-c j") 'counsel-git-grep)
-(global-set-key (kbd "C-c k") 'counsel-ag)
-(global-set-key (kbd "C-x l") 'counsel-locate)
-(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
-#+end_src
-#+BEGIN_TEXINFO
-@subsubheading Ivy-resume and other commands
-#+END_TEXINFO
-=ivy-resume= resumes the last Ivy-based completion.
-#+begin_src elisp
-(global-set-key (kbd "C-c C-r") 'ivy-resume)
-#+end_src
-
-** Minibuffer key bindings
-
-Ivy includes several minibuffer bindings, which are defined in the
-=ivy-minibuffer-map= keymap variable. The most frequently used ones
-are described here.
-
-=swiper= or =counsel-M-x= add more through the =keymap= argument to
-=ivy-read=. These keys, also active in the minibuffer, are described
-under their respective commands.
-
-*** Key bindings for navigation
-
-- ~C-n~ (=ivy-next-line=) selects the next candidate
-- ~C-p~ (=ivy-previous-line=) selects the previous candidate
-- ~M-<~ (=ivy-beginning-of-buffer=) selects the first candidate
-- ~M->~ (=ivy-end-of-buffer=) selects the last candidate
-- ~C-v~ (=ivy-scroll-up-command=) scrolls up by =ivy-height= lines
-- ~M-v~ (=ivy-scroll-down-command=) scrolls down by =ivy-height= lines
-
-{{{defopt(ivy-wrap)}}}
-This user option allows to get the wrap-around behavior for ~C-n~ and
-~C-p~.  When set to =t=, =ivy-next-line= and =ivy-previous-line= will
-cycle past the last and the first candidates respectively.
-
-This behavior is off by default.
-{{{endopt}}}
-
-{{{defopt(ivy-height)}}}
-Use this variable to adjust the minibuffer height, and therefore the
-scroll size for ~C-v~ and ~M-v~.
-{{{endopt}}}
-
-*** Key bindings for single selection, action, then exit minibuffer
-
-Ivy can offer several actions from which to choose which action to
-run. This "calling an action" operates on the selected candidate. For
-example, when viewing a list of files, one action could open it for
-editing, one to view it, another to invoke a special function, and so
-on. Custom actions can be added to this interface. The precise action
-to call on the selected candidate can be delayed until after the
-narrowing is completed. No need to exit the interface if unsure which
-action to run. This delayed flexibility and customization of actions
-extends usability of lists in Emacs.
-
-~C-m~ or ~RET~ (=ivy-done=) calls the default action and exits the
-minibuffer.
-
-~M-o~ (=ivy-dispatching-done=) presents all available valid actions
-from which to choose. When there is only one action available, there
-is no difference between ~M-o~ and ~C-m~.
-
-~C-j~ (=ivy-alt-done=) calls the alternate action, such as completing
-a directory name in a file list whereas ~C-m~ will select that directory
-and exit the minibuffer.
-
-Exiting the minibuffer also closes the Ivy window (as specified by
-=ivy-height=). This closing and exiting sequence is conveniently off
-when applying multiple actions. Multiple actions and multiple
-selections as covered in the next section of this manual.
-
-~TAB~ (=ivy-partial-or-done=) attempts partial completion, extending
-current input as much as possible.
-
-~TAB TAB~ is the same as ~C-j~.
-
-~C-M-j~ (=ivy-immediate-done=) is useful when there is no match for
-the given input. Or there is an incorrect partial match. ~C-M-j~ with
-=find-file= lists ignores the partial match and instead takes the
-current input to create a new directory with =dired-create-directory=.
-
-=ivy-immediate-done= illustrates how Ivy distinguishes between calling
-an action on the /currently selected/ candidate and calling an action
-on the /current input/.
-
-#+BEGIN_TEXINFO
-Invoking avy completion with @kbd{C-'} (@code{ivy-avy}).
-#+END_TEXINFO
-~C-`~ uses avy's visible jump mechanism, which can further reduce
-Ivy's line-by-line scrolling that requires multiple ~C-n~ or ~C-p~
-keystrokes.
-
-*** Key bindings for multiple selections and actions, keep minibuffer open
-
-For repeatedly applying multiple actions or acting on multiple
-candidates, Ivy does not close the minibuffer between commands. It
-keeps the minibuffer open for applying subsequent actions.
-
-Adding an extra meta key to the normal key chord invokes the special
-version of the regular commands that enables applying multiple
-actions.
-
-~C-M-m~ (=ivy-call=) is the non-exiting version of the default action,
-~C-m~ (=ivy-done=). Instead of closing the minibuffer, ~C-M-m~ allows
-selecting another candidate or another action. For example, ~C-M-m~ on
-functions list invokes =describe-function=. When combined with ~C-n~,
-function descriptions can be invoked quickly in succession.
-
-~RET~ exits the minibuffer.
-
-=ivy-resume= recalls the state of the completion session just before
-its last exit. Useful after an accidental ~C-m~ (=ivy-done=).
-
-~C-M-o~ (=ivy-dispatching-call=) is a non-exiting version of ~M-o~
-(=ivy-dispatching-done=) that can accumulate candidates into a queue.
-For example, for playback in =counsel-rhythmbox=, ~C-M-o e~ en-queues
-the selected candidate, and ~C-n C-m~ plays the next one in the queue.
-
-~C-M-n~ (=ivy-next-line-and-call=) combines ~C-n~ and ~C-M-m~. Applies
-an action and moves to next line. Comes in handy when opening multiple
-files from =counsel-find-file=, =counsel-git-grep=, =counsel-ag=, or
-=counsel-locate= lists. Just hold ~C-M-n~ for rapid-fire default
-action on each successive element of the list.
-
-~C-M-p~ (=ivy-previous-line-and-call=) combines ~C-p~ and ~C-M-m~. Is
-the same as above except that it moves through the list in the other
-direction.
-
-*** Key bindings that alter minibuffer input
-
-~M-n~ (=ivy-next-history-element=) and ~M-p~
-(=ivy-previous-history-element=) cycle through the Ivy command
-history. Ivy updates an internal history list after each action. When
-this history list is empty, ~M-n~ inserts symbol (or URL) at point
-into the minibuffer.
-
-~M-i~ (=ivy-insert-current=) inserts the current candidate into the
-minibuffer. Useful for copying and renaming files, for example: ~M-i~
-to insert the original file name string, edit it, and then ~C-m~ to
-complete the renaming.
-
-~M-j~ (=ivy-yank-word=) inserts sub-word at point into minibuffer. This
-is similar to ~C-s C-w~ with =isearch=. Ivy reserves ~C-w~ for
-=kill-region=.
-
-~S-SPC~ (=ivy-restrict-to-matches=) deletes the current input, and
-resets the candidates list to the currently restricted matches. This
-is how Ivy provides narrowing in successive tiers.
-
-~C-r~ (=ivy-reverse-i-search=) works just like ~C-r~ at bash command
-prompt, where the completion candidates are the history items. Upon
-completion, the selected candidate string is inserted into the
-minibuffer.
-
-*** Other key bindings
-
-~M-w~ (=ivy-kill-ring-save=) copies selected candidates to the kill
-ring; when the region is active, copies active region.
-
-*** Hydra in the minibuffer
-
-~C-o~ (=hydra-ivy/body=) invokes Hydra menus with key shortcuts.
-
-~C-o~ or ~i~ resumes editing.
-
-Hydra reduces key strokes, for example: ~C-n C-n C-n C-n~ is ~C-o
-jjjj~ in Hydra. Hydra has other benefits besides certain shorter key
-bindings:
-- ~<~ and ~>~ to adjust height of minibuffer,
-- describes the current completion state, such as case folding and the
-  current action.
-
-Minibuffer editing is disabled when Hydra is active.
-
-*** Saving the current completion session to a buffer
-
-~C-c C-o~ (=ivy-occur=) saves the current candidates to a new buffer;
-the list is active in the new buffer.
-
-~RET~ or ~mouse-1~ in the new buffer calls the appropriate action on
-the selected candidate.
-
-Ivy has no limit on the number of active buffers like these.
-
-Ivy takes care of making these buffer names unique. It applies
-descriptive names, for example: =*ivy-occur counsel-describe-variable
-"function$*=.
-
-* Completion styles
-
-Ivy's completion functions rely on the highly configurable regex
-builder.
-
-The default is:
-#+begin_src elisp
-(setq ivy-re-builders-alist
-      '((t . ivy--regex-plus)))
-#+end_src
-
-The default =ivy--regex-plus= narrowing is always invoked unless
-specified otherwise. For example, file name completion may have a
-custom completion function:
-#+begin_src elisp
-(setq ivy-re-builders-alist
-      '((read-file-name-internal . ivy--regex-fuzzy)
-        (t . ivy--regex-plus)))
-#+end_src
-
-Ivy's flexibility extends to using different styles of completion
-mechanics (regex-builders) for different types of lists. Despite this
-flexibility, Ivy operates within a consistent and uniform interface.
-The main regex-builders currently in Ivy are:
-
-** ivy--regex-plus
-
-=ivy--regex-plus= is Ivy's default completion method.
-
-=ivy--regex-plus= matches by splitting the input by spaces and
-rebuilding it into a regex.
-
-As the search string is typed in Ivy's minibuffer, it is transformed
-into proper regex syntax. If the string is "for example", it is
-transformed into
-
-#+BEGIN_EXAMPLE
-"\\(for\\).*\\(example\\)"
-#+END_EXAMPLE
-
-which in regex terminology matches "for" followed by a wild card and
-then "example". Note how Ivy uses the space character to build
-wild cards. For literal white space matching in Ivy, use an extra space:
-to match one space type two spaces, to match two spaces type three
-spaces, and so on.
-
-As Ivy transforms typed characters into regex strings, it provides an
-intuitive feedback through font highlights.
-
-Ivy supports regexp negation with "!". For example, "define key ! ivy
-quit" first selects everything matching "define.*key", then removes
-everything matching "ivy", and finally removes everything matching
-"quit". What remains is the final result set of the negation regexp.
-
-#+BEGIN_EXAMPLE
-Standard regexp identifiers work:
-
-"^", "$", "\b" or "[a-z]"
-#+END_EXAMPLE
-
-Since Ivy treats minibuffer input as a regexp, standard regexp
-identifiers work as usual. The exceptions are spaces, which
-translate to ".*", and "!" that signal the beginning of a negation
-group.
-
-** ivy--regex-ignore-order
-
-=ivy--regex-ignore-order= ignores the order of regexp tokens when
-searching for matching candidates. For instance, the input "for
-example" will match "example test for". Otherwise =ivy--regex-plus=
-normal behavior is to honor the order of regexp tokens.
-
-** ivy--regex-fuzzy
-
-=ivy--regex-fuzzy= splits each character with a wild card. Searching
-for "for" returns all "f.*o.*r" matches, resulting in a large number
-of hits.  Yet some searches need these extra hits. Ivy sorts such
-large lists using =flx= package's scoring mechanism, if it's
-installed.
-
-* Variable Index
-#+BEGIN_TEXINFO
-@printindex vr
-#+END_TEXINFO
diff --git a/doc/ivy.texi b/doc/ivy.texi
deleted file mode 100644
index b06c68c..0000000
--- a/doc/ivy.texi
+++ /dev/null
@@ -1,591 +0,0 @@
-\input texinfo    @c -*- texinfo -*-
-@c %**start of header
-@setfilename ./ivy.info
-@settitle Ivy User Manual
-@documentencoding UTF-8
-@documentlanguage en
-@c %**end of header
-
-@copying
-@ifnottex
-Ivy manual, version 0.7.0
-
-Ivy is an interactive interface for completion in Emacs. Emacs uses
-completion mechanism in a variety of contexts: code, menus, commands,
-variables, functions, etc. Completion entails listing, sorting,
-filtering, previewing, and applying actions on selected items. When
-active, @code{ivy-mode} completes the selection process by narrowing
-available choices while previewing in the minibuffer. Selecting the
-final candidate is either through simple keyboard character inputs or
-through powerful regular expressions. @end ifnottex
-
-Copyright @copyright{} 2015 Free Software Foundation, Inc.
-
-@quotation
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.3 or
-any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
-and with the Back-Cover Texts as in (a) below.  A copy of the license
-is included in the section entitled ``GNU Free Documentation License.''
-
-(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
-modify this GNU manual.''
-@end quotation
-@end copying
-
-@dircategory Emacs
-@direntry
-* Ivy: (ivy).           Using Ivy for completion.
-@end direntry
-
-@finalout
-@titlepage
-@title Ivy User Manual
-@author Oleh Krehel
-@page
-@vskip 0pt plus 1filll
-@insertcopying
-@end titlepage
-
-@contents
-
-@ifnottex
-@node Top
-@top Ivy User Manual
-@insertcopying
-@end ifnottex
-
-@menu
-* Introduction::
-* Installation::
-* Getting started::
-* Key bindings::
-* Completion styles::
-* Variable Index::
-
-@detailmenu
---- The Detailed Node Listing ---
-
-Installation
-
-* Installing from Emacs Package Manager::
-* Installing from the Git repository::
-
-Getting started
-
-* Basic customization::
-
-Key bindings
-
-* Global key bindings::
-* Minibuffer key bindings::
-
-Minibuffer key bindings
-
-* Key bindings for navigation::
-* Key bindings for single selection, action, then exit minibuffer: Key 
bindings for single selection action then exit minibuffer.
-* Key bindings for multiple selections and actions, keep minibuffer open: Key 
bindings for multiple selections and actions keep minibuffer open.
-* Key bindings that alter minibuffer input::
-* Other key bindings::
-* Hydra in the minibuffer::
-* Saving the current completion session to a buffer::
-Completion styles
-
-* ivy--regex-plus::
-* ivy--regex-ignore-order::
-* ivy--regex-fuzzy::
-@end detailmenu
-@end menu
-
-@node Introduction
-@chapter Introduction
-
-Ivy is for quick and easy selection from a list. When Emacs prompts
-for a string from a list of several possible choices, Ivy springs into
-action to assist in narrowing and picking the right string from a vast
-number of choices.
-
-Ivy strives for minimalism, simplicity, customizability and
-discoverability.
-
-@subsubheading Minimalism
-Uncluttered minibuffer is minimalism. Ivy shows the completion
-defaults, the number of matches, and 10 candidate matches below the
-input line. Customize @code{ivy-length} to adjust the number of candidate
-matches displayed in the minibuffer.
-
-@subsubheading Simplicity
-Simplicity is about Ivy's behavior in the minibuffer. It is also about
-the code interface to extend Ivy's functionality. The minibuffer area
-behaves as close to @code{fundamental-mode} as possible. @kbd{SPC} inserts a
-space, for example, instead of being bound to the more complex
-@code{minibuffer-complete-word}. Ivy's code uses easy-to-examine global
-variables; avoids needless complications with branch-introducing
-custom macros.
-
-@subsubheading Customizability
-Customizability is about being able to use different methods and
-interfaces of completion to tailor the selection process. For example,
-adding a custom display function that points to a selected candidate
-with @code{->}, instead of highlighting the selected candidate with the
-@code{ivy-current-match} face. Or take the customization of actions, say
-after the candidate function is selected. @kbd{RET} uses
-@code{counsel-describe-function} to describe the function, whereas @kbd{M-o d}
-jumps to that function's definition in the code. The @kbd{M-o} prefix can
-be uniformly used with characters like @kbd{d} to group similar actions.
-
-@subsubheading Discoverability
-Ivy displays easily discoverable commands through the hydra facility.
-@kbd{C-o} in the minibuffer displays a hydra menu. It opens up within an
-expanded minibuffer area. Each menu item comes with short
-documentation strings and highlighted one-key completions. So
-discovering even seldom used keys is simply a matter of @kbd{C-o} in the
-minibuffer while in the midst of the Ivy interaction. This
-discoverability minimizes exiting Ivy interface for documentation
-look-ups.
-
-@node Installation
-@chapter Installation
-
-Install Ivy automatically through Emacs's package manager, or manually
-from Ivy's development repository.
-@menu
-* Installing from Emacs Package Manager::
-* Installing from the Git repository::
-@end menu
-
-@node Installing from Emacs Package Manager
-@section Installing from Emacs Package Manager
-
-@kbd{M-x} @code{package-install} @kbd{RET} @code{swiper} @kbd{RET}
-
-Ivy is installed as part of @code{swiper} package. @code{swiper} is available
-from two different package archives, GNU ELPA and MELPA. For the
-latest stable version, use the GNU ELPA archives using the above M-x
-command.
-
-For current hourly builds, use the MELPA archives. See the code below
-for adding MELPA to the list of package archives:
-
-
-@lisp
-(require 'package)
-(add-to-list 'package-archives
-             '("melpa" . "http://melpa.org/packages/";))
-@end lisp
-
-After this do @kbd{M-x} @code{package-refresh-contents} @kbd{RET}, followed by
-@kbd{M-x} @code{package-install} @kbd{RET} @code{swiper} @kbd{RET}.
-
-For package manager details, see @ref{Packages,,,emacs,}.
-
-@node Installing from the Git repository
-@section Installing from the Git repository
-
-Why install from Git?
-
-@itemize
-@item
-No need to wait for MELPA's hourly builds
-@item
-Easy to revert to previous versions
-@item
-Contribute to Ivy's development; send patches; pull requests
-@end itemize
-
-@strong{Configuration steps}
-
-First clone the Swiper repository:
-
-@example
-cd ~/git && git clone https://github.com/abo-abo/swiper
-cd swiper && make compile
-@end example
-
-Then add this to Emacs init:
-
-@lisp
-(add-to-list 'load-path "~/git/swiper/")
-(require 'ivy)
-@end lisp
-
-To update the code:
-
-@example
-git pull
-make
-@end example
-
-@node Getting started
-@chapter Getting started
-
-First enable Ivy completion everywhere:
-
-
-@lisp
-(ivy-mode 1)
-@end lisp
-
-Note: @code{ivy-mode} can be toggled on and off with @kbd{M-x} @code{ivy-mode}.
-@menu
-* Basic customization::
-@end menu
-
-@node Basic customization
-@section Basic customization
-
-Here are some basic settings particularly useful for new Ivy
-users:
-
-@lisp
-(setq ivy-use-virtual-buffers t)
-(setq ivy-height 10)
-(setq ivy-display-style 'fancy)
-(setq ivy-count-format "(%d/%d) ")
-@end lisp
-
-For additional customizations, refer to @code{M-x describe-variable}
-documentation.
-
-@node Key bindings
-@chapter Key bindings
-
-@menu
-* Global key bindings::
-* Minibuffer key bindings::
-@end menu
-
-@node Global key bindings
-@section Global key bindings
-
-Recommended key bindings are:
-@subsubheading Ivy-based interface to standard commands
-
-@lisp
-(global-set-key (kbd "C-s") 'swiper)
-(global-set-key (kbd "M-x") 'counsel-M-x)
-(global-set-key (kbd "C-x C-f") 'counsel-find-file)
-(global-set-key (kbd "<f1> f") 'counsel-describe-function)
-(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
-(global-set-key (kbd "<f1> l") 'counsel-load-library)
-(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
-(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
-@end lisp
-@subsubheading Ivy-based interface to shell and system tools
-
-@lisp
-(global-set-key (kbd "C-c g") 'counsel-git)
-(global-set-key (kbd "C-c j") 'counsel-git-grep)
-(global-set-key (kbd "C-c k") 'counsel-ag)
-(global-set-key (kbd "C-x l") 'counsel-locate)
-(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
-@end lisp
-@subsubheading Ivy-resume and other commands
-@code{ivy-resume} resumes the last Ivy-based completion.
-
-@lisp
-(global-set-key (kbd "C-c C-r") 'ivy-resume)
-@end lisp
-
-@node Minibuffer key bindings
-@section Minibuffer key bindings
-
-Ivy includes several minibuffer bindings, which are defined in the
-@code{ivy-minibuffer-map} keymap variable. The most frequently used ones
-are described here.
-
-@code{swiper} or @code{counsel-M-x} add more through the @code{keymap} 
argument to
-@code{ivy-read}. These keys, also active in the minibuffer, are described
-under their respective commands.
-@menu
-* Key bindings for navigation::
-* Key bindings for single selection, action, then exit minibuffer: Key 
bindings for single selection action then exit minibuffer.
-* Key bindings for multiple selections and actions, keep minibuffer open: Key 
bindings for multiple selections and actions keep minibuffer open.
-* Key bindings that alter minibuffer input::
-* Other key bindings::
-* Hydra in the minibuffer::
-* Saving the current completion session to a buffer::
-@end menu
-
-@node Key bindings for navigation
-@subsection Key bindings for navigation
-
-@itemize
-@item
-@kbd{C-n} (@code{ivy-next-line}) selects the next candidate
-@item
-@kbd{C-p} (@code{ivy-previous-line}) selects the previous candidate
-@item
-@kbd{M-<} (@code{ivy-beginning-of-buffer}) selects the first candidate
-@item
-@kbd{M->} (@code{ivy-end-of-buffer}) selects the last candidate
-@item
-@kbd{C-v} (@code{ivy-scroll-up-command}) scrolls up by @code{ivy-height} lines
-@item
-@kbd{M-v} (@code{ivy-scroll-down-command}) scrolls down by @code{ivy-height} 
lines
-@end itemize
-
-@defopt ivy-wrap
-This user option allows to get the wrap-around behavior for @kbd{C-n} and
-@kbd{C-p}.  When set to @code{t}, @code{ivy-next-line} and 
@code{ivy-previous-line} will
-cycle past the last and the first candidates respectively.
-
-This behavior is off by default.
-@end defopt
-
-@defopt ivy-height
-Use this variable to adjust the minibuffer height, and therefore the
-scroll size for @kbd{C-v} and @kbd{M-v}.
-@end defopt
-
-@node Key bindings for single selection action then exit minibuffer
-@subsection Key bindings for single selection, action, then exit minibuffer
-
-Ivy can offer several actions from which to choose which action to
-run. This "calling an action" operates on the selected candidate. For
-example, when viewing a list of files, one action could open it for
-editing, one to view it, another to invoke a special function, and so
-on. Custom actions can be added to this interface. The precise action
-to call on the selected candidate can be delayed until after the
-narrowing is completed. No need to exit the interface if unsure which
-action to run. This delayed flexibility and customization of actions
-extends usability of lists in Emacs.
-
-@kbd{C-m} or @kbd{RET} (@code{ivy-done}) calls the default action and exits the
-minibuffer.
-
-@kbd{M-o} (@code{ivy-dispatching-done}) presents all available valid actions
-from which to choose. When there is only one action available, there
-is no difference between @kbd{M-o} and @kbd{C-m}.
-
-@kbd{C-j} (@code{ivy-alt-done}) calls the alternate action, such as completing
-a directory name in a file list whereas @kbd{C-m} will select that directory
-and exit the minibuffer.
-
-Exiting the minibuffer also closes the Ivy window (as specified by
-@code{ivy-height}). This closing and exiting sequence is conveniently off
-when applying multiple actions. Multiple actions and multiple
-selections as covered in the next section of this manual.
-
-@kbd{TAB} (@code{ivy-partial-or-done}) attempts partial completion, extending
-current input as much as possible.
-
-@kbd{TAB TAB} is the same as @kbd{C-j}.
-
-@kbd{C-M-j} (@code{ivy-immediate-done}) is useful when there is no match for
-the given input. Or there is an incorrect partial match. @kbd{C-M-j} with
-@code{find-file} lists ignores the partial match and instead takes the
-current input to create a new directory with @code{dired-create-directory}.
-
-@code{ivy-immediate-done} illustrates how Ivy distinguishes between calling
-an action on the @emph{currently selected} candidate and calling an action
-on the @emph{current input}.
-
-Invoking avy completion with @kbd{C-'} (@code{ivy-avy}).
-@kbd{C-`} uses avy's visible jump mechanism, which can further reduce
-Ivy's line-by-line scrolling that requires multiple @kbd{C-n} or @kbd{C-p}
-keystrokes.
-
-@node Key bindings for multiple selections and actions keep minibuffer open
-@subsection Key bindings for multiple selections and actions, keep minibuffer 
open
-
-For repeatedly applying multiple actions or acting on multiple
-candidates, Ivy does not close the minibuffer between commands. It
-keeps the minibuffer open for applying subsequent actions.
-
-Adding an extra meta key to the normal key chord invokes the special
-version of the regular commands that enables applying multiple
-actions.
-
-@kbd{C-M-m} (@code{ivy-call}) is the non-exiting version of the default action,
-@kbd{C-m} (@code{ivy-done}). Instead of closing the minibuffer, @kbd{C-M-m} 
allows
-selecting another candidate or another action. For example, @kbd{C-M-m} on
-functions list invokes @code{describe-function}. When combined with @kbd{C-n},
-function descriptions can be invoked quickly in succession.
-
-@kbd{RET} exits the minibuffer.
-
-@code{ivy-resume} recalls the state of the completion session just before
-its last exit. Useful after an accidental @kbd{C-m} (@code{ivy-done}).
-
-@kbd{C-M-o} (@code{ivy-dispatching-call}) is a non-exiting version of @kbd{M-o}
-(@code{ivy-dispatching-done}) that can accumulate candidates into a queue.
-For example, for playback in @code{counsel-rhythmbox}, @kbd{C-M-o e} en-queues
-the selected candidate, and @kbd{C-n C-m} plays the next one in the queue.
-
-@kbd{C-M-n} (@code{ivy-next-line-and-call}) combines @kbd{C-n} and 
@kbd{C-M-m}. Applies
-an action and moves to next line. Comes in handy when opening multiple
-files from @code{counsel-find-file}, @code{counsel-git-grep}, 
@code{counsel-ag}, or
-@code{counsel-locate} lists. Just hold @kbd{C-M-n} for rapid-fire default
-action on each successive element of the list.
-
-@kbd{C-M-p} (@code{ivy-previous-line-and-call}) combines @kbd{C-p} and 
@kbd{C-M-m}. Is
-the same as above except that it moves through the list in the other
-direction.
-
-@node Key bindings that alter minibuffer input
-@subsection Key bindings that alter minibuffer input
-
-@kbd{M-n} (@code{ivy-next-history-element}) and @kbd{M-p}
-(@code{ivy-previous-history-element}) cycle through the Ivy command
-history. Ivy updates an internal history list after each action. When
-this history list is empty, @kbd{M-n} inserts symbol (or URL) at point
-into the minibuffer.
-
-@kbd{M-i} (@code{ivy-insert-current}) inserts the current candidate into the
-minibuffer. Useful for copying and renaming files, for example: @kbd{M-i}
-to insert the original file name string, edit it, and then @kbd{C-m} to
-complete the renaming.
-
-@kbd{M-j} (@code{ivy-yank-word}) inserts sub-word at point into minibuffer. 
This
-is similar to @kbd{C-s C-w} with @code{isearch}. Ivy reserves @kbd{C-w} for
-@code{kill-region}.
-
-@kbd{S-SPC} (@code{ivy-restrict-to-matches}) deletes the current input, and
-resets the candidates list to the currently restricted matches. This
-is how Ivy provides narrowing in successive tiers.
-
-@kbd{C-r} (@code{ivy-reverse-i-search}) works just like @kbd{C-r} at bash 
command
-prompt, where the completion candidates are the history items. Upon
-completion, the selected candidate string is inserted into the
-minibuffer.
-
-@node Other key bindings
-@subsection Other key bindings
-
-@kbd{M-w} (@code{ivy-kill-ring-save}) copies selected candidates to the kill
-ring; when the region is active, copies active region.
-
-@node Hydra in the minibuffer
-@subsection Hydra in the minibuffer
-
-@kbd{C-o} (@code{hydra-ivy/body}) invokes Hydra menus with key shortcuts.
-
-@kbd{C-o} or @kbd{i} resumes editing.
-
-Hydra reduces key strokes, for example: @kbd{C-n C-n C-n C-n} is @kbd{C-o
-jjjj} in Hydra. Hydra has other benefits besides certain shorter key
-bindings:
-@itemize
-@item
-@kbd{<} and @kbd{>} to adjust height of minibuffer,
-@item
-describes the current completion state, such as case folding and the
-current action.
-@end itemize
-
-Minibuffer editing is disabled when Hydra is active.
-
-@node Saving the current completion session to a buffer
-@subsection Saving the current completion session to a buffer
-
-@kbd{C-c C-o} (@code{ivy-occur}) saves the current candidates to a new buffer;
-the list is active in the new buffer.
-
-@kbd{RET} or @kbd{mouse-1} in the new buffer calls the appropriate action on
-the selected candidate.
-
-Ivy has no limit on the number of active buffers like these.
-
-Ivy takes care of making these buffer names unique. It applies
-descriptive names, for example: @code{*ivy-occur counsel-describe-variable
-"function$*}.
-
-@node Completion styles
-@chapter Completion styles
-
-Ivy's completion functions rely on the highly configurable regex
-builder.
-
-The default is:
-
-@lisp
-(setq ivy-re-builders-alist
-      '((t . ivy--regex-plus)))
-@end lisp
-
-The default @code{ivy--regex-plus} narrowing is always invoked unless
-specified otherwise. For example, file name completion may have a
-custom completion function:
-
-@lisp
-(setq ivy-re-builders-alist
-      '((read-file-name-internal . ivy--regex-fuzzy)
-        (t . ivy--regex-plus)))
-@end lisp
-
-Ivy's flexibility extends to using different styles of completion
-mechanics (regex-builders) for different types of lists. Despite this
-flexibility, Ivy operates within a consistent and uniform interface.
-The main regex-builders currently in Ivy are:
-@menu
-* ivy--regex-plus::
-* ivy--regex-ignore-order::
-* ivy--regex-fuzzy::
-@end menu
-
-@node ivy--regex-plus
-@section ivy--regex-plus
-
-@code{ivy--regex-plus} is Ivy's default completion method.
-
-@code{ivy--regex-plus} matches by splitting the input by spaces and
-rebuilding it into a regex.
-
-As the search string is typed in Ivy's minibuffer, it is transformed
-into proper regex syntax. If the string is "for example", it is
-transformed into
-
-@verbatim
-"\\(for\\).*\\(example\\)"
-@end verbatim
-
-which in regex terminology matches "for" followed by a wild card and
-then "example". Note how Ivy uses the space character to build
-wild cards. For literal white space matching in Ivy, use an extra space:
-to match one space type two spaces, to match two spaces type three
-spaces, and so on.
-
-As Ivy transforms typed characters into regex strings, it provides an
-intuitive feedback through font highlights.
-
-Ivy supports regexp negation with "!". For example, "define key ! ivy
-quit" first selects everything matching "define.*key", then removes
-everything matching "ivy", and finally removes everything matching
-"quit". What remains is the final result set of the negation regexp.
-
-@verbatim
-Standard regexp identifiers work:
-
-"^", "$", "\b" or "[a-z]"
-@end verbatim
-
-Since Ivy treats minibuffer input as a regexp, standard regexp
-identifiers work as usual. The exceptions are spaces, which
-translate to ".*", and "!" that signal the beginning of a negation
-group.
-
-@node ivy--regex-ignore-order
-@section ivy--regex-ignore-order
-
-@code{ivy--regex-ignore-order} ignores the order of regexp tokens when
-searching for matching candidates. For instance, the input "for
-example" will match "example test for". Otherwise @code{ivy--regex-plus}
-normal behavior is to honor the order of regexp tokens.
-
-@node ivy--regex-fuzzy
-@section ivy--regex-fuzzy
-
-@code{ivy--regex-fuzzy} splits each character with a wild card. Searching
-for "for" returns all "f.*o.*r" matches, resulting in a large number
-of hits.  Yet some searches need these extra hits. Ivy sorts such
-large lists using @code{flx} package's scoring mechanism, if it's
-installed.
-
-@node Variable Index
-@chapter Variable Index
-
-@printindex vr
-
-@bye
diff --git a/doc/style.css b/doc/style.css
deleted file mode 100644
index 547b4f0..0000000
--- a/doc/style.css
+++ /dev/null
@@ -1,107 +0,0 @@
-body {
-    color: #333;
-    background-color: #ffffff;
-    margin-left: 1em;
-    margin-right: auto;
-    font-family: 'Ubuntu Mono', sans-serif;
-    max-width: 50em;
-}
-
-body a {
-    color: blue;
-}
-
-h2 {
-    font-weight: normal;
-    text-indent: 0;
-    border-radius: 15px;
-    background-color: #d6d8ec;
-    text-align: left;
-    padding: 3px 3px 3px 3px;
-}
-
-h2 a[id^="unnumbered"] {
-    background-color: #d6d8ec;
-}
-
-h2 a {
-    color: white;
-    background-color:#777777;
-    font-size:18px;
-    border-radius:3px;
-    padding: 0px 5px 0px 5px; 
-}
-
-kbd {
-    padding:0.1em 0.6em;
-    border:1px solid #ccc;
-    font-size:13px;
-    font-weight:bold;
-    font-family:monospace;
-    background-color:#d6d8ec;
-    color:#333;
-    -moz-box-shadow:0 1px 0px rgba(0, 0, 0, 0.2),0 0 0 2px #ffffff inset;
-    -webkit-box-shadow:0 1px 0px rgba(0, 0, 0, 0.2),0 0 0 2px #ffffff inset;
-    box-shadow:0 1px 0px rgba(0, 0, 0, 0.2),0 0 0 2px #ffffff inset;
-    -moz-border-radius:3px;
-    -webkit-border-radius:3px;
-    border-radius:3px;
-    display:inline-block;
-    margin:0 0.1em;
-    text-shadow:0 1px 0 #fff;
-    line-height:1.4;
-    white-space:nowrap;
-}
-
-body a code {
-    color: black;
-    border: 1px solid Blue;
-    border-radius:3px;
-}
-
-code {
-    font-size:13px;
-    border: 1px solid Silver;
-    background-color: #e3e4ec;
-}
-
-pre {
-    border: 1px solid Silver;
-    background-color: #eeeeee;
-    padding: 3px;
-    margin-left: 1em;
-}
-
-cursor {
-    color: #fff;
-    background-color: #000;
-    overflow: hidden;
-}
-
-h3 {
-    counter-reset: chapter;
-}
-
-h4 {
-    margin-left: auto;
-}
-
-table, td, th {
-    border: 0px;
-}
-
-th {
-    background-color:#d6d8ec;
-}
-
-tr:nth-child(odd) {
-    background-color:#fff;
-}
-tr:nth-child(even) {
-    background-color:#d6d8ec;
-}
-
-.region {
-    color: #ffffff;
-    background-color: #f9b593;
-}
diff --git a/ivy-hydra.el b/ivy-hydra.el
deleted file mode 100644
index 63755da..0000000
--- a/ivy-hydra.el
+++ /dev/null
@@ -1,90 +0,0 @@
-;;; ivy-hydra.el --- Additional key bindings for Ivy  -*- lexical-binding: t 
-*-
-
-;; Copyright (C) 2015  Free Software Foundation, Inc.
-
-;; Author: Oleh Krehel
-
-;; This file is part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; For a full copy of the GNU General Public License
-;; see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; This package provides the `hydra-ivy/body' command, which is a
-;; quasi-prefix map, with many useful bindings.  These bindings are
-;; shorter than usual, using mostly unprefixed keys.
-
-;;; Code:
-(require 'hydra nil t)
-(require 'ivy)
-
-(eval-when-compile
-  (unless (or (featurep 'hydra) (package-installed-p 'hydra))
-    (defmacro defhydra (name &rest _)
-      "This is a stub for the uninstalled `hydra' package."
-      `(defun ,(intern (format "%S/body" name)) ()
-         (interactive)
-         (let ((enable-recursive-minibuffers t))
-           (if (yes-or-no-p "Package `hydra' not installed. Install?")
-               (progn
-                 (package-install 'hydra)
-                 (save-window-excursion
-                   (find-library "ivy-hydra")
-                   (byte-compile-file (buffer-file-name) t)))
-             (error "Please install `hydra' and recompile/reinstall 
`ivy-hydra'")))))))
-
-(defun ivy--matcher-desc ()
-  (if (eq ivy--regex-function
-          'ivy--regex-fuzzy)
-      "fuzzy"
-    "ivy"))
-
-(defhydra hydra-ivy (:hint nil
-                     :color pink)
-  "
-^^^^^^          ^Yes^    ^^      ^No^     ^Maybe^            
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Action^               ^
-^^^^^^^^^^^^^^^----------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------
-^ ^ _k_ ^ ^     _f_ollow occ_u_r _i_nsert _c_: calling %-5s(if ivy-calling 
\"on\" \"off\") _w_/_s_/_a_: %-14s(ivy-action-name)
-_h_ ^+^ _l_     _d_one      ^ ^  _o_ops   _m_: matcher 
%-5s(ivy--matcher-desc)^^^^^^^^^^^^ _C_ase-fold: %-10`ivy-case-fold-search
-^ ^ _j_ ^ ^     _g_o        ^ ^  ^ ^      _<_/_>_: 
shrink/grow^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _t_runcate: %-11`truncate-lines
-"
-  ;; arrows
-  ("h" ivy-beginning-of-buffer)
-  ("j" ivy-next-line)
-  ("k" ivy-previous-line)
-  ("l" ivy-end-of-buffer)
-  ;; actions
-  ("o" keyboard-escape-quit :exit t)
-  ("C-g" keyboard-escape-quit :exit t)
-  ("i" nil)
-  ("C-o" nil)
-  ("f" ivy-alt-done :exit nil)
-  ("C-j" ivy-alt-done :exit nil)
-  ("d" ivy-done :exit t)
-  ("g" ivy-call)
-  ("C-m" ivy-done :exit t)
-  ("c" ivy-toggle-calling)
-  ("m" ivy-toggle-fuzzy)
-  (">" ivy-minibuffer-grow)
-  ("<" ivy-minibuffer-shrink)
-  ("w" ivy-prev-action)
-  ("s" ivy-next-action)
-  ("a" ivy-read-action)
-  ("t" (setq truncate-lines (not truncate-lines)))
-  ("C" ivy-toggle-case-fold)
-  ("u" ivy-occur :exit t))
-
-(provide 'ivy-hydra)
-
-;;; ivy-hydra.el ends here
diff --git a/ivy-test.el b/ivy-test.el
deleted file mode 100644
index ec5857d..0000000
--- a/ivy-test.el
+++ /dev/null
@@ -1,140 +0,0 @@
-;;; ivy-test.el --- tests for ivy
-
-;; Copyright (C) 2015  Free Software Foundation, Inc.
-
-;; Author: Oleh Krehel
-
-;; This file is part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; For a full copy of the GNU General Public License
-;; see <http://www.gnu.org/licenses/>.
-
-(require 'ert)
-(require 'ivy)
-
-(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-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")
-           "z"))
-  (should (equal
-           (ivy-with '(ivy-read "pattern: " '("blue" "yellow"))
-                     "y <backspace> C-m")
-           "blue"))
-  (should (equal
-           (ivy-with '(let ((ivy-re-builders-alist '((t . ivy--regex-fuzzy))))
-                       (ivy-read "pattern: " '("package-list-packages" 
"something-else")))
-                     "plp C-m")
-           "package-list-packages"))
-  (should (equal
-           (ivy-with '(ivy-read "test" '("aaab" "aaac"))
-                     "a C-n <tab> C-m")
-           "aaac"))
-  (should (equal
-           (ivy-with '(ivy-read "pattern: " '("can do" "can" "can't do"))
-                     "can C-m")
-           "can")))
-
-(ert-deftest swiper--re-builder ()
-  (setq swiper--width 4)
-  (should (string= (swiper--re-builder "^")
-                   "."))
-  (should (string= (swiper--re-builder "^a")
-                   "^ ?\\(a\\)"))
-  (should (string= (swiper--re-builder "^a b")
-                   "^ \\(a\\).*?\\(b\\)")))
-
-(ert-deftest ivy--split ()
-  (should (equal (ivy--split "King of the who?")
-                 '("King" "of" "the" "who?")))
-  (should (equal (ivy--split "The  Brittons.")
-                 '("The Brittons.")))
-  (should (equal (ivy--split "Who  are the  Brittons?")
-                 '("Who are" "the Brittons?")))
-  (should (equal (ivy--split "We're  all  Britons and   I   am your   king.")
-                 '("We're all Britons"
-                  "and  I  am"
-                   "your  king."))))
-
-(ert-deftest ivy--regex-fuzzy ()
-  (should (string= (ivy--regex-fuzzy "tmux")
-                   "\\(t\\).*\\(m\\).*\\(u\\).*\\(x\\)"))
-  (should (string= (ivy--regex-fuzzy "^tmux")
-                   "^\\(t\\).*\\(m\\).*\\(u\\).*\\(x\\)"))
-  (should (string= (ivy--regex-fuzzy "^tmux$")
-                   "^\\(t\\).*\\(m\\).*\\(u\\).*\\(x\\)$"))
-  (should (string= (ivy--regex-fuzzy "")
-                   ""))
-  (should (string= (ivy--regex-fuzzy "^")
-                   "^"))
-  (should (string= (ivy--regex-fuzzy "$")
-                   "$")))
-
-(ert-deftest ivy--format ()
-  (should (string= (let ((ivy--index 10)
-                         (ivy-format-function (lambda (x) (mapconcat (lambda 
(y) (car y)) x "\n")))
-                         (cands '("NAME"
-                                  "SYNOPSIS"
-                                  "DESCRIPTION"
-                                  "FUNCTION LETTERS"
-                                  "SWITCHES"
-                                  "DIAGNOSTICS"
-                                  "EXAMPLE 1"
-                                  "EXAMPLE 2"
-                                  "EXAMPLE 3"
-                                  "SEE ALSO"
-                                  "AUTHOR")))
-                     (ivy--format cands))
-                   #("\nDESCRIPTION\nFUNCTION 
LETTERS\nSWITCHES\nDIAGNOSTICS\nEXAMPLE 1\nEXAMPLE 2\nEXAMPLE 3\nSEE 
ALSO\nAUTHOR"
-                     0 90 (read-only nil)
-                     90 96 (face ivy-current-match read-only nil)))))
-
-(ert-deftest ivy--filter ()
-  (setq ivy-last (make-ivy-state))
-  (should (equal (ivy--filter "the" '("foo" "the" "The"))
-                 '("the" "The")))
-  (should (equal (ivy--filter "The" '("foo" "the" "The"))
-                 '("The"))))
diff --git a/ivy.el b/ivy.el
deleted file mode 100644
index 5127582..0000000
--- a/ivy.el
+++ /dev/null
@@ -1,2445 +0,0 @@
-;;; ivy.el --- Incremental Vertical completYon -*- lexical-binding: t -*-
-
-;; Copyright (C) 2015  Free Software Foundation, Inc.
-
-;; Author: Oleh Krehel <ohwoeowho@gmail.com>
-;; URL: https://github.com/abo-abo/swiper
-;; Package-Requires: ((emacs "24.1"))
-;; Keywords: matching
-
-;; This file is part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; For a full copy of the GNU General Public License
-;; see <http://www.gnu.org/licenses/>.
-
-;;; Commentary:
-;;
-;; This package provides `ivy-read' as an alternative to
-;; `completing-read' and similar functions.
-;;
-;; There's no intricate code to determine the best candidate.
-;; Instead, the user can navigate to it with `ivy-next-line' and
-;; `ivy-previous-line'.
-;;
-;; The matching is done by splitting the input text by spaces and
-;; re-building it into a regex.
-;; So "for example" is transformed into "\\(for\\).*\\(example\\)".
-
-;;; Code:
-(require 'cl-lib)
-(require 'ffap)
-
-;;* Customization
-(defgroup ivy nil
-  "Incremental vertical completion."
-  :group 'convenience)
-
-(defgroup ivy-faces nil
-  "Font-lock faces for `ivy'."
-  :group 'ivy)
-
-(defface ivy-current-match
-  '((((class color) (background light))
-     :background "#1a4b77" :foreground "white")
-    (((class color) (background dark))
-     :background "#65a7e2" :foreground "black"))
-  "Face used by Ivy for highlighting the current match.")
-
-(defface ivy-minibuffer-match-face-1
-  '((((class color) (background light))
-     :background "#d3d3d3")
-    (((class color) (background dark))
-     :background "#555555"))
-  "The background face for `ivy' minibuffer matches.")
-
-(defface ivy-minibuffer-match-face-2
-  '((((class color) (background light))
-     :background "#e99ce8" :weight bold)
-    (((class color) (background dark))
-     :background "#777777" :weight bold))
-  "Face for `ivy' minibuffer matches modulo 1.")
-
-(defface ivy-minibuffer-match-face-3
-  '((((class color) (background light))
-     :background "#bbbbff" :weight bold)
-    (((class color) (background dark))
-     :background "#7777ff" :weight bold))
-  "Face for `ivy' minibuffer matches modulo 2.")
-
-(defface ivy-minibuffer-match-face-4
-  '((((class color) (background light))
-     :background "#ffbbff" :weight bold)
-    (((class color) (background dark))
-     :background "#8a498a" :weight bold))
-  "Face for `ivy' minibuffer matches modulo 3.")
-
-(defface ivy-confirm-face
-  '((t :foreground "ForestGreen" :inherit minibuffer-prompt))
-  "Face used by Ivy for a confirmation prompt.")
-
-(defface ivy-match-required-face
-  '((t :foreground "red" :inherit minibuffer-prompt))
-  "Face used by Ivy for a match required prompt.")
-
-(setcdr (assoc load-file-name custom-current-group-alist) 'ivy)
-
-(defface ivy-subdir
-  '((t (:inherit 'dired-directory)))
-  "Face used by Ivy for highlighting subdirs in the alternatives.")
-
-(defface ivy-modified-buffer
-  '((t :inherit 'default))
-  "Face used by Ivy for highlighting modified file visiting buffers.")
-
-(defface ivy-remote
-  '((t (:foreground "#110099")))
-  "Face used by Ivy for highlighting remotes in the alternatives.")
-
-(defface ivy-virtual
-  '((t :inherit font-lock-builtin-face))
-  "Face used by Ivy for matching virtual buffer names.")
-
-(defcustom ivy-height 10
-  "Number of lines for the minibuffer window."
-  :type 'integer)
-
-(defcustom ivy-count-format "%-4d "
-  "The style to use for displaying the current candidate count for `ivy-read'.
-Set this to \"\" to suppress the count visibility.
-Set this to \"(%d/%d) \" to display both the index and the count."
-  :type '(choice
-          (const :tag "Count disabled" "")
-          (const :tag "Count matches" "%-4d ")
-          (const :tag "Count matches and show current match" "(%d/%d) ")
-          string))
-
-(defcustom ivy-wrap nil
-  "When non-nil, wrap around after the first and the last candidate."
-  :type 'boolean)
-
-(defcustom ivy-display-style (unless (version< emacs-version "24.5") 'fancy)
-  "The style for formatting the minibuffer.
-
-By default, the matched strings are copied as is.
-
-The fancy display style highlights matching parts of the regexp,
-a behavior similar to `swiper'.
-
-This setting depends on `add-face-text-property' - a C function
-available as of Emacs 24.5. Fancy style will render poorly in
-earlier versions of Emacs."
-  :type '(choice
-          (const :tag "Plain" nil)
-          (const :tag "Fancy" fancy)))
-
-(defcustom ivy-on-del-error-function 'minibuffer-keyboard-quit
-  "The handler for when `ivy-backward-delete-char' throws.
-Usually a quick exit out of the minibuffer."
-  :type 'function)
-
-(defcustom ivy-extra-directories '("../" "./")
-  "Add this to the front of the list when completing file names.
-Only \"./\" and \"../\" apply here. They appear in reverse order."
-  :type '(repeat :tag "Dirs"
-          (choice
-           (const :tag "Parent Directory" "../")
-           (const :tag "Current Directory" "./"))))
-
-(defcustom ivy-use-virtual-buffers nil
-  "When non-nil, add `recentf-mode' and bookmarks to `ivy-switch-buffer'."
-  :type 'boolean)
-
-(defvar ivy--actions-list nil
-  "A list of extra actions per command.")
-
-(defun ivy-set-actions (cmd actions)
-  "Set CMD extra exit points to ACTIONS."
-  (setq ivy--actions-list
-        (plist-put ivy--actions-list cmd actions)))
-
-;;* Keymap
-(require 'delsel)
-(defvar ivy-minibuffer-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-m") 'ivy-done)
-    (define-key map (kbd "C-M-m") 'ivy-call)
-    (define-key map (kbd "C-j") 'ivy-alt-done)
-    (define-key map (kbd "C-M-j") 'ivy-immediate-done)
-    (define-key map (kbd "TAB") 'ivy-partial-or-done)
-    (define-key map (kbd "C-n") 'ivy-next-line)
-    (define-key map (kbd "C-p") 'ivy-previous-line)
-    (define-key map (kbd "<down>") 'ivy-next-line)
-    (define-key map (kbd "<up>") 'ivy-previous-line)
-    (define-key map (kbd "C-s") 'ivy-next-line-or-history)
-    (define-key map (kbd "C-r") 'ivy-reverse-i-search)
-    (define-key map (kbd "SPC") 'self-insert-command)
-    (define-key map (kbd "DEL") 'ivy-backward-delete-char)
-    (define-key map (kbd "M-DEL") 'ivy-backward-kill-word)
-    (define-key map (kbd "C-d") 'ivy-delete-char)
-    (define-key map (kbd "C-f") 'ivy-forward-char)
-    (define-key map (kbd "M-d") 'ivy-kill-word)
-    (define-key map (kbd "M-<") 'ivy-beginning-of-buffer)
-    (define-key map (kbd "M->") 'ivy-end-of-buffer)
-    (define-key map (kbd "M-n") 'ivy-next-history-element)
-    (define-key map (kbd "M-p") 'ivy-previous-history-element)
-    (define-key map (kbd "C-g") 'minibuffer-keyboard-quit)
-    (define-key map (kbd "C-v") 'ivy-scroll-up-command)
-    (define-key map (kbd "M-v") 'ivy-scroll-down-command)
-    (define-key map (kbd "C-M-n") 'ivy-next-line-and-call)
-    (define-key map (kbd "C-M-p") 'ivy-previous-line-and-call)
-    (define-key map (kbd "M-q") 'ivy-toggle-regexp-quote)
-    (define-key map (kbd "M-j") 'ivy-yank-word)
-    (define-key map (kbd "M-i") 'ivy-insert-current)
-    (define-key map (kbd "C-o") 'hydra-ivy/body)
-    (define-key map (kbd "M-o") 'ivy-dispatching-done)
-    (define-key map (kbd "C-M-o") 'ivy-dispatching-call)
-    (define-key map (kbd "C-k") 'ivy-kill-line)
-    (define-key map (kbd "S-SPC") 'ivy-restrict-to-matches)
-    (define-key map (kbd "M-w") 'ivy-kill-ring-save)
-    (define-key map (kbd "C-'") 'ivy-avy)
-    (define-key map (kbd "C-M-a") 'ivy-read-action)
-    (define-key map (kbd "C-c C-o") 'ivy-occur)
-    map)
-  "Keymap used in the minibuffer.")
-(autoload 'hydra-ivy/body "ivy-hydra" "" t)
-
-(defvar ivy-mode-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map [remap switch-to-buffer] 'ivy-switch-buffer)
-    map)
-  "Keymap for `ivy-mode'.")
-
-;;* Globals
-(cl-defstruct ivy-state
-  prompt collection
-  predicate require-match initial-input
-  history preselect keymap update-fn sort
-  ;; The window in which `ivy-read' was called
-  window
-  ;; The buffer in which `ivy-read' was called
-  buffer
-  ;; The value of `ivy-text' to be used by `ivy-occur'
-  text
-  action
-  unwind
-  re-builder
-  matcher
-  ;; When this is non-nil, call it for each input change to get new candidates
-  dynamic-collection
-  caller)
-
-(defvar ivy-last nil
-  "The last parameters passed to `ivy-read'.
-
-This should eventually become a stack so that you could use
-`ivy-read' recursively.")
-
-(defsubst ivy-set-action (action)
-  (setf (ivy-state-action ivy-last) action))
-
-(defvar ivy-history nil
-  "History list of candidates entered in the minibuffer.
-
-Maximum length of the history list is determined by the value
-of `history-length'.")
-
-(defvar ivy--directory nil
-  "Current directory when completing file names.")
-
-(defvar ivy--length 0
-  "Store the amount of viable candidates.")
-
-(defvar ivy-text ""
-  "Store the user's string as it is typed in.")
-
-(defvar ivy--current ""
-  "Current candidate.")
-
-(defvar ivy--index 0
-  "Store the index of the current candidate.")
-
-(defvar ivy-exit nil
-  "Store 'done if the completion was successfully selected.
-Otherwise, store nil.")
-
-(defvar ivy--all-candidates nil
-  "Store the candidates passed to `ivy-read'.")
-
-(defvar ivy--default nil
-  "Default initial input.")
-
-(defvar ivy--prompt nil
-  "Store the format-style prompt.
-When non-nil, it should contain at least one %d.")
-
-(defvar ivy--prompt-extra ""
-  "Temporary modifications to the prompt.")
-
-(defvar ivy--old-re nil
-  "Store the old regexp.")
-
-(defvar ivy--old-cands nil
-  "Store the candidates matched by `ivy--old-re'.")
-
-(defvar ivy--regex-function 'ivy--regex
-  "Current function for building a regex.")
-
-(defvar ivy--subexps 0
-  "Number of groups in the current `ivy--regex'.")
-
-(defvar ivy--full-length nil
-  "When :dynamic-collection is non-nil, this can be the total amount of 
candidates.")
-
-(defvar ivy--old-text ""
-  "Store old `ivy-text' for dynamic completion.")
-
-(defvar ivy-case-fold-search 'auto
-  "Store the current overriding `case-fold-search'.")
-
-(defvar Info-current-file)
-
-(defmacro ivy-quit-and-run (&rest body)
-  "Quit the minibuffer and run BODY afterwards."
-  `(progn
-     (put 'quit 'error-message "")
-     (run-at-time nil nil
-                  (lambda ()
-                    (put 'quit 'error-message "Quit")
-                    ,@body))
-     (minibuffer-keyboard-quit)))
-
-(defun ivy-exit-with-action (action)
-  "Quit the minibuffer and call ACTION afterwards."
-  (ivy-set-action
-   `(lambda (x)
-      (funcall ',action x)
-      (ivy-set-action ',(ivy-state-action ivy-last))))
-  (setq ivy-exit 'done)
-  (exit-minibuffer))
-
-(defmacro with-ivy-window (&rest body)
-  "Execute BODY in the window from which `ivy-read' was called."
-  (declare (indent 0)
-           (debug t))
-  `(with-selected-window (ivy--get-window ivy-last)
-     ,@body))
-
-(defun ivy--done (text)
-  "Insert TEXT and exit minibuffer."
-  (if (and ivy--directory
-           (not (eq (ivy-state-history ivy-last) 'grep-files-history)))
-      (insert (setq ivy--current (expand-file-name
-                                  text ivy--directory)))
-    (insert (setq ivy--current text)))
-  (setq ivy-exit 'done)
-  (exit-minibuffer))
-
-;;* Commands
-(defun ivy-done ()
-  "Exit the minibuffer with the selected candidate."
-  (interactive)
-  (delete-minibuffer-contents)
-  (cond ((> ivy--length 0)
-         (ivy--done ivy--current))
-        ((memq (ivy-state-collection ivy-last)
-               '(read-file-name-internal internal-complete-buffer))
-         (if (or (not (eq confirm-nonexistent-file-or-buffer t))
-                 (equal " (confirm)" ivy--prompt-extra))
-             (ivy--done ivy-text)
-           (setq ivy--prompt-extra " (confirm)")
-           (insert ivy-text)
-           (ivy--exhibit)))
-        ((memq (ivy-state-require-match ivy-last)
-               '(nil confirm confirm-after-completion))
-         (ivy--done ivy-text))
-        (t
-         (setq ivy--prompt-extra " (match required)")
-         (insert ivy-text)
-         (ivy--exhibit))))
-
-(defun ivy-read-action ()
-  "Change the action to one of the available ones."
-  (interactive)
-  (let ((actions (ivy-state-action ivy-last)))
-    (unless (null (ivy--actionp actions))
-      (let* ((hint (concat ivy--current
-                           "\n"
-                           (mapconcat
-                            (lambda (x)
-                              (format "%s: %s"
-                                      (propertize
-                                       (car x)
-                                       'face 'font-lock-builtin-face)
-                                      (nth 2 x)))
-                            (cdr actions)
-                            "\n")
-                           "\n"))
-             (key (string (read-key hint)))
-             (action-idx (cl-position-if
-                          (lambda (x) (equal (car x) key))
-                          (cdr actions))))
-        (cond ((string= key ""))
-              ((null action-idx)
-               (error "%s is not bound" key))
-              (t
-               (message "")
-               (setcar actions (1+ action-idx))
-               (ivy-set-action actions)))))))
-
-(defun ivy-dispatching-done ()
-  "Select one of the available actions and call `ivy-done'."
-  (interactive)
-  (ivy-read-action)
-  (ivy-done))
-
-(defun ivy-dispatching-call ()
-  "Select one of the available actions and call `ivy-call'."
-  (interactive)
-  (let ((actions (copy-sequence (ivy-state-action ivy-last))))
-    (unwind-protect
-         (when (ivy-read-action)
-           (ivy-call))
-      (ivy-set-action actions))))
-
-(defun ivy-build-tramp-name (x)
-  "Reconstruct X into a path.
-Is is a cons cell, related to `tramp-get-completion-function'."
-  (let ((user (car x))
-        (domain (cadr x)))
-    (if user
-        (concat user "@" domain)
-      domain)))
-
-(declare-function tramp-get-completion-function "tramp")
-(declare-function Info-find-node "info")
-
-(defun ivy-alt-done (&optional arg)
-  "Exit the minibuffer with the selected candidate.
-When ARG is t, exit with current text, ignoring the candidates."
-  (interactive "P")
-  (cond (arg
-         (ivy-immediate-done))
-        (ivy--directory
-         (ivy--directory-done))
-        ((eq (ivy-state-collection ivy-last) 'Info-read-node-name-1)
-         (if (or (equal ivy--current "(./)")
-                 (equal ivy--current "(../)"))
-             (ivy-quit-and-run
-              (ivy-read "Go to file: " 'read-file-name-internal
-                        :action (lambda (x)
-                                  (Info-find-node
-                                   (expand-file-name x ivy--directory)
-                                   "Top"))))
-           (ivy-done)))
-        (t
-         (ivy-done))))
-
-(defun ivy--directory-done ()
-  "Handle exit from the minibuffer when completing file names."
-  (let (dir)
-    (cond
-      ((equal ivy-text "/sudo::")
-       (setq dir (concat ivy-text ivy--directory))
-       (ivy--cd dir)
-       (ivy--exhibit))
-      ((or
-        (and
-         (not (equal ivy-text ""))
-         (ignore-errors
-           (file-directory-p
-            (setq dir
-                  (file-name-as-directory
-                   (expand-file-name
-                    ivy-text ivy--directory))))))
-        (and
-         (not (string= ivy--current "./"))
-         (cl-plusp ivy--length)
-         (ignore-errors
-           (file-directory-p
-            (setq dir (file-name-as-directory
-                       (expand-file-name
-                        ivy--current ivy--directory)))))))
-       (ivy--cd dir)
-       (ivy--exhibit))
-      ((or (and (equal ivy--directory "/")
-                (string-match "\\`[^/]+:.*:.*\\'" ivy-text))
-           (string-match "\\`/[^/]+:.*:.*\\'" ivy-text))
-       (ivy-done))
-      ((or (and (equal ivy--directory "/")
-                (cond ((string-match
-                        "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
-                        ivy-text))
-                      ((string-match
-                        "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
-                        ivy--current)
-                       (setq ivy-text ivy--current))))
-           (string-match
-            "\\`/\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
-            ivy-text))
-       (let ((method (match-string 1 ivy-text))
-             (user (match-string 2 ivy-text))
-             (rest (match-string 3 ivy-text))
-             res)
-         (require 'tramp)
-         (dolist (x (tramp-get-completion-function method))
-           (setq res (append res (funcall (car x) (cadr x)))))
-         (setq res (delq nil res))
-         (when user
-           (dolist (x res)
-             (setcar x user)))
-         (setq res (cl-delete-duplicates res :test #'equal))
-         (let* ((old-ivy-last ivy-last)
-                (enable-recursive-minibuffers t)
-                (host (ivy-read "Find File: "
-                                (mapcar #'ivy-build-tramp-name res)
-                                :initial-input rest)))
-           (setq ivy-last old-ivy-last)
-           (when host
-             (setq ivy--directory "/")
-             (ivy--cd (concat "/" method ":" host ":"))))))
-      (t
-       (ivy-done)))))
-
-(defcustom ivy-tab-space nil
-  "When non-nil, `ivy-partial-or-done' should insert a space."
-  :type 'boolean)
-
-(defun ivy-partial-or-done ()
-  "Complete the minibuffer text as much as possible.
-If the text hasn't changed as a result, forward to `ivy-alt-done'."
-  (interactive)
-  (if (and (eq (ivy-state-collection ivy-last) #'read-file-name-internal)
-           (or (and (equal ivy--directory "/")
-                    (string-match "\\`[^/]+:.*\\'" ivy-text))
-               (string-match "\\`/" ivy-text)))
-      (let ((default-directory ivy--directory))
-        (minibuffer-complete)
-        (setq ivy-text (ivy--input))
-        (when (file-directory-p
-               (expand-file-name ivy-text ivy--directory))
-          (ivy--cd (file-name-as-directory
-                    (expand-file-name ivy-text ivy--directory)))))
-    (or (ivy-partial)
-        (when (or (eq this-command last-command)
-                  (eq ivy--length 1))
-          (ivy-alt-done)))))
-
-(defun ivy-partial ()
-  "Complete the minibuffer text as much as possible."
-  (interactive)
-  (let* ((parts (or (split-string ivy-text " " t) (list "")))
-         (postfix (car (last parts)))
-         (completion-ignore-case t)
-         (startp (string-match "^\\^" postfix))
-         (new (try-completion (if startp
-                                  (substring postfix 1)
-                                postfix)
-                              (mapcar (lambda (str)
-                                        (let ((i (string-match postfix str)))
-                                          (when i
-                                            (substring str i))))
-                                      ivy--old-cands))))
-    (cond ((eq new t) nil)
-          ((string= new ivy-text) nil)
-          (new
-           (delete-region (minibuffer-prompt-end) (point-max))
-           (setcar (last parts)
-                   (if startp
-                       (concat "^" new)
-                     new))
-           (insert (mapconcat #'identity parts " ")
-                   (if ivy-tab-space " " ""))
-           t))))
-
-(defun ivy-immediate-done ()
-  "Exit the minibuffer with the current input."
-  (interactive)
-  (delete-minibuffer-contents)
-  (insert (setq ivy--current
-                (if ivy--directory
-                    (expand-file-name ivy-text ivy--directory)
-                  ivy-text)))
-  (setq ivy-exit 'done)
-  (exit-minibuffer))
-
-;;;###autoload
-(defun ivy-resume ()
-  "Resume the last completion session."
-  (interactive)
-  (when (eq (ivy-state-caller ivy-last) 'swiper)
-    (switch-to-buffer (ivy-state-buffer ivy-last)))
-  (with-current-buffer (ivy-state-buffer ivy-last)
-    (ivy-read
-     (ivy-state-prompt ivy-last)
-     (ivy-state-collection ivy-last)
-     :predicate (ivy-state-predicate ivy-last)
-     :require-match (ivy-state-require-match ivy-last)
-     :initial-input ivy-text
-     :history (ivy-state-history ivy-last)
-     :preselect (unless (eq (ivy-state-collection ivy-last)
-                            'read-file-name-internal)
-                  ivy--current)
-     :keymap (ivy-state-keymap ivy-last)
-     :update-fn (ivy-state-update-fn ivy-last)
-     :sort (ivy-state-sort ivy-last)
-     :action (ivy-state-action ivy-last)
-     :unwind (ivy-state-unwind ivy-last)
-     :re-builder (ivy-state-re-builder ivy-last)
-     :matcher (ivy-state-matcher ivy-last)
-     :dynamic-collection (ivy-state-dynamic-collection ivy-last)
-     :caller (ivy-state-caller ivy-last))))
-
-(defvar ivy-calling nil
-  "When non-nil, call the current action when `ivy--index' changes.")
-
-(defun ivy-set-index (index)
-  "Set `ivy--index' to INDEX."
-  (setq ivy--index index)
-  (when ivy-calling
-    (ivy--exhibit)
-    (ivy-call)))
-
-(defun ivy-beginning-of-buffer ()
-  "Select the first completion candidate."
-  (interactive)
-  (ivy-set-index 0))
-
-(defun ivy-end-of-buffer ()
-  "Select the last completion candidate."
-  (interactive)
-  (ivy-set-index (1- ivy--length)))
-
-(defun ivy-scroll-up-command ()
-  "Scroll the candidates upward by the minibuffer height."
-  (interactive)
-  (ivy-set-index (min (1- (+ ivy--index ivy-height))
-                      (1- ivy--length))))
-
-(defun ivy-scroll-down-command ()
-  "Scroll the candidates downward by the minibuffer height."
-  (interactive)
-  (ivy-set-index (max (1+ (- ivy--index ivy-height))
-                      0)))
-
-(defun ivy-minibuffer-grow ()
-  "Grow the minibuffer window by 1 line."
-  (interactive)
-  (setq-local max-mini-window-height
-              (cl-incf ivy-height)))
-
-(defun ivy-minibuffer-shrink ()
-  "Shrink the minibuffer window by 1 line."
-  (interactive)
-  (unless (<= ivy-height 2)
-    (setq-local max-mini-window-height
-                (cl-decf ivy-height))
-    (window-resize (selected-window) -1)))
-
-(defun ivy-next-line (&optional arg)
-  "Move cursor vertically down ARG candidates."
-  (interactive "p")
-  (setq arg (or arg 1))
-  (let ((index (+ ivy--index arg)))
-    (if (> index (1- ivy--length))
-        (if ivy-wrap
-            (ivy-beginning-of-buffer)
-          (ivy-set-index (1- ivy--length)))
-      (ivy-set-index index))))
-
-(defun ivy-next-line-or-history (&optional arg)
-  "Move cursor vertically down ARG candidates.
-If the input is empty, select the previous history element instead."
-  (interactive "p")
-  (when (string= ivy-text "")
-    (ivy-previous-history-element 1))
-  (ivy-next-line arg))
-
-(defun ivy-previous-line (&optional arg)
-  "Move cursor vertically up ARG candidates."
-  (interactive "p")
-  (setq arg (or arg 1))
-  (let ((index (- ivy--index arg)))
-    (if (< index 0)
-        (if ivy-wrap
-            (ivy-end-of-buffer)
-          (ivy-set-index 0))
-      (ivy-set-index index))))
-
-(defun ivy-previous-line-or-history (arg)
-  "Move cursor vertically up ARG candidates.
-If the input is empty, select the previous history element instead."
-  (interactive "p")
-  (when (string= ivy-text "")
-    (ivy-previous-history-element 1))
-  (ivy-previous-line arg))
-
-(defun ivy-toggle-calling ()
-  "Flip `ivy-calling'."
-  (interactive)
-  (when (setq ivy-calling (not ivy-calling))
-    (ivy-call)))
-
-(defun ivy--get-action (state)
-  "Get the action function from STATE."
-  (let ((action (ivy-state-action state)))
-    (when action
-      (if (functionp action)
-          action
-        (cadr (nth (car action) action))))))
-
-(defun ivy--get-window (state)
-  "Get the window from STATE."
-  (let ((window (ivy-state-window state)))
-    (if (window-live-p window)
-        window
-      (if (= (length (window-list)) 1)
-          (selected-window)
-        (next-window)))))
-
-(defun ivy--actionp (x)
-  "Return non-nil when X is a list of actions."
-  (and x (listp x) (not (eq (car x) 'closure))))
-
-(defun ivy-next-action ()
-  "When the current action is a list, scroll it forwards."
-  (interactive)
-  (let ((action (ivy-state-action ivy-last)))
-    (when (ivy--actionp action)
-      (unless (>= (car action) (1- (length action)))
-        (cl-incf (car action))))))
-
-(defun ivy-prev-action ()
-  "When the current action is a list, scroll it backwards."
-  (interactive)
-  (let ((action (ivy-state-action ivy-last)))
-    (when (ivy--actionp action)
-      (unless (<= (car action) 1)
-        (cl-decf (car action))))))
-
-(defun ivy-action-name ()
-  "Return the name associated with the current action."
-  (let ((action (ivy-state-action ivy-last)))
-    (if (ivy--actionp action)
-        (format "[%d/%d] %s"
-                (car action)
-                (1- (length action))
-                (nth 2 (nth (car action) action)))
-      "[1/1] default")))
-
-(defun ivy-call ()
-  "Call the current action without exiting completion."
-  (interactive)
-  (let ((action (ivy--get-action ivy-last)))
-    (when action
-      (let* ((collection (ivy-state-collection ivy-last))
-             (x (if (and (consp collection)
-                         (consp (car collection)))
-                    (cdr (assoc ivy--current collection))
-                  (if (equal ivy--current "")
-                      ivy-text
-                    ivy--current))))
-        (prog1 (funcall action x)
-          (unless (or (eq ivy-exit 'done)
-                      (equal (selected-window)
-                             (active-minibuffer-window))
-                      (null (active-minibuffer-window)))
-            (select-window (active-minibuffer-window))))))))
-
-(defun ivy-next-line-and-call (&optional arg)
-  "Move cursor vertically down ARG candidates.
-Call the permanent action if possible."
-  (interactive "p")
-  (ivy-next-line arg)
-  (ivy--exhibit)
-  (ivy-call))
-
-(defun ivy-previous-line-and-call (&optional arg)
-  "Move cursor vertically down ARG candidates.
-Call the permanent action if possible."
-  (interactive "p")
-  (ivy-previous-line arg)
-  (ivy--exhibit)
-  (ivy-call))
-
-(defun ivy-previous-history-element (arg)
-  "Forward to `previous-history-element' with ARG."
-  (interactive "p")
-  (previous-history-element arg)
-  (ivy--cd-maybe)
-  (move-end-of-line 1)
-  (ivy--maybe-scroll-history))
-
-(defun ivy-next-history-element (arg)
-  "Forward to `next-history-element' with ARG."
-  (interactive "p")
-  (next-history-element arg)
-  (ivy--cd-maybe)
-  (move-end-of-line 1)
-  (ivy--maybe-scroll-history))
-
-(defun ivy--cd-maybe ()
-  "Check if the current input points to a different directory.
-If so, move to that directory, while keeping only the file name."
-  (when ivy--directory
-    (let ((input (ivy--input))
-          url)
-      (if (setq url (ffap-url-p input))
-          (ivy-exit-with-action
-           (lambda (_)
-             (funcall ffap-url-fetcher url)))
-        (setq input (expand-file-name input))
-        (let ((file (file-name-nondirectory input))
-              (dir (expand-file-name (file-name-directory input))))
-          (if (string= dir ivy--directory)
-              (progn
-                (delete-minibuffer-contents)
-                (insert file))
-            (ivy--cd dir)
-            (insert file)))))))
-
-(defun ivy--maybe-scroll-history ()
-  "If the selected history element has an index, scroll there."
-  (let ((idx (ignore-errors
-               (get-text-property
-                (minibuffer-prompt-end)
-                'ivy-index))))
-    (when idx
-      (ivy--exhibit)
-      (setq ivy--index idx))))
-
-(defun ivy--cd (dir)
-  "When completing file names, move to directory DIR."
-  (if (null ivy--directory)
-      (error "Unexpected")
-    (setq ivy--old-cands nil)
-    (setq ivy--old-re nil)
-    (setq ivy--index 0)
-    (setq ivy--all-candidates
-          (ivy--sorted-files (setq ivy--directory dir)))
-    (setq ivy-text "")
-    (delete-minibuffer-contents)))
-
-(defun ivy-backward-delete-char ()
-  "Forward to `backward-delete-char'.
-On error (read-only), call `ivy-on-del-error-function'."
-  (interactive)
-  (if (and ivy--directory (= (minibuffer-prompt-end) (point)))
-      (progn
-        (ivy--cd (file-name-directory
-                  (directory-file-name
-                   (expand-file-name
-                    ivy--directory))))
-        (ivy--exhibit))
-    (condition-case nil
-        (backward-delete-char 1)
-      (error
-       (when ivy-on-del-error-function
-         (funcall ivy-on-del-error-function))))))
-
-(defun ivy-delete-char (arg)
-  "Forward to `delete-char' ARG."
-  (interactive "p")
-  (unless (= (point) (line-end-position))
-    (delete-char arg)))
-
-(defun ivy-forward-char (arg)
-  "Forward to `forward-char' ARG."
-  (interactive "p")
-  (unless (= (point) (line-end-position))
-    (forward-char arg)))
-
-(defun ivy-kill-word (arg)
-  "Forward to `kill-word' ARG."
-  (interactive "p")
-  (unless (= (point) (line-end-position))
-    (kill-word arg)))
-
-(defun ivy-kill-line ()
-  "Forward to `kill-line'."
-  (interactive)
-  (if (eolp)
-      (kill-region (minibuffer-prompt-end) (point))
-    (kill-line)))
-
-(defun ivy-backward-kill-word ()
-  "Forward to `backward-kill-word'."
-  (interactive)
-  (if (and ivy--directory (= (minibuffer-prompt-end) (point)))
-      (progn
-        (ivy--cd (file-name-directory
-                  (directory-file-name
-                   (expand-file-name
-                    ivy--directory))))
-        (ivy--exhibit))
-    (ignore-errors
-      (let ((pt (point)))
-        (forward-word -1)
-        (delete-region (point) pt)))))
-
-(defvar ivy--regexp-quote 'regexp-quote
-  "Store the regexp quoting state.")
-
-(defun ivy-toggle-regexp-quote ()
-  "Toggle the regexp quoting."
-  (interactive)
-  (setq ivy--old-re nil)
-  (cl-rotatef ivy--regex-function ivy--regexp-quote))
-
-(defvar avy-all-windows)
-(defvar avy-action)
-(defvar avy-keys)
-(defvar avy-keys-alist)
-(defvar avy-style)
-(defvar avy-styles-alist)
-(declare-function avy--process "ext:avy")
-(declare-function avy--style-fn "ext:avy")
-
-(eval-after-load 'avy
-  '(add-to-list 'avy-styles-alist '(ivy-avy . pre)))
-
-(defun ivy-avy ()
-  "Jump to one of the current ivy candidates."
-  (interactive)
-  (unless (require 'avy nil 'noerror)
-    (error "Package avy isn't installed"))
-  (let* ((avy-all-windows nil)
-         (avy-keys (or (cdr (assq 'ivy-avy avy-keys-alist))
-                       avy-keys))
-         (avy-style (or (cdr (assq 'ivy-avy
-                                   avy-styles-alist))
-                        avy-style))
-         (candidate
-          (let ((candidates))
-            (save-excursion
-              (save-restriction
-                (narrow-to-region
-                 (window-start)
-                 (window-end))
-                (goto-char (point-min))
-                (forward-line)
-                (while (< (point) (point-max))
-                  (push
-                   (cons (point)
-                         (selected-window))
-                   candidates)
-                  (forward-line))))
-            (setq avy-action #'identity)
-            (avy--process
-             (nreverse candidates)
-             (avy--style-fn avy-style)))))
-    (ivy-set-index (- (line-number-at-pos candidate) 2))
-    (ivy--exhibit)
-    (ivy-done)))
-
-(defun ivy-sort-file-function-default (x y)
-  "Compare two files X and Y.
-Prioritize directories."
-  (if (get-text-property 0 'dirp x)
-      (if (get-text-property 0 'dirp y)
-          (string< x y)
-        t)
-    (if (get-text-property 0 'dirp y)
-        nil
-      (string< x y))))
-
-(defcustom ivy-sort-functions-alist
-  '((read-file-name-internal . ivy-sort-file-function-default)
-    (internal-complete-buffer . nil)
-    (counsel-git-grep-function . nil)
-    (Man-goto-section . nil)
-    (org-refile . nil)
-    (t . string-lessp))
-  "An alist of sorting functions for each collection function.
-Interactive functions that call completion fit in here as well.
-
-Nil means no sorting, which is useful to turn off the sorting for
-functions that have candidates in the natural buffer order, like
-`org-refile' or `Man-goto-section'.
-
-The entry associated with t is used for all fall-through cases.
-
-See also `ivy-sort-max-size'."
-  :type
-  '(alist
-    :key-type (choice
-               (const :tag "All other functions" t)
-               (symbol :tag "Function"))
-    :value-type (choice
-                 (const :tag "plain sort" string-lessp)
-                 (const :tag "file sort" ivy-sort-file-function-default)
-                 (const :tag "no sort" nil)))
-  :group 'ivy)
-
-(defvar ivy-index-functions-alist
-  '((swiper . ivy-recompute-index-swiper)
-    (swiper-multi . ivy-recompute-index-swiper)
-    (counsel-git-grep . ivy-recompute-index-swiper)
-    (counsel-grep . ivy-recompute-index-swiper-async)
-    (t . ivy-recompute-index-zero))
-  "An alist of index recomputing functions for each collection function.
-When the input changes, the appropriate function returns an
-integer - the index of the matched candidate that should be
-selected.")
-
-(defvar ivy-re-builders-alist
-  '((t . ivy--regex-plus))
-  "An alist of regex building functions for each collection function.
-Each function should take a string and return a valid regex or a
-regex sequence (see below).
-
-The entry associated with t is used for all fall-through cases.
-Possible choices: `ivy--regex', `regexp-quote', `ivy--regex-plus'.
-
-If a function returns a list, it should format like this:
-'((\"matching-regexp\" . t) (\"non-matching-regexp\") ...).
-
-The matches will be filtered in a sequence, you can mix the
-regexps that should match and that should not match as you
-like.")
-
-(defvar ivy-initial-inputs-alist
-  '((org-refile . "^")
-    (org-agenda-refile . "^")
-    (org-capture-refile . "^")
-    (counsel-M-x . "^")
-    (counsel-describe-function . "^")
-    (counsel-describe-variable . "^")
-    (man . "^")
-    (woman . "^"))
-  "Command to initial input table.")
-
-(defcustom ivy-sort-max-size 30000
-  "Sorting won't be done for collections larger than this."
-  :type 'integer)
-
-(defun ivy--sorted-files (dir)
-  "Return the list of files in DIR.
-Directories come first."
-  (let* ((default-directory dir)
-         (seq (all-completions "" 'read-file-name-internal))
-         sort-fn)
-    (if (equal dir "/")
-        seq
-      (setq seq (delete "./" (delete "../" seq)))
-      (when (eq (setq sort-fn (cdr (assoc 'read-file-name-internal
-                                          ivy-sort-functions-alist)))
-                #'ivy-sort-file-function-default)
-        (setq seq (mapcar (lambda (x)
-                            (propertize x 'dirp (string-match-p "/\\'" x)))
-                          seq)))
-      (when sort-fn
-        (setq seq (cl-sort seq sort-fn)))
-      (dolist (dir ivy-extra-directories)
-        (push dir seq))
-      seq)))
-
-;;** Entry Point
-(cl-defun ivy-read (prompt collection
-                           &key predicate require-match initial-input
-                           history preselect keymap update-fn sort
-                           action unwind re-builder matcher dynamic-collection 
caller)
-  "Read a string in the minibuffer, with completion.
-
-PROMPT is a format string, normally ending in a colon and a
-space; %d anywhere in the string is replaced by the current
-number of matching candidates. For the literal % character,
-escape it with %%. See also `ivy-count-format'.
-
-COLLECTION is either a list of strings, a function, an alist, or
-a hash table.
-
-If INITIAL-INPUT is not nil, then insert that input in the
-minibuffer initially.
-
-KEYMAP is composed with `ivy-minibuffer-map'.
-
-If PRESELECT is not nil, then select the corresponding candidate
-out of the ones that match the INITIAL-INPUT.
-
-UPDATE-FN is called each time the current candidate(s) is changed.
-
-When SORT is t, use `ivy-sort-functions-alist' for sorting.
-
-ACTION is a lambda function to call after selecting a result. It
-takes a single string argument.
-
-UNWIND is a lambda function to call before exiting.
-
-RE-BUILDER is a lambda function to call to transform text into a
-regex pattern.
-
-MATCHER is to override matching.
-
-DYNAMIC-COLLECTION is a boolean to specify if the list of
-candidates is updated after each input by calling COLLECTION.
-
-CALLER is a symbol to uniquely identify the caller to `ivy-read'.
-It is used, along with COLLECTION, to determine which
-customizations apply to the current completion session."
-  (let ((extra-actions (plist-get ivy--actions-list this-command)))
-    (when extra-actions
-      (setq action
-            (if (functionp action)
-                `(1
-                  ("o" ,action "default")
-                  ,@extra-actions)
-              (delete-dups (append action extra-actions))))))
-  (let ((recursive-ivy-last (and (active-minibuffer-window) ivy-last)))
-    (setq ivy-last
-          (make-ivy-state
-           :prompt prompt
-           :collection collection
-           :predicate predicate
-           :require-match require-match
-           :initial-input initial-input
-           :history history
-           :preselect preselect
-           :keymap keymap
-           :update-fn update-fn
-           :sort sort
-           :action action
-           :window (selected-window)
-           :buffer (current-buffer)
-           :unwind unwind
-           :re-builder re-builder
-           :matcher matcher
-           :dynamic-collection dynamic-collection
-           :caller caller))
-    (ivy--reset-state ivy-last)
-    (prog1
-        (unwind-protect
-            (minibuffer-with-setup-hook
-                #'ivy--minibuffer-setup
-              (let* ((hist (or history 'ivy-history))
-                     (minibuffer-completion-table collection)
-                     (minibuffer-completion-predicate predicate)
-                     (resize-mini-windows (cond
-                                           ((display-graphic-p) nil)
-                                           ((null resize-mini-windows) 
'grow-only)
-                                           (t resize-mini-windows)))
-                     (res (read-from-minibuffer
-                           prompt
-                           (ivy-state-initial-input ivy-last)
-                           (make-composed-keymap keymap ivy-minibuffer-map)
-                           nil
-                           hist)))
-                (when (eq ivy-exit 'done)
-                  (let ((item (if ivy--directory
-                                  ivy--current
-                                ivy-text)))
-                    (unless (equal item "")
-                      (set hist (cons (propertize item 'ivy-index ivy--index)
-                                      (delete item
-                                              (cdr (symbol-value hist)))))))
-                  res)))
-          (remove-hook 'post-command-hook #'ivy--exhibit)
-          (when (setq unwind (ivy-state-unwind ivy-last))
-            (funcall unwind)))
-      (ivy-call)
-      (when recursive-ivy-last
-        (ivy--reset-state (setq ivy-last recursive-ivy-last))))))
-
-(defun ivy--reset-state (state)
-  "Reset the ivy to STATE.
-This is useful for recursive `ivy-read'."
-  (let ((prompt (or (ivy-state-prompt state) ""))
-        (collection (ivy-state-collection state))
-        (predicate (ivy-state-predicate state))
-        (history (ivy-state-history state))
-        (preselect (ivy-state-preselect state))
-        (sort (ivy-state-sort state))
-        (re-builder (ivy-state-re-builder state))
-        (dynamic-collection (ivy-state-dynamic-collection state))
-        (initial-input (ivy-state-initial-input state))
-        (require-match (ivy-state-require-match state))
-        (caller (ivy-state-caller state)))
-    (unless initial-input
-      (setq initial-input (cdr (assoc this-command
-                                      ivy-initial-inputs-alist))))
-    (setq ivy--directory nil)
-    (setq ivy-case-fold-search 'auto)
-    (setq ivy--regex-function
-          (or re-builder
-              (and (functionp collection)
-                   (cdr (assoc collection ivy-re-builders-alist)))
-              (and caller
-                   (cdr (assoc caller ivy-re-builders-alist)))
-              (cdr (assoc t ivy-re-builders-alist))
-              'ivy--regex))
-    (setq ivy--subexps 0)
-    (setq ivy--regexp-quote 'regexp-quote)
-    (setq ivy--old-text "")
-    (setq ivy--full-length nil)
-    (setq ivy-text "")
-    (setq ivy-calling nil)
-    (let (coll sort-fn)
-      (cond ((eq collection 'Info-read-node-name-1)
-             (if (equal Info-current-file "dir")
-                 (setq coll
-                       (mapcar (lambda (x) (format "(%s)" x))
-                               (cl-delete-duplicates
-                                (all-completions "(" collection predicate)
-                                :test #'equal)))
-               (setq coll (all-completions "" collection predicate))))
-            ((eq collection 'read-file-name-internal)
-             (setq ivy--directory default-directory)
-             (require 'dired)
-             (when preselect
-               (let ((preselect-directory (file-name-directory preselect)))
-                 (unless (or (null preselect-directory)
-                             (string= preselect-directory
-                                      default-directory))
-                   (setq ivy--directory preselect-directory))
-                 (setf
-                  (ivy-state-preselect state)
-                  (setq preselect (file-name-nondirectory preselect)))))
-             (setq coll (ivy--sorted-files ivy--directory))
-             (when initial-input
-               (unless (or require-match
-                           (equal initial-input default-directory)
-                           (equal initial-input ""))
-                 (setq coll (cons initial-input coll)))
-               (setq initial-input nil)))
-            ((eq collection 'internal-complete-buffer)
-             (setq coll (ivy--buffer-list "" ivy-use-virtual-buffers)))
-            ((or (functionp collection)
-                 (byte-code-function-p collection)
-                 (vectorp collection)
-                 (and (consp collection) (listp (car collection)))
-                 (hash-table-p collection))
-             (setq coll (all-completions "" collection predicate)))
-            (t
-             (setq coll collection)))
-      (when sort
-        (if (and (functionp collection)
-                 (setq sort-fn (assoc collection ivy-sort-functions-alist)))
-            (when (and (setq sort-fn (cdr sort-fn))
-                       (not (eq collection 'read-file-name-internal)))
-              (setq coll (cl-sort coll sort-fn)))
-          (unless (eq history 'org-refile-history)
-            (if (and (setq sort-fn (cdr (assoc t ivy-sort-functions-alist)))
-                     (<= (length coll) ivy-sort-max-size))
-                (setq coll (cl-sort (copy-sequence coll) sort-fn))))))
-      (when preselect
-        (unless (or (and require-match
-                         (not (eq collection 'internal-complete-buffer)))
-                    dynamic-collection
-                    (let ((re (regexp-quote preselect)))
-                      (cl-find-if (lambda (x) (string-match re x))
-                                  coll)))
-          (setq coll (cons preselect coll))))
-      (setq ivy--old-re nil)
-      (setq ivy--old-cands nil)
-      (when (integerp preselect)
-        (setq ivy--old-re "")
-        (setq ivy--index preselect))
-      (when initial-input
-        ;; Needed for anchor to work
-        (setq ivy--old-cands coll)
-        (setq ivy--old-cands (ivy--filter initial-input coll)))
-      (setq ivy--all-candidates coll)
-      (unless (integerp preselect)
-        (setq ivy--index (or
-                          (and dynamic-collection
-                               ivy--index)
-                          (and preselect
-                               (ivy--preselect-index
-                                preselect
-                                (if initial-input
-                                    ivy--old-cands
-                                  coll)))
-                          0))))
-    (setq ivy-exit nil)
-    (setq ivy--default (or
-                        (thing-at-point 'url)
-                        (thing-at-point 'symbol)
-                        ""))
-    (setq ivy--prompt
-          (cond ((string-match "%.*d" prompt)
-                 prompt)
-                ((null ivy-count-format)
-                 (error
-                  "`ivy-count-format' can't be nil.  Set it to an empty string 
instead"))
-                ((string-match "%d.*%d" ivy-count-format)
-                 (let ((w (length (number-to-string
-                                   (length ivy--all-candidates))))
-                       (s (copy-sequence ivy-count-format)))
-                   (string-match "%d" s)
-                   (match-end 0)
-                   (string-match "%d" s (match-end 0))
-                   (setq s (replace-match (format "%%-%dd" w) nil nil s))
-                   (string-match "%d" s)
-                   (concat (replace-match (format "%%%dd" w) nil nil s)
-                           prompt)))
-                ((string-match "%.*d" ivy-count-format)
-                 (concat ivy-count-format prompt))
-                (ivy--directory
-                 prompt)
-                (t
-                 nil)))
-    (setf (ivy-state-initial-input ivy-last) initial-input)))
-
-;;;###autoload
-(defun ivy-completing-read (prompt collection
-                            &optional predicate require-match initial-input
-                              history def inherit-input-method)
-  "Read a string in the minibuffer, with completion.
-
-This interface conforms to `completing-read' and can be used for
-`completing-read-function'.
-
-PROMPT is a string to prompt with; normally it ends in a colon and a space.
-COLLECTION can be a list of strings, an alist, an obarray or a hash table.
-PREDICATE limits completion to a subset of COLLECTION.
-REQUIRE-MATCH is specified with a boolean value.  See `completing-read'.
-INITIAL-INPUT is a string that can be inserted into the minibuffer initially.
-HISTORY is a list of previously selected inputs.
-DEF is the default value.
-INHERIT-INPUT-METHOD is currently ignored."
-  (if (memq this-command '(tmm-menubar tmm-shortcut))
-      (completing-read-default prompt collection
-                               predicate require-match
-                               initial-input history
-                               def inherit-input-method)
-    ;; See the doc of `completing-read'.
-    (when (consp history)
-      (when (numberp (cdr history))
-        (setq initial-input (nth (1- (cdr history))
-                                 (symbol-value (car history)))))
-      (setq history (car history)))
-    (ivy-read (replace-regexp-in-string "%" "%%" prompt)
-              collection
-              :predicate predicate
-              :require-match require-match
-              :initial-input (if (consp initial-input)
-                                 (car initial-input)
-                               (if (and (stringp initial-input)
-                                        (string-match "\\+" initial-input))
-                                   (replace-regexp-in-string
-                                    "\\+" "\\\\+" initial-input)
-                                 initial-input))
-              :preselect (if (listp def) (car def) def)
-              :history history
-              :keymap nil
-              :sort
-              (let ((sort (assoc this-command ivy-sort-functions-alist)))
-                (if sort
-                    (cdr sort)
-                  t)))))
-
-;;;###autoload
-(define-minor-mode ivy-mode
-  "Toggle Ivy mode on or off.
-Turn Ivy mode on if ARG is positive, off otherwise.
-Turning on Ivy mode sets `completing-read-function' to
-`ivy-completing-read'.
-
-Global bindings:
-\\{ivy-mode-map}
-
-Minibuffer bindings:
-\\{ivy-minibuffer-map}"
-  :group 'ivy
-  :global t
-  :keymap ivy-mode-map
-  :lighter " ivy"
-  (if ivy-mode
-      (setq completing-read-function 'ivy-completing-read)
-    (setq completing-read-function 'completing-read-default)))
-
-(defun ivy--preselect-index (preselect candidates)
-  "Return the index of PRESELECT in CANDIDATES."
-  (cond ((integerp preselect)
-         preselect)
-        ((cl-position preselect candidates :test #'equal))
-        ((stringp preselect)
-         (let ((re (regexp-quote preselect)))
-           (cl-position-if
-            (lambda (x)
-              (string-match re x))
-            candidates)))))
-
-;;* Implementation
-;;** Regex
-(defvar ivy--regex-hash
-  (make-hash-table :test #'equal)
-  "Store pre-computed regex.")
-
-(defun ivy--split (str)
-  "Split STR into a list by single spaces.
-The remaining spaces stick to their left.
-This allows to \"quote\" N spaces by inputting N+1 spaces."
-  (let ((len (length str))
-        start0
-        (start1 0)
-        res s
-        match-len)
-    (while (and (string-match " +" str start1)
-                (< start1 len))
-      (setq match-len (- (match-end 0) (match-beginning 0)))
-      (if (= match-len 1)
-          (progn
-            (when start0
-              (setq start1 start0)
-              (setq start0 nil))
-            (push (substring str start1 (match-beginning 0)) res)
-            (setq start1 (match-end 0)))
-        (setq str (replace-match
-                   (make-string (1- match-len) ?\ )
-                   nil nil str))
-        (setq start0 (or start0 start1))
-        (setq start1 (1- (match-end 0)))))
-    (if start0
-        (push (substring str start0) res)
-      (setq s (substring str start1))
-      (unless (= (length s) 0)
-        (push s res)))
-    (nreverse res)))
-
-(defun ivy--regex (str &optional greedy)
-  "Re-build regex pattern from STR in case it has a space.
-When GREEDY is non-nil, join words in a greedy way."
-  (let ((hashed (unless greedy
-                  (gethash str ivy--regex-hash))))
-    (if hashed
-        (prog1 (cdr hashed)
-          (setq ivy--subexps (car hashed)))
-      (when (string-match "\\([^\\]\\|^\\)\\\\$" str)
-        (setq str (substring str 0 -1)))
-      (cdr (puthash str
-                    (let ((subs (ivy--split str)))
-                      (if (= (length subs) 1)
-                          (cons
-                           (setq ivy--subexps 0)
-                           (car subs))
-                        (cons
-                         (setq ivy--subexps (length subs))
-                         (mapconcat
-                          (lambda (x)
-                            (if (string-match "\\`\\\\(.*\\\\)\\'" x)
-                                x
-                              (format "\\(%s\\)" x)))
-                          subs
-                          (if greedy
-                              ".*"
-                            ".*?")))))
-                    ivy--regex-hash)))))
-
-(defun ivy--regex-ignore-order (str)
-  "Re-build regex from STR by splitting at spaces.
-Ignore the order of each group.
-
-ATTENTION: This is just a proof of concept and may not work as
-expected. Besides ignoring the order of the tokens where 'foo'
-and 'bar', 'bar' and 'foo' are matched, it also matches multiple
-occurrences of 'foo' and 'bar'. To ignore the sort order and avoid
-multiple matches, use `ivy-restrict-to-matches' instead.
-"
-  (let* ((subs (split-string str " +" t))
-         (len (length subs)))
-    (cl-case len
-      (1
-       (setq ivy--subexps 0)
-       (car subs))
-      (t
-       (setq ivy--subexps len)
-       (let ((all (mapconcat #'identity subs "\\|")))
-         (mapconcat
-          (lambda (x)
-            (if (string-match "\\`\\\\(.*\\\\)\\'" x)
-                x
-              (format "\\(%s\\)" x)))
-          (make-list len all)
-          ".*?"))))))
-
-(defun ivy--regex-plus (str)
-  "Build a regex sequence from STR.
-Spaces are wild card characters, everything before \"!\" should
-match. Everything after \"!\" should not match."
-  (let ((parts (split-string str "!" t)))
-    (cl-case (length parts)
-      (0
-       "")
-      (1
-       (ivy--regex (car parts)))
-      (2
-       (let ((res
-              (mapcar #'list
-                      (split-string (cadr parts) " " t))))
-         (cons (cons (ivy--regex (car parts)) t)
-               res)))
-      (t (error "Unexpected: use only one !")))))
-
-(defun ivy--regex-fuzzy (str)
-  "Build a regex sequence from STR.
-Insert .* between each char."
-  (if (string-match "\\`\\(\\^?\\)\\(.*?\\)\\(\\$?\\)\\'" str)
-      (prog1
-          (concat (match-string 1 str)
-                  (mapconcat
-                   (lambda (x)
-                     (format "\\(%c\\)" x))
-                   (string-to-list (match-string 2 str)) ".*")
-                  (match-string 3 str))
-        (setq ivy--subexps (length (match-string 2 str))))
-    str))
-
-;;** Rest
-(defun ivy--minibuffer-setup ()
-  "Setup ivy completion in the minibuffer."
-  (set (make-local-variable 'completion-show-inline-help) nil)
-  (set (make-local-variable 'minibuffer-default-add-function)
-       (lambda ()
-         (list ivy--default)))
-  (when (display-graphic-p)
-    (setq truncate-lines t))
-  (setq-local max-mini-window-height ivy-height)
-  (add-hook 'post-command-hook #'ivy--exhibit nil t)
-  ;; show completions with empty input
-  (ivy--exhibit))
-
-(defun ivy--input ()
-  "Return the current minibuffer input."
-  ;; assume one-line minibuffer input
-  (buffer-substring-no-properties
-   (minibuffer-prompt-end)
-   (line-end-position)))
-
-(defun ivy--cleanup ()
-  "Delete the displayed completion candidates."
-  (save-excursion
-    (goto-char (minibuffer-prompt-end))
-    (delete-region (line-end-position) (point-max))))
-
-(defun ivy--insert-prompt ()
-  "Update the prompt according to `ivy--prompt'."
-  (when ivy--prompt
-    (unless (memq this-command '(ivy-done ivy-alt-done ivy-partial-or-done
-                                          counsel-find-symbol))
-      (setq ivy--prompt-extra ""))
-    (let (head tail)
-      (if (string-match "\\(.*\\): \\'" ivy--prompt)
-          (progn
-            (setq head (match-string 1 ivy--prompt))
-            (setq tail ": "))
-        (setq head (substring ivy--prompt 0 -1))
-        (setq tail " "))
-      (let ((inhibit-read-only t)
-            (std-props '(front-sticky t rear-nonsticky t field t read-only t))
-            (n-str
-             (concat
-              (if (and (bound-and-true-p minibuffer-depth-indicate-mode)
-                       (> (minibuffer-depth) 1))
-                  (format "[%d] " (minibuffer-depth))
-                "")
-              (concat
-               (if (string-match "%d.*%d" ivy-count-format)
-                   (format head
-                           (1+ ivy--index)
-                           (or (and (ivy-state-dynamic-collection ivy-last)
-                                    ivy--full-length)
-                               ivy--length))
-                 (format head
-                         (or (and (ivy-state-dynamic-collection ivy-last)
-                                  ivy--full-length)
-                             ivy--length)))
-               ivy--prompt-extra
-               tail)))
-            (d-str (if ivy--directory
-                       (abbreviate-file-name ivy--directory)
-                     "")))
-        (save-excursion
-          (goto-char (point-min))
-          (delete-region (point-min) (minibuffer-prompt-end))
-          (if (> (+ (mod (+ (length n-str) (length d-str)) (window-width))
-                    (length ivy-text))
-                 (window-width))
-              (setq n-str (concat n-str "\n" d-str))
-            (setq n-str (concat n-str d-str)))
-          (let ((regex (format "\\([^\n]\\{%d\\}\\)[^\n]" (window-width))))
-            (while (string-match regex n-str)
-              (setq n-str (replace-match (concat (match-string 1 n-str) "\n") 
nil t n-str 1))))
-          (set-text-properties 0 (length n-str)
-                               `(face minibuffer-prompt ,@std-props)
-                               n-str)
-          (ivy--set-match-props n-str "confirm"
-                                `(face ivy-confirm-face ,@std-props))
-          (ivy--set-match-props n-str "match required"
-                                `(face ivy-match-required-face ,@std-props))
-          (insert n-str))
-        ;; get out of the prompt area
-        (constrain-to-field nil (point-max))))))
-
-(defun ivy--set-match-props (str match props)
-  "Set STR text properties that match MATCH to PROPS."
-  (when (string-match match str)
-    (set-text-properties
-     (match-beginning 0)
-     (match-end 0)
-     props
-     str)))
-
-(defvar inhibit-message)
-
-(defun ivy--sort-maybe (collection)
-  "Sort COLLECTION if needed."
-  (let ((sort (ivy-state-sort ivy-last))
-        entry)
-    (if (null sort)
-        collection
-      (let ((sort-fn (cond ((functionp sort)
-                            sort)
-                           ((setq entry (assoc (ivy-state-collection ivy-last)
-                                               ivy-sort-functions-alist))
-                            (cdr entry))
-                           (t
-                            (cdr (assoc t ivy-sort-functions-alist))))))
-        (if (functionp sort-fn)
-            (cl-sort (copy-sequence collection) sort-fn)
-          collection)))))
-
-(defun ivy--exhibit ()
-  "Insert Ivy completions display.
-Should be run via minibuffer `post-command-hook'."
-  (when (memq 'ivy--exhibit post-command-hook)
-    (let ((inhibit-field-text-motion nil))
-      (constrain-to-field nil (point-max)))
-    (setq ivy-text (ivy--input))
-    (if (ivy-state-dynamic-collection ivy-last)
-        ;; while-no-input would cause annoying
-        ;; "Waiting for process to die...done" message interruptions
-        (let ((inhibit-message t))
-          (unless (equal ivy--old-text ivy-text)
-            (while-no-input
-              (setq ivy--all-candidates
-                    (ivy--sort-maybe
-                     (funcall (ivy-state-collection ivy-last) ivy-text)))
-              (setq ivy--old-text ivy-text)))
-          (when ivy--all-candidates
-            (ivy--insert-minibuffer
-             (ivy--format ivy--all-candidates))))
-      (cond (ivy--directory
-             (if (string-match "/\\'" ivy-text)
-                 (if (member ivy-text ivy--all-candidates)
-                     (ivy--cd (expand-file-name ivy-text ivy--directory))
-                   (when (string-match "//\\'" ivy-text)
-                     (if (and default-directory
-                              (string-match "\\`[[:alpha:]]:/" 
default-directory))
-                         (ivy--cd (match-string 0 default-directory))
-                       (ivy--cd "/")))
-                   (when (string-match "[[:alpha:]]:/$" ivy-text)
-                     (let ((drive-root (match-string 0 ivy-text)))
-                       (when (file-exists-p drive-root)
-                         (ivy--cd drive-root)))))
-               (if (string-match "\\`~\\'" ivy-text)
-                   (ivy--cd (expand-file-name "~/")))))
-            ((eq (ivy-state-collection ivy-last) 'internal-complete-buffer)
-             (when (or (and (string-match "\\` " ivy-text)
-                            (not (string-match "\\` " ivy--old-text)))
-                       (and (string-match "\\` " ivy--old-text)
-                            (not (string-match "\\` " ivy-text))))
-               (setq ivy--all-candidates
-                     (if (and (> (length ivy-text) 0)
-                              (eq (aref ivy-text 0)
-                                  ?\ ))
-                         (ivy--buffer-list " ")
-                       (ivy--buffer-list "" ivy-use-virtual-buffers)))
-               (setq ivy--old-re nil))))
-      (ivy--insert-minibuffer
-       (with-current-buffer (ivy-state-buffer ivy-last)
-         (ivy--format
-          (ivy--filter ivy-text ivy--all-candidates))))
-      (setq ivy--old-text ivy-text))))
-
-(defun ivy--insert-minibuffer (text)
-  "Insert TEXT into minibuffer with appropriate cleanup."
-  (let ((resize-mini-windows nil)
-        (update-fn (ivy-state-update-fn ivy-last))
-        deactivate-mark)
-    (ivy--cleanup)
-    (when update-fn
-      (funcall update-fn))
-    (ivy--insert-prompt)
-    ;; Do nothing if while-no-input was aborted.
-    (when (stringp text)
-      (let ((buffer-undo-list t))
-        (save-excursion
-          (forward-line 1)
-          (insert text))))
-    (when (display-graphic-p)
-      (ivy--resize-minibuffer-to-fit))))
-
-(defun ivy--resize-minibuffer-to-fit ()
-  "Resize the minibuffer window size to fit the text in the minibuffer."
-  (with-selected-window (minibuffer-window)
-    (if (fboundp 'window-text-pixel-size)
-        (let ((text-height (cdr (window-text-pixel-size)))
-              (body-height (window-body-height nil t)))
-          (when (> text-height body-height)
-            (window-resize nil (- text-height body-height) nil t t)))
-      (let ((text-height (count-screen-lines))
-            (body-height (window-body-height)))
-        (when (> text-height body-height)
-          (window-resize nil (- text-height body-height) nil t))))))
-
-(declare-function colir-blend-face-background "ext:colir")
-
-(defun ivy--add-face (str face)
-  "Propertize STR with FACE.
-`font-lock-append-text-property' is used, since it's better than
-`propertize' or `add-face-text-property' in this case."
-  (require 'colir)
-  (condition-case nil
-      (progn
-        (colir-blend-face-background 0 (length str) face str)
-        (let ((foreground (face-foreground face)))
-          (when foreground
-            (add-face-text-property
-             0 (length str)
-             `(:foreground ,foreground)
-             nil
-             str))))
-    (error
-     (ignore-errors
-       (font-lock-append-text-property 0 (length str) 'face face str))))
-  str)
-
-(declare-function flx-make-string-cache "ext:flx")
-(declare-function flx-score "ext:flx")
-
-(defvar ivy--flx-cache nil)
-
-(eval-after-load 'flx
-  '(setq ivy--flx-cache (flx-make-string-cache)))
-
-(defun ivy-toggle-case-fold ()
-  "Toggle the case folding between nil and auto.
-In any completion session, the case folding starts in auto:
-
-- when the input is all lower case, `case-fold-search' is t
-- otherwise nil.
-
-You can toggle this to make `case-fold-search' nil regardless of input."
-  (interactive)
-  (setq ivy-case-fold-search
-        (if ivy-case-fold-search
-            nil
-          'auto))
-  ;; reset cache so that the candidate list updates
-  (setq ivy--old-re nil))
-
-(defun ivy--filter (name candidates)
-  "Return all items that match NAME in CANDIDATES.
-CANDIDATES are assumed to be static."
-  (let ((re (funcall ivy--regex-function name)))
-    (if (and (equal re ivy--old-re)
-             ivy--old-cands)
-        ;; quick caching for "C-n", "C-p" etc.
-        ivy--old-cands
-      (let* ((re-str (if (listp re) (caar re) re))
-             (matcher (ivy-state-matcher ivy-last))
-             (case-fold-search
-              (and ivy-case-fold-search
-                   (string= name (downcase name))))
-             (cands (cond
-                     (matcher
-                      (funcall matcher re candidates))
-                     ((and ivy--old-re
-                           (stringp re)
-                           (stringp ivy--old-re)
-                           (not (string-match "\\\\" ivy--old-re))
-                           (not (equal ivy--old-re ""))
-                           (memq (cl-search
-                                  (if (string-match "\\\\)\\'" ivy--old-re)
-                                       (substring ivy--old-re 0 -2)
-                                     ivy--old-re)
-                                   re)
-                                  '(0 2)))
-                       (ignore-errors
-                         (cl-remove-if-not
-                          (lambda (x) (string-match re x))
-                          ivy--old-cands)))
-                      (t
-                       (let ((re-list (if (stringp re) (list (cons re t)) re))
-                             (res candidates))
-                         (dolist (re re-list)
-                           (setq res
-                                 (ignore-errors
-                                   (funcall
-                                    (if (cdr re)
-                                        #'cl-remove-if-not
-                                      #'cl-remove-if)
-                                    (let ((re-str (car re)))
-                                      (lambda (x) (string-match re-str x)))
-                                    res))))
-                         res)))))
-        (ivy--recompute-index name re-str cands)
-        (setq ivy--old-re (if cands re-str ""))
-        (setq ivy--old-cands (ivy--sort name cands))))))
-
-(defcustom ivy-sort-matches-functions-alist '((t . nil))
-  "An alist of functions used to sort the matching candidates.
-
-This is different from `ivy-sort-functions-alist', which is used
-to sort the whole collection only once.  The functions taken from
-here are instead used on each input change, but they are used
-only on already matching candidates, not on all of them.
-
-The alist KEY is a collection function or t to match previously
-not matched collection functions.
-
-The alist VAL is a sorting function with the signature of
-`ivy--prefix-sort'.")
-
-(defun ivy--sort-files-by-date (_name candidates)
-  "Re-soft CANDIDATES according to file modification date."
-  (let ((default-directory ivy--directory))
-    (cl-sort (copy-sequence candidates)
-             (lambda (f1 f2)
-               (time-less-p
-                (nth 5 (file-attributes f2))
-                (nth 5 (file-attributes f1)))))))
-
-(defun ivy--sort (name candidates)
-  "Re-sort CANDIDATES by NAME.
-All CANDIDATES are assumed to match NAME."
-  (let ((key (or (ivy-state-caller ivy-last)
-                 (when (functionp (ivy-state-collection ivy-last))
-                   (ivy-state-collection ivy-last))))
-        fun)
-    (cond ((and (require 'flx nil 'noerror)
-                (eq ivy--regex-function 'ivy--regex-fuzzy))
-           (ivy--flx-sort name candidates))
-          ((setq fun (cdr (or (assoc key ivy-sort-matches-functions-alist)
-                              (assoc t ivy-sort-matches-functions-alist))))
-           (funcall fun name candidates))
-          (t
-           candidates))))
-
-(defun ivy--prefix-sort (name candidates)
-  "Re-sort CANDIDATES.
-Prefix matches to NAME are put ahead of the list."
-  (if (or (string-match "^\\^" name) (string= name ""))
-      candidates
-    (let ((re-prefix (concat "^" (funcall ivy--regex-function name)))
-          res-prefix
-          res-noprefix)
-      (dolist (s candidates)
-        (if (string-match re-prefix s)
-            (push s res-prefix)
-          (push s res-noprefix)))
-      (nconc
-       (nreverse res-prefix)
-       (nreverse res-noprefix)))))
-
-(defun ivy--recompute-index (name re-str cands)
-  (let* ((caller (ivy-state-caller ivy-last))
-         (func (or (and caller (cdr (assoc caller ivy-index-functions-alist)))
-                   (cdr (assoc t ivy-index-functions-alist))
-                   #'ivy-recompute-index-zero)))
-    (unless (eq this-command 'ivy-resume)
-      (setq ivy--index
-            (or
-             (cl-position (if (and (> (length re-str) 0)
-                                   (eq ?^ (aref re-str 0)))
-                              (substring re-str 1)
-                            re-str) cands
-                            :test #'equal)
-             (and ivy--directory
-                  (cl-position
-                   (concat re-str "/") cands
-                   :test #'equal))
-             (and (not (string= name ""))
-                  (not (and (require 'flx nil 'noerror)
-                            (eq ivy--regex-function 'ivy--regex-fuzzy)
-                            (< (length cands) 200)))
-
-                  (cl-position (nth ivy--index ivy--old-cands)
-                               cands))
-             (funcall func re-str cands))))
-    (when (and (or (string= name "")
-                   (string= name "^"))
-               (not (equal ivy--old-re "")))
-      (setq ivy--index
-            (or (ivy--preselect-index
-                 (ivy-state-preselect ivy-last)
-                 cands)
-                ivy--index)))))
-
-(defun ivy-recompute-index-swiper (_re-str cands)
-  (let ((tail (nthcdr ivy--index ivy--old-cands))
-        idx)
-    (if (and tail ivy--old-cands (not (equal "^" ivy--old-re)))
-        (progn
-          (while (and tail (null idx))
-            ;; Compare with eq to handle equal duplicates in cands
-            (setq idx (cl-position (pop tail) cands)))
-          (or idx 0))
-      (if ivy--old-cands
-          ivy--index
-        ;; already in ivy-state-buffer
-        (let ((n (line-number-at-pos))
-              (res 0)
-              (i 0))
-          (dolist (c cands)
-            (when (eq n (read (get-text-property 0 'display c)))
-              (setq res i))
-            (cl-incf i))
-          res)))))
-
-(defun ivy-recompute-index-swiper-async (_re-str cands)
-  (let ((tail (nthcdr ivy--index ivy--old-cands))
-        idx)
-    (if (and tail ivy--old-cands (not (equal "^" ivy--old-re)))
-        (progn
-          (while (and tail (null idx))
-            ;; Compare with `equal', since the collection is re-created
-            ;; each time with `split-string'
-            (setq idx (cl-position (pop tail) cands :test #'equal)))
-          (or idx 0))
-      ivy--index)))
-
-(defun ivy-recompute-index-zero (_re-str _cands)
-  0)
-
-(defun ivy--flx-sort (name cands)
-  "Sort according to closeness to string NAME the string list CANDS."
-  (condition-case nil
-      (if (and cands
-               (< (length cands) 200))
-          (let* ((flx-name (if (string-match "^\\^" name)
-                               (substring name 1)
-                             name))
-                 (cands-with-score
-                  (delq nil
-                        (mapcar
-                         (lambda (x)
-                           (let ((score (car (flx-score x flx-name 
ivy--flx-cache))))
-                             (and score
-                                  (cons score x))))
-                         cands))))
-            (if cands-with-score
-                (mapcar #'cdr
-                        (sort cands-with-score
-                              (lambda (x y)
-                                (> (car x) (car y)))))
-              cands))
-        cands)
-    (error
-     cands)))
-
-(defcustom ivy-format-function 'ivy-format-function-default
-  "Function to transform the list of candidates into a string.
-This string is inserted into the minibuffer."
-  :type '(choice
-          (const :tag "Default" ivy-format-function-default)
-          (const :tag "Arrow prefix" ivy-format-function-arrow)
-          (const :tag "Full line" ivy-format-function-line)))
-
-(defun ivy--truncate-string (str width)
-  "Truncate STR to WIDTH."
-  (if (> (string-width str) width)
-      (concat (substring str 0 (min (- width 3)
-                                    (- (length str) 3))) "...")
-    str))
-
-(defun ivy--format-function-generic (selected-fn other-fn cand-pairs separator)
-  "Transform CAND-PAIRS into a string for minibuffer.
-SELECTED-FN and OTHER-FN each take two string arguments.
-SEPARATOR is used to join the candidates."
-  (let ((i -1))
-    (mapconcat
-     (lambda (pair)
-       (let ((str (car pair))
-             (extra (cdr pair))
-             (curr (eq (cl-incf i) ivy--index)))
-         (if curr
-             (funcall selected-fn str extra)
-           (funcall other-fn str extra))))
-     cand-pairs
-     separator)))
-
-(defun ivy-format-function-default (cand-pairs)
-  "Transform CAND-PAIRS into a string for minibuffer."
-  (ivy--format-function-generic
-   (lambda (str extra)
-     (concat (ivy--add-face str 'ivy-current-match) extra))
-   #'concat
-   cand-pairs
-   "\n"))
-
-(defun ivy-format-function-arrow (cand-pairs)
-  "Transform CAND-PAIRS into a string for minibuffer."
-  (ivy--format-function-generic
-   (lambda (str extra)
-     (concat "> " (ivy--add-face str 'ivy-current-match) extra))
-   (lambda (str extra)
-     (concat "  " str extra))
-   cand-pairs
-   "\n"))
-
-(defun ivy-format-function-line (cand-pairs)
-  "Transform CAND-PAIRS into a string for minibuffer."
-  (ivy--format-function-generic
-   (lambda (str extra)
-     (ivy--add-face (concat str extra "\n") 'ivy-current-match))
-   (lambda (str extra)
-     (concat str extra "\n"))
-   cand-pairs
-   ""))
-
-(defcustom ivy-minibuffer-faces
-  '(ivy-minibuffer-match-face-1
-    ivy-minibuffer-match-face-2
-    ivy-minibuffer-match-face-3
-    ivy-minibuffer-match-face-4)
-  "List of `ivy' faces for minibuffer group matches.")
-
-(defun ivy--format-minibuffer-line (str)
-  (let ((start 0)
-        (str (copy-sequence str)))
-    (when (eq ivy-display-style 'fancy)
-      (unless ivy--old-re
-        (setq ivy--old-re (funcall ivy--regex-function ivy-text)))
-      (while (and (string-match ivy--old-re str start)
-                  (> (- (match-end 0) (match-beginning 0)) 0))
-        (setq start (match-end 0))
-        (let ((i 0))
-          (while (<= i ivy--subexps)
-            (let ((face
-                   (cond ((zerop ivy--subexps)
-                          (cadr ivy-minibuffer-faces))
-                         ((zerop i)
-                          (car ivy-minibuffer-faces))
-                         (t
-                          (nth (1+ (mod (+ i 2) (1- (length 
ivy-minibuffer-faces))))
-                               ivy-minibuffer-faces)))))
-              (if (fboundp 'add-face-text-property)
-                  (add-face-text-property
-                   (match-beginning i)
-                   (match-end i)
-                   face
-                   nil
-                   str)
-                (font-lock-append-text-property
-                 (match-beginning i)
-                 (match-end i)
-                 'face
-                 face
-                 str)))
-            (cl-incf i)))))
-    str))
-
-(defun ivy--format (cands)
-  "Return a string for CANDS suitable for display in the minibuffer.
-CANDS is a list of strings."
-  (setq ivy--length (length cands))
-  (when (>= ivy--index ivy--length)
-    (setq ivy--index (max (1- ivy--length) 0)))
-  (if (null cands)
-      (setq ivy--current "")
-    (let* ((half-height (/ ivy-height 2))
-           (start (max 0 (- ivy--index half-height)))
-           (end (min (+ start (1- ivy-height)) ivy--length))
-           (start (max 0 (min start (- end (1- ivy-height)))))
-           (cands (cl-subseq cands start end))
-           (index (- ivy--index start)))
-      (cond (ivy--directory
-             (setq cands (mapcar (lambda (x)
-                                   (if (string-match-p "/\\'" x)
-                                       (propertize x 'face 'ivy-subdir)
-                                     x))
-                                 cands)))
-            ((eq (ivy-state-collection ivy-last) 'internal-complete-buffer)
-             (setq cands (mapcar (lambda (x)
-                                   (let ((b (get-buffer x)))
-                                     (if (and b
-                                              (buffer-file-name b)
-                                              (buffer-modified-p b))
-                                         (propertize x 'face 
'ivy-modified-buffer)
-                                       x)))
-                                 cands))))
-      (setq ivy--current (copy-sequence (nth index cands)))
-      (let* ((ivy--index index)
-             (cand-pairs (mapcar
-                          (lambda (cand)
-                            (cons (ivy--format-minibuffer-line cand) nil)) 
cands))
-             (res (concat "\n" (funcall ivy-format-function cand-pairs))))
-        (put-text-property 0 (length res) 'read-only nil res)
-        res))))
-
-(defvar ivy--virtual-buffers nil
-  "Store the virtual buffers alist.")
-
-(defvar recentf-list)
-
-(defcustom ivy-virtual-abbreviate 'name
-  "The mode of abbreviation for virtual buffer names."
-  :type '(choice
-          (const :tag "Only name" name)
-          (const :tag "Full path" full)
-          ;; eventually, uniquify
-          ))
-
-(defun ivy--virtual-buffers ()
-  "Adapted from `ido-add-virtual-buffers-to-list'."
-  (unless recentf-mode
-    (recentf-mode 1))
-  (let ((bookmarks (and (boundp 'bookmark-alist)
-                        bookmark-alist))
-        virtual-buffers name)
-    (dolist (head (append
-                   recentf-list
-                   (delete "   - no file -"
-                           (delq nil (mapcar (lambda (bookmark)
-                                               (cdr (assoc 'filename 
bookmark)))
-                                             bookmarks)))))
-      (setq name
-            (if (eq ivy-virtual-abbreviate 'name)
-                (file-name-nondirectory head)
-              (expand-file-name head)))
-      (when (equal name "")
-        (setq name (file-name-nondirectory (directory-file-name head))))
-      (when (equal name "")
-        (setq name head))
-      (and (not (equal name ""))
-           (null (get-file-buffer head))
-           (not (assoc name virtual-buffers))
-           (push (cons name head) virtual-buffers)))
-    (when virtual-buffers
-      (dolist (comp virtual-buffers)
-        (put-text-property 0 (length (car comp))
-                           'face 'ivy-virtual
-                           (car comp)))
-      (setq ivy--virtual-buffers (nreverse virtual-buffers))
-      (mapcar #'car ivy--virtual-buffers))))
-
-(defun ivy--buffer-list (str &optional virtual)
-  "Return the buffers that match STR.
-When VIRTUAL is non-nil, add virtual buffers."
-  (delete-dups
-   (append
-    (mapcar
-     (lambda (x)
-       (if (with-current-buffer x
-             (file-remote-p
-              (abbreviate-file-name default-directory)))
-           (propertize x 'face 'ivy-remote)
-         x))
-     (all-completions str 'internal-complete-buffer))
-    (and virtual
-         (ivy--virtual-buffers)))))
-
-(defun ivy--switch-buffer-action (buffer)
-  "Switch to BUFFER.
-BUFFER may be a string or nil."
-  (with-ivy-window
-    (if (zerop (length buffer))
-        (switch-to-buffer
-         ivy-text nil 'force-same-window)
-      (let ((virtual (assoc buffer ivy--virtual-buffers)))
-        (if (and virtual
-                 (not (get-buffer buffer)))
-            (find-file (cdr virtual))
-          (switch-to-buffer
-           buffer nil 'force-same-window))))))
-
-(defun ivy--switch-buffer-other-window-action (buffer)
-  "Switch to BUFFER in other window.
-BUFFER may be a string or nil."
-  (if (zerop (length buffer))
-      (switch-to-buffer-other-window ivy-text)
-    (let ((virtual (assoc buffer ivy--virtual-buffers)))
-      (if (and virtual
-               (not (get-buffer buffer)))
-          (find-file-other-window (cdr virtual))
-        (switch-to-buffer-other-window buffer)))))
-
-(defun ivy--rename-buffer-action (buffer)
-  "Rename BUFFER."
-  (let ((new-name (read-string "Rename buffer (to new name): ")))
-    (with-current-buffer buffer
-      (rename-buffer new-name))))
-
-(defvar ivy-switch-buffer-map (make-sparse-keymap))
-
-(ivy-set-actions
- 'ivy-switch-buffer
- '(("k"
-    (lambda (x)
-      (kill-buffer x)
-      (ivy--reset-state ivy-last))
-    "kill")
-   ("j"
-    ivy--switch-buffer-other-window-action
-    "other")
-   ("r"
-    ivy--rename-buffer-action
-    "rename")))
-
-;;;###autoload
-(defun ivy-switch-buffer ()
-  "Switch to another buffer."
-  (interactive)
-  (if (not ivy-mode)
-      (call-interactively 'switch-to-buffer)
-    (let ((this-command 'ivy-switch-buffer))
-      (ivy-read "Switch to buffer: " 'internal-complete-buffer
-                :preselect (buffer-name (other-buffer (current-buffer)))
-                :action #'ivy--switch-buffer-action
-                :keymap ivy-switch-buffer-map))))
-
-;;;###autoload
-(defun ivy-recentf ()
-  "Find a file on `recentf-list'."
-  (interactive)
-  (ivy-read "Recentf: " recentf-list
-            :action
-            (lambda (f)
-              (with-ivy-window
-                (find-file f)))))
-
-(defun ivy-yank-word ()
-  "Pull next word from buffer into search string."
-  (interactive)
-  (let (amend)
-    (with-ivy-window
-      (let ((pt (point))
-            (le (line-end-position)))
-        (forward-word 1)
-        (if (> (point) le)
-            (goto-char pt)
-          (setq amend (buffer-substring-no-properties pt (point))))))
-    (when amend
-      (insert (replace-regexp-in-string "  +" " " amend)))))
-
-(defun ivy-kill-ring-save ()
-  "Store the current candidates into the kill ring.
-If the region is active, forward to `kill-ring-save' instead."
-  (interactive)
-  (if (region-active-p)
-      (call-interactively 'kill-ring-save)
-    (kill-new
-     (mapconcat
-      #'identity
-      ivy--old-cands
-      "\n"))))
-
-(defun ivy-insert-current ()
-  "Make the current candidate into current input.
-Don't finish completion."
-  (interactive)
-  (delete-minibuffer-contents)
-  (if (and ivy--directory
-           (string-match "/$" ivy--current))
-      (insert (substring ivy--current 0 -1))
-    (insert ivy--current)))
-
-(defun ivy-toggle-fuzzy ()
-  "Toggle the re builder between `ivy--regex-fuzzy' and `ivy--regex-plus'."
-  (interactive)
-  (setq ivy--old-re nil)
-  (if (eq ivy--regex-function 'ivy--regex-fuzzy)
-      (setq ivy--regex-function 'ivy--regex-plus)
-    (setq ivy--regex-function 'ivy--regex-fuzzy)))
-
-(defun ivy-reverse-i-search ()
-  "Enter a recursive `ivy-read' session using the current history.
-The selected history element will be inserted into the minibuffer."
-  (interactive)
-  (let ((enable-recursive-minibuffers t)
-        (history (symbol-value (ivy-state-history ivy-last)))
-        (old-last ivy-last))
-    (ivy-read "Reverse-i-search: "
-              history
-              :action (lambda (x)
-                        (ivy--reset-state
-                         (setq ivy-last old-last))
-                        (delete-minibuffer-contents)
-                        (insert (substring-no-properties x))
-                        (ivy--cd-maybe)))))
-
-(defun ivy-restrict-to-matches ()
-  "Restrict candidates to current matches and erase input."
-  (interactive)
-  (delete-minibuffer-contents)
-  (setq ivy--all-candidates
-        (ivy--filter ivy-text ivy--all-candidates)))
-
-;;* Occur
-(defvar-local ivy-occur-last nil
-  "Buffer-local value of `ivy-last'.
-Can't re-use `ivy-last' because using e.g. `swiper' in the same
-buffer would modify `ivy-last'.")
-
-(defvar ivy-occur-mode-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map [mouse-1] 'ivy-occur-click)
-    (define-key map (kbd "RET") 'ivy-occur-press)
-    (define-key map (kbd "j") 'next-line)
-    (define-key map (kbd "k") 'previous-line)
-    (define-key map (kbd "h") 'backward-char)
-    (define-key map (kbd "l") 'forward-char)
-    (define-key map (kbd "g") 'ivy-occur-press)
-    (define-key map (kbd "a") 'ivy-occur-read-action)
-    (define-key map (kbd "o") 'ivy-occur-dispatch)
-    (define-key map (kbd "q") 'quit-window)
-    map)
-  "Keymap for Ivy Occur mode.")
-
-(define-derived-mode ivy-occur-mode fundamental-mode "Ivy-Occur"
-  "Major mode for output from \\[ivy-occur].
-
-\\{ivy-occur-mode-map}")
-
-(defvar ivy-occur-grep-mode-map
-  (let ((map (copy-keymap ivy-occur-mode-map)))
-    (define-key map (kbd "C-x C-q") 'ivy-wgrep-change-to-wgrep-mode)
-    map)
-  "Keymap for Ivy Occur Grep mode.")
-
-(define-derived-mode ivy-occur-grep-mode grep-mode "Ivy-Occur"
-  "Major mode for output from \\[ivy-occur].
-
-\\{ivy-occur-grep-mode-map}")
-
-(defvar counsel-git-grep-cmd)
-
-(defun ivy-occur ()
-  "Stop completion and put the current matches into a new buffer.
-
-The new buffer remembers current action(s).
-
-While in the *ivy-occur* buffer, selecting a candidate with RET or
-a mouse click will call the appropriate action for that candidate.
-
-There is no limit on the number of *ivy-occur* buffers."
-  (interactive)
-  (let ((buffer
-         (generate-new-buffer
-          (format "*ivy-occur%s \"%s\"*"
-                  (let (caller)
-                    (if (setq caller (ivy-state-caller ivy-last))
-                        (concat " " (prin1-to-string caller))
-                      ""))
-                  ivy-text)))
-        (do-grep (eq (ivy-state-caller ivy-last) 'counsel-git-grep)))
-    (with-current-buffer buffer
-      (if do-grep
-          (progn
-            (setq ivy--old-cands
-                  (split-string
-                   (shell-command-to-string
-                    (format counsel-git-grep-cmd ivy--old-re))
-                   "\n"
-                   t))
-            (ivy-occur-grep-mode))
-        (ivy-occur-mode))
-      (setf (ivy-state-text ivy-last) ivy-text)
-      (setq ivy-occur-last ivy-last)
-      (setq-local ivy--directory ivy--directory)
-      (let ((inhibit-read-only t))
-        (erase-buffer)
-        (when do-grep
-          ;; Need precise number of header lines for `wgrep' to work.
-          (insert (format "-*- mode:grep; default-directory: %S -*-\n\n\n"
-                          default-directory)))
-        (insert (format "%d candidates:\n" (length ivy--old-cands)))
-        (dolist (cand ivy--old-cands)
-          (let ((str (if do-grep
-                         (concat "./" cand)
-                       (concat "    " cand))))
-            (add-text-properties
-             0 (length str)
-             `(mouse-face
-               highlight
-               help-echo "mouse-1: call ivy-action")
-             str)
-            (insert str "\n")))))
-    (ivy-exit-with-action
-     `(lambda (_) (pop-to-buffer ,buffer)))))
-
-(declare-function wgrep-change-to-wgrep-mode "ext:wgrep")
-
-(defun ivy-wgrep-change-to-wgrep-mode ()
-  "Forward to `wgrep-change-to-wgrep-mode'."
-  (interactive)
-  (if (require 'wgrep nil 'noerror)
-      (wgrep-change-to-wgrep-mode)
-    (error "Package wgrep isn't installed")))
-
-(defun ivy-occur-read-action ()
-  "Select one of the available actions as the current one."
-  (interactive)
-  (let ((ivy-last ivy-occur-last))
-    (ivy-read-action)))
-
-(defun ivy-occur-dispatch ()
-  "Call one of the available actions on the current item."
-  (interactive)
-  (let* ((state-action (ivy-state-action ivy-occur-last))
-         (actions (if (symbolp state-action)
-                      state-action
-                    (copy-sequence state-action))))
-    (unwind-protect
-         (progn
-           (ivy-occur-read-action)
-           (ivy-occur-press))
-      (setf (ivy-state-action ivy-occur-last) actions))))
-
-(defun ivy-occur-click (event)
-  "Execute action for the current candidate.
-EVENT gives the mouse position."
-  (interactive "e")
-  (let ((window (posn-window (event-end event)))
-        (pos (posn-point (event-end event))))
-    (with-current-buffer (window-buffer window)
-      (goto-char pos)
-      (ivy-occur-press))))
-
-(defun ivy-occur-press ()
-  "Execute action for the current candidate."
-  (interactive)
-  (require 'pulse)
-  (when (save-excursion
-          (beginning-of-line)
-          (looking-at "\\(?:./\\|    \\)\\(.*\\)$"))
-    (let* ((ivy-last ivy-occur-last)
-           (ivy-text (ivy-state-text ivy-last))
-           (str (buffer-substring
-                 (match-beginning 1)
-                 (match-end 1)))
-           (coll (ivy-state-collection ivy-last))
-           (action (ivy--get-action ivy-last))
-           (ivy-exit 'done))
-      (with-ivy-window
-        (funcall action
-                 (if (and (consp coll)
-                          (consp (car coll)))
-                     (cdr (assoc str coll))
-                   str))
-        (if (memq (ivy-state-caller ivy-last)
-                  '(swiper counsel-git-grep))
-            (with-current-buffer (window-buffer (selected-window))
-              (swiper--cleanup)
-              (swiper--add-overlays
-               (ivy--regex ivy-text)
-               (line-beginning-position)
-               (line-end-position)
-               (selected-window))
-              (run-at-time 0.5 nil 'swiper--cleanup))
-          (pulse-momentary-highlight-one-line (point)))))))
-
-(provide 'ivy)
-
-;;; ivy.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]