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

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

[elpa] master e1351c8 348/348: Merge commit 'ace01d5603ddf49b025eb811b61


From: Oleh Krehel
Subject: [elpa] master e1351c8 348/348: Merge commit 'ace01d5603ddf49b025eb811b612af72ec38dcfb' from swiper
Date: Sat, 8 Apr 2017 11:04:28 -0400 (EDT)

branch: master
commit e1351c8ef7cf14bd21ec27a67ae3fe37abcd63bf
Merge: 4bfb692 ace01d5
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Merge commit 'ace01d5603ddf49b025eb811b612af72ec38dcfb' from swiper
---
 ivy-overlay.el                 |  114 +++
 packages/avy/.dir-locals.el    |    3 +-
 packages/ivy/.travis.yml       |   14 +-
 packages/ivy/Makefile          |   17 +-
 packages/ivy/README.md         |   71 +-
 packages/ivy/colir.el          |   15 +-
 packages/ivy/counsel.el        | 1607 ++++++++++++++++++++++++++++++-----
 packages/ivy/doc/Changelog.org | 1837 ++++++++++++++++++++++++++++++++++++++--
 packages/ivy/doc/ivy.org       |   95 ++-
 packages/ivy/doc/ivy.texi      |   80 +-
 packages/ivy/ivy-hydra.el      |   46 +-
 packages/ivy/ivy-test.el       |  235 ++++-
 packages/ivy/ivy.el            | 1535 +++++++++++++++++++++++----------
 packages/ivy/swiper.el         |  460 +++++++---
 targets/obsolete-config.el     |    4 +
 15 files changed, 5187 insertions(+), 946 deletions(-)

diff --git a/ivy-overlay.el b/ivy-overlay.el
new file mode 100644
index 0000000..78344c7
--- /dev/null
+++ b/ivy-overlay.el
@@ -0,0 +1,114 @@
+;;; ivy-overlay.el --- Overlay display functions for Ivy  -*- lexical-binding: 
t -*-
+
+;; Copyright (C) 2016-2017  Free Software Foundation, Inc.
+
+;; Author: Oleh Krehel <address@hidden>
+;; Keywords: convenience
+
+;; This program 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 of the License, 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.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; This package allows to setup Ivy's completion at point to actually
+;; show the candidates and the input at point, instead of in the
+;; minibuffer.
+
+;;; Code:
+(defface ivy-cursor
+  '((t (:background "black"
+        :foreground "white")))
+  "Cursor face for inline completion."
+  :group 'ivy-faces)
+
+(defvar ivy--old-cursor-type t)
+
+(defvar ivy-overlay-at nil
+  "Overlay variable for `ivy-display-function-overlay'.")
+
+(defun ivy-left-pad (str width)
+  "Pad STR from left with WIDTH spaces."
+  (let ((padding (make-string width ?\ )))
+    (mapconcat (lambda (x)
+                 (setq x (concat padding x))
+                 (if (> (length x) (window-width))
+                     (concat
+                      (substring x 0 (- (window-width) 4))
+                      "...")
+                   x))
+               (split-string str "\n")
+               "\n")))
+
+(declare-function company-abort "ext:company")
+
+(defun ivy-overlay-cleanup ()
+  "Clean up after `ivy-display-function-overlay'."
+  (when (overlayp ivy-overlay-at)
+    (delete-overlay ivy-overlay-at)
+    (setq ivy-overlay-at nil))
+  (unless cursor-type
+    (setq cursor-type ivy--old-cursor-type))
+  (when (fboundp 'company-abort)
+    (company-abort)))
+
+(defun ivy-overlay-show-after (str)
+  "Display STR in an overlay at point.
+
+First, fill each line of STR with spaces to the current column.
+Then attach the overlay the character before point."
+  (if ivy-overlay-at
+      (progn
+        (move-overlay ivy-overlay-at (1- (point)) (line-end-position))
+        (overlay-put ivy-overlay-at 'invisible nil))
+    (setq ivy-overlay-at (make-overlay (1- (point)) (line-end-position)))
+    (overlay-put ivy-overlay-at 'priority 9999))
+  (overlay-put ivy-overlay-at 'display str)
+  (overlay-put ivy-overlay-at 'after-string ""))
+
+(declare-function org-current-level "org")
+(defvar org-indent-indentation-per-level)
+
+(defun ivy-display-function-overlay (str)
+  "Called from the minibuffer, display STR in an overlay in Ivy window.
+Hide the minibuffer contents and cursor."
+  (add-face-text-property (minibuffer-prompt-end) (point-max)
+                          '(:foreground "white"))
+  (let ((cursor-pos (1+ (- (point) (minibuffer-prompt-end))))
+        (ivy-window (ivy--get-window ivy-last)))
+    (setq cursor-type nil)
+    (with-selected-window ivy-window
+      (when cursor-type
+        (setq ivy--old-cursor-type cursor-type))
+      (setq cursor-type nil)
+      (let ((overlay-str
+             (concat
+              (buffer-substring (max 1 (1- (point))) (point))
+              ivy-text
+              (if (eolp)
+                  " "
+                "")
+              (buffer-substring (point) (line-end-position))
+              (ivy-left-pad
+               str
+               (+ (if (eq major-mode 'org-mode)
+                      (* org-indent-indentation-per-level (org-current-level))
+                    0)
+                  (save-excursion
+                    (goto-char ivy-completion-beg)
+                    (current-column)))))))
+        (add-face-text-property cursor-pos (1+ cursor-pos)
+                                'ivy-cursor t overlay-str)
+        (ivy-overlay-show-after overlay-str)))))
+
+(provide 'ivy-overlay)
+;;; ivy-overlay.el ends here
diff --git a/packages/avy/.dir-locals.el b/packages/avy/.dir-locals.el
index 3bcda92..acba84e 100644
--- a/packages/avy/.dir-locals.el
+++ b/packages/avy/.dir-locals.el
@@ -2,4 +2,5 @@
 ;;; For more information see (info "(emacs) Directory Variables")
 
 ((emacs-lisp-mode
-  (indent-tabs-mode . nil)))
+  (indent-tabs-mode . nil)
+  (outline-regexp . ";;\\([;*]+ [^\s\t\n]\\|###autoload\\)\\|(")))
diff --git a/packages/ivy/.travis.yml b/packages/ivy/.travis.yml
index 1f5dbc7..0af43c8 100644
--- a/packages/ivy/.travis.yml
+++ b/packages/ivy/.travis.yml
@@ -1,12 +1,16 @@
 language: emacs-lisp
 env:
-  matrix:
-    - EMACS=emacs24
+  - EVM_EMACS=emacs-24.3-travis
+  - EVM_EMACS=emacs-24.4-travis
+  - EVM_EMACS=emacs-24.5-travis
+  - EVM_EMACS=emacs-git-snapshot-travis
 
 before_install:
-  - sudo add-apt-repository -y ppa:cassou/emacs
-  - sudo apt-get update -qq
-  - sudo apt-get install -qq $EMACS
+  - git clone https://github.com/rejeep/evm.git $HOME/.evm
+  - export PATH=$HOME/.evm/bin:$PATH
+
+  - evm config path /tmp
+  - evm install $EVM_EMACS --use --skip
 
 script:
   - make test
diff --git a/packages/ivy/Makefile b/packages/ivy/Makefile
index c362e30..01e7dd0 100644
--- a/packages/ivy/Makefile
+++ b/packages/ivy/Makefile
@@ -1,8 +1,7 @@
 emacs ?= emacs
+elmake = $(emacs) -batch -l makefi.el -f
 
-LOAD = -l colir.el -l ivy.el -l swiper.el -l counsel.el
-
-.PHONY: all compile clean
+LOAD = -l colir.el -l ivy-overlay.el -l ivy.el -l swiper.el -l counsel.el
 
 all: test
 
@@ -12,5 +11,17 @@ test:
 compile:
        $(emacs) -batch --eval "(progn (add-to-list 'load-path 
default-directory) (mapc #'byte-compile-file '(\"ivy.el\" \"swiper.el\" 
\"counsel.el\")))"
 
+plain:
+       $(emacs) --version
+       $(emacs) -Q $(LOAD) --eval "(progn (package-initialize) (ivy-mode))"
+
+obsolete:
+       $(emacs) -batch -l targets/obsolete-config.el
+
+update-issues:
+       $(elmake) update-issues
+
 clean:
        rm -f *.elc
+
+.PHONY: all compile clean test update-issues
diff --git a/packages/ivy/README.md b/packages/ivy/README.md
index 3348189..7cdb9ac 100644
--- a/packages/ivy/README.md
+++ b/packages/ivy/README.md
@@ -1,21 +1,19 @@
-[![Build 
Status](https://travis-ci.org/abo-abo/swiper.svg?branch=master)](https://travis-ci.org/abo-abo/swiper)
 
[![MELPA](https://melpa.org/packages/swiper-badge.svg)](https://melpa.org/#/swiper)
+[![Build 
Status](https://travis-ci.org/abo-abo/swiper.svg?branch=master)](https://travis-ci.org/abo-abo/swiper)
 
-## Swiper
+***flexible, simple tools for minibuffer completion in Emacs***
 
-Package for GNU Emacs that shows an overview during regex searching.
+This repository contains:
 
-![swiper.png](http://oremacs.com/download/swiper.png)
+**Ivy**, a generic completion mechanism for Emacs.
 
-The package uses the `ivy` back end for the overview, see also
-[swiper-helm](https://github.com/abo-abo/swiper-helm).
+**Counsel**, a collection of Ivy-enhanced versions of common Emacs
+commands.
 
-## Screenshots
+**Swiper**, an Ivy-enhanced alternative to isearch.
 
-![ivy-swiper-1.png](http://oremacs.com/download/ivy-swiper-1.png)
+# Ivy
 
-There's also a ten minute [video 
demo](https://www.youtube.com/watch?v=VvnJQpTFVDc).
-
-## Ivy
+[![MELPA](http://melpa.org/packages/ivy-badge.svg)](http://melpa.org/#/ivy)
 
 Ivy is a generic completion mechanism for Emacs. While it operates
 similarly to other completion schemes such as `icomplete-mode`, Ivy
@@ -26,9 +24,9 @@ To try Ivy, just call <kbd>M-x</kbd> `ivy-mode`. This will 
enable
 generic Ivy completion, including specific completion for file and
 buffer names.
 
-## Installation
+### Installation
 
-Install the `swiper` package from MELPA / GNU ELPA.
+Install the `ivy` package from MELPA / GNU ELPA.
 
 ## Documentation
 
@@ -47,6 +45,7 @@ Ivy and Swiper wiki is here: [the 
wiki](https://github.com/abo-abo/swiper/wiki).
 ```elisp
 (ivy-mode 1)
 (setq ivy-use-virtual-buffers t)
+(setq enable-recursive-minibuffers t)
 (global-set-key "\C-s" 'swiper)
 (global-set-key (kbd "C-c C-r") 'ivy-resume)
 (global-set-key (kbd "<f6>") 'ivy-resume)
@@ -54,7 +53,7 @@ Ivy and Swiper wiki is here: [the 
wiki](https://github.com/abo-abo/swiper/wiki).
 (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 "<f1> l") 'counsel-find-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)
@@ -65,15 +64,51 @@ Ivy and Swiper wiki is here: [the 
wiki](https://github.com/abo-abo/swiper/wiki).
 (define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
 ```
 
-## Contributing
+# Counsel
+
+`ivy-mode` ensures that any Emacs command using
+`completing-read-function` uses ivy for completion.
+
+Counsel takes this further, providing versions of common Emacs
+commands that are customised to make the best use of ivy. For example,
+`counsel-find-file` has some additional keybindings. Pressing
+<kbd>DEL</kbd> will move you to the parent directory.
+
+# Swiper
+
+[![MELPA](https://melpa.org/packages/swiper-badge.svg)](https://melpa.org/#/swiper)
+
+Swiper is an alternative to isearch that uses ivy to show an overview
+of all matches.
+
+![swiper.png](http://oremacs.com/download/swiper.png)
+
+A helm version of swiper is also available:
+[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).
+
+# Frequently asked questions
+
+Q: How do I enter an input that matches one of the candidates instead
+   of this candidate? Example: create a file `bar` when a file
+   `barricade` exists in the current directory.
+
+A: Press <kbd>C-M-j</kbd>.
+
+# Contributing
 
-### Copyright Assignment
+## Copyright Assignment
 
-Swiper is subject to the same [copyright 
assignment](http://www.gnu.org/prep/maintain/html_node/Copyright-Papers.html) 
policy as Emacs itself, org-mode, CEDET and other packages in [GNU 
ELPA](http://elpa.gnu.org/packages/). Any [legally 
significant](http://www.gnu.org/prep/maintain/html_node/Legally-Significant.html#Legally-Significant)
 contributions can only be accepted after the author has completed their 
paperwork. Please see [the request 
form](http://git.savannah.gnu.org/cgit/gnulib. [...]
+These package are subject to the same [copyright 
assignment](http://www.gnu.org/prep/maintain/html_node/Copyright-Papers.html) 
policy as Emacs itself, org-mode, CEDET and other packages in [GNU 
ELPA](http://elpa.gnu.org/packages/). Any [legally 
significant](http://www.gnu.org/prep/maintain/html_node/Legally-Significant.html#Legally-Significant)
 contributions can only be accepted after the author has completed their 
paperwork. Please see [the request form](http://git.savannah.gnu.org/cgit [...]
 
 The copyright assignment isn't a big deal, it just says that the copyright for 
your submitted changes to Emacs belongs to the FSF. This assignment works for 
all projects related to Emacs. To obtain it, you need to send one email, then 
send one letter (if you live in the US, it's digital), and wait for some time 
(in my case, I had to wait for one month).
 
-### Style
+## Style
 
 The basic code style guide is to use `(setq indent-tabs-mode nil)`. It is 
provided for you in 
[.dir-locals.el](https://github.com/abo-abo/swiper/blob/master/.dir-locals.el), 
please obey it.
 
diff --git a/packages/ivy/colir.el b/packages/ivy/colir.el
index 792033f..9ab724f 100644
--- a/packages/ivy/colir.el
+++ b/packages/ivy/colir.el
@@ -1,6 +1,6 @@
 ;;; colir.el --- Color blending library -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015  Free Software Foundation, Inc.
+;; Copyright (C) 2015-2017  Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel <address@hidden>
 
@@ -69,6 +69,15 @@ C1 and C2 are triples of floats in [0.0 1.0] range."
             colir-compose-method)
           c1 c2)))
 
+(defun colir-color-parse (color)
+  "Convert string COLOR to triple of floats in [0.0 1.0]."
+  (if (string-match 
"#\\([[:xdigit:]]\\{2\\}\\)\\([[:xdigit:]]\\{2\\}\\)\\([[:xdigit:]]\\{2\\}\\)" 
color)
+      (mapcar (lambda (v) (/ (string-to-number v 16) 255.0))
+              (list (match-string 1 color) (match-string 2 color) 
(match-string 3 color)))
+    ;; does not work properly in terminal (maps color to nearest color
+    ;; from available color palette).
+    (color-name-to-rgb color)))
+
 (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,
@@ -89,8 +98,8 @@ See also `font-lock-append-text-property'."
                (if background-prev
                    (cons `(background-color
                            . ,(colir-blend
-                               (color-name-to-rgb background-prev)
-                               (color-name-to-rgb (face-background face nil 
t))))
+                               (colir-color-parse background-prev)
+                               (colir-color-parse (face-background face nil 
t))))
                          prev)
                  (list face prev))
                object)))
diff --git a/packages/ivy/counsel.el b/packages/ivy/counsel.el
index 50f5f15..f47ad2f 100644
--- a/packages/ivy/counsel.el
+++ b/packages/ivy/counsel.el
@@ -1,11 +1,11 @@
 ;;; counsel.el --- Various completion functions using Ivy -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 2015  Free Software Foundation, Inc.
+;; Copyright (C) 2015-2017  Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel <address@hidden>
 ;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.8.0
-;; Package-Requires: ((emacs "24.1") (swiper "0.8.0"))
+;; Version: 0.9.0
+;; Package-Requires: ((emacs "24.3") (swiper "0.9.0"))
 ;; Keywords: completion, matching
 
 ;; This file is part of GNU Emacs.
@@ -28,7 +28,15 @@
 ;; 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.
+;; Currently available:
+;; - Symbol completion for Elisp, Common Lisp, Python and Clojure.
+;; - Describe fuctions for Elisp: function, variable, library, command,
+;;   bindings, theme.
+;; - Navigation functions: imenu, ace-line, semantic, outline
+;; - Git utilities: git-files, git-grep, git-log, git-stash.
+;; - Grep utitilies: grep, ag, pt, recoll.
+;; - System utilities: process list, rhythmbox, linux-app.
+;; - Many more.
 
 ;;; Code:
 
@@ -69,7 +77,7 @@
            (directory-file-name dir)) "/"))
 
 (defun counsel-string-compose (prefix str)
-  "Make PREFIX the display prefix of STR though text properties."
+  "Make PREFIX the display prefix of STR through text properties."
   (let ((str (copy-sequence str)))
     (put-text-property
      0 1 'display
@@ -152,9 +160,10 @@ Or the time of the last minibuffer update.")
              (unless (stringp re)
                (setq re (caar re)))
              (if (null ivy--old-cands)
-                 (unless (setq ivy--index (ivy--preselect-index
-                                           (ivy-state-preselect ivy-last)
-                                           ivy--all-candidates))
+                 (unless (ivy-set-index
+                          (ivy--preselect-index
+                           (ivy-state-preselect ivy-last)
+                           ivy--all-candidates))
                    (ivy--recompute-index
                     ivy-text re ivy--all-candidates))
                (ivy--recompute-index
@@ -203,9 +212,15 @@ Update the minibuffer with the amount of lines collected 
every
     (function :tag "Custom"))
   :group 'ivy)
 
-(defun counsel-prompt-function-default (prompt)
-  "Return PROMPT appended with a semicolon."
-  (format "%s: " prompt))
+(make-obsolete-variable
+ 'counsel-prompt-function
+ "Use `ivy-set-prompt' instead"
+ "0.8.0 <2016-06-20 Mon>")
+
+(defun counsel-prompt-function-default ()
+  "Return prompt appended with a semicolon."
+  (ivy-add-prompt-count
+   (format "%s: " (ivy-state-prompt ivy-last))))
 
 (defun counsel-delete-process ()
   (let ((process (get-process " *counsel*")))
@@ -343,25 +358,27 @@ Update the minibuffer with the amount of lines collected 
every
   "History for `counsel-unicode-char'.")
 
 ;;;###autoload
-(defun counsel-unicode-char ()
+(defun counsel-unicode-char (&optional count)
   "Insert a Unicode character at point."
-  (interactive)
-  (let ((minibuffer-allow-text-properties t))
+  (interactive "p")
+  (let ((minibuffer-allow-text-properties t)
+        (ivy-sort-max-size (expt 256 6)))
     (setq ivy-completion-beg (point))
     (setq ivy-completion-end (point))
     (ivy-read "Unicode name: "
               (mapcar (lambda (x)
                         (propertize
-                         (format "% -6X% -60s%c" (cdr x) (car x) (cdr x))
+                         (format "%06X % -60s%c" (cdr x) (car x) (cdr x))
                          'result (cdr x)))
                       (ucs-names))
               :action (lambda (char)
                         (with-ivy-window
                           (delete-region ivy-completion-beg ivy-completion-end)
                           (setq ivy-completion-beg (point))
-                          (insert-char (get-text-property 0 'result char))
+                          (insert-char (get-text-property 0 'result char) 
count)
                           (setq ivy-completion-end (point))))
-              :history 'counsel-unicode-char-history)))
+              :history 'counsel-unicode-char-history
+              :sort t)))
 
 ;;* Elisp symbols
 ;;** `counsel-describe-variable'
@@ -412,7 +429,7 @@ Update the minibuffer with the amount of lines collected 
every
                  (find-library
                   (prin1-to-string sym)))
                 (t
-                 (error "Couldn't fild definition of %s"
+                 (error "Couldn't find definition of %s"
                         sym))))))))
 
 (define-obsolete-function-alias 'counsel-symbol-at-point
@@ -474,6 +491,88 @@ Update the minibuffer with the amount of lines collected 
every
                          (intern x)))
               :caller 'counsel-describe-function)))
 
+;;** `counsel-set-variable'
+(defvar counsel-set-variable-history nil
+  "Store history for `counsel-set-variable'.")
+
+(defun counsel-read-setq-expression (sym)
+  "Read and eval a setq expression for SYM."
+  (setq this-command 'eval-expression)
+  (let* ((minibuffer-completing-symbol t)
+         (sym-value (symbol-value sym))
+         (expr (minibuffer-with-setup-hook
+                   (lambda ()
+                     (add-function :before-until (local 
'eldoc-documentation-function)
+                                   #'elisp-eldoc-documentation-function)
+                     (add-hook 'completion-at-point-functions 
#'elisp-completion-at-point nil t)
+                     (run-hooks 'eval-expression-minibuffer-setup-hook)
+                     (goto-char (minibuffer-prompt-end))
+                     (forward-char 6)
+                     (insert (format "%S " sym)))
+                 (read-from-minibuffer "Eval: "
+                                       (format
+                                        (if (and sym-value (consp sym-value))
+                                            "(setq '%S)"
+                                          "(setq %S)")
+                                        sym-value)
+                                       read-expression-map t
+                                       'read-expression-history))))
+    (eval-expression expr)))
+
+(defun counsel--setq-doconst (x)
+  "Return a cons of description and value for X.
+X is an item of a radio- or choice-type defcustom."
+  (let (y)
+    (when (and (listp x)
+               (consp (setq y (last x))))
+      (setq x (car y))
+      (cons (prin1-to-string x)
+            (if (symbolp x)
+                (list 'quote x)
+              x)))))
+
+;;;###autoload
+(defun counsel-set-variable ()
+  "Set a variable, with completion.
+
+When the selected variable is a `defcustom' with the type boolean
+or radio, offer completion of all possible values.
+
+Otherwise, offer a variant of `eval-expression', with the initial
+input corresponding to the chosen variable."
+  (interactive)
+  (let ((sym (intern
+              (ivy-read "Variable: "
+                        (counsel-variable-list)
+                        :preselect (ivy-thing-at-point)
+                        :history 'counsel-set-variable-history)))
+        sym-type
+        cands)
+    (if (and (boundp sym)
+             (setq sym-type (get sym 'custom-type))
+             (cond
+               ((and (consp sym-type)
+                     (memq (car sym-type) '(choice radio)))
+                (setq cands (delq nil (mapcar #'counsel--setq-doconst (cdr 
sym-type)))))
+               ((eq sym-type 'boolean)
+                (setq cands '(("nil" . nil) ("t" . t))))
+               (t nil)))
+        (let* ((sym-val (symbol-value sym))
+               ;; Escape '%' chars if present
+               (sym-val-str (replace-regexp-in-string "%" "%%" (format "%s" 
sym-val)))
+               (res (ivy-read (format "Set (%S <%s>): " sym sym-val-str)
+                              cands
+                              :preselect (prin1-to-string sym-val))))
+          (when res
+            (setq res
+                  (if (assoc res cands)
+                      (cdr (assoc res cands))
+                    (read res)))
+            (eval `(setq ,sym ,res))))
+      (unless (boundp sym)
+        (set sym nil))
+      (counsel-read-setq-expression sym))))
+
 ;;** `counsel-info-lookup-symbol'
 (defvar info-lookup-mode)
 (declare-function info-lookup->completions "info-look")
@@ -484,7 +583,7 @@ Update the minibuffer with the amount of lines collected 
every
 
 ;;;###autoload
 (defun counsel-info-lookup-symbol (symbol &optional mode)
-  "Forward to (`info-describe-symbol' SYMBOL MODE) with ivy completion."
+  "Forward to (`info-lookup-symbol' SYMBOL MODE) with ivy completion."
   (interactive
    (progn
      (require 'info-look)
@@ -500,6 +599,7 @@ Update the minibuffer with the amount of lines collected 
every
             (value (ivy-read
                     "Describe symbol: "
                     (mapcar #'car completions)
+                    :preselect (ivy-thing-at-point)
                     :sort t)))
        (list value info-lookup-mode))))
   (require 'info-look)
@@ -515,6 +615,42 @@ Update the minibuffer with the amount of lines collected 
every
  'counsel-M-x
  'counsel-M-x-transformer)
 
+(declare-function bookmark-all-names "bookmark")
+(declare-function bookmark-location "bookmark")
+
+(defcustom counsel-bookmark-avoid-dired nil
+  "If non-nil, choosing a directory in `counsel-bookmark'
+forwards the choice to `counsel-find-file' instead of opening a
+dired buffer."
+  :type 'boolean
+  :group 'ivy)
+
+;;;###autoload
+(defun counsel-bookmark ()
+  "Forward to `bookmark-jump' or `bookmark-set' if bookmark doesn't exist."
+  (interactive)
+  (require 'bookmark)
+  (ivy-read "Create or jump to bookmark: "
+            (bookmark-all-names)
+            :action (lambda (x)
+                      (cond ((and counsel-bookmark-avoid-dired
+                                  (member x (bookmark-all-names))
+                                  (file-directory-p (bookmark-location x)))
+                             (with-ivy-window
+                               (let ((default-directory (bookmark-location x)))
+                                 (counsel-find-file))))
+                            ((member x (bookmark-all-names))
+                             (with-ivy-window
+                               (bookmark-jump x)))
+                            (t
+                             (bookmark-set x))))
+            :caller 'counsel-bookmark))
+
+(ivy-set-actions
+ 'counsel-bookmark
+ '(("d" bookmark-delete "delete")
+   ("e" bookmark-rename "edit")))
+
 (defun counsel-M-x-transformer (cmd)
   "Return CMD appended with the corresponding binding in the current window."
   (let ((binding (substitute-command-keys (format "\\[%s]" cmd))))
@@ -564,6 +700,12 @@ Optional INITIAL-INPUT is the initial input in the 
minibuffer."
       (setq cands smex-ido-cache)
       (setq pred nil)
       (setq sort nil))
+    ;; When `counsel-M-x' returns, `last-command' would be set to
+    ;; `counsel-M-x' because :action hasn't been invoked yet.
+    ;; Instead, preserve the old value of `this-command'.
+    (setq this-command last-command)
+    (setq real-this-command real-last-command)
+
     (ivy-read (counsel--M-x-prompt) cands
               :predicate pred
               :require-match t
@@ -572,8 +714,9 @@ Optional INITIAL-INPUT is the initial input in the 
minibuffer."
               (lambda (cmd)
                 (when (featurep 'smex)
                   (smex-rank (intern cmd)))
-                (let ((prefix-arg current-prefix-arg)
-                      (this-command (intern cmd)))
+                (let ((prefix-arg current-prefix-arg))
+                  (setq real-this-command
+                        (setq this-command (intern cmd)))
                   (command-execute (intern cmd) 'record)))
               :sort sort
               :keymap counsel-describe-map
@@ -581,10 +724,8 @@ Optional INITIAL-INPUT is the initial input in the 
minibuffer."
               :caller 'counsel-M-x)))
 
 ;;** `counsel-load-library'
-;;;###autoload
-(defun counsel-load-library ()
-  "Load a selected the Emacs Lisp library.
-The libraries are offered from `load-path'."
+(defun counsel-library-candidates ()
+  "Return a list of completion candidates for `counsel-load-library'."
   (interactive)
   (let ((dirs load-path)
         (suffix (concat (regexp-opt '(".el" ".el.gz") t) "\\'"))
@@ -623,12 +764,35 @@ The libraries are offered from `load-path'."
                                 'full-name (expand-file-name file dir))
                                dir) cands)))))))
     (maphash (lambda (_k v) (push (car v) res)) cands)
-    (ivy-read "Load library: " (nreverse res)
+    (nreverse res)))
+
+;;;###autoload
+(defun counsel-load-library ()
+  "Load a selected the Emacs Lisp library.
+The libraries are offered from `load-path'."
+  (interactive)
+  (let ((cands (counsel-library-candidates)))
+    (ivy-read "Load library: " cands
               :action (lambda (x)
                         (load-library
                          (get-text-property 0 'full-name x)))
               :keymap counsel-describe-map)))
 
+(ivy-set-actions
+ 'counsel-load-library
+ '(("d" counsel--find-symbol "definition")))
+
+;;** `counsel-find-library'
+;;;###autoload
+(defun counsel-find-library ()
+  "Visit a selected the Emacs Lisp library.
+The libraries are offered from `load-path'."
+  (interactive)
+  (let ((cands (counsel-library-candidates)))
+    (ivy-read "Find library: " cands
+              :action #'counsel--find-symbol
+              :keymap counsel-describe-map)))
+
 ;;** `counsel-load-theme'
 (declare-function powerline-reset "ext:powerline")
 
@@ -637,7 +801,7 @@ The libraries are offered from `load-path'."
   (condition-case nil
       (progn
         (mapc #'disable-theme custom-enabled-themes)
-        (load-theme (intern x))
+        (load-theme (intern x) t)
         (when (fboundp 'powerline-reset)
           (powerline-reset)))
     (error "Problem loading theme %s" x)))
@@ -698,15 +862,15 @@ Usable with `ivy-resume', `ivy-next-line-and-call' and
     (nreverse res)))
 
 (defun counsel-descbinds-action-describe (x)
-  (let ((cmd (cdr x)))
+  (let ((cmd (cddr x)))
     (describe-function cmd)))
 
 (defun counsel-descbinds-action-find (x)
-  (let ((cmd (cdr x)))
+  (let ((cmd (cddr x)))
     (counsel--find-symbol (symbol-name cmd))))
 
 (defun counsel-descbinds-action-info (x)
-  (let ((cmd (cdr x)))
+  (let ((cmd (cddr x)))
     (counsel-info-lookup-symbol (symbol-name cmd))))
 
 ;;;###autoload
@@ -718,33 +882,50 @@ Describe the selected candidate."
             :action #'counsel-descbinds-action-describe
             :history 'counsel-descbinds-history
             :caller 'counsel-descbinds))
+;;** `counsel-describe-face'
+(defun counsel-describe-face ()
+  "Completion for `describe-face'."
+  (interactive)
+  (let (cands)
+    (mapatoms
+     (lambda (s)
+       (if (facep s)
+           (push (symbol-name s) cands))))
+    (ivy-read "Face: " cands
+              :preselect (symbol-name (face-at-point t))
+              :action #'describe-face)))
 ;;* Git
 ;;** `counsel-git'
+(defvar counsel-git-cmd "git ls-files --full-name --"
+  "Command for `counsel-git'.")
+
 (defvar counsel--git-dir nil
   "Store the base git directory.")
 
 (ivy-set-actions
  'counsel-git
- '(("j"
-    find-file-other-window
-    "other")))
+ '(("j" find-file-other-window "other window")
+   ("x" counsel-find-file-extern "open externally")))
 
 ;;;###autoload
 (defun counsel-git ()
   "Find file in the current Git repository."
   (interactive)
-  (setq counsel--git-dir (expand-file-name
-                          (locate-dominating-file
-                           default-directory ".git")))
-  (let* ((default-directory counsel--git-dir)
-         (cands (split-string
-                 (shell-command-to-string
-                  "git ls-files --full-name --")
-                 "\n"
-                 t)))
-    (ivy-read (funcall counsel-prompt-function "Find file")
-              cands
-              :action #'counsel-git-action)))
+  (setq counsel--git-dir (locate-dominating-file
+                          default-directory ".git"))
+  (ivy-set-prompt 'counsel-git counsel-prompt-function)
+  (if (null counsel--git-dir)
+      (error "Not in a git repository")
+    (setq counsel--git-dir (expand-file-name
+                            counsel--git-dir))
+    (let* ((default-directory counsel--git-dir)
+           (cands (split-string
+                   (shell-command-to-string counsel-git-cmd)
+                   "\n"
+                   t)))
+      (ivy-read "Find file" cands
+                :action #'counsel-git-action
+                :caller 'counsel-git))))
 
 (defun counsel-git-action (x)
   (with-ivy-window
@@ -762,7 +943,10 @@ Describe the selected candidate."
 (ivy-set-occur 'counsel-git-grep 'counsel-git-grep-occur)
 (ivy-set-display-transformer 'counsel-git-grep 'counsel-git-grep-transformer)
 
-(defvar counsel-git-grep-cmd "git --no-pager grep --full-name -n --no-color -i 
-e %S"
+(defvar counsel-git-grep-cmd-default "git --no-pager grep --full-name -n 
--no-color -i -e '%s'"
+  "Initial command for `counsel-git-grep'.")
+
+(defvar counsel-git-grep-cmd nil
   "Store the command for `counsel-git-grep'.")
 
 (defvar counsel--git-grep-dir nil
@@ -775,20 +959,27 @@ Describe the selected candidate."
   "History for `counsel-git-grep'.")
 
 (defvar counsel-git-grep-cmd-history
-  '("git --no-pager grep --full-name -n --no-color -i -e %S")
+  (list counsel-git-grep-cmd-default)
   "History for `counsel-git-grep' shell commands.")
 
-(defun counsel-prompt-function-dir (prompt)
-  "Return PROMPT appended with the parent directory."
-  (let ((directory counsel--git-grep-dir))
-    (format "%s [%s]: "
-            prompt
-            (let ((dir-list (eshell-split-path directory)))
-              (if (> (length dir-list) 3)
-                  (apply #'concat
-                         (append '("...")
-                                 (cl-subseq dir-list (- (length dir-list) 3))))
-                directory)))))
+(defcustom counsel-grep-post-action-hook nil
+  "Hook that runs after the point moves to the next candidate.
+Typical value: '(recenter)."
+  :type 'hook
+  :group 'ivy)
+
+(defun counsel-prompt-function-dir ()
+  "Return prompt appended with the parent directory."
+  (ivy-add-prompt-count
+   (let ((directory counsel--git-grep-dir))
+     (format "%s [%s]: "
+             (ivy-state-prompt ivy-last)
+             (let ((dir-list (eshell-split-path directory)))
+               (if (> (length dir-list) 3)
+                   (apply #'concat
+                          (append '("...")
+                                  (cl-subseq dir-list (- (length dir-list) 
3))))
+                 directory))))))
 
 (defun counsel-git-grep-function (string &optional _pred &rest _unused)
   "Grep in the current git repository for STRING."
@@ -812,6 +1003,8 @@ Describe the selected candidate."
         (goto-char (point-min))
         (forward-line (1- (string-to-number line-number)))
         (re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
+        (swiper--ensure-visible)
+        (run-hooks 'counsel-grep-post-action-hook)
         (unless (eq ivy-exit 'done)
           (swiper--cleanup)
           (swiper--add-overlays (ivy--regex ivy-text)))))))
@@ -853,6 +1046,11 @@ Describe the selected candidate."
                          str))
   str)
 
+(defvar counsel-git-grep-projects-alist nil
+  "An alist of project directory to \"git-grep\" command.
+Allows to automatically use a custom \"git-grep\" command for all
+files in a project.")
+
 ;;;###autoload
 (defun counsel-git-grep (&optional cmd initial-input)
   "Grep for a string in the current git repository.
@@ -860,33 +1058,57 @@ 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
-     (funcall counsel-prompt-function "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)))
+  (ivy-set-prompt 'counsel-git-grep counsel-prompt-function)
+  (let ((dd (expand-file-name default-directory))
+        proj)
+    (cond
+      ((stringp cmd)
+       (setq counsel-git-grep-cmd cmd))
+      (cmd
+       (if (setq proj
+                 (cl-find-if
+                  (lambda (x)
+                    (string-match (car x) dd))
+                  counsel-git-grep-projects-alist))
+           (setq counsel-git-grep-cmd (cdr proj))
+         (setq counsel-git-grep-cmd
+               (ivy-read "cmd: " counsel-git-grep-cmd-history
+                         :history 'counsel-git-grep-cmd-history
+                         :re-builder #'ivy--regex))
+         (setq counsel-git-grep-cmd-history
+               (delete-dups counsel-git-grep-cmd-history))))
+      (t
+       (setq counsel-git-grep-cmd counsel-git-grep-cmd-default)))
+    (setq counsel--git-grep-dir
+          (if proj
+              (car proj)
+            (locate-dominating-file default-directory ".git")))
+    (if (null counsel--git-grep-dir)
+        (error "Not in a git repository")
+      (unless proj
+        (setq counsel--git-grep-count
+              (if (eq system-type 'windows-nt)
+                  0
+                (counsel--gg-count "" t))))
+      (ivy-read "git grep" (if proj
+                               'counsel-git-grep-proj-function
+                             'counsel-git-grep-function)
+                :initial-input initial-input
+                :matcher #'counsel-git-grep-matcher
+                :dynamic-collection (or proj (> 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))))
+
+(defun counsel-git-grep-proj-function (str)
+  (if (< (length str) 3)
+      (counsel-more-chars 3)
+    (let ((regex (setq ivy--old-re
+                       (ivy--regex str t))))
+      (counsel--async-command (format counsel-git-grep-cmd regex))
+      nil)))
 
 (defun counsel-git-grep-switch-cmd ()
   "Set `counsel-git-grep-cmd' to a different value."
@@ -926,7 +1148,8 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
      #'counsel--gg-sentinel)))
 
 (defun counsel--gg-sentinel (process event)
-  (if (string= event "finished\n")
+  (if (member event '("finished\n"
+                      "exited abnormally with code 141\n"))
       (progn
         (with-current-buffer (process-buffer process)
           (setq ivy--all-candidates
@@ -984,6 +1207,9 @@ When REVERT is non-nil, regenerate the current *ivy-occur* 
buffer."
   (unless (eq major-mode 'ivy-occur-grep-mode)
     (ivy-occur-grep-mode)
     (setq default-directory counsel--git-grep-dir))
+  (setq ivy-text
+        (and (string-match "\"\\(.*\\)\"" (buffer-name))
+             (match-string 1 (buffer-name))))
   (let ((cands (split-string
                 (shell-command-to-string
                  (format counsel-git-grep-cmd
@@ -1025,7 +1251,7 @@ When REVERT is non-nil, regenerate the current 
*ivy-occur* buffer."
 (defun counsel-git-grep-recenter ()
   (interactive)
   (with-ivy-window
-    (counsel-git-grep-action ivy--current)
+    (counsel-git-grep-action (ivy-state-current ivy-last))
     (recenter-top-bottom)))
 
 ;;** `counsel-git-stash'
@@ -1049,6 +1275,9 @@ done") "\n" t)))
                   :action 'counsel-git-stash-kill-action
                   :caller 'counsel-git-stash)))))
 ;;** `counsel-git-log'
+(defvar counsel-git-log-cmd "GIT_PAGER=cat git log --grep '%s'"
+  "Command used for \"git log\".")
+
 (defun counsel-git-log-function (input)
   (if (< (length input) 3)
       (counsel-more-chars 3)
@@ -1057,10 +1286,8 @@ done") "\n" t)))
     (counsel--async-command
      ;; "git log --grep" likes to have groups quoted e.g. \(foo\).
      ;; But it doesn't like the non-greedy ".*?".
-     (format "GIT_PAGER=cat git log --grep '%s'"
-             (replace-regexp-in-string
-              "\\.\\*\\?" ".*"
-              ivy--old-re)))
+     (format counsel-git-log-cmd
+             (replace-regexp-in-string "\\.\\*\\?" ".*" ivy--old-re)))
     nil))
 
 (defun counsel-git-log-action (x)
@@ -1095,9 +1322,45 @@ done") "\n" t)))
 
 (add-to-list 'ivy-ffap-url-functions 'counsel-github-url-p)
 (add-to-list 'ivy-ffap-url-functions 'counsel-emacs-url-p)
+(defun counsel-find-file-cd-bookmark-action (_)
+  "Reset `counsel-find-file' from selected directory."
+  (ivy-read "cd: "
+            (progn
+              (ivy--virtual-buffers)
+              (delete-dups
+               (mapcar (lambda (x) (file-name-directory (cdr x)))
+                       ivy--virtual-buffers)))
+            :action (lambda (x)
+                      (let ((default-directory (file-name-directory x)))
+                        (counsel-find-file)))))
+
+(defcustom counsel-root-command "sudo"
+  "Command to gain root privileges."
+  :type 'string
+  :group 'ivy)
+
+(defun counsel-find-file-as-root (x)
+  "Find file with root privileges."
+  (let* ((host (file-remote-p x 'host))
+         (file-name (format "/%s:%s:%s"
+                            counsel-root-command
+                            (or host "")
+                            (expand-file-name
+                             (if host
+                                 (file-remote-p x 'localname)
+                               x)))))
+    ;; If the current buffer visits the same file we are about to open,
+    ;; replace the current buffer with the new one.
+    (if (eq (current-buffer) (get-file-buffer x))
+        (find-alternate-file file-name)
+      (find-file file-name))))
+
 (ivy-set-actions
  'counsel-find-file
- '(("f" find-file-other-window "other window")))
+ '(("j" find-file-other-window "other window")
+   ("b" counsel-find-file-cd-bookmark-action "cd bookmark")
+   ("x" counsel-find-file-extern "open externally")
+   ("r" counsel-find-file-as-root "open as root")))
 
 (defcustom counsel-find-file-at-point nil
   "When non-nil, add file-at-point to the list of candidates."
@@ -1140,6 +1403,9 @@ Skip some dotfiles unless `ivy-text' requires them."
 
 (declare-function ffap-guesser "ffap")
 
+(defvar counsel-find-file-speedup-remote t
+  "Speed up opening remote files by disabling `find-file-hook' for them.")
+
 ;;;###autoload
 (defun counsel-find-file (&optional initial-input)
   "Forward to `find-file'.
@@ -1151,7 +1417,12 @@ When INITIAL-INPUT is non-nil, use it in the minibuffer 
during completion."
             :action
             (lambda (x)
               (with-ivy-window
-                (find-file (expand-file-name x ivy--directory))))
+                (let ((find-file-hook (if (and
+                                           counsel-find-file-speedup-remote
+                                           (file-remote-p ivy--directory))
+                                          nil
+                                        find-file-hook)))
+                  (find-file (expand-file-name x ivy--directory)))))
             :preselect (when counsel-find-file-at-point
                          (require 'ffap)
                          (let ((f (ffap-guesser)))
@@ -1171,11 +1442,13 @@ When INITIAL-INPUT is non-nil, use it in the minibuffer 
during completion."
           (file-name-as-directory (file-name-nondirectory dir-file-name)))))
 
 (defun counsel-at-git-issue-p ()
-  "Whe point is at an issue in a Git-versioned file, return the issue string."
+  "When point is at an issue in a Git-versioned file, return the issue string."
   (and (looking-at "#[0-9]+")
        (or
         (eq (vc-backend (buffer-file-name)) 'Git)
-        (memq major-mode '(magit-commit-mode)))
+        (or
+         (memq major-mode '(magit-commit-mode))
+         (bound-and-true-p magit-commit-mode)))
        (match-string-no-properties 0)))
 
 (defun counsel-github-url-p ()
@@ -1213,8 +1486,27 @@ When INITIAL-INPUT is non-nil, use it in the minibuffer 
during completion."
   :group 'ivy
   :type '(repeat string))
 
-(make-obsolete-variable 'counsel-locate-options 'counsel-locate-cmd "0.7.0")
+;;** `counsel-recentf'
+(defvar recentf-list)
+(declare-function recentf-mode "recentf")
+
+;;;###autoload
+(defun counsel-recentf ()
+  "Find a file on `recentf-list'."
+  (interactive)
+  (require 'recentf)
+  (recentf-mode)
+  (ivy-read "Recentf: " (mapcar #'substring-no-properties recentf-list)
+            :action (lambda (f)
+                      (with-ivy-window
+                       (find-file f)))
+            :caller 'counsel-recentf))
+(ivy-set-actions
+ 'counsel-recentf
+ '(("j" find-file-other-window "other window")
+   ("x" counsel-find-file-extern "open externally")))
 
+;;** `counsel-locate'
 (defcustom counsel-locate-cmd (cond ((eq system-type 'darwin)
                                      'counsel-locate-cmd-noregex)
                                     ((and (eq system-type 'windows-nt)
@@ -1244,15 +1536,21 @@ string - the full shell command to run."
   "History for `counsel-locate'.")
 
 (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))))
+  "Use xdg-open shell command, or corresponding system command, on X."
+  (interactive (list (read-file-name "File: ")))
+  (if (and (eq system-type 'windows-nt)
+           (fboundp 'w32-shell-execute))
+      (w32-shell-execute "open" x)
+    (call-process shell-file-name nil
+                  nil nil
+                  shell-command-switch
+                  (format "%s %s"
+                          (cl-case system-type
+                            (darwin "open")
+                            (t "xdg-open"))
+                          (shell-quote-argument x)))))
+
+(defalias 'counsel-find-file-extern 'counsel-locate-action-extern)
 
 (declare-function dired-jump "dired-x")
 
@@ -1303,6 +1601,96 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
             :unwind #'counsel-delete-process
             :caller 'counsel-locate))
 
+;;** `counsel-dpkg'
+;;;###autoload
+(defun counsel-dpkg ()
+  "Call the \"dpkg\" shell command."
+  (interactive)
+  (let ((cands (mapcar
+                (lambda (x)
+                  (let ((y (split-string x "  +")))
+                    (cons (format "%-40s   %s"
+                                  (ivy--truncate-string
+                                   (nth 1 y) 40)
+                                  (nth 4 y))
+                          (mapconcat #'identity y " "))))
+                (split-string
+                 (shell-command-to-string "dpkg -l | tail -n+6") "\n" t))))
+    (ivy-read "dpkg: " cands
+              :action (lambda (x)
+                        (message (cdr x)))
+              :caller 'counsel-dpkg)))
+
+;;** `counsel-rpm'
+;;;###autoload
+(defun counsel-rpm ()
+  "Call the \"rpm\" shell command."
+  (interactive)
+  (let ((cands (mapcar
+                (lambda (x)
+                  (let ((y (split-string x "|")))
+                    (cons (format "%-40s   %s"
+                                  (ivy--truncate-string
+                                   (nth 0 y) 40)
+                                  (nth 1 y))
+                          (mapconcat #'identity y " "))))
+                (split-string
+                 (shell-command-to-string "rpm -qa --qf 
\"%{NAME}|%{SUMMARY}\\n\"") "\n" t))))
+    (ivy-read "rpm: " cands
+              :action (lambda (x)
+                        (message (cdr x)))
+              :caller 'counsel-rpm)))
+
+;;** File Jump and Dired Jump
+
+;;;###autoload
+(defun counsel-file-jump (&optional initial-input initial-directory)
+  "Jump to a file from a list of all files directories
+below the current one.  INITIAL-INPUT can be given as the initial
+minibuffer input.  INITIAL-DIRECTORY, if non-nil, is used as the
+root directory for search."
+  (interactive
+   (list nil
+         (when current-prefix-arg
+           (read-directory-name "From directory: "))))
+  (let* ((default-directory (or initial-directory default-directory)))
+    (ivy-read "Find file: "
+              (split-string
+               (shell-command-to-string "find * -type f -not -path '*\/.git*'")
+               "\n" t)
+              :matcher #'counsel--find-file-matcher
+              :initial-input initial-input
+              :action (lambda (x)
+                        (with-ivy-window
+                          (find-file (expand-file-name x ivy--directory))))
+              :preselect (when counsel-find-file-at-point
+                           (require 'ffap)
+                           (let ((f (ffap-guesser)))
+                             (when f (expand-file-name f))))
+              :require-match 'confirm-after-completion
+              :history 'file-name-history
+              :keymap counsel-find-file-map
+              :caller 'counsel-file-jump)))
+
+;;;###autoload
+(defun counsel-dired-jump (&optional initial-input initial-directory)
+  "Jump to a directory (in dired) from a list of all directories
+below the current one.  INITIAL-INPUT can be given as the initial
+minibuffer input.  INITIAL-DIRECTORY, if non-nil, is used as the
+root directory for search."
+  (interactive
+   (list nil
+         (when current-prefix-arg
+           (read-directory-name "From directory: "))))
+  (let* ((default-directory (or initial-directory default-directory)))
+    (ivy-read "Directory: "
+              (split-string
+               (shell-command-to-string "find * -type d -not -path '*\/.git*'")
+               "\n" t)
+              :initial-input initial-input
+              :action (lambda (d) (dired-jump nil (expand-file-name d)))
+              :caller 'counsel-dired-jump)))
+
 ;;* Grep
 ;;** `counsel-ag'
 (defvar counsel-ag-map
@@ -1311,10 +1699,10 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
     (define-key map (kbd "M-q") 'counsel-git-grep-query-replace)
     map))
 
-(defcustom counsel-ag-base-command "ag --nocolor --nogroup %s -- ."
-  "Format string to use in `cousel-ag-function' to construct the
-command. %S will be replaced by the regex string. The default is
-\"ag --nocolor --nogroup %s -- .\"."
+(defcustom counsel-ag-base-command "ag --nocolor --nogroup %s"
+  "Format string to use in `counsel-ag-function' to construct the
+command. The %s will be replaced by optional extra ag arguments followed by the
+regex string. The default is \"ag --nocolor --nogroup %s\"."
   :type 'string
   :group 'ivy)
 
@@ -1322,32 +1710,60 @@ command. %S will be replaced by the regex string. The 
default is
 (ivy-set-occur 'counsel-ag 'counsel-ag-occur)
 (ivy-set-display-transformer 'counsel-ag 'counsel-git-grep-transformer)
 
-(defun counsel-ag-function (string)
-  "Grep in the current directory for STRING."
+(defun counsel-ag-function (string base-cmd extra-ag-args)
+  "Grep in the current directory for STRING.
+If non-nil, EXTRA-AG-ARGS string is appended to BASE-CMD."
+  (when (null extra-ag-args)
+    (setq extra-ag-args ""))
   (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 counsel-ag-base-command (shell-quote-argument regex)))
-      nil)))
+      (let* ((args-end (string-match " -- " extra-ag-args))
+             (file (if args-end
+                       (substring-no-properties extra-ag-args (+ args-end 3))
+                     ""))
+             (extra-ag-args (if args-end
+                                (substring-no-properties extra-ag-args 0 
args-end)
+                              extra-ag-args))
+             (ag-cmd (format base-cmd
+                             (concat extra-ag-args
+                                     " -- "
+                                     (shell-quote-argument regex)
+                                     file))))
+        (if (file-remote-p default-directory)
+            (split-string (shell-command-to-string ag-cmd) "\n" t)
+          (counsel--async-command ag-cmd)
+          nil)))))
 
 ;;;###autoload
-(defun counsel-ag (&optional initial-input initial-directory)
+(defun counsel-ag (&optional initial-input initial-directory extra-ag-args 
ag-prompt)
   "Grep for a string in the current directory using ag.
-INITIAL-INPUT can be given as the initial minibuffer input."
-  (interactive
-   (list nil
-         (when current-prefix-arg
-           (read-directory-name (concat
-                                 (car (split-string counsel-ag-base-command))
-                                 " in directory: ")))))
+  INITIAL-INPUT can be given as the initial minibuffer input.
+  INITIAL-DIRECTORY, if non-nil, is used as the root directory for search.
+  EXTRA-AG-ARGS string, if non-nil, is appended to `counsel-ag-base-command'.
+  AG-PROMPT, if non-nil, is passed as `ivy-read' prompt argument. "
+  (interactive)
+  (when current-prefix-arg
+    (setq initial-directory
+          (or initial-directory
+              (read-directory-name (concat
+                                    (car (split-string 
counsel-ag-base-command))
+                                    " in directory: "))))
+    (setq extra-ag-args
+          (or extra-ag-args
+              (let* ((pos (cl-position ?  counsel-ag-base-command))
+                     (command (substring-no-properties counsel-ag-base-command 
0 pos))
+                     (ag-args (replace-regexp-in-string
+                               "%s" "" (substring-no-properties 
counsel-ag-base-command pos))))
+                (read-string (format "(%s) args:" command) ag-args)))))
+  (ivy-set-prompt 'counsel-ag counsel-prompt-function)
   (setq counsel--git-grep-dir (or initial-directory default-directory))
-  (ivy-read (funcall counsel-prompt-function
-                     (car (split-string counsel-ag-base-command)))
-            'counsel-ag-function
+  (ivy-read (or ag-prompt (car (split-string counsel-ag-base-command)))
+            (lambda (string)
+              (counsel-ag-function string counsel-ag-base-command 
extra-ag-args))
             :initial-input initial-input
             :dynamic-collection t
             :keymap counsel-ag-map
@@ -1383,23 +1799,86 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
       cands))))
 
 ;;** `counsel-pt'
-(defcustom counsel-pt-base-command "pt --nocolor --nogroup -e %s -- ."
+(defcustom counsel-pt-base-command "pt --nocolor --nogroup -e %s"
   "Used to in place of `counsel-ag-base-command' to search with
 pt using `counsel-ag'."
   :type 'string
   :group 'ivy)
 
 ;;;###autoload
-(defun counsel-pt ()
+(defun counsel-pt (&optional initial-input)
   "Grep for a string in the current directory using pt.
 This uses `counsel-ag' with `counsel-pt-base-command' replacing
 `counsel-ag-base-command'."
   (interactive)
   (let ((counsel-ag-base-command counsel-pt-base-command))
-    (call-interactively 'counsel-ag)))
+    (counsel-ag initial-input)))
+
+;;** `counsel-rg'
+(defcustom counsel-rg-base-command "rg -i --no-heading --line-number %s ."
+  "Used to in place of `counsel-rg-base-command' to search with
+ripgrep using `counsel-rg'."
+  :type 'string
+  :group 'ivy)
+
+(counsel-set-async-exit-code 'counsel-rg 1 "No matches found")
+(ivy-set-occur 'counsel-rg 'counsel-rg-occur)
+(ivy-set-display-transformer 'counsel-rg 'counsel-git-grep-transformer)
+
+;;;###autoload
+(defun counsel-rg (&optional initial-input initial-directory extra-rg-args 
rg-prompt)
+  "Grep for a string in the current directory using rg.
+INITIAL-INPUT can be given as the initial minibuffer input.
+INITIAL-DIRECTORY, if non-nil, is used as the root directory for search.
+EXTRA-RG-ARGS string, if non-nil, is appended to `counsel-rg-base-command'.
+RG-PROMPT, if non-nil, is passed as `ivy-read' prompt argument. "
+  (interactive
+   (list nil
+         (when current-prefix-arg
+           (read-directory-name (concat
+                                 (car (split-string counsel-rg-base-command))
+                                 " in directory: ")))))
+  (ivy-set-prompt 'counsel-rg counsel-prompt-function)
+  (setq counsel--git-grep-dir (or initial-directory default-directory))
+  (ivy-read (or rg-prompt (car (split-string counsel-rg-base-command)))
+            (lambda (string)
+              (counsel-ag-function string counsel-rg-base-command 
extra-rg-args))
+            :initial-input initial-input
+            :dynamic-collection t
+            :keymap counsel-ag-map
+            :history 'counsel-git-grep-history
+            :action #'counsel-git-grep-action
+            :unwind (lambda ()
+                      (counsel-delete-process)
+                      (swiper--cleanup))
+            :caller 'counsel-rg))
+
+(defun counsel-rg-occur ()
+  "Generate a custom occur buffer for `counsel-rg'."
+  (unless (eq major-mode 'ivy-occur-grep-mode)
+    (ivy-occur-grep-mode))
+  (setq default-directory counsel--git-grep-dir)
+  (let* ((regex (counsel-unquote-regex-parens
+                 (setq ivy--old-re
+                       (ivy--regex
+                        (progn (string-match "\"\\(.*\\)\"" (buffer-name))
+                               (match-string 1 (buffer-name)))))))
+         (cands (split-string
+                 (shell-command-to-string
+                  (format counsel-rg-base-command (shell-quote-argument 
regex)))
+                 "\n"
+                 t)))
+    ;; 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 cands)))
+    (ivy--occur-insert-lines
+     (mapcar
+      (lambda (cand) (concat "./" cand))
+      cands))))
 
 ;;** `counsel-grep'
-(defcustom counsel-grep-base-command "grep -nE \"%s\" %s"
+(defcustom counsel-grep-base-command "grep -nE '%s' %s"
   "Format string to use in `cousel-grep-function' to construct
 the command."
   :type 'string
@@ -1413,7 +1892,8 @@ the command."
                   (setq ivy--old-re
                         (ivy--regex string)))))
       (counsel--async-command
-       (format counsel-grep-base-command regex counsel--git-grep-dir))
+       (format counsel-grep-base-command regex
+               (shell-quote-argument counsel--git-grep-dir)))
       nil)))
 
 (defun counsel-grep-action (x)
@@ -1437,6 +1917,7 @@ the command."
           (forward-line (- line-number counsel-grep-last-line))
           (setq counsel-grep-last-line line-number))
         (re-search-forward (ivy--regex ivy-text t) (line-end-position) t)
+        (run-hooks 'counsel-grep-post-action-hook)
         (if (eq ivy-exit 'done)
             (swiper--ensure-visible)
           (isearch-range-invisible (line-beginning-position)
@@ -1456,7 +1937,7 @@ the command."
                           (ivy--regex
                            (progn (string-match "\"\\(.*\\)\"" (buffer-name))
                                   (match-string 1 (buffer-name))) t)))
-                   counsel--git-grep-dir))
+                   (shell-quote-argument counsel--git-grep-dir)))
           "\n" t))
         (file (file-name-nondirectory counsel--git-grep-dir)))
     ;; Need precise number of header lines for `wgrep' to work.
@@ -1484,12 +1965,14 @@ the command."
                              :dynamic-collection t
                              :preselect (format "%d:%s"
                                                 (line-number-at-pos)
-                                                (buffer-substring-no-properties
-                                                 (line-beginning-position)
-                                                 (line-end-position)))
+                                                (regexp-quote
+                                                 
(buffer-substring-no-properties
+                                                  (line-beginning-position)
+                                                  (line-end-position))))
                              :history 'counsel-git-grep-history
                              :update-fn (lambda ()
-                                          (counsel-grep-action ivy--current))
+                                          (counsel-grep-action 
(ivy-state-current ivy-last)))
+                             :re-builder #'ivy--regex
                              :action #'counsel-grep-action
                              :unwind (lambda ()
                                        (counsel-delete-process)
@@ -1504,6 +1987,12 @@ the command."
   :type 'integer
   :group 'ivy)
 
+(defvar counsel-compressed-file-regex
+  (progn
+    (require 'jka-compr nil t)
+    (jka-compr-build-file-regexp))
+  "Store the regex for compressed file names.")
+
 ;;;###autoload
 (defun counsel-grep-or-swiper ()
   "Call `swiper' for small buffers and `counsel-grep' for large ones."
@@ -1512,6 +2001,9 @@ the command."
            (not (buffer-narrowed-p))
            (not (ignore-errors
                   (file-remote-p (buffer-file-name))))
+           (not (string-match
+                 counsel-compressed-file-regex
+                 (buffer-file-name)))
            (> (buffer-size)
               (if (eq major-mode 'org-mode)
                   (/ counsel-grep-swiper-limit 4)
@@ -1523,11 +2015,12 @@ the command."
 
 ;;** `counsel-recoll'
 (defun counsel-recoll-function (string)
-  "Grep in the current directory for STRING."
+  "Run recoll for STRING."
   (if (< (length string) 3)
       (counsel-more-chars 3)
     (counsel--async-command
-     (format "recoll -t -b '%s'" string))
+     (format "recoll -t -b %s"
+             (shell-quote-argument string)))
     nil))
 
 ;; This command uses the recollq command line tool that comes together
@@ -1647,7 +2140,8 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
                        (counsel-org--set-tags))))))
            (counsel-org--set-tags)))
         ((eq this-command 'ivy-call)
-         (delete-minibuffer-contents))))
+         (with-selected-window (active-minibuffer-window)
+           (delete-minibuffer-contents)))))
 
 (defun counsel-org-tag-prompt ()
   (format "Tags (%s): "
@@ -1712,6 +2206,106 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
            (org-agenda-set-tags nil nil))
       (fset 'org-set-tags store))))
 
+;;** `counsel-mark-ring'
+(defun counsel--pad (string length)
+  "Pad string to length with spaces."
+  (let ((padding (max 0 (- length (length string)))))
+    (concat string (make-string padding ?\s))))
+
+(defun counsel-mark-ring ()
+  "Browse `mark-ring' interactively."
+  (interactive)
+  (let ((candidates
+         (with-current-buffer (current-buffer)
+           (let ((padding (length (format "%s: " (line-number-at-pos 
(eobp))))))
+             (save-mark-and-excursion
+              (goto-char (point-min))
+              (mapcar (lambda (mark)
+                        (let* ((position (marker-position mark))
+                               (line-number (line-number-at-pos position))
+                               (line-marker (counsel--pad (format "%s:" 
line-number) padding))
+                               (bol (point-at-bol line-number))
+                               (eol (point-at-eol line-number))
+                               (line (buffer-substring bol eol)))
+                          (cons (format "%s%s" line-marker line) position)))
+                      (cl-remove-duplicates mark-ring :test #'equal)))))))
+    (ivy-read "Marks: " candidates
+              :action (lambda (elem)
+                        (goto-char (cdr elem))))))
+
+;;** `counsel-package'
+(defvar package--initialized)
+(defvar package-archive-contents)
+(declare-function package-installed-p "package")
+(declare-function package-delete "package")
+
+(defun counsel-package ()
+  "Install or delete packages.
+
+Packages not currently installed have a \"+\"
+prepended. Selecting one of these will try to install
+it. Currently installed packages have a \"-\" prepended, and
+selecting one of these will delete the package.
+
+Additional Actions:
+
+  \\<ivy-minibuffer-map>\\[ivy-dispatching-done] d: describe package"
+  (interactive)
+  (unless package--initialized
+    (package-initialize t))
+  (unless package-archive-contents
+    (package-refresh-contents))
+  (let ((cands (mapcar #'counsel-package-make-package-cell
+                       package-archive-contents)))
+    (ivy-read "Packages (install +pkg or delete -pkg): "
+              (cl-sort cands #'counsel--package-sort)
+              :action #'counsel-package-action
+              :initial-input "^+ "
+              :require-match t
+              :caller 'counsel-package)))
+
+(defun counsel-package-make-package-cell (pkg)
+  (let* ((pkg-sym (car pkg))
+         (pkg-name (symbol-name pkg-sym)))
+    (cons (format "%s%s"
+                  (if (package-installed-p pkg-sym) "-" "+")
+                  pkg-name)
+          pkg)))
+
+(defun counsel-package-action (pkg-cons)
+  (let ((pkg (cadr pkg-cons)))
+    (if (package-installed-p pkg)
+        (package-delete pkg)
+      (package-install pkg))))
+
+(defun counsel-package-action-describe (pkg-cons)
+  "Call `describe-package' for package in PKG-CONS."
+  (describe-package (cadr pkg-cons)))
+
+(declare-function package-desc-extras "package")
+
+(defun counsel-package-action-homepage (pkg-cons)
+  "Open homepage for package in PKG-CONS."
+  (let* ((desc-list (cddr pkg-cons))
+         (desc (if (listp desc-list) (car desc-list) desc-list))
+         (url (cdr (assoc :url (package-desc-extras desc)))))
+    (when url
+      (require 'browse-url)
+      (browse-url url))))
+
+(defun counsel--package-sort (a b)
+  "Sort function for `counsel-package'."
+  (let* ((a (car a))
+         (b (car b))
+         (a-inst (equal (substring a 0 1) "+"))
+         (b-inst (equal (substring b 0 1) "+")))
+    (or (and a-inst (not b-inst))
+        (and (eq a-inst b-inst) (string-lessp a b)))))
+
+(ivy-set-actions 'counsel-package
+                 '(("d" counsel-package-action-describe "describe package")
+                   ("h" counsel-package-action-homepage "open package 
homepage")))
+
 ;;** `counsel-tmm'
 (defvar tmm-km-list nil)
 (declare-function tmm-get-keymap "tmm")
@@ -1773,6 +2367,11 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
           (mapconcat #'identity seq "\n")))
     (error str)))
 
+(defcustom counsel-yank-pop-separator "\n"
+  "Separator for the kill ring strings in `counsel-yank-pop'."
+  :group 'ivy
+  :type 'string)
+
 (defun counsel--yank-pop-format-function (cand-pairs)
   (ivy--format-function-generic
    (lambda (str)
@@ -1785,7 +2384,7 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
    (lambda (str)
      (counsel--yank-pop-truncate str))
    cand-pairs
-   "\n"))
+   counsel-yank-pop-separator))
 
 (defun counsel-yank-pop-action (s)
   "Insert S into the buffer, overwriting the previous yank."
@@ -1808,11 +2407,13 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
                 (point))))
     (setq ivy-completion-beg (point))
     (setq ivy-completion-end (point)))
-  (let ((candidates (cl-remove-if
-                     (lambda (s)
-                       (or (< (length s) 3)
-                           (string-match "\\`[\n[:blank:]]+\\'" s)))
-                     (delete-dups kill-ring))))
+  (let ((candidates
+         (mapcar #'ivy-cleanup-string
+                 (cl-remove-if
+                  (lambda (s)
+                    (or (< (length s) 3)
+                        (string-match "\\`[\n[:blank:]]+\\'" s)))
+                  (delete-dups kill-ring)))))
     (let ((ivy-format-function #'counsel--yank-pop-format-function)
           (ivy-height 5))
       (ivy-read "kill-ring: " candidates
@@ -1821,6 +2422,7 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
 
 ;;** `counsel-imenu'
 (defvar imenu-auto-rescan)
+(defvar imenu-auto-rescan-maxout)
 (declare-function imenu--subalist-p "imenu")
 (declare-function imenu--make-index-alist "imenu")
 
@@ -1834,7 +2436,12 @@ PREFIX is used to create the key."
                          (cons e (if (integerp v) (copy-marker v) v)))
                     ;; pass the prefix to next recursive call
                     (concat prefix (if prefix ".") (car elm)))
-                 (let ((key (concat prefix (if prefix ".") (car elm))))
+                 (let ((key (concat
+                             (when prefix
+                               (concat
+                                (propertize prefix 'face 'compilation-info)
+                                ": "))
+                             (car elm))))
                    (list (cons key
                                ;; create a imenu candidate here
                                (cons key (if (overlayp (cdr elm))
@@ -1849,6 +2456,9 @@ PREFIX is used to create the key."
   (unless (featurep 'imenu)
     (require 'imenu nil t))
   (let* ((imenu-auto-rescan t)
+         (imenu-auto-rescan-maxout (if current-prefix-arg
+                                       (buffer-size)
+                                     imenu-auto-rescan-maxout))
          (items (imenu--make-index-alist t))
          (items (delete (assoc "*Rescan*" items) items)))
     (ivy-read "imenu items:" (counsel-imenu-get-candidates-from items)
@@ -1858,7 +2468,7 @@ PREFIX is used to create the key."
                         (with-ivy-window
                           ;; In org-mode, (imenu candidate) will expand child 
node
                           ;; after jump to the candidate position
-                          (imenu candidate)))
+                          (imenu (cdr candidate))))
               :caller 'counsel-imenu)))
 
 ;;** `counsel-list-processes'
@@ -1916,7 +2526,7 @@ An extra action allows to switch to the process buffer."
     (if (null collection)
         (error "%S is not supported" major-mode)
       (ivy-read "Ace-Link: " (funcall collection)
-                :action action
+                :action (lambda (x) (funcall action (cdr x)))
                 :require-match t
                 :caller 'counsel-ace-link))))
 ;;** `counsel-expression-history'
@@ -1930,6 +2540,14 @@ And insert it into the minibuffer. Useful during
     (ivy-read "Expr: " (delete-dups read-expression-history)
               :action #'insert)))
 
+;;** `counsel-shell-command-history'
+;;;###autoload
+(defun counsel-shell-command-history ()
+  (interactive)
+  (ivy-read "cmd: " shell-command-history
+            :action #'insert
+            :caller 'counsel-shell-command-history))
+
 ;;** `counsel-esh-history'
 (defun counsel--browse-history (elements)
   "Use Ivy to navigate through ELEMENTS."
@@ -1958,14 +2576,90 @@ And insert it into the minibuffer. Useful during
   (require 'comint)
   (counsel--browse-history comint-input-ring))
 
+;;** `counsel-hydra-heads'
+(defvar hydra-curr-body-fn)
+(declare-function hydra-keyboard-quit "ext:hydra")
+
+(defun counsel-hydra-heads ()
+  "Call a head of the current/last hydra."
+  (interactive)
+  (let* ((base (substring
+                (prin1-to-string hydra-curr-body-fn)
+                0 -4))
+         (heads (eval (intern (concat base "heads"))))
+         (keymap (eval (intern (concat base "keymap"))))
+         (head-names
+          (mapcar (lambda (x)
+                    (cons
+                     (if (nth 2 x)
+                         (format "[%s] %S (%s)" (nth 0 x) (nth 1 x) (nth 2 x))
+                       (format "[%s] %S" (nth 0 x) (nth 1 x)))
+                     (lookup-key keymap (kbd (nth 0 x)))))
+                  heads)))
+    (ivy-read "head: " head-names
+              :action (lambda (x) (call-interactively (cdr x))))
+    (hydra-keyboard-quit)))
+;;** `counsel-semantic'
+(declare-function semantic-tag-start "tag")
+(declare-function semantic-tag-of-class-p "tag")
+(declare-function semantic-fetch-tags "semantic")
+
+(defun counsel-semantic-action (tag)
+  (with-ivy-window
+    (goto-char (semantic-tag-start tag))))
+
+(defun counsel-semantic ()
+  "Jump to a semantic tag in the current buffer."
+  (interactive)
+  (let ((tags
+         (mapcar
+          (lambda (tag)
+            (if (semantic-tag-of-class-p tag 'function)
+                (cons
+                 (propertize
+                  (car tag)
+                  'face 'font-lock-function-name-face)
+                 (cdr tag))
+              tag))
+          (semantic-fetch-tags))))
+    (ivy-read "tag: " tags
+              :action 'counsel-semantic-action)))
+
+;;** `counsel-outline'
+(defun counsel-outline-candidates ()
+  (let (cands)
+    (save-excursion
+      (goto-char (point-min))
+      (while (re-search-forward outline-regexp nil t)
+        (skip-chars-forward " ")
+        (push (cons (buffer-substring-no-properties
+                     (point) (line-end-position))
+                    (line-beginning-position))
+              cands))
+      (nreverse cands))))
+
+(defun counsel-outline-action (x)
+  (with-ivy-window
+    (goto-char (cdr x))))
+
+(defun counsel-outline ()
+  "Jump to outline with completion."
+  (interactive)
+  (ivy-read "outline: " (counsel-outline-candidates)
+            :action #'counsel-outline-action))
+
 ;;* Misc OS
 ;;** `counsel-rhythmbox'
-(defvar helm-rhythmbox-library)
-(declare-function helm-rhythmbox-load-library "ext:helm-rhythmbox")
 (declare-function dbus-call-method "dbus")
 (declare-function dbus-get-property "dbus")
-(declare-function helm-rhythmbox-song-uri "ext:helm-rhythmbox")
-(declare-function helm-rhythmbox-candidates "ext:helm-rhythmbox")
+
+(defun counsel-rhythmbox-play-song (song)
+  "Let Rhythmbox play SONG."
+  (let ((service "org.gnome.Rhythmbox3")
+        (path "/org/mpris/MediaPlayer2")
+        (interface "org.mpris.MediaPlayer2.Player"))
+    (dbus-call-method :session service path interface
+                      "OpenUri" (cdr song))))
 
 (defun counsel-rhythmbox-enqueue-song (song)
   "Let Rhythmbox enqueue SONG."
@@ -1973,11 +2667,13 @@ And insert it into the minibuffer. Useful during
         (path "/org/gnome/Rhythmbox3/PlayQueue")
         (interface "org.gnome.Rhythmbox3.PlayQueue"))
     (dbus-call-method :session service path interface
-                      "AddToQueue" (helm-rhythmbox-song-uri song))))
+                      "AddToQueue" (cdr song))))
 
 (defvar counsel-rhythmbox-history nil
   "History for `counsel-rhythmbox'.")
 
+(defvar counsel-rhythmbox-songs nil)
+
 (defun counsel-rhythmbox-current-song ()
   "Return the currently playing song title."
   (ignore-errors
@@ -1996,21 +2692,36 @@ And insert it into the minibuffer. Useful during
 (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 helm-rhythmbox-library
-    (helm-rhythmbox-load-library)
-    (while (null helm-rhythmbox-library)
-      (sit-for 0.1)))
-  (ivy-read "Rhythmbox: "
-            (helm-rhythmbox-candidates)
+  (require 'dbus)
+  (unless counsel-rhythmbox-songs
+    (let* ((service "org.gnome.Rhythmbox3")
+           (path "/org/gnome/UPnP/MediaServer2/Library/all")
+           (interface "org.gnome.UPnP.MediaContainer2")
+           (nb-songs (dbus-get-property
+                      :session service path interface "ChildCount")))
+      (if (not nb-songs)
+          (error "Couldn't connect to Rhythmbox")
+        (setq counsel-rhythmbox-songs
+              (mapcar (lambda (x)
+                        (cons
+                         (format
+                          "%s - %s - %s"
+                          (cl-caadr (assoc "Artist" x))
+                          (cl-caadr (assoc "Album" x))
+                          (cl-caadr (assoc "DisplayName" x)))
+                         (cl-caaadr (assoc "URLs" x))))
+                      (dbus-call-method
+                       :session service path interface "ListChildren"
+                       0 nb-songs '("*")))))))
+  (ivy-read "Rhythmbox: " counsel-rhythmbox-songs
             :history 'counsel-rhythmbox-history
             :preselect (counsel-rhythmbox-current-song)
             :action
             '(1
-              ("p" helm-rhythmbox-play-song "Play song")
+              ("p" counsel-rhythmbox-play-song "Play song")
               ("e" counsel-rhythmbox-enqueue-song "Enqueue song"))
             :caller 'counsel-rhythmbox))
+
 ;;** `counsel-linux-app'
 (defvar counsel-linux-apps-alist nil
   "List of data located in /usr/share/applications.")
@@ -2018,47 +2729,57 @@ And insert it into the minibuffer. Useful during
 (defvar counsel-linux-apps-faulty nil
   "List of faulty data located in /usr/share/applications.")
 
+(defcustom counsel-linux-apps-directories
+  '("/usr/local/share/applications/" "/usr/share/applications/")
+  "Directories in which to search for applications (.desktop files)."
+  :group 'counsel
+  :type '(list directory))
+
 (defun counsel-linux-apps-list ()
-  (let ((files
-         (delete
-          ".." (delete
-                "." (file-expand-wildcards 
"/usr/share/applications/*.desktop")))))
+  (let ((files (apply 'append
+                      (mapcar
+                       (lambda (dir)
+                         (when (file-exists-p dir)
+                           (directory-files dir t ".*\\.desktop$")))
+                       counsel-linux-apps-directories))))
     (dolist (file (cl-set-difference files (append (mapcar 'car 
counsel-linux-apps-alist)
                                                    counsel-linux-apps-faulty)
                                      :test 'equal))
       (with-temp-buffer
-        (insert-file-contents (expand-file-name file 
"/usr/share/applications"))
+        (insert-file-contents file)
         (let (name comment exec)
           (goto-char (point-min))
-          (if (re-search-forward "^Name *= *\\(.*\\)$" nil t)
-              (setq name (match-string 1))
-            (error "File %s has no Name" file))
-          (goto-char (point-min))
-          (when (re-search-forward "^Comment *= *\\(.*\\)$" nil t)
-            (setq comment (match-string 1)))
-          (goto-char (point-min))
-          (when (re-search-forward "^Exec *= *\\(.*\\)$" nil t)
-            (setq exec (match-string 1)))
-          (if (and exec (not (equal exec "")))
-              (add-to-list
-               'counsel-linux-apps-alist
-               (cons (format "% -45s: %s%s"
-                             (propertize exec 'face 'font-lock-builtin-face)
-                             name
-                             (if comment
-                                 (concat " - " comment)
-                               ""))
-                     file))
-            (add-to-list 'counsel-linux-apps-faulty file))))))
+          (if (null (re-search-forward "^Name *= *\\(.*\\)$" nil t))
+              (message "Warning: File %s has no Name" file)
+            (setq name (match-string 1))
+            (goto-char (point-min))
+            (when (re-search-forward "^Comment *= *\\(.*\\)$" nil t)
+              (setq comment (match-string 1)))
+            (goto-char (point-min))
+            (when (re-search-forward "^Exec *= *\\(.*\\)$" nil t)
+              (setq exec (match-string 1)))
+            (if (and exec (not (equal exec "")))
+                (add-to-list
+                 'counsel-linux-apps-alist
+                 (cons (format "% -45s: %s%s"
+                               (propertize exec 'face 'font-lock-builtin-face)
+                               name
+                               (if comment
+                                   (concat " - " comment)
+                                 ""))
+                       file))
+              (add-to-list 'counsel-linux-apps-faulty file)))))))
   counsel-linux-apps-alist)
 
 (defun counsel-linux-app-action-default (desktop-shortcut)
   "Launch DESKTOP-SHORTCUT."
+  (setq desktop-shortcut (cdr desktop-shortcut))
   (call-process-shell-command
    (format "gtk-launch %s" (file-name-nondirectory desktop-shortcut))))
 
 (defun counsel-linux-app-action-file (desktop-shortcut)
   "Launch DESKTOP-SHORTCUT with a selected file."
+  (setq desktop-shortcut (cdr desktop-shortcut))
   (let* ((entry (rassoc desktop-shortcut counsel-linux-apps-alist))
          (short-name (and entry
                           (string-match "\\([^ ]*\\) " (car entry))
@@ -2068,7 +2789,7 @@ And insert it into the minibuffer. Useful during
                      (format "Run %s on: " short-name)))))
     (if file
         (call-process-shell-command
-         (format "gtk-launch %s %s"
+         (format "gtk-launch %s \"%s\""
                  (file-name-nondirectory desktop-shortcut)
                  file))
       (user-error "cancelled"))))
@@ -2085,6 +2806,502 @@ And insert it into the minibuffer. Useful during
             :action #'counsel-linux-app-action-default
             :caller 'counsel-linux-app))
 
+(defvar company-candidates)
+(defvar company-point)
+(defvar company-common)
+(declare-function company-complete "ext:company")
+(declare-function company-mode "ext:company")
+(declare-function company-complete-common "ext:company")
+
+;;;###autoload
+(defun counsel-company ()
+  "Complete using `company-candidates'."
+  (interactive)
+  (company-mode 1)
+  (unless company-candidates
+    (company-complete))
+  (when company-point
+    (company-complete-common)
+    (when (looking-back company-common (line-beginning-position))
+      (setq ivy-completion-beg (match-beginning 0))
+      (setq ivy-completion-end (match-end 0)))
+    (ivy-read "company cand: " company-candidates
+              :action #'ivy-completion-in-region-action)))
+
+;;;** `counsel-colors'
+(defun counsel-colors--best-contrast-color (color)
+  "Choose the best-contrast foreground color for a background color COLOR.
+
+Use the relative luminance formula to improve the perceived contrast.
+If the relative luminance is beyond a given threshold, in this case a
+midpoint, then the chosen color is black, otherwise is white.  This
+helps to improve the contrast and readability of a text regardless of
+the background color."
+  (let ((rgb (color-name-to-rgb color)))
+    (if rgb
+        (if (>
+             (+ (* (nth 0 rgb) 0.299)
+                (* (nth 1 rgb) 0.587)
+                (* (nth 2 rgb) 0.114))
+             0.5)
+            "#000000"
+          "#FFFFFF")
+      color)))
+
+(defun counsel-colors--update-highlight (cand)
+  "Update the highlight face for the current candidate CAND.
+
+This is necessary because the default `ivy-current-match' face
+background mask most of the colors and you can not see the current
+candidate color when is selected, which is counter-intuitive and not
+user friendly.  The default Emacs command `list-colors-display' have
+the same problem."
+  (when (> (length cand) 0)
+    (let ((color (substring-no-properties cand 26 33)))
+      (face-remap-add-relative
+       'ivy-current-match
+       :background color
+       ;; Another alternatives like use the attribute
+       ;; `distant-foreground' or the function `color-complement-hex'
+       ;; do not work well here because they use the absolute
+       ;; luminance difference between the colors, when the human eye
+       ;; does not perceive all the colors with the same brightness.
+       :foreground (counsel-colors--best-contrast-color color)))))
+
+(defun counsel-colors-action-insert-name (x)
+  "Insert the X color name."
+  (let ((color (car (split-string (substring x 0 25)))))
+    (insert color)))
+
+(defun counsel-colors-action-insert-hex (x)
+  "Insert the X color hexadecimal rgb value."
+  (let ((rgb (substring x 26 33)))
+    (insert rgb)))
+
+(defun counsel-colors-action-kill-name (x)
+  "Kill the X color name."
+  (let ((color (car (split-string (substring x 0 25)))))
+    (kill-new color)))
+
+(defun counsel-colors-action-kill-hex (x)
+  "Kill the X color hexadecimal rgb value."
+  (let ((rgb (substring x 26 33)))
+    (kill-new rgb)))
+
+;;** `counsel-colors-emacs'
+(ivy-set-actions
+ 'counsel-colors-emacs
+ '(("n" counsel-colors-action-insert-name "insert color name")
+   ("h" counsel-colors-action-insert-hex "insert color hexadecimal value")
+   ("N" counsel-colors-action-kill-name "kill color name")
+   ("H" counsel-colors-action-kill-hex "kill color hexadecimal value")))
+
+(defvar counsel-colors-emacs-history nil
+  "History for `counsel-colors-emacs'.")
+
+(defun counsel-colors--name-to-hex (color)
+  "Return hexadecimal rgb value of a color from his name COLOR."
+  (apply 'color-rgb-to-hex (color-name-to-rgb color)))
+
+;;;###autoload
+(defun counsel-colors-emacs ()
+  "Show a list of all supported colors for a particular frame.
+
+You can insert or kill the name or the hexadecimal rgb value of the
+selected candidate."
+  (interactive)
+  (let ((minibuffer-allow-text-properties t))
+    (ivy-read "%d Emacs color: "
+              (mapcar (lambda (x)
+                        (concat
+                         (propertize
+                          (format "%-25s" (car x))
+                          'result (car x))
+                         (propertize
+                          (format "%8s  "
+                                  (counsel-colors--name-to-hex (car x)))
+                          'face (list :foreground (car x)))
+                         (propertize
+                          (format "%10s" " ")
+                          'face (list :background (car x)))
+                         (propertize
+                          (format "  %-s" (mapconcat #'identity (cdr x) ", "))
+                          'face (list :foreground (car x)))))
+                      (list-colors-duplicates))
+              :require-match t
+              :update-fn (lambda ()
+                           (counsel-colors--update-highlight 
(ivy-state-current ivy-last)))
+              :action #'counsel-colors-action-insert-name
+              :history 'counsel-colors-emacs-history
+              :caller 'counsel-colors-emacs
+              :sort nil)))
+
+;;** `counsel-colors-web'
+(defvar counsel-colors--web-colors-alist
+  '(("aliceblue"            .  "#f0f8ff")
+    ("antiquewhite"         .  "#faebd7")
+    ("aqua"                 .  "#00ffff")
+    ("aquamarine"           .  "#7fffd4")
+    ("azure"                .  "#f0ffff")
+    ("beige"                .  "#f5f5dc")
+    ("bisque"               .  "#ffe4c4")
+    ("black"                .  "#000000")
+    ("blanchedalmond"       .  "#ffebcd")
+    ("blue"                 .  "#0000ff")
+    ("blueviolet"           .  "#8a2be2")
+    ("brown"                .  "#a52a2a")
+    ("burlywood"            .  "#deb887")
+    ("cadetblue"            .  "#5f9ea0")
+    ("chartreuse"           .  "#7fff00")
+    ("chocolate"            .  "#d2691e")
+    ("coral"                .  "#ff7f50")
+    ("cornflowerblue"       .  "#6495ed")
+    ("cornsilk"             .  "#fff8dc")
+    ("crimson"              .  "#dc143c")
+    ("cyan"                 .  "#00ffff")
+    ("darkblue"             .  "#00008b")
+    ("darkcyan"             .  "#008b8b")
+    ("darkgoldenrod"        .  "#b8860b")
+    ("darkgray"             .  "#a9a9a9")
+    ("darkgreen"            .  "#006400")
+    ("darkkhaki"            .  "#bdb76b")
+    ("darkmagenta"          .  "#8b008b")
+    ("darkolivegreen"       .  "#556b2f")
+    ("darkorange"           .  "#ff8c00")
+    ("darkorchid"           .  "#9932cc")
+    ("darkred"              .  "#8b0000")
+    ("darksalmon"           .  "#e9967a")
+    ("darkseagreen"         .  "#8fbc8f")
+    ("darkslateblue"        .  "#483d8b")
+    ("darkslategray"        .  "#2f4f4f")
+    ("darkturquoise"        .  "#00ced1")
+    ("darkviolet"           .  "#9400d3")
+    ("deeppink"             .  "#ff1493")
+    ("deepskyblue"          .  "#00bfff")
+    ("dimgray"              .  "#696969")
+    ("dodgerblue"           .  "#1e90ff")
+    ("firebrick"            .  "#b22222")
+    ("floralwhite"          .  "#fffaf0")
+    ("forestgreen"          .  "#228b22")
+    ("fuchsia"              .  "#ff00ff")
+    ("gainsboro"            .  "#dcdcdc")
+    ("ghostwhite"           .  "#f8f8ff")
+    ("goldenrod"            .  "#daa520")
+    ("gold"                 .  "#ffd700")
+    ("gray"                 .  "#808080")
+    ("green"                .  "#008000")
+    ("greenyellow"          .  "#adff2f")
+    ("honeydew"             .  "#f0fff0")
+    ("hotpink"              .  "#ff69b4")
+    ("indianred"            .  "#cd5c5c")
+    ("indigo"               .  "#4b0082")
+    ("ivory"                .  "#fffff0")
+    ("khaki"                .  "#f0e68c")
+    ("lavenderblush"        .  "#fff0f5")
+    ("lavender"             .  "#e6e6fa")
+    ("lawngreen"            .  "#7cfc00")
+    ("lemonchiffon"         .  "#fffacd")
+    ("lightblue"            .  "#add8e6")
+    ("lightcoral"           .  "#f08080")
+    ("lightcyan"            .  "#e0ffff")
+    ("lightgoldenrodyellow" .  "#fafad2")
+    ("lightgreen"           .  "#90ee90")
+    ("lightgrey"            .  "#d3d3d3")
+    ("lightpink"            .  "#ffb6c1")
+    ("lightsalmon"          .  "#ffa07a")
+    ("lightseagreen"        .  "#20b2aa")
+    ("lightskyblue"         .  "#87cefa")
+    ("lightslategray"       .  "#778899")
+    ("lightsteelblue"       .  "#b0c4de")
+    ("lightyellow"          .  "#ffffe0")
+    ("lime"                 .  "#00ff00")
+    ("limegreen"            .  "#32cd32")
+    ("linen"                .  "#faf0e6")
+    ("magenta"              .  "#ff00ff")
+    ("maroon"               .  "#800000")
+    ("mediumaquamarine"     .  "#66cdaa")
+    ("mediumblue"           .  "#0000cd")
+    ("mediumorchid"         .  "#ba55d3")
+    ("mediumpurple"         .  "#9370d8")
+    ("mediumseagreen"       .  "#3cb371")
+    ("mediumslateblue"      .  "#7b68ee")
+    ("mediumspringgreen"    .  "#00fa9a")
+    ("mediumturquoise"      .  "#48d1cc")
+    ("mediumvioletred"      .  "#c71585")
+    ("midnightblue"         .  "#191970")
+    ("mintcream"            .  "#f5fffa")
+    ("mistyrose"            .  "#ffe4e1")
+    ("moccasin"             .  "#ffe4b5")
+    ("navajowhite"          .  "#ffdead")
+    ("navy"                 .  "#000080")
+    ("oldlace"              .  "#fdf5e6")
+    ("olive"                .  "#808000")
+    ("olivedrab"            .  "#6b8e23")
+    ("orange"               .  "#ffa500")
+    ("orangered"            .  "#ff4500")
+    ("orchid"               .  "#da70d6")
+    ("palegoldenrod"        .  "#eee8aa")
+    ("palegreen"            .  "#98fb98")
+    ("paleturquoise"        .  "#afeeee")
+    ("palevioletred"        .  "#d87093")
+    ("papayawhip"           .  "#ffefd5")
+    ("peachpuff"            .  "#ffdab9")
+    ("peru"                 .  "#cd853f")
+    ("pink"                 .  "#ffc0cb")
+    ("plum"                 .  "#dda0dd")
+    ("powderblue"           .  "#b0e0e6")
+    ("purple"               .  "#800080")
+    ("rebeccapurple"        .  "#663399")
+    ("red"                  .  "#ff0000")
+    ("rosybrown"            .  "#bc8f8f")
+    ("royalblue"            .  "#4169e1")
+    ("saddlebrown"          .  "#8b4513")
+    ("salmon"               .  "#fa8072")
+    ("sandybrown"           .  "#f4a460")
+    ("seagreen"             .  "#2e8b57")
+    ("seashell"             .  "#fff5ee")
+    ("sienna"               .  "#a0522d")
+    ("silver"               .  "#c0c0c0")
+    ("skyblue"              .  "#87ceeb")
+    ("slateblue"            .  "#6a5acd")
+    ("slategray"            .  "#708090")
+    ("snow"                 .  "#fffafa")
+    ("springgreen"          .  "#00ff7f")
+    ("steelblue"            .  "#4682b4")
+    ("tan"                  .  "#d2b48c")
+    ("teal"                 .  "#008080")
+    ("thistle"              .  "#d8bfd8")
+    ("tomato"               .  "#ff6347")
+    ("turquoise"            .  "#40e0d0")
+    ("violet"               .  "#ee82ee")
+    ("wheat"                .  "#f5deb3")
+    ("white"                .  "#ffffff")
+    ("whitesmoke"           .  "#f5f5f5")
+    ("yellow"               .  "#ffff00")
+    ("yellowgreen"          .  "#9acd32"))
+  "These are the colors defined by the W3C consortium to use in CSS sheets.
+
+All of these colors are compatible with any common browser.  The
+colors gray, green, maroon and purple have alternative values as
+defined by the X11 standard, here they follow the W3C one.")
+
+(ivy-set-actions
+ 'counsel-colors-web
+ '(("n" counsel-colors-action-insert-name "insert name")
+   ("h" counsel-colors-action-insert-hex "insert hex")
+   ("N" counsel-colors-action-kill-name "kill rgb")
+   ("H" counsel-colors-action-kill-hex "kill hex")))
+
+(defvar counsel-colors-web-history nil
+  "History for `counsel-colors-web'.")
+
+;;;###autoload
+(defun counsel-colors-web ()
+  "Show a list of all W3C web colors for use in CSS.
+
+You can insert or kill the name or the hexadecimal rgb value of the
+selected candidate."
+  (interactive)
+  (let ((minibuffer-allow-text-properties t))
+    (ivy-read "%d Web color: "
+              (mapcar (lambda (x)
+                        (concat
+                         (propertize
+                          (format "%-25s" (car x)))
+                         (propertize
+                          (format "%8s  " (cdr x))
+                          'face (list :foreground (car x)))
+                         (propertize
+                          (format "%10s" " ")
+                          'face (list :background (cdr x)))))
+                      counsel-colors--web-colors-alist)
+              :require-match t
+              :action #'counsel-colors-action-insert-name
+              :update-fn (lambda ()
+                           (counsel-colors--update-highlight 
(ivy-state-current ivy-last)))
+              :history 'counsel-colors-web-history
+              :caller 'counsel-colors-web
+              :sort t)))
+
+
+;;** `counsel-faces'
+(defun counsel-faces-action-describe (x)
+  "Describe the face X."
+  (describe-face (intern x)))
+
+(defun counsel-faces-action-customize (x)
+  "Customize the face X."
+  (customize-face (intern x)))
+
+(ivy-set-actions
+ 'counsel-faces
+ '(("d" counsel-faces-action-describe "describe face")
+   ("c" counsel-faces-action-customize "customize face")
+   ("i" insert "insert face name")
+   ("k" kill-new "kill face name")))
+
+(defvar counsel-faces-history nil
+  "History for `counsel-faces'.")
+
+(defvar counsel-faces--sample-text
+  "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789"
+  "Text string to display as the sample text for `counsel-faces'.")
+
+(defvar counsel--faces-fmt nil)
+
+(defun counsel--faces-format-function (cands)
+  (ivy--format-function-generic
+   (lambda (str)
+     (concat
+      (format counsel--faces-fmt
+              (ivy--add-face str 'ivy-current-match))
+      (propertize counsel-faces--sample-text 'face (intern str))))
+   (lambda (str)
+     (concat
+      (format counsel--faces-fmt
+              str)
+      (propertize counsel-faces--sample-text 'face (intern str))))
+   cands
+   "\n"))
+
+(defun counsel-faces ()
+  "Show a list of all defined faces.
+
+You can describe, customize, insert or kill the name or selected
+candidate."
+  (interactive)
+  (let* ((minibuffer-allow-text-properties t)
+         (max-length
+          (apply #'max
+                 (mapcar
+                  (lambda (x)
+                    (length (symbol-name x)))
+                  (face-list))))
+         (counsel--faces-fmt (format "%%-%ds  " max-length))
+         (ivy-format-function #'counsel--faces-format-function))
+    (ivy-read "%d Face: " (face-list)
+              :require-match t
+              :action #'counsel-faces-action-describe
+              :history 'counsel-faces-history
+              :caller 'counsel-faces
+              :sort t)))
+
+;;** `counsel-command-history'
+(defun counsel-command-history-action-eval (cmd)
+  "Eval the command CMD."
+    (eval (read cmd)))
+
+(defun counsel-command-history-action-edit-and-eval (cmd)
+  "Edit and eval the command CMD."
+    (edit-and-eval-command "Eval: " (read cmd)))
+
+(ivy-set-actions
+ 'counsel-command-history
+ '(("r" counsel-command-history-action-eval           "eval command")
+   ("e" counsel-command-history-action-edit-and-eval  "edit and eval 
command")))
+
+(defun counsel-command-history ()
+  "Show the history of commands."
+  (interactive)
+  (ivy-read "%d Command: " (mapcar #'prin1-to-string command-history)
+          :require-match t
+          :action #'counsel-command-history-action-eval
+          :caller 'counsel-command-history))
+
+;;** `counsel-org-agenda-headlines'
+(defvar org-odd-levels-only)
+(declare-function org-set-startup-visibility "org")
+(declare-function org-show-entry "org")
+(declare-function org-map-entries "org")
+(declare-function org-heading-components "org")
+
+(defun counsel-org-agenda-headlines-action-goto (headline)
+  "Go to the `org-mode' agenda HEADLINE."
+  (find-file (nth 1 headline))
+  (org-set-startup-visibility)
+  (goto-char (nth 2 headline))
+  (org-show-entry))
+
+(ivy-set-actions
+ 'counsel-org-agenda-headlines
+ '(("g" counsel-org-agenda-headlines-action-goto "goto headline")))
+
+(defvar counsel-org-agenda-headlines-history nil
+  "History for `counsel-org-agenda-headlines'.")
+
+(defun counsel-org-agenda-headlines--candidates ()
+  "Return a list of completion candidates for `counsel-org-agenda-headlines'."
+  (org-map-entries
+   (lambda ()
+     (let* ((components (org-heading-components))
+            (level (make-string
+                    (if org-odd-levels-only
+                        (nth 1 components)
+                      (nth 0 components))
+                    ?*))
+            (todo (nth 2 components))
+            (priority (nth 3 components))
+            (text (nth 4 components))
+            (tags (nth 5 components)))
+       (list
+        (mapconcat
+         'identity
+         (cl-remove-if 'null
+                       (list
+                        level
+                        todo
+                        (if priority (format "[#%c]" priority))
+                        text
+                        tags))
+         " ")
+        (buffer-file-name) (point))))
+   nil
+   'agenda))
+
+;;;###autoload
+(defun counsel-org-agenda-headlines ()
+  "Choose from headers of `org-mode' files in the agenda."
+  (interactive)
+  (let ((minibuffer-allow-text-properties t))
+    (ivy-read "Org headline: "
+              (counsel-org-agenda-headlines--candidates)
+              :action #'counsel-org-agenda-headlines-action-goto
+              :history 'counsel-org-agenda-headlines-history
+              :caller 'counsel-org-agenda-headlines)))
+
+;;** `counsel-irony'
+;;;###autoload
+(defun counsel-irony ()
+  "Inline C/C++ completion using Irony."
+  (interactive)
+  (irony-completion-candidates-async 'counsel-irony-callback))
+
+(defun counsel-irony-callback ()
+  (interactive)
+  (let ((coll (irony-completion-at-point)))
+    (when coll
+      (setq ivy-completion-beg (nth 0 coll))
+      (setq ivy-completion-end (nth 1 coll))
+      (ivy-read "code: " (mapcar #'counsel-irony-annotate
+                                 (nth 2 coll))
+                :caller 'counsel-irony
+                :action 'ivy-completion-in-region-action))))
+
+(defun counsel-irony-annotate (x)
+  (cons
+   (condition-case nil
+       (concat
+        x " "
+        (irony-completion--at-point-annotate x))
+     (error x))
+   x))
+
+(add-to-list 'ivy-display-functions-alist '(counsel-irony . 
ivy-display-function-overlay))
+
+(declare-function irony-completion-candidates-async "ext:irony-completion")
+(declare-function irony-completion-at-point "ext:irony-completion")
+(declare-function irony-completion--at-point-annotate "ext:irony-completion")
+
 ;;** `counsel-mode'
 (defvar counsel-mode-map
   (let ((map (make-sparse-keymap)))
@@ -2094,10 +3311,13 @@ And insert it into the minibuffer. Useful during
                 (describe-function . counsel-describe-function)
                 (describe-variable . counsel-describe-variable)
                 (find-file . counsel-find-file)
+                (find-library . counsel-find-library)
                 (imenu . counsel-imenu)
                 (load-library . counsel-load-library)
                 (load-theme . counsel-load-theme)
-                (yank-pop . counsel-yank-pop)))
+                (yank-pop . counsel-yank-pop)
+                (info-lookup-symbol . counsel-info-lookup-symbol)
+                (pop-mark . counsel-mark-ring)))
       (define-key map (vector 'remap (car binding)) (cdr binding)))
     map)
   "Map for `counsel-mode'. Remaps built-in functions to counsel
@@ -2120,9 +3340,14 @@ replacements. "
   :keymap counsel-mode-map
   :lighter " counsel"
   (if counsel-mode
-      (when (and (fboundp 'advice-add)
-                 counsel-mode-override-describe-bindings)
-        (advice-add #'describe-bindings :override #'counsel-descbinds))
+      (progn
+        (when (and (fboundp 'advice-add)
+                   counsel-mode-override-describe-bindings)
+          (advice-add #'describe-bindings :override #'counsel-descbinds))
+        (define-key minibuffer-local-shell-command-map (kbd "C-r")
+          'counsel-shell-command-history)
+        (define-key read-expression-map (kbd "C-r")
+          'counsel-expression-history))
     (when (fboundp 'advice-remove)
       (advice-remove #'describe-bindings #'counsel-descbinds))))
 
diff --git a/packages/ivy/doc/Changelog.org b/packages/ivy/doc/Changelog.org
index df721d3..0af0db2 100644
--- a/packages/ivy/doc/Changelog.org
+++ b/packages/ivy/doc/Changelog.org
@@ -1,47 +1,127 @@
-#+OPTIONS: toc:nil
+#+OPTIONS: H:4 num:nil toc:3
+#+SETUPFILE: ~/git/org-html-themes/setup/theme-readtheorg.setup
+#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="kbd-style.css"/>
+
 * 0.6.0
+:PROPERTIES:
+:CUSTOM_ID: 0.6.0
+:END:
+-----
 ** Fixes
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fixes
+:END:
 *** =swiper-avy= should use only the current window
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-swiper-avy-should-use-only-the-current-window
+:END:
 Not all windows. See [[https://github.com/abo-abo/swiper/issues/117][#117]].
+-----
 *** fix wrap-around for =ivy-next-line=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-fix-wrap-around-for-ivy-next-line
+:END:
 See [[https://github.com/abo-abo/swiper/issues/118][#118]].
+-----
 *** =swiper-avy= should do nothing for empty input
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-swiper-avy-should-do-nothing-for-empty-input
+:END:
 See [[https://github.com/abo-abo/avy/issues/50][#50]].
+-----
 *** =ivy-alt-done= should require TRAMP if necessary
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-ivy-alt-done-should-require-tramp-if-necessary
+:END:
 See [[https://github.com/abo-abo/swiper/pull/145][#145]].
+-----
 *** =swiper-query-replace= shouldn't miss the first occurrence
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-swiper-query-replace-shouldnt-miss-the-first-occurrence
+:END:
 See [[https://github.com/abo-abo/swiper/pull/144][#144]].
+-----
 *** =swiper= should not deactivate mark
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-swiper-should-not-deactivate-mark
+:END:
 *** =ivy-mode= should not switch to TRAMP for certain input
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-ivy-mode-should-not-switch-to-tramp-for-certain-input
+:END:
 See [[https://github.com/abo-abo/swiper/pull/145][#145]].
+-----
 *** =counsel-find-file= should work better with TRAMP
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-counsel-find-file-should-work-better-with-tramp
+:END:
 "/ssh:foo" should not be cut off
 See [[https://github.com/abo-abo/swiper/pull/145][#145]].
+-----
 *** =counsel-find-file= supports Windows drive letters
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-counsel-find-file-supports-windows-drive-letters
+:END:
 See [[https://github.com/abo-abo/swiper/pull/155][#155]].
+-----
 *** =counsel-file-file= should work better with files that contain "~"
+:PROPERTIES:
+:CUSTOM_ID: 
0-6-0-fx-counsel-file-file-should-work-better-with-files-that-contain-
+:END:
 See [[https://github.com/abo-abo/swiper/pull/157][#157]].
+-----
 *** =counsel-M-x= should respect =ivy-format-function=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-counsel-m-x-should-respect-ivy-format-function
+:END:
 See [[https://github.com/abo-abo/swiper/pull/150][#150]].
+-----
 *** =counsel-git-grep= should position better on exit
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-counsel-git-grep-should-position-better-on-exit
+:END:
 See [[https://github.com/abo-abo/swiper/pull/153][#153]].
+-----
 *** =ivy-mode= should re-scale text to minibuffer height
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-ivy-mode-should-re-scale-text-to-minibuffer-height
+:END:
 See [[https://github.com/abo-abo/swiper/pull/151][#151]].
+-----
 *** =counsel-unicode-char= should use action-style call
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-counsel-unicode-char-should-use-action-style-call
+:END:
 See [[https://github.com/abo-abo/swiper/pull/160][#160]].
+-----
 *** =ivy-read= should allow % in prompt string
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-ivy-read-should-allow--in-prompt-string
+:END:
 See [[https://github.com/abo-abo/swiper/pull/171][#171]].
+-----
 *** =ivy-call= should execute in proper window
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-ivy-call-should-execute-in-proper-window
+:END:
 See [[https://github.com/abo-abo/swiper/pull/176][#176]].
 ** New Features
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-fx-new-features
+:END:
 *** =ivy-mode=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nf-ivy-mode
+:END:
 **** 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
@@ -51,6 +131,7 @@ To enable fuzzy matching, set your =ivy-re-builders-alist= 
accordingly:
 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:
 
@@ -58,6 +139,7 @@ Bind case-fold-search to t when the input is all lower-case:
 - 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
@@ -66,6 +148,7 @@ To have this feature, use something like this:
 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
@@ -98,36 +181,64 @@ See [[https://github.com/abo-abo/swiper/pull/164][#164]].
 
 
 
+-----
 *** =counsel-describe-function= and =counsel-decribe-variable=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nf-counsel-describe-function-and-counsel-decribe-variable
+:END:
 **** 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nf-ivy-switch-buffer
+:END:
 **** 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nf-counsel-git-grep
+:END:
 **** 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nf-swiper
+:END:
 **** Own history variable
 Having own history variable allows to get more use of ~M-p~, ~M-n~ and ~C-r~.
+-----
 *** =counsel-el=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nf-counsel-el
+:END:
 **** Switch to action-style call
 This allows to make use of ~C-M-n~ and ~C-M-p~.
+-----
 *** =counsel-locate=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nf-counsel-locate
+:END:
 **** Add Async
 **** Add extra actions
 In addition to the default action of opening a file add:
@@ -136,9 +247,14 @@ In addition to the default action of opening a file add:
 - =dired= action
 
 Press ~M-o~ or ~C-o~ to access these actions.
+-----
 **** Add own history
 
+-----
 *** API
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nf-api
+:END:
 **** Add :matcher
 A matcher is a function that accepts a regexp and a list of candidates
 and returns the filtered list of candidates.
@@ -147,20 +263,32 @@ 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
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nf-new-commands
+:END:
 *** =ivy-call=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-ivy-call
+:END:
 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-counsel-find-file
+:END:
 Forward to =find-file= with Ivy completion.
 
 =ivy-next-line-and-call= as well as =ivy-resume= should work for this command.
@@ -186,7 +314,11 @@ See [[https://github.com/abo-abo/swiper/issues/122][#122]] 
and [[https://github.
 
 See [[https://github.com/abo-abo/swiper/pull/152][#152]] about ~M-n~, ~M-p~ 
and ~M-i~ switching directories when necessary.
 
+-----
 *** =ivy-recentf=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-ivy-recentf
+:END:
 Find a file on =recentf-list=.
 
 Note that if your set =ivy-use-virtual-buffers=, =recentf-list= is
@@ -194,7 +326,11 @@ 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-ivy-yank-word
+:END:
 Add word at point to minibuffer input.
 
 This is similar to what ~C-w~ does for =isearch=.  However it's bound
@@ -202,7 +338,11 @@ 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-counsel-m-x
+:END:
 Forward to =execute-extended-command= with Ivy completion.
 The candidate list will also display the key binding for each bound command.
 
@@ -215,7 +355,11 @@ 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-hydra-ivy
+:END:
 Press ~C-o~ to toggle the Hydra for Ivy.
 It gives access to shorter bindings and many customizable options.
 
@@ -224,14 +368,22 @@ Use ~C-o <~ to shrink the minibuffer.
 
 See [[https://github.com/abo-abo/swiper/pull/151][#151]].
 
+-----
 *** =ivy-toggle-calling=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-ivy-toggle-calling
+:END:
 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-ivy-insert-current
+:END:
 Inserts the current candidate into the minibuffer.
 
 Press ~M-i~ if you want something close to the current candidate. You
@@ -242,19 +394,35 @@ 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-counsel-load-theme
+:END:
 Forward to =load-theme= with Ivy completion. Allows to rapidly try themes 
(e.g. with ~C-M-n~).
 
+-----
 *** =ivy-reverse-i-search=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-ivy-reverse-i-search
+:END:
 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-counsel-rhythmbox
+:END:
 [[http://oremacs.com/2015/07/09/counsel-rhythmbox/][Control Rhythmbox from 
Emacs.]]
+-----
 *** =ivy-dispatching-done=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-ivy-dispatching-done
+:END:
 Select an action for the current candidate and execute it. Bound to ~M-o~.
 
 Some commands that support ~M-o~:
@@ -265,7 +433,11 @@ Some commands that support ~M-o~:
 - =ivy-switch-buffer=
 - =counsel-locate=
 
+-----
 *** =counsel-org-tag=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-counsel-org-tag
+:END:
 Forward to =org-set-tags= with Ivy completion.
 
 Selecting any tag each time will toggle it on/off.
@@ -273,95 +445,211 @@ 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-counsel-org-tag-agenda
+:END:
 Forward to =org-agenda-set-tags= with Ivy completion.
 See [[https://github.com/abo-abo/swiper/pull/177][#177]].
 
+-----
 *** =counsel-ag=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-counsel-ag
+:END:
 Interactively =ag= using Ivy completion.
 
+-----
 *** =counsel-recoll=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-counsel-recoll
+:END:
 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-swiper-from-isearch
+:END:
 Start =swiper= from the current =isearch= input.
 
+-----
 *** =ivy-immediate-done=
+:PROPERTIES:
+:CUSTOM_ID: 0-6-0-nc-ivy-immediate-done
+:END:
 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
+:PROPERTIES:
+:CUSTOM_ID: 0.7.0
+:END:
+-----
 ** Fixes
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fixes
+:END:
 *** Fix :dynamic-collection not being sorted
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-fix-dynamic-collection-not-being-sorted
+:END:
 *** When :initial-input contains a plus, escape it
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-when-initial-input-contains-a-plus,-escape-it
+:END:
 See [[https://github.com/abo-abo/swiper/issues/195][#195]].
+-----
 *** Set line-spacing to 0 in the minibuffer
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-set-line-spacing-to-0-in-the-minibuffer
+:END:
 See [[https://github.com/abo-abo/swiper/issues/198][#198]].
+-----
 *** Enlarge the minibuffer window if the candidate list doesn't fit
+:PROPERTIES:
+:CUSTOM_ID: 
0-7-0-fx-enlarge-the-minibuffer-window-if-the-candidate-list-doesnt-fit
+:END:
 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
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-fix-minibuffer-collapsing-to-one-line
+:END:
 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
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-use-minibuffer-allow-text-properties
+:END:
 Allows =ivy-read= to return a propertized string.
+-----
 *** Improve ~C-g~ out of a long-running async process
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-improve-c-g-out-of-a-long-running-async-process
+:END:
 Use =counsel-delete-process= as =:unwind=.
+-----
 *** Don't regexp-quote :preselect
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-dont-regexp-quote-preselect
+:END:
 See [[https://github.com/abo-abo/swiper/issues/245][#245]].
+-----
 *** Fix ivy-partial for fuzzy completion
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-fix-ivy-partial-for-fuzzy-completion
+:END:
 See [[https://github.com/abo-abo/swiper/issues/266][#266]].
+-----
 *** ivy-resume should pass :caller
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-ivy-resume-should-pass-caller
+:END:
 See [[https://github.com/abo-abo/swiper/issues/245][#245]].
+-----
 *** Fix the regression in perfect match logic
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-fix-the-regression-in-perfect-match-logic
+:END:
 See [[https://github.com/abo-abo/swiper/issues/270][#270]].
+-----
 *** Fix pasting file paths on Windows
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-fix-pasting-file-paths-on-windows
+:END:
 *** ~C-j~ should no stop completion for a pasted file path
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-c-j-should-no-stop-completion-for-a-pasted-file-path
+:END:
 *** ~C-M-j~ should use =ivy--directory=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-c-m-j-should-use-ivy--directory
+:END:
 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
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-use-a-specific-blend-method-for-dark-themes
+:END:
 See [[https://github.com/abo-abo/swiper/issues/278][#278]].
+-----
 *** Fix one-off bug in =ivy-scroll-up-command= and =ivy-scroll-down-command=
+:PROPERTIES:
+:CUSTOM_ID: 
0-7-0-fx-fix-one-off-bug-in-ivy-scroll-up-command-and-ivy-scroll-down-command
+:END:
 *** ~M-o~ shouldn't set the action permanently
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-m-o-shouldnt-set-the-action-permanently
+:END:
 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
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-fix-swiper-preselect-issue-with-similar-or-identical-lines
+:END:
 See [[https://github.com/abo-abo/swiper/issues/290][#290]].
+-----
 *** Make ivy-completing-read handle history as cons
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-make-ivy-completing-read-handle-history-as-cons
+:END:
 See [[https://github.com/abo-abo/swiper/issues/295][#295]].
+-----
 *** Perform string-match in the original buffer
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-perform-string-match-in-the-original-buffer
+:END:
 The syntax for whitespace, separators etc. is different for modes.  See 
[[https://github.com/abo-abo/swiper/issues/298][#298]].
 ** New Features
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-fx-new-features
+:END:
 *** =swiper=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-swiper
+:END:
 **** 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
@@ -379,6 +667,7 @@ It's also useful to indicate the current depth:
 #+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
@@ -387,13 +676,19 @@ the minibuffer. This fixes the =swiper= problems with
 
 
 
+-----
 *** =ivy=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-ivy
+:END:
 **** 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
@@ -401,6 +696,7 @@ completion hasn't finished.  For example, ~<f1> f~ to call
 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
@@ -423,10 +719,13 @@ For example:
 (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.
@@ -438,16 +737,20 @@ 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
@@ -458,9 +761,11 @@ This new face is blank by default, but you can use e.g.:
 (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]].
@@ -488,60 +793,104 @@ Here's another example of using this defcustom:
 
 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-ivy-hydra
+:END:
 **** 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-ivy-switch-buffer
+:END:
 **** Make ~M-o r~ rename the buffer instead of switching.
 See [[https://github.com/abo-abo/swiper/issues/233][#233]].
+-----
 *** =counsel-locate=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-counsel-locate
+:END:
 **** 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-counsel-org-tag
+:END:
 **** Now works in agenda
 See [[https://github.com/abo-abo/swiper/issues/200][#200]].
+-----
 *** =counsel-unicode-char=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-counsel-unicode-char
+:END:
 **** Add own history
 *** =counsel-M-x=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-counsel-m-x
+:END:
 **** 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-counsel-find-file
+:END:
 **** 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-counsel-git-grep
+:END:
 **** 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-counsel--find-symbol
+:END:
 **** Allow to jump back with pop-tag-mark
 Using ~C-.~ in:
 
@@ -557,35 +906,67 @@ 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-counsel-ag
+:END:
 **** 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
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nf-new-commands
+:END:
 *** =ivy-occur=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-ivy-occur
+:END:
 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-ivy-avy
+:END:
 Bound to ~C-'~.
 
 Speeds up selecting a candidate that's currently visible in the minibuffer.
+-----
 *** =ivy-kill-ring-save=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-ivy-kill-ring-save
+:END:
 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-ivy-dispatching-call
+:END:
 Bound to ~C-M-o~.
 
 This is a non-exiting version of ~M-o~ (=ivy-dispatching-done=).
+-----
 *** =ivy-read-action=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-ivy-read-action
+:END:
 Bound to ~C-M-a~. Select the current action. Don't call it yet.
+-----
 *** =swiper-multi=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-swiper-multi
+:END:
 Use =swiper= in multiple buffers.
 See [[https://github.com/abo-abo/swiper/issues/182][#182]].
 
@@ -595,33 +976,71 @@ Basic usage tips for selecting multiple buffers:
 - 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-swiper-mc
+:END:
 Open multiple cursors at all selected candidates.
+-----
 *** =swiper-all=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-swiper-all
+:END:
 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-counsel-grep
+:END:
 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=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-counsel-git-grep-query-replace
+:END:
 Bound to ~M-q~. Perform =query-replace= on all matches in all buffers.
+-----
 *** =counsel-jedi=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-counsel-jedi
+:END:
 Complete Python symbols using Jedi.
+-----
 *** =counsel-cl=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-counsel-cl
+:END:
 Complete Common Lisp symbols using SLIME.
+-----
 *** =counsel-yank-pop=
+:PROPERTIES:
+:CUSTOM_ID: 0-7-0-nc-counsel-yank-pop
+:END:
 Give completion for inserting from the kill ring.
 See =counsel-yank-pop-truncate= defcustom and 
[[https://github.com/abo-abo/swiper/issues/218][#218]].
-
+-----
 * 0.8.0
+:PROPERTIES:
+:CUSTOM_ID: 0.8.0
+:END:
+-----
 ** Package rename
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-package-rename
+:END:
 Due to popular demand, =swiper-0.7.0= is succeeded by =ivy-0.8.0= in GNU
 ELPA. The contents of the package don't change, only the name. Make
 sure to remove the =~/.emacs.d/elpa/swiper-0.7.0= directory if you
 have it and ~M-x~ =package-install ivy=.
 ** Documentation
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-documentation
+:END:
 HTML documentation is available at http://oremacs.com/swiper/.
 
 Texinfo documentation is in doc/ivy.texi.
@@ -630,62 +1049,115 @@ The HTML file shouldn't be in this repository to avoid 
bloat, instead
 it's in the gh-pages branch at
 https://github.com/abo-abo/swiper/tree/gh-pages.
 ** Fixes
-*** ivy-read
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fixes
+:END:
+*** =ivy-read=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-read
+:END:
 **** Fix recursive minibuffer exit with ~C-g~
 Make it so e.g. ~C-h f C-h v C-g~ goes back to the =describe-function= 
selection.
+-----
 **** Ensure the return result
 In some cases, =read-from-minibuffer= will return the whole minibuffer
 contents (i.e. all available candidates). Return =ivy--current= instead.
+-----
 **** Properly support matching ignoring order
 See [[https://github.com/abo-abo/swiper/issues/296][#296]] and 
[[https://github.com/abo-abo/swiper/issues/329][#329]].
+-----
 **** Insert intermediate candidates during async completions
 See [[https://github.com/abo-abo/swiper/issues/340][#340]].
+-----
 **** Initialize =ivy-last= to empty state
 See [[https://github.com/abo-abo/swiper/issues/352][#352]].
+-----
 **** Fix extra actions for =completing-read=
 See [[https://github.com/abo-abo/swiper/issues/337][#337]].
+-----
 **** Support a list of symbols as collection
 See [[https://github.com/abo-abo/swiper/issues/375][#375]].
+-----
 **** Define =setq-local= and =defvar-local= unless defined
 With this commit, Ivy works on emacs-24.2.
 See [[https://github.com/abo-abo/swiper/issues/415][#415]].
+-----
 **** Make ~M-o~ not modify the action
 See [[https://github.com/abo-abo/swiper/issues/454][#454]].
+-----
 **** Make sure user keybindings are respected
 See [[https://github.com/abo-abo/swiper/issues/466][#466]].
+-----
 **** Fix =read-file-name= with a specified dir
 See [[https://github.com/abo-abo/swiper/issues/475][#475]].
+-----
 **** Don't highlight the match in the file part
 See [[https://github.com/abo-abo/swiper/issues/483][#483]].
+-----
 **** Add a few tests for alists
-*** ivy-occur
+-----
+*** =ivy-occur=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-occur
+:END:
 **** Fix =default-directory=
 This way, =next-error= etc will work properly.
-*** ivy--resize-minibuffer-to-fit
+-----
+*** =ivy--resize-minibuffer-to-fit=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy--resize-minibuffer-to-fit
+:END:
 **** Fix for small delta
 See [[https://github.com/abo-abo/swiper/issues/339][#339]].
+-----
 **** Check =frame-root-window-p=
 See [[https://github.com/abo-abo/swiper/issues/380][#380]].
-*** ivy-completing-read
+-----
+*** =ivy-completing-read=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-completing-read
+:END:
 **** Use =completing-read-default= for tmm
 See [[https://github.com/abo-abo/swiper/issues/316][#316]].
-*** ivy--regex-plus
+-----
+*** =ivy--regex-plus=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy--regex-plus
+:END:
 **** Recognize ! at the beginning of the str
 See [[https://github.com/abo-abo/swiper/issues/318][#318]].
+-----
 **** Prettify a bit
 See [[https://github.com/abo-abo/swiper/issues/344][#344]].
+-----
 **** Don't consider =\\(?...\)= a group
 See [[https://github.com/abo-abo/swiper/issues/393][#393]].
-*** ivy--get-window
+-----
+*** =ivy--get-window=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy--get-window
+:END:
 **** Always return a valid window
 Even if =state= is invalid.
-*** ivy--recompute-index
+-----
+*** =ivy--recompute-index=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy--recompute-index
+:END:
 **** Update =cl-position= logic
 See [[https://github.com/abo-abo/swiper/issues/207][#207]].
-*** ivy-reverse-i-search
+-----
+*** =ivy-reverse-i-search=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-reverse-i-search
+:END:
 **** Fix due to recursive update
 See [[https://github.com/abo-abo/swiper/issues/323][#323]].
-*** ivy--reset-state
+-----
+*** =ivy--reset-state=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy--reset-state
+:END:
 **** Don't null =initial-input=
 This is specifically for ='read-file-name-internal= collection.  The
 input needs to be set to nil for e.g. =rgrep=, which supplies the
@@ -693,50 +1165,96 @@ input needs to be set to nil for e.g. =rgrep=, which 
supplies the
 
 For now, don't set input to nil if =:action= was passed to =ivy-read=.
 See [[https://github.com/abo-abo/swiper/issues/336][#336]].
+-----
 **** Don't deactivate region
 See [[https://github.com/abo-abo/swiper/issues/377][#377]].
-*** ivy-completion-in-region
+-----
+*** =ivy-completion-in-region=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-completion-in-region
+:END:
 **** Use =completion-all-completions=
 See [[https://github.com/abo-abo/swiper/issues/341][#341]].
+-----
 **** Optimize for 1 candidate
 When there's only one candidate, call the action immediately.
+-----
 **** Add feedback for 1 candidate
 When the sole completion is the same as the input, notify the user.
 See [[https://github.com/abo-abo/swiper/issues/350][#350]].
+-----
 **** Bind =completion-ignore-case=
 It's convenient to have it the same value as =case-fold-search=.
-*** ivy-read-action
+-----
+*** =ivy-read-action=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-read-action
+:END:
 **** Give enough minibuffer space
 See [[https://github.com/abo-abo/swiper/issues/402][#402]].
+-----
 **** Allow to customize the action hint formatter
 See [[https://github.com/abo-abo/swiper/issues/469][#469]].
-*** ivy-count-format
+-----
+*** =ivy-count-format=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-count-format
+:END:
 **** Fix for nil value
 See [[https://github.com/abo-abo/swiper/issues/349][#349]].
-*** ivy-switch-buffer
+-----
+*** =ivy-switch-buffer=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-switch-buffer
+:END:
 **** Don't fall back to =switch-to-buffer=
 See [[https://github.com/abo-abo/swiper/issues/410][#410]].
-*** ivy-next-history-element
+-----
+*** =ivy-next-history-element=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-next-history-element
+:END:
 **** No "\\_<" for dynamic-collection
 "\\_<" regex is Emacs-specific and should only be done if
 =:dynamic-collection= is nil.  It is nil for =counsel-git-grep= with
 repositories < 20000 lines, but non-nil for larger ones.
 
 Fixes [[https://github.com/abo-abo/swiper/issues/409][#409]].
-*** ivy-occur-press
+-----
+*** =ivy-occur-press=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-occur-press
+:END:
 **** Pulse no longer
 Repeated pulses within a short time span resulted in horrible window
 flickering.
-*** ivy-resume
+-----
+*** =ivy-resume=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-resume
+:END:
 **** Add a guard against null =:action=
-*** ivy-avy
+-----
+*** =ivy-avy=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-avy
+:END:
 **** Make ~C-g~ cancel gracefully
 See abo-abo/avy[[https://github.com/abo-abo/swiper/issues/140][#140]].
-*** ivy-dispatching-done
+-----
+*** =ivy-dispatching-done=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-ivy-dispatching-done
+:END:
 Allow to exit with no candidates.
-*** swiper
+-----
+*** =swiper=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-swiper
+:END:
 **** Improve for multiple occurrences on one line
 See [[https://github.com/abo-abo/swiper/issues/314][#314]].
+-----
 **** Fix "backward" search
 When none of the previous candidates after the point match the current
 input, instead of returning 0, return the index of the last matching
@@ -744,49 +1262,88 @@ candidate.  This is a good choice, because that 
candidate is the
 closest to the point of the initial search start.
 
 See [[https://github.com/abo-abo/swiper/issues/319][#319]].
+-----
 **** Return point
 See [[https://github.com/abo-abo/swiper/issues/370][#370]].
+-----
 **** Update =regexp-search-ring=
 See [[https://github.com/abo-abo/swiper/issues/89][#89]].
+-----
 **** Always remove '(field) text property
 Allows to search better in modes for shell interaction.
-*** swiper-font-lock-ensure
+-----
+*** =swiper-font-lock-ensure=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-swiper-font-lock-ensure
+:END:
 **** Add modes
 Add bongo-library-mode, bongo-playlist-mode, sauron-mode.
 
 See [[https://github.com/abo-abo/swiper/issues/19][#19]].
+-----
 **** Don't fail when font-lock is off
 See [[https://github.com/abo-abo/swiper/issues/400][#400]].
-*** swiper--multi-candidates
+-----
+*** =swiper--multi-candidates=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-swiper--multi-candidates
+:END:
 **** Add check for =make-string=
 See [[https://github.com/abo-abo/swiper/issues/481][#481]].
-*** counsel--async-sentinel
+-----
+*** =counsel--async-sentinel=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-counsel--async-sentinel
+:END:
 **** Fix issue with =ivy--regex-ignore-order=
 See [[https://github.com/abo-abo/swiper/issues/342][#342]].
+-----
 **** Re-display when no cands
 **** Recognize error codes other than 1
 See [[https://github.com/abo-abo/swiper/issues/394][#394]].
-*** consel-git
+-----
+*** =counsel-git=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-counsel-git
+:END:
 **** Fix window selection.
 Use =with-ivy-window=, so that each new file chosen with e.g. ~C-M-n~ is
 selected in the same window.
-*** counsel-recoll
+-----
+*** =counsel-recoll=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-counsel-recoll
+:END:
 **** Add =:unwind=
 See [[https://github.com/abo-abo/swiper/issues/403][#403]].
+-----
 *** compilation warnings
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-compilation-warnings
+:END:
 See [[https://github.com/abo-abo/swiper/issues/324][#324]].
+-----
 ** New Features
-*** ivy-read
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-fx-new-features
+:END:
+*** =ivy-read=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-read
+:END:
 **** Use =flx= for highlighting fuzzy matches
 See [[https://github.com/abo-abo/swiper/issues/207][#207]].
+-----
 **** Simplify the signature for =:dynamic-collection= functions
 When given =:dynamic-collection=, assume the collection function only
 needs one argument - the string input.
+-----
 **** Modify ~M-n~ prediction when region is active
 When the region is active and ~M-n~ is called, insert the region
 contents into the minibuffer and deactivate the region. The region
 deactivation is done for =swiper=, to make it easier to search for
 multiple words or a subword.
+-----
 **** Allow to compose collections
 ***** Example 1: async collection
 Stack =recentf= on top of =counsel-locate=:
@@ -815,6 +1372,7 @@ The order matters, so you can have e.g.:
 #+end_src
 
 See [[https://github.com/abo-abo/swiper/issues/373][#373]].
+-----
 ***** Example 2: sync collection
 #+begin_src elisp
 (defun my-extra-source ()
@@ -847,6 +1405,7 @@ to mess up e.g. =counsel-find-file=.
 The function =my-extra-source= gets called once in =ivy-read= via
 =ivy--reset-state=. It takes no args and returns a list of strings,
 possibly empty.
+-----
 **** Improve documentation UI
 Bind ~C-h m~ to =ivy-help=.
 
@@ -855,6 +1414,7 @@ Bind ~C-h m~ to =ivy-help=.
 Bind ~D~ in =hydra-ivy= to go to hydra's definition.
 
 See [[https://github.com/abo-abo/swiper/issues/376][#376]] and 
[[https://github.com/abo-abo/swiper/issues/379][#379]].
+-----
 **** Add ignore pattern toggling
 ~C-c C-a~ is bound to =ivy-toggle-ignore= - a new command to toggle ignore
 patterns (user-configured filtering). If the ignore patterns are
@@ -863,16 +1423,29 @@ that match the current text. This feature currently 
works for
 =ivy-switch-buffer= and =counsel-find-file=.
 
 See [[https://github.com/abo-abo/swiper/issues/369][#369]].
-*** ivy-mode
+-----
+*** =ivy-mode=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-mode
+:END:
 **** Set =completion-in-region-function=
 See [[https://github.com/abo-abo/swiper/issues/331][#331]].
+-----
 **** Improve ~M-n~ for ='read-file-name-internal=
-*** ivy-set-occur
+-----
+*** =ivy-set-occur=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-set-occur
+:END:
 Allows to customize =ivy-occur= per-command.
-**** =ivy-switch-buffer=
-Add custom occur.
+-----
+**** Add custom occur for =ivy-switch-buffer=
 See [[https://github.com/abo-abo/swiper/issues/438][#438]] and 
[[https://github.com/abo-abo/swiper/issues/440][#440]].
-*** ivy-occur-mode
+-----
+*** =ivy-occur-mode=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-occur-mode
+:END:
 **** New commands on ~j~, ~k~, ~c~
 (ivy-occur-toggle-calling): New command bound to ~c~.
 (ivy-occur-next-line): New command bound to ~j~.
@@ -888,6 +1461,7 @@ Example:
 - =run= (=self-insert-command=)
 - ~C-c C-o~ (=ivy-occur=); ~C-o u~ also works.
 - ~cjjjjkkkk~
+-----
 **** New command =ivy-occur-revert-buffer= on ~g~
 Does what e.g. =revert-buffer= does for *Help* buffers.
 
@@ -896,9 +1470,14 @@ Has special handling for =counsel-git-grep=, =counsel-ag= 
and
 updates in files.
 
 Move =ivy-occur-press= from ~g~ to ~f~.
+-----
 **** Improve the feedback for ~j~ and ~k~
 The overlays will be more responsive now.
-*** ivy-re-builders-alist
+-----
+*** =ivy-re-builders-alist=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-re-builders-alist
+:END:
 **** Allow =this-command= to be a key
 Example:
 #+begin_src elisp
@@ -917,7 +1496,11 @@ This is useful for commands that you didn't write. For 
new commands
 that you write, consider using =ivy-read= and =:caller=.
 
 See [[https://github.com/abo-abo/swiper/issues/330][#330]].
-*** ivy-set-actions
+-----
+*** =ivy-set-actions=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-set-actions
+:END:
 **** Call with =t= to affect all commands
 Example:
 
@@ -931,19 +1514,37 @@ Now an "insert" action will be available for all 
=ivy-read= sessions
 when pressing ~M-o~.
 
 See [[https://github.com/abo-abo/swiper/issues/337][#337]].
-*** ivy-faces
+-----
+*** =ivy-faces=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-faces
+:END:
 New defcustom group.
 See [[https://github.com/abo-abo/swiper/issues/389][#389]].
-*** ivy-flx-limit
+-----
+*** =ivy-flx-limit=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-flx-limit
+:END:
 New variable. Configure when =flx= is used.
 See [[https://github.com/abo-abo/swiper/issues/207][#207]].
-*** ivy-ignore-buffers
-New defcustom. See [[https://github.com/abo-abo/swiper/issues/366][#366]].
-*** ivy-inhibit-action
+-----
+*** =ivy-inhibit-action=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-inhibit-action
+:END:
 New variable. See [[https://github.com/abo-abo/swiper/issues/363][#363]].
-*** ivy-do-completion-in-region
+-----
+*** =ivy-do-completion-in-region=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-do-completion-in-region
+:END:
 New defcustom. See [[https://github.com/abo-abo/swiper/issues/367][#367]].
-*** ivy-fixed-height-minibuffer
+-----
+*** =ivy-fixed-height-minibuffer=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-fixed-height-minibuffer
+:END:
 New defcustom.
 
 When non nil, fix the height of the minibuffer during ivy completion
@@ -952,32 +1553,56 @@ and tries to ensure that it does not change depending on 
the number of
 candidates.
 
 See [[https://github.com/abo-abo/swiper/issues/353][#353]].
-*** ivy-set-display-transformer
+-----
+*** =ivy-set-display-transformer=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-set-display-transformer
+:END:
 New API function.
 
 Now used by =switch-to-buffer= and =read-file-name=.
 
 See [[https://github.com/abo-abo/swiper/issues/399][#399]].
-*** ivy-ignore-buffers
+-----
+*** =ivy-ignore-buffers=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-ignore-buffers
+:END:
 New defcustom similar to =ido-ignore-buffers=.
 
-See [[https://github.com/abo-abo/swiper/issues/382][#382]].
-*** ivy-add-newline-after-prompt
+See [[https://github.com/abo-abo/swiper/issues/382][#382]] and 
[[https://github.com/abo-abo/swiper/issues/366][#366]].
+-----
+*** =ivy-add-newline-after-prompt=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-add-newline-after-prompt
+:END:
 New defcustom.
 
 See [[https://github.com/abo-abo/swiper/issues/451][#451]].
-*** ivy-switch-buffer
+-----
+*** =ivy-switch-buffer=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-switch-buffer
+:END:
 **** Add virtual views
 =ivy-views= variable stores pre-defined views. Allows to set a window
 configuration with many buffers from =ivy-switch-buffer=.
 
 How to use: just set =ivy-views= appropriately. An example value is
 provided (but nulled, so that it's empty initially).
-*** ivy-use-ignore-default
+-----
+*** =ivy-use-ignore-default=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-ivy-use-ignore-default
+:END:
 New defcustom
 
 See [[https://github.com/abo-abo/swiper/issues/477][#477]].
-*** swiper
+-----
+*** =swiper=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-swiper
+:END:
 **** Improve =swiper-query-replace=
 To replace a symbol with a similar symbol,
 
@@ -988,23 +1613,40 @@ To replace a symbol with a similar symbol,
 
 Here step-3 was modified to yank e.g. "symbol" instead of
 "\_<symbol\_>" previously.
-
-*** swiper-font-lock-exclude
+-----
+*** =swiper-font-lock-exclude=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-swiper-font-lock-exclude
+:END:
 New variable for major modes that misbehave with =font-lock-ensure=.
 See [[https://github.com/abo-abo/swiper/issues/346][#346]].
-*** swiper-all
+-----
+*** =swiper-all=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-swiper-all
+:END:
 **** New auto-updates position
 See [[https://github.com/abo-abo/swiper/issues/401][#401]].
-*** counsel-mode
+-----
+*** =counsel-mode=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-mode
+:END:
 A minor-mode that remaps built-in functions that have counsel
 replacements available.
 
 See [[https://github.com/abo-abo/swiper/issues/414][#414]].
+-----
 **** Allow use of describe-prefix-bindings
 See [[https://github.com/abo-abo/swiper/issues/441][#441]].
-*** counsel-find-file
+-----
+*** =counsel-find-file=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-find-file
+:END:
 **** Add =initial-input=
 See [[https://github.com/abo-abo/swiper/issues/336][#336]].
+-----
 **** Change tramp prompt from "Find File: " to "address@hidden: "
 **** Bind =counsel-up-directory= to ~C-DEL~
 New function that moves up to the parent directory and at the same
@@ -1012,6 +1654,7 @@ time preselects the current directory. This is useful for 
moving up
 and down a file tree quickly.
 
 See [[https://github.com/abo-abo/swiper/issues/343][#343]].
+-----
 **** Customize =M-n= action
 This feature allows to quickly visit Github issues from either
 =magit-commit-mode= or from a version-controlled file. The point has to
@@ -1023,17 +1666,21 @@ thing for places other than Github.
 The ~C-x C-f M-n~ key binding will work better with =counsel-find-file=,
 for plain =find-file= it will open a =dired= buffer in addition to opening
 the URL.
+-----
 **** Can un-ignore dotfiles with a leading dot input
 When =ivy-text= starts with a dot, don't use
 =counsel-find-file-ignore-regexp=. The generic way to do this is with
 ~C-c C-a~ (=ivy-toggle-ignore=), but this is faster and more convenient.
 
 See [[https://github.com/abo-abo/swiper/issues/408][#408]].
+-----
 **** Bind ~M-o f~ to =find-file-other-window=
 **** Correctly expand file name at point
 See [[https://github.com/abo-abo/swiper/issues/430][#430]].
+-----
 **** Add display transformer
 See [[https://github.com/abo-abo/swiper/issues/458][#458]].
+-----
 **** Add magic slash that changes the directory
 Update to the behavior: the slash ("/") will enter a directory even if
 its name isn't completely typed out if either:
@@ -1049,7 +1696,11 @@ This is an experimental feature, please report if it 
breaks someone's
 workflow.
 
 See [[https://github.com/abo-abo/swiper/issues/321][#321]] and 
[[https://github.com/abo-abo/swiper/issues/480][#480]].
-*** counsel-git-grep
+-----
+*** =counsel-git-grep=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-git-grep
+:END:
 **** Bind ~C-c C-m~ to =counsel-git-grep-switch-cmd=
 The initial command always runs on all files.
 
@@ -1059,18 +1710,28 @@ To switch to all files again, ~C-c C-m~ and select the 
appropriate
 entry.
 
 See [[https://github.com/abo-abo/swiper/issues/420][#420]].
-*** counsel-locate
+-----
+*** =counsel-locate=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-locate
+:END:
 **** counsel-locate-cmd
 New defcustom that replaces =counsel-locate-options=.
 
 See [[https://github.com/abo-abo/swiper/issues/385][#385]].
+-----
 **** counsel-locate-cmd-mdfind
 New function.
 See [[https://github.com/abo-abo/swiper/issues/390][#390]].
+-----
 **** counsel-locate-cmd-es
 New function.
 See [[https://github.com/abo-abo/swiper/issues/426][#426]].
-*** counsel-yank-pop
+-----
+*** =counsel-yank-pop=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-yank-pop
+:END:
 **** Truncate during display
 During the completion, only the context around the match will be shown.
 By default, the context is +2 lines above and +2 lines below the match.
@@ -1079,11 +1740,23 @@ Additionally, =ivy-height= is temporarily bound to 5 
during completion.
 This way, the maximum minibuffer height should be 1+4*5=21 lines.
 
 See [[https://github.com/abo-abo/swiper/issues/315][#315]].
-*** counsel-unicode-char
+-----
+*** =counsel-unicode-char=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-unicode-char
+:END:
 Display hex codes in left column.
-*** counsel-rhythmbox
+-----
+*** =counsel-rhythmbox=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-rhythmbox
+:END:
 **** Preselect the current song
-*** counsel-ag
+-----
+*** =counsel-ag=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-ag
+:END:
 **** =counsel-ag-base-command=
 Allows the command run by =counsel-ag-function= to be customized. There
 are several reasons to allow this: The vimgrep option is a recent
@@ -1096,85 +1769,163 @@ Standard value:
 #+end_src
 
 See [[https://github.com/abo-abo/swiper/issues/335][#335]].
+-----
 **** Add dir prompt for ~C-u~
 See [[https://github.com/abo-abo/swiper/issues/429][#429]].
+-----
 **** Add =counsel-ag-map=
 See [[https://github.com/abo-abo/swiper/issues/462][#462]].
-*** counsel-async-split-string-re
+-----
+*** =counsel-async-split-string-re=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-async-split-string-re
+:END:
 New defcustom.
-*** counsel--async-cmd
+-----
+*** =counsel--async-cmd=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel--async-cmd
+:END:
 **** Add optional exit-code table
 This argument can be used to associate exit codes with the underlying
 reason. Used in counsel-ag-function to signal that an exit code of 1
 means that no matches were found.
 
 See [[https://github.com/abo-abo/swiper/issues/421][#421]].
-*** counsel-prompt-function
+-----
+*** =counsel-prompt-function=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-prompt-function
+:END:
 New defcustom
 
 See [[https://github.com/abo-abo/swiper/issues/424][#424]] and 
[[https://github.com/abo-abo/swiper/issues/425][#425]].
-*** counsel-grep
+-----
+*** =counsel-grep=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-grep
+:END:
 **** Reveal outlines
 Just like =swiper=.
+-----
 **** Should pick candidates closest to point
 Fixes the algorithm selecting the first matching candidate in case
 there are 0 matching candidates following point. Now the last matching
 candidate will be selected, resulting in less scrolling.
+-----
 **** Speed up x40 times
 The default shell command will not use =--ignore-case= switch for
 =grep=. It's a bit less convenient, but results in a huge speed-up.
-*** counsel-M-x
+-----
+*** =counsel-M-x=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-counsel-m-x
+:END:
 **** Add help action
 Bound to ~M-o h~ by default.
 
 See [[https://github.com/abo-abo/swiper/issues/452][#452]].
 ** New Commands
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nf-new-commands
+:END:
 *** =counsel-tmm=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-tmm
+:END:
 Completion for the menu bar items. For example:
 
 =counsel-tmm= -> =Options= -> =Set Default Font...=.
 
 Thanks to completion, the latter stages of the chain would look like: =op= 
~RET~ =set= ~RET~.
+-----
 *** =counsel-imenu=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-imenu
+:END:
 Jump to a buffer position indexed by imenu.
+-----
 *** =counsel-decbinds=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-decbinds
+:END:
 Show a list of all defined keys, and their definitions. Describe the
 selected candidate.
 See [[https://github.com/abo-abo/swiper/issues/332][#332]].
+-----
 *** =counsel-list-processes=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-list-processes
+:END:
 Offer completion for =process-list=
 
 The default action deletes the selected process.  An extra action
 allows to switch to the process buffer.
 
 See [[https://github.com/abo-abo/swiper/issues/357][#357]] and 
[[https://github.com/abo-abo/swiper/issues/398][#398]].
+-----
 *** =ivy-switch-buffer-other-window=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-ivy-switch-buffer-other-window
+:END:
 Remap =switch-to-buffer-other-window= to =ivy-switch-buffer-other-window= for 
=ivy-mode=.
 
 See [[https://github.com/abo-abo/swiper/issues/361][#361]].
+-----
 *** =counsel-git-stash=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-git-stash
+:END:
 Search through all available git stashes.
 
 See [[https://github.com/abo-abo/swiper/issues/374][#374]].
+-----
 *** =counsel-git-log=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-git-log
+:END:
 Call the =git log --grep= shell command and search through the output.
+-----
 *** =counsel-pt=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-pt
+:END:
 Grep for a string in the current directory using pt.
 
 See [[https://github.com/abo-abo/swiper/issues/434][#434]].
+-----
 *** =counsel-linux-app=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-linux-app
+:END:
 Launch a Linux desktop application, similar to Alt-<F2>.
 
 See [[https://github.com/abo-abo/swiper/issues/446][#446]].
+-----
 *** =counsel-ace-link=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-ace-link
+:END:
 Ivy completion for =ace-link=.
+-----
 *** =counsel-esh-history=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-esh-history
+:END:
 Browse Eshell history.
 
 See [[https://github.com/abo-abo/swiper/issues/459][#459]].
+-----
 *** =counsel-shell-history=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-shell-history
+:END:
 Browse shell history.
+-----
 *** =counsel-grep-or-swiper=
+:PROPERTIES:
+:CUSTOM_ID: 0-8-0-nc-counsel-grep-or-swiper
+:END:
 New command: automatically use =swiper= for smaller buffers and
 =counsel-grep= for larger buffers.
 
@@ -1184,3 +1935,961 @@ Adjust with:
 #+end_src
 
 By default, the splitting predicate is 300K bytes in a file.
+-----
+#+BEGIN_EXPORT html
+<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
+<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
+<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
+#+END_EXPORT
+* 0.9.0
+:PROPERTIES:
+:CUSTOM_ID: 0.9.0
+:END:
+-----
+** Fixes
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fixes
+:END:
+*** =colir-parse-color=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-colir-parse-color
+:END:
+Fix color parsing in terminal. See 
[[https://github.com/abo-abo/swiper/issues/541][#541]] and 
[[https://github.com/abo-abo/swiper/issues/543][#543]].
+-----
+*** =counsel--gg-sentinel=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel--gg-sentinel
+:END:
+Check for an additional 141 return code.
+-----
+*** =counsel-ace-link=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-ace-link
+:END:
+Use =cdr= for action. See 
[[https://github.com/abo-abo/swiper/issues/835][#835]].
+-----
+*** =counsel-ag=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-ag
+:END:
+**** Use sync on remote
+See [[https://github.com/abo-abo/swiper/issues/669][#669]].
+**** Add missing parameter
+See [[https://github.com/abo-abo/swiper/issues/858][#858]], 
[[https://github.com/abo-abo/swiper/issues/861][#861]].
+-----
+*** =counsel-find-file=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-find-file
+:END:
+**** Improve stability on arcane systems
+It can happen that =(all-completions "" 'read-file-name-internal)= may
+fail on systems with symlinks. I think it's related to the file
+functions trying to compute occupied space. In any case, a plain
+=directory-files= is roughly the equivalent and is less likely to fail.
+**** Check compat between preselect and initial-input
+See [[https://github.com/abo-abo/swiper/issues/514][#514]], 
[[https://github.com/abo-abo/swiper/issues/515][#515]].
+**** Prevent expand-file-name nil
+See [[https://github.com/abo-abo/swiper/issues/518][#518]].
+**** Don't crash if default-directory is nil
+See [[https://github.com/abo-abo/swiper/issues/586][#586]].
+**** Allow to ~C-y~ a "/ssh:" file
+**** Press ~M-n~ on issue works for newer magit version
+See [[https://github.com/abo-abo/swiper/issues/692][#692]].
+**** Fix when initial input is a file name
+See [[https://github.com/abo-abo/swiper/issues/744][#744]].
+**** Account for =file-name-directory= returning nil
+See [[https://github.com/abo-abo/swiper/issues/780][#780]].
+**** Fix ~RET~ on no input
+See [[https://github.com/abo-abo/swiper/issues/782][#782]].
+**** Fix ~RET~ when file exists
+See [[https://github.com/abo-abo/swiper/issues/792][#792]].
+-----
+*** =counsel-git=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-git
+:END:
+**** Add a better error message.
+See [[https://github.com/abo-abo/swiper/issues/537][#537]].
+**** Add ~x~ action
+To open externally.
+-----
+*** =counsel-grep=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-grep
+:END:
+Quote =:preselect=.
+-----
+*** =counsel-grep-or-swiper=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-grep-or-swiper
+:END:
+Don't grep on compressed files. See 
[[https://github.com/abo-abo/swiper/issues/536][#536]].
+-----
+*** =counsel-imenu=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-imenu
+:END:
+**** Improve readability
+See [[https://github.com/abo-abo/swiper/issues/558][#558]].
+**** Force rescan if requested
+See [[https://github.com/abo-abo/swiper/issues/631][#631]].
+-----
+*** =counsel-info-lookup-symbol=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-info-lookup-symbol
+:END:
+Fix doc, see [[https://github.com/abo-abo/swiper/issues/721][#721]].
+Add preselect, see [[https://github.com/abo-abo/swiper/issues/722][#722]].
+-----
+*** =counsel-linux-app=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-linux-app
+:END:
+**** Don't quit on bad data
+See [[https://github.com/abo-abo/swiper/issues/604][#604]].
+**** Check if dir exists
+See [[https://github.com/abo-abo/swiper/issues/896][#896]].
+-----
+*** =counsel-load-theme=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-load-theme
+:END:
+Add noconfirm flag in =counsel-load-theme-action=.
+-----
+*** =counsel-locate=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-locate
+:END:
+**** Make =counsel-locate-action-extern= interactive
+See [[https://github.com/abo-abo/swiper/issues/605][#605]].
+**** Add w32 support to =counsel-locate-action-extern=
+See [[https://github.com/abo-abo/swiper/issues/607][#607]], 
[[https://github.com/abo-abo/swiper/issues/688][#688]].
+-----
+*** =counsel-M-x=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-m-x
+:END:
+**** Fix interaction with =repeat=
+See [[https://github.com/abo-abo/swiper/issues/564][#564]].
+**** Preserve =last-command=
+See [[https://github.com/abo-abo/swiper/issues/891][#891]], 
[[https://github.com/abo-abo/swiper/issues/893][#893]].
+-----
+*** =counsel-org-tag-action=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-org-tag-action
+:END:
+Perform in the minibuffer. See 
[[https://github.com/abo-abo/swiper/issues/890][#890]].
+-----
+*** =counsel-recoll=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-recoll
+:END:
+Add =shell-quote-argument=. See 
[[https://github.com/abo-abo/swiper/issues/713][#713]].
+-----
+*** =counsel-rhythmbox=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-rhythmbox
+:END:
+No longer depends on =helm-rhythmbox=.
+-----
+*** =counsel-yank-pop=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-counsel-yank-pop
+:END:
+Fix candidates not showing sometimes.
+-----
+*** doc
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-doc
+:END:
+**** Fixed typos in the doc
+See [[https://github.com/abo-abo/swiper/issues/497][#497]], 
[[https://github.com/abo-abo/swiper/issues/809][#809]].
+**** Added =ivy-format-function= to the doc
+See [[https://github.com/abo-abo/swiper/issues/577][#577]].
+**** Added info on generating the doc
+See [[https://github.com/abo-abo/swiper/issues/601][#601]].
+**** Added info on associating values
+See [[https://github.com/abo-abo/swiper/issues/714][#714]].
+**** Update package names on ELPA/MELPA
+See [[https://github.com/abo-abo/swiper/issues/833][#833]].
+-----
+*** =ivy--filter=
+Recompute index after filter
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy--filter-recompute-index-after-filter
+:END:
+See [[https://github.com/abo-abo/swiper/issues/491][#491]].
+-----
+*** =ivy--flx-sort=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy--flx-sort
+:END:
+Improve. See [[https://github.com/abo-abo/swiper/issues/843][#843]].
+-----
+*** =ivy--format-minibuffer-line=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy--format-minibuffer-line
+:END:
+Fix for =ivy-display-style= nil. See 
[[https://github.com/abo-abo/swiper/issues/828][#828]].
+-----
+*** =ivy--minibuffer-setup=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy--minibuffer-setup
+:END:
+Fix =max-mini-window-height=. See 
[[https://github.com/abo-abo/swiper/issues/732][#732]].
+-----
+*** =ivy--occur-insert-lines=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy--occur-insert-lines
+:END:
+Scroll to first command. See 
[[https://github.com/abo-abo/swiper/issues/829][#829]].
+-----
+*** =ivy--regex-ignore-order=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy--regex-ignore-order
+:END:
+Ensure it returns legal regexps. See 
[[https://github.com/abo-abo/swiper/issues/765][#765]].
+-----
+*** =ivy--reset-state=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy--reset-state
+:END:
+Simplify. See [[https://github.com/abo-abo/swiper/issues/827][#827]].
+-----
+*** =ivy--virtual-buffers=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy--virtual-buffers
+:END:
+Don't modify recentfs or bookmarks. See 
[[https://github.com/abo-abo/swiper/issues/821][#821]].
+-----
+*** =ivy-call=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-call
+:END:
+Set =default-directory=, see 
[[https://github.com/abo-abo/swiper/issues/717][#717]], 
[[https://github.com/abo-abo/swiper/issues/760][#760]], 
[[https://github.com/abo-abo/swiper/issues/779][#779]], 
[[https://github.com/abo-abo/swiper/issues/810][#810]].
+Recursive logic, see [[https://github.com/abo-abo/swiper/issues/924][#924]], 
[[https://github.com/abo-abo/swiper/issues/937][#937]].
+-----
+*** =ivy-completion-in-region=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-completion-in-region
+:END:
+Fix double insert bug.
+Fix common length bug. See 
[[https://github.com/abo-abo/swiper/issues/528][#528]].
+Remove =:require-match=, see 
[[https://github.com/abo-abo/swiper/issues/907][#907]].
+-----
+*** =ivy-completion-in-region-action=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-completion-in-region-action
+:END:
+Remove string properties, see 
[[https://github.com/abo-abo/swiper/issues/517][#517]].
+Remove =with-ivy-window=, see 
[[https://github.com/abo-abo/swiper/issues/928][#928]].
+-----
+*** =ivy-fixed-height-minibuffer=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-fixed-height-minibuffer
+:END:
+Add correction. See [[https://github.com/abo-abo/swiper/issues/737][#737]].
+-----
+*** =ivy-help-file=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-help-file
+:END:
+Define with =defconst=, see 
[[https://github.com/abo-abo/swiper/issues/938][#938]].
+-----
+*** =ivy-hydra= is now a separate package on MELPA
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-hydra-is-now-a-separate-package-on-melpa
+:END:
+See [[https://github.com/abo-abo/swiper/issues/464][#464]], 
[[https://github.com/abo-abo/swiper/issues/512][#512]].
+-----
+*** =ivy-immediate-done=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-immediate-done
+:END:
+Update docstring, see [[https://github.com/abo-abo/swiper/issues/525][#525]].
+-----
+*** =ivy-minibuffer-map=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-minibuffer-map
+:END:
+**** Move =ivy-toggle-regexp-quote= from ~M-q~ to ~M-r~.
+See [[https://github.com/abo-abo/swiper/issues/566][#566]].
+**** Remap scroll-up/down-command
+Instead of assigning ~C-v~ / ~M-v~ so page up/down works.
+See [[https://github.com/abo-abo/swiper/issues/797][#797]], 
[[https://github.com/abo-abo/swiper/issues/798][#798]].
+**** Remap =backward-delete-char-untabify= to =ivy-backward-delete-char=
+**** Rebind ~C-v~ and ~M-v~
+The ultimate solution to have PgUp and PgDown and whatever else was
+mapped to =scroll-up-command= bound in =ivy-minibuffer-map=. While
+still having the standard ~C-v~ and ~M-v~ bindings.
+
+See [[https://github.com/abo-abo/swiper/issues/797][#797]], 
[[https://github.com/abo-abo/swiper/issues/798][#798]], 
[[https://github.com/abo-abo/swiper/issues/535][#535]].
+-----
+*** =ivy-occur-press=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-occur-press
+:END:
+Pass the whole cons cell to action, see 
[[https://github.com/abo-abo/swiper/issues/634][#634]].
+-----
+*** =ivy-partial=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-partial
+:END:
+Fix for =:dynamic-collection=.
+See [[https://github.com/abo-abo/swiper/issues/946][#946]].
+-----
+*** =ivy-read=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-read
+:END:
+**** Document all args
+See [[https://github.com/abo-abo/swiper/issues/533][#533]].
+**** Use predicate when reading file names
+See [[https://github.com/abo-abo/swiper/issues/804][#804]].
+-----
+*** =ivy-remote=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-remote
+:END:
+Use a lighter color for dark themes, see 
[[https://github.com/abo-abo/swiper/issues/646][#646]].
+-----
+*** =ivy-resume=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-resume
+:END:
+The original =default-directory= will be restored, see 
[[https://github.com/abo-abo/swiper/issues/591][#591]].
+-----
+*** =ivy-sort-functions-alist=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-sort-functions-alist
+:END:
+Improve. See [[https://github.com/abo-abo/swiper/issues/870][#870]].
+-----
+*** =ivy-switch-buffer=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-switch-buffer
+:END:
+**** Reset index to 0 on input
+See [[https://github.com/abo-abo/swiper/issues/522][#522]], 
[[https://github.com/abo-abo/swiper/issues/513][#513]].
+-----
+*** =ivy-switch-buffer-other-window=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-ivy-switch-buffer-other-window
+:END:
+Obey =ivy-ignore-buffers=. See 
[[https://github.com/abo-abo/swiper/issues/745][#745]].
+-----
+*** Recursive minibuffers with two emacsclients
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-recursive-minibuffers-with-two-emacsclients
+:END:
+See [[https://github.com/abo-abo/swiper/issues/738][#738]].
+-----
+*** shrink minibuffer after reading actions
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-shrink-minibuffer-after-reading-actions
+:END:
+See [[https://github.com/abo-abo/swiper/issues/764][#764]], 
[[https://github.com/abo-abo/swiper/issues/402][#402]].
+-----
+*** =swiper=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-swiper
+:END:
+**** Fix "foo!bar" syntax
+See [[https://github.com/abo-abo/swiper/issues/565][#565]].
+**** Now respects =ivy-re-builders-alist=
+See [[https://github.com/abo-abo/swiper/issues/613][#613]].
+
+Example:
+#+begin_src
+(setq ivy-re-builders-alist
+          '((swiper . ivy--regex-fuzzy)
+            (t . ivy--regex-plus)))
+#+end_src
+-----
+*** =swiper-avy=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-swiper-avy
+:END:
+Require =avy=, see [[https://github.com/abo-abo/swiper/issues/593][#593]].
+-----
+*** =swiper-font-lock-exclude=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-swiper-font-lock-exclude
+:END:
+Add =forth-mode=, see [[https://github.com/abo-abo/swiper/issues/526][#526]].
+Add =forth-block-mode=, see 
[[https://github.com/abo-abo/swiper/issues/527][#527]].
+Add =bookmark-bmenu-mode=.
+Add =nix-mode=, see [[https://github.com/abo-abo/swiper/issues/879][#879]].
+Add =circe-mode=, see [[https://github.com/abo-abo/swiper/issues/900][#900]], 
[[https://github.com/abo-abo/swiper/issues/901][#901]].
+-----
+*** =swiper-multi=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-fx-swiper-multi
+:END:
+Fix regression, See [[https://github.com/abo-abo/swiper/issues/673][#673]].
+Don't use virtual buffers, See 
[[https://github.com/abo-abo/swiper/issues/705][#705]].
+-----
+** New Features
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-new-features
+:END:
+*** =counsel-ag=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-ag
+:END:
+**** Extend more
+See [[https://github.com/abo-abo/swiper/issues/576][#576]].
+**** Add =counsel-git-cmd=
+See [[https://github.com/abo-abo/swiper/issues/590][#590]].
+**** Prompt for extra args when using prefix arg
+See [[https://github.com/abo-abo/swiper/issues/774][#774]].
+**** Support limiting in files
+See [[https://github.com/abo-abo/swiper/issues/820][#820]], 
[[https://github.com/abo-abo/swiper/issues/822][#822]], 
[[https://github.com/abo-abo/swiper/issues/823][#823]].
+**** =counsel-grep-post-action-hook=
+New hook for counsel-ag/grep/pt. See 
[[https://github.com/abo-abo/swiper/issues/800][#800]], 
[[https://github.com/abo-abo/swiper/issues/751][#751]].
+-----
+*** =counsel-bookmark=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-bookmark
+:END:
+**** =counsel-bookmark-avoid-dired=
+When non-nil and a directory is selected from =counsel-bookmark=,
+forward the choice to =counsel-find-file= instead of opening a =dired=
+buffer.  See [[https://github.com/abo-abo/swiper/issues/813][#813]].
+-----
+*** =counsel-find-file=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-find-file
+:END:
+**** Add binding to jump to a bookmarked directory without quit
+Press ~M-o b~ to set the current directory to one of the virtual
+buffers' directories. You continue to select a file from that directory.
+
+See [[https://github.com/abo-abo/swiper/issues/531][#531]].
+**** Add =counsel-find-file-root=
+Press ~M-o r~ to find the current file as root.
+See [[https://github.com/abo-abo/swiper/issues/948][#948]].
+-----
+*** =counsel-git-grep=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-git-grep
+:END:
+**** Support custom per-project commands
+The idea is to grep several Git repositories at once. For example, my
+Emacs config is a Git repository with many Git submodule repositories
+inside.
+
+When used with ~C-u~, and inside =counsel-git-grep-projects-alist=, use
+the corresponding command instead.  Additionally,
+=counsel-git-grep-proj-function= is used.
+
+For a possible implementation of the custom git-grep command, see:
+https://github.com/abo-abo/oremacs/commit/c7effdb94749dc600b1204ea7a9db319ebdb0f00
+
+See [[https://github.com/abo-abo/swiper/issues/616][#616]].
+**** Reveal text hidden in outlines
+**** Works with "Git for Windows" and native Emacs build
+**** Fix for files with spaces in the name
+See [[https://github.com/abo-abo/swiper/issues/700][#700]].
+**** Fix ~g~ (=counsel-git-grep-occur=)
+Things go wrong when `ivy-text' is changed from the original value.
+Extract =ivy-text= from the buffer name.
+
+Quote the directory name. See 
[[https://github.com/abo-abo/swiper/issues/811][#811]].
+**** Update quoting
+See [[https://github.com/abo-abo/swiper/issues/876][#876]].
+**** =counsel-git-grep-cmd-default=
+The initial value for =counsel-git-grep-cmd=.
+-----
+*** =counsel-git-log=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-git-log
+:END:
+**** Add =counsel-git-log-cmd=
+Allows to customize the command, see 
[[https://github.com/abo-abo/swiper/issues/652][#652]].
+-----
+*** =counsel-linux-app=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-linux-app
+:END:
+**** =counsel-linux-apps-directories=
+Customize the search path.
+-----
+*** =counsel-load-library=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-load-library
+:END:
+**** Allow to find library with an action
+See [[https://github.com/abo-abo/swiper/issues/873][#873]].
+-----
+*** =counsel-mode=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-mode
+:END:
+**** Bind =counsel-info-lookup-symbol=
+Substitutes =info-lookup-symbol=, see 
[[https://github.com/abo-abo/swiper/issues/493][#493]].
+**** Bind ~C-r~ for =eval-expression= and =shell-command=
+Press ~C-r~ while inside the minibuffer during =eval-expression= or
+=shell-command= to get completion for history.
+-----
+*** =counsel-pt=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-pt
+:END:
+Add =initial-input= arg. See 
[[https://github.com/abo-abo/swiper/issues/757][#757]].
+-----
+*** =counsel-unicode-char=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-unicode-char
+:END:
+**** Add leading zeros to the display
+See [[https://github.com/abo-abo/swiper/issues/662][#662]].
+**** Support universal argument
+See [[https://github.com/abo-abo/swiper/issues/868][#868]].
+-----
+*** =counsel-yank-pop=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-counsel-yank-pop
+:END:
+**** Add =counsel-yank-pop-separator=
+Allows to customize the separator.
+See [[https://github.com/abo-abo/swiper/issues/660][#660]].
+-----
+*** =ivy=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-ivy
+:END:
+**** completion at point
+- =ivy-display-functions-alist= ::
+    New defcustom, which decides how to display the candidates.
+=ivy-completion-in-region= will use completion at point by default.
+
+Related: [[https://github.com/abo-abo/swiper/issues/707][#707]], 
[[https://github.com/abo-abo/swiper/issues/712][#712]], 
[[https://github.com/abo-abo/swiper/issues/788][#788]].
+**** =ivy-action-wrap=
+Set this to have =ivy-next-action= and =ivy-prev-action= wrap around.
+**** =ivy-add-actions=
+This is a convenience extension to the existing =ivy-set-actions=.
+See [[https://github.com/abo-abo/swiper/issues/470][#470]].
+**** =ivy-case-fold-search= additional value ='always=
+If the value of ivy-case-fold-search is set to 'always, the search is
+always case-insensive, regardless of the input.
+See [[https://github.com/abo-abo/swiper/issues/916][#916]].
+**** =ivy-completion-in-region-action=
+Add support for =multiple-cursors=, see 
[[https://github.com/abo-abo/swiper/issues/547][#547]].
+**** =ivy-highlight-functions-alist=
+Customize the highlighters. See 
[[https://github.com/abo-abo/swiper/issues/691][#691]], 
[[https://github.com/abo-abo/swiper/issues/654][#654]], 
[[https://github.com/abo-abo/swiper/issues/827][#827]].
+**** =ivy-magic-tilde=
+New defcustom. Decide if =~= or =~/= should cd home.
+
+See [[https://github.com/abo-abo/swiper/issues/687][#687]], 
[[https://github.com/abo-abo/swiper/issues/679][#679]].
+**** =ivy-set-prompt=
+Allow to set the prompt using the =:caller= as key.
+**** =ivy-set-prompt-text-properties-function=
+An advanced override of the prompt string.
+**** =ivy-sort-file-function-using-ido=
+Extends the options for sorting file names. See 
[[https://github.com/abo-abo/swiper/issues/498][#498]].
+-----
+*** =ivy-completing-read=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-ivy-completing-read
+:END:
+**** Set =:caller= to =this-command=
+Improves sorting customization. See 
[[https://github.com/abo-abo/swiper/issues/899][#899]].
+**** Don't =:require-match= for null
+See [[https://github.com/abo-abo/swiper/issues/909][#909]].
+**** =ivy-completing-read-handlers-alist=
+New defcustom. See [[https://github.com/abo-abo/swiper/issues/892][#892]].
+-----
+*** =ivy-minibuffer-map=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-ivy-minibuffer-map
+:END:
+**** Alternative action list ~M-o~ using Hydra
+Not hiding the candidates and using a single line for actions results
+in a more distraction-free experience.
+
+Use this code to turn it on:
+#+begin_src elisp
+(require 'ivy-hydra)
+#+end_src
+-----
+*** =ivy-occur-mode=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-ivy-occur-mode
+:END:
+**** ~RET~ now switches to candidate window
+**** =read-only-mode= is enabled
+See [[https://github.com/abo-abo/swiper/issues/720][#720]].
+**** Set =view-read-only= locally
+See [[https://github.com/abo-abo/swiper/issues/789][#789]].
+**** Run =wgrep-setup=
+See [[https://github.com/abo-abo/swiper/issues/904][#904]].
+-----
+*** =ivy-read=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-ivy-read
+:END:
+**** Make key binding for other window action consistent
+By default, ~M-o j~ will select the file or buffer in other window, for
+both =ivy-switch-buffer= and =counsel-find-file=.
+**** Facilitate sorting of cons cells
+See [[https://github.com/abo-abo/swiper/issues/554][#554]].
+#+begin_src elisp
+(defvar ivy-sorter-data '(("b 1" . 1) ("a 2" . 2) ("d 0" . 0) ("c 5" . 5)))
+
+(defun isn (a b)
+  (< (cdr a) (cdr b)))
+
+(add-to-list 'ivy-sort-functions-alist '(ivy-sorter . isn))
+
+(ivy-read "string: " ivy-sorter-data
+          :sort t
+          :caller 'ivy-sorter)
+#+end_src
+**** Add prefix arg for action functions
+See [[https://github.com/abo-abo/swiper/issues/552][#552]].
+
+Single actions:
+| C-m     | ivy-done             | store prefix |
+| M-o     | ivy-dispatching-done | store prefix |
+| C-j     | ivy-alt-done         | store prefix |
+| C-M-j   | ivy-immediate-done   | store prefix |
+| TAB TAB | ivy-partial-or-done  | unsupported  |
+| C-'     | ivy-avy              | unsupported  |
+
+Multiple actions:
+| C-M-m | ivy-call                   | store prefix, type prefix again for 
next call |
+| C-M-o | ivy-dispatching-call       | store prefix, type prefix again for 
next call |
+| C-M-n | ivy-next-line-and-call     | store prefix, type prefix again for 
next call |
+| C-M-p | ivy-previous-line-and-call | store prefix, type prefix again for 
next call |
+
+An example application:
+
+no prefix prints first number in a message-box
+one prefix prints last number in a message-box
+numeric prefix selects the index to print in a message-box
+#+begin_src elisp
+(ivy-read "choose: " '(("a" 1 2 3)
+                       ("b" 3 4 5))
+          :action
+          (lambda (x)
+            (message-box "%s"
+                         (cond
+                           ((null ivy-current-prefix-arg)
+                            (elt x 0))
+                           ((equal '(4) ivy-current-prefix-arg)
+                            (car (last x)))
+                           (t
+                            (elt x (prefix-numeric-value 
ivy-current-prefix-arg)))))))
+#+end_src
+**** Breaking change for alist type collection actions
+The action will be called with collection's =ITEM=, instead of =(cdr
+ITEM)= like before. This allows to simplify the logic of complex action
+functions: they don't have to look up the full item by string in their
+own collection, moreover they don't have to know anything about their
+collection.
+**** Implement unique index for alist completion
+The uniqueness assumption is that the completion system is passed a
+list of /unique/ strings, of which one (or more) are selected.
+
+Unlike plain string completion, alists may require violating the
+uniqueness assumption: there may be two elements with the same =car= but
+different =cdr=. Example: C function declaration and definition for tag
+completion.
+
+Until now, whenever two equal strings were sent to =ivy-read=, only the
+first one could be selected. Now, each alist car gets an integer index
+assigned to it as a text property ='idx=. So it's possible to
+differentiate two alist items with the same key.
+**** Make =with-ivy-window= not necessary in the action function
+This allows for a lot of simplification, e.g. use =insert= instead of
+=(lambda (x) (with-ivy-window (insert x)))=.
+
+See [[https://github.com/abo-abo/swiper/issues/639][#639]].
+-----
+*** =ivy-switch-buffer=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-ivy-switch-buffer
+:END:
+**** Add =ivy-sort-function-buffer=
+Puts e.g. the =*scratch*= buffer ahead of the =misc= buffer if the input
+is "sc", since it's almost like a prefix match.
+
+See [[https://github.com/abo-abo/swiper/issues/595][#595]].
+**** Sort virtual buffers after open buffers
+See [[https://github.com/abo-abo/swiper/issues/706][#706]], 
[[https://github.com/abo-abo/swiper/issues/743][#743]].
+**** =ivy-switch-buffer-faces-alist=
+Allow to customize faces in =ivy-switch-buffer= by the mode of each buffer.
+
+Example:
+#+begin_src elisp
+(setq ivy-switch-buffer-faces-alist
+      '((emacs-lisp-mode . swiper-match-face-1)
+        (dired-mode . ivy-subdir)
+        (org-mode . org-level-4)))
+#+end_src
+-----
+*** =swiper=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-swiper
+:END:
+**** Add option for swiper line number to be searchable
+See =swiper-include-line-number-in-search= and 
[[https://github.com/abo-abo/swiper/issues/562][#562]].
+**** Restore window position after using swiper.
+Relevant for high settings of =scroll-conservatively=.
+See [[https://github.com/abo-abo/swiper/issues/643][#643]].
+**** Improve fuzzy highlight
+If you've set the regex builder to fuzzy (non-default), you'll get a
+highlight quality on par with the default one.  See 
[[https://github.com/abo-abo/swiper/issues/651][#651]], 
[[https://github.com/abo-abo/swiper/issues/653][#653]].
+**** Add =char-fold-to-regexp=
+See [[https://github.com/abo-abo/swiper/issues/622][#622]].
+**** Add compatibility with =evil-ex-search=
+See [[https://github.com/abo-abo/swiper/issues/887][#887]].
+**** Apply =evil= search highlighting
+See [[https://github.com/abo-abo/swiper/issues/888][#888]].
+**** Set =evil-ex-search-direction=
+See [[https://github.com/abo-abo/swiper/issues/947][#947]].
+**** =swiper-goto-start-of-match=
+New defcustom. When non-nil, swiper default action will go to the
+beginning of the match instead of on its end. This behavior is
+inspired by vim's and evil's way of searching.
+
+See [[https://github.com/abo-abo/swiper/issues/944][#944]], 
[[https://github.com/abo-abo/swiper/issues/942][#942]].
+**** =swiper-avy= works with more regexp builders
+See [[https://github.com/abo-abo/swiper/issues/932][#932]].
+-----
+*** =swiper-all=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nf-swiper-all
+:END:
+**** Is now async
+This means extremely fast startup time.
+
+Additionally, the feedback to input is quite fast even with a hundred
+buffers. This is because, unlike =swiper=, line numbers are not
+computed. Computing line numbers, while situationally useful, is
+really slow for huge buffers, and even slower for dozens of huge
+buffers.
+
+See [[https://github.com/abo-abo/swiper/issues/620][#620]].
+**** Press ~M-q~ for query-replace
+See [[https://github.com/abo-abo/swiper/issues/623][#623]].
+**** Ignore TAGS buffers
+See [[https://github.com/abo-abo/swiper/issues/787][#787]].
+**** Consider magit stash buffers
+See [[https://github.com/abo-abo/swiper/issues/819][#819]].
+**** Fix =case-fold-search=
+See [[https://github.com/abo-abo/swiper/issues/880][#880]].
+-----
+** New Commands
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-new-commands
+:END:
+*** =counsel-bookmark=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-bookmark
+:END:
+Completion for =bookmark-jump=.
+
+Can delete and rename bookmarks, see 
[[https://github.com/abo-abo/swiper/issues/758][#758]].
+-----
+*** =counsel-colors-emacs=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-colors-emacs
+:END:
+See [[https://github.com/abo-abo/swiper/issues/815][#815]], 
[[https://github.com/abo-abo/swiper/issues/921][#921]].
+-----
+*** =counsel-colors-web=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-colors-web
+:END:
+See [[https://github.com/abo-abo/swiper/issues/815][#815]].
+-----
+*** =counsel-command-history=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-command-history
+:END:
+See [[https://github.com/abo-abo/swiper/issues/826][#826]].
+-----
+*** =counsel-company=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-company
+:END:
+Picks up company's candidates and inserts the result into the buffer.
+See [[https://github.com/abo-abo/swiper/issues/331][#331]], 
[[https://github.com/abo-abo/swiper/issues/547][#547]].
+-----
+*** =counsel-describe-face=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-describe-face
+:END:
+See [[https://github.com/abo-abo/swiper/issues/585][#585]], 
[[https://github.com/abo-abo/swiper/issues/703][#703]].
+-----
+*** =counsel-dired-jump=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-dired-jump
+:END:
+Like, =counsel-file-jump=, but for directories.
+-----
+*** =counsel-dpkg=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-dpkg
+:END:
+Completion for =dpkg -l=.
+-----
+*** =counsel-faces=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-faces
+:END:
+See [[https://github.com/abo-abo/swiper/issues/815][#815]].
+-----
+*** =counsel-file-jump=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-file-jump
+:END:
+Jump to a file from a list of all files in the current directory, see 
[[https://github.com/abo-abo/swiper/issues/609][#609]], 
[[https://github.com/abo-abo/swiper/issues/610][#610]].
+-----
+*** =counsel-find-library=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-find-library
+:END:
+A helpful and unsurprising alternative to using ~C-.~ with
+=counsel-load-library=.
+See [[https://github.com/abo-abo/swiper/issues/794][#794]], 
[[https://github.com/abo-abo/swiper/issues/801][#801]].
+-----
+*** =counsel-hydra-heads=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-hydra-heads
+:END:
+Call a head of the current/last hydra by name.
+See [[https://github.com/abo-abo/swiper/issues/696][#696]].
+-----
+*** =counsel-irony=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-irony
+:END:
+Inline C++ completion using Irony.
+-----
+*** =counsel-mark-ring=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-mark-ring
+:END:
+See [[https://github.com/abo-abo/swiper/issues/834][#834]].
+-----
+*** =counsel-org-agenda-headlines=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-org-agenda-headlines
+:END:
+See [[https://github.com/abo-abo/swiper/issues/825][#825]].
+-----
+*** =counsel-outline=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-outline
+:END:
+Completion for outlines in the current buffer.
+-----
+*** =counsel-package=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-package
+:END:
+Manage packages. Allows installing, deleting, describing etc.
+See [[https://github.com/abo-abo/swiper/issues/869][#869]], 
[[https://github.com/abo-abo/swiper/issues/872][#872]].
+-----
+*** =counsel-recentf=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-recentf
+:END:
+Renamed from =ivy-recentf=, see 
[[https://github.com/abo-abo/swiper/issues/624][#624]].
+
+Added actions in [[https://github.com/abo-abo/swiper/issues/701][#701]]:
+
+- ~j~ for =find-file-other-window=
+- ~x~ for =counsel-find-file-extern=
+
+Remove text properties, see 
[[https://github.com/abo-abo/swiper/issues/770][#770]].
+-----
+*** =counsel-rg=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-rg
+:END:
+Grep for a string in the current directory using =rg=.
+Use =counsel-rg-base-command= to customize.
+See [[https://github.com/abo-abo/swiper/issues/784][#784]], 
[[https://github.com/abo-abo/swiper/issues/785][#785]], 
[[https://github.com/abo-abo/swiper/issues/795][#795]], 
[[https://github.com/abo-abo/swiper/issues/796][#796]].
+-----
+*** =counsel-rpm=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-rpm
+:END:
+Call the =rpm= shell command. See 
[[https://github.com/abo-abo/swiper/issues/695][#695]].
+-----
+*** =counsel-semantic=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-semantic
+:END:
+Completion for semantic tags.
+-----
+*** =counsel-set-variable=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-set-variable
+:END:
+Completion for setting a variable to a value.
+See [[https://github.com/abo-abo/swiper/issues/544][#544]], 
[[https://github.com/abo-abo/swiper/issues/546][#546]], 
[[https://github.com/abo-abo/swiper/issues/549][#549]], 
[[https://github.com/abo-abo/swiper/issues/550][#550]], 
[[https://github.com/abo-abo/swiper/issues/556][#556]].
+-----
+*** =counsel-shell-command-history=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-counsel-shell-command-history
+:END:
+Search through history in =shell-mode=. See 
[[https://github.com/abo-abo/swiper/issues/689][#689]].
+
+When =counsel-mode= is on, ~M-! C-r~ will call
+=counsel-shell-command-history=.
+-----
+*** =ivy-push-view=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-ivy-push-view
+:END:
+And =ivy-pop-view=.
+
+1. Use =ivy-push-view= to store a view - your current window tree.  This
+   contains: all windows on the current frame, and their configuration
+   w.r.t. horizontal or vertical splits. The point positions in each
+   window are stored as well.
+
+2. Use =ivy-switch-buffer= to select stored views.
+
+3. Use =ivy-pop-view= to delete a stored view that you don't want any
+   more.
+
+See [[https://github.com/abo-abo/swiper/issues/584][#584]].
+-----
+*** =ivy-rotate-sort=
+:PROPERTIES:
+:CUSTOM_ID: 0-9-0-nc-ivy-rotate-sort
+:END:
+Modify =ivy-sort-functions-alist= to allow a list of sorting functions
+to apply to a collection. The car of this list is the current
+one. =ivy-rotate-sort= then rotates this list through the different
+possibilities. Bound to ~C-c C-s~. Here is a simple example to
+illustrate.
+
+#+begin_src elisp
+(setq ivy-sort-functions-alist
+      '((read-file-name-internal .
+                                (ivy-sort-file-function-default string-lessp 
string-greaterp))
+       (internal-complete-buffer . nil)
+       (counsel-git-grep-function . nil)
+       (Man-goto-section . nil)
+       (org-refile . nil)
+       (t . string-lessp)))
+#+end_src
+
+~M-x~ =find-file= ~RET C-c C-s~ now switches from the default sorting to
+using =string-lessp=. ~C-c C-s~ again switches to =string-greaterp= and so
+on.
+
+See [[https://github.com/abo-abo/swiper/issues/845][#845]], 
[[https://github.com/abo-abo/swiper/issues/927][#927]].
+-----
+#+BEGIN_EXPORT html
+<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
+<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
+<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
+#+END_EXPORT
diff --git a/packages/ivy/doc/ivy.org b/packages/ivy/doc/ivy.org
index 8c0f357..1ff790d 100644
--- a/packages/ivy/doc/ivy.org
+++ b/packages/ivy/doc/ivy.org
@@ -41,13 +41,18 @@ Set =CUSTOM_ID= property to name each heading. For example, 
=worf='s
 
 Keep one empty line before each source block for proper Texinfo
 exports.
+
+** Exporting to texinfo
+
+ivy.texi is generated from ivy.org. To update the .texi file, eval
+ivy-ox.el then ~C-c C-e i t~ in the ivy.org bufer.
 * Copying
 :PROPERTIES:
 :COPYING:  t
 :CUSTOM_ID: copying
 :END:
 #+TEXINFO: @ifnottex
-Ivy manual, version 0.7.0
+Ivy manual, version 0.8.0
 
 Ivy is an interactive interface for completion in Emacs. Emacs uses
 completion mechanism in a variety of contexts: code, menus, commands,
@@ -105,13 +110,14 @@ discoverability.
      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.
+     selected candidate with =>=, instead of highlighting the selected
+     candidate with the =ivy-current-match= face (see
+     =ivy-format-function=). 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.
 
 - Discoverability ::
      Ivy displays easily discoverable commands through the hydra
@@ -139,15 +145,16 @@ oldest version that runs Ivy with fancy faces display.
 :CUSTOM_ID: installing-from-emacs-package-manager
 :END:
 
-~M-x~ =package-install= ~RET~ =swiper= ~RET~
+~M-x~ =package-install= ~RET~ =ivy= ~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.
+Ivy is installed as part of =ivy= package, which 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:
+For current hourly builds, use the MELPA archives. In MELPA, Ivy is
+split into three packages: =ivy=, =swiper= and =counsel=; you can simply
+install =counsel= which will bring in the other two as dependencies.
+See the code below for adding MELPA to the list of package archives:
 
 #+begin_src elisp
 (require 'package)
@@ -155,8 +162,8 @@ for adding MELPA to the list of 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~.
+After this do ~M-x~ =package-refresh-contents= ~RET~, followed by ~M-x~
+=package-install= ~RET~ =counsel= ~RET~.
 
 For package manager details, see [[info:emacs#Packages]].
 
@@ -213,7 +220,6 @@ 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-count-format "(%d/%d) ")
 #+end_src
 
@@ -243,7 +249,7 @@ The recommended key bindings are:
      (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 "<f1> l") 'counsel-find-library)
      (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
      (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
      #+end_src
@@ -402,7 +408,7 @@ actions.
      line.
 
      Comes in handy when opening multiple files from
-     =counsel-find-file=, =counsel-git-grep=, =counsel-ag=, or
+     =counsel-find-file=, =counsel-git-grep=, =counsel-ag=, =counsel-rg=, or
      =counsel-locate= lists. Just hold ~C-M-n~ for rapid-fire default
      action on each successive element of the list.
 
@@ -673,7 +679,6 @@ installed.
 
 ~C-o m~ toggles the current regexp builder.
 
-
 * Customization
 :PROPERTIES:
 :CUSTOM_ID: customization
@@ -929,7 +934,7 @@ To examine each action with each candidate in a 
key-efficient way, try:
      =completing-read-function= (which =ivy-mode= sets). Try refiling
      headings with similar names to appreciate =ivy-mode=.
 - =magit= ::
-     Magit requries this setting for ivy completion:
+     Magit requires this setting for ivy completion:
 
      #+begin_src elisp
      (setq magit-completing-read-function 'ivy-completing-read)
@@ -937,13 +942,13 @@ To examine each action with each candidate in a 
key-efficient way, try:
 - =find-file-in-project= ::
      It uses ivy by default if Ivy is installed.
 - =projectile= ::
-     Projectile requires this seeting for ivy completion:
+     Projectile requires this setting for ivy completion:
 
      #+begin_src elisp
      (setq projectile-completion-system 'ivy)
      #+end_src
 - =helm-make= ::
-     Helm-make requires this seeting for ivy completion.
+     Helm-make requires this setting for ivy completion.
 
      #+begin_src elisp
      (setq helm-make-completion-method 'ivy)
@@ -957,7 +962,7 @@ To examine each action with each candidate in a 
key-efficient way, try:
 :PROPERTIES:
 :CUSTOM_ID: file-name-completion
 :END:
-Since file name completion is ubiquitious, Ivy provides extra
+Since file name completion is ubiquitous, Ivy provides extra
 bindings that work here:
 
 
@@ -1001,6 +1006,10 @@ bindings that work here:
 
      ~C-i~ works in a similar way to the default completion.
 
+     You can also get sudo access for the current directory by
+     inputting =/sudo::= ~RET~. Using =/sudo:= (i.e. single colon instead of
+     double) will result in a completion session for the desired user.
+
 - History ::
      File history works the same with ~M-p~, ~M-n~, and ~C-r~, but
      uses a custom code for file name completion that cycles through
@@ -1019,7 +1028,7 @@ bindings that work here:
      #+begin_src elisp
      (setq ivy-use-virtual-buffers t)
      #+end_src
-     will add additional virual buffers to the buffers list for recent
+     will add additional virtual buffers to the buffers list for recent
      files. Selecting such virtual buffers, which are highlighted with
      =ivy-virtual= face, will open the corresponding file.
 
@@ -1118,7 +1127,7 @@ features such as multi-actions, non-exiting actions, 
=ivy-occur= and
 - =matcher= ::
      Is a function that takes a regex string and a list of strings and
      returns a list of strings matching the regex. Any ordinary Emacs
-     matching function will suffice, yet finely tuned mathing
+     matching function will suffice, yet finely tuned matching
      functions can be used. See =counsel-find-file= for an example
      usage.
 - =dynamic-collection= ::
@@ -1271,6 +1280,38 @@ that they appear:
   we want to kill the running process created by
   =counsel--async-command=.
 - =caller= argument identifies this command for easier customization.
+** Example - =ivy-read-with-extra-properties=
+:PROPERTIES:
+:CUSTOM_ID: example---ivy-read-with-extra-properties
+:END:
+This is another example to show how to associate additional values to each
+displayed strings.
+
+#+BEGIN_SRC elisp
+(defun find-candidates-function (str pred _)
+  (let ((props '(1 2))
+        (strs '("foo" "foo2")))
+    (cl-mapcar (lambda (s p) (propertize s 'property p))
+               strs
+               props)))
+
+(defun find-candidates ()
+  (interactive)
+  (ivy-read "Find symbols: "
+            #'find-candidates-function
+            :action (lambda (x)
+                      (message "Value: %s" (get-text-property 0 'property x)
+                       ))))
+#+END_SRC
+
+Here are the interesting features of the above function:
+
+- =find-candidates-function= builds up a list of strings and associates "foo" 
with
+  the value 1 and "foo2" with 2.
+- =find-candidates= is an interactive function.
+- =#'find-candidates= is passed as the =collection= argument.
+- =action= gets passed the selected string with the associated value. It
+  then retrieves that value and displays it.
 
 * Variable Index
 :PROPERTIES:
diff --git a/packages/ivy/doc/ivy.texi b/packages/ivy/doc/ivy.texi
index 64afd6b..956fdcc 100644
--- a/packages/ivy/doc/ivy.texi
+++ b/packages/ivy/doc/ivy.texi
@@ -8,7 +8,7 @@
 
 @copying
 @ifnottex
-Ivy manual, version 0.7.0
+Ivy manual, version 0.8.0
 
 Ivy is an interactive interface for completion in Emacs. Emacs uses
 completion mechanism in a variety of contexts: code, menus, commands,
@@ -72,35 +72,43 @@ modify this GNU manual.''
 @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 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 the 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::
 
+
+
 Customization
 
 * Faces::
@@ -108,6 +116,8 @@ Customization
 * Actions::
 * Packages::
 
+
+
 Actions
 
 * What are actions?::
@@ -116,20 +126,28 @@ Actions
 * Example - add two actions to each command::
 * Example - define a new command with several actions::
 
+
+
+
 Example - add two actions to each command
 
 * How to undo adding the two actions::
 * How to add actions to a specific command::
 
+
+
 Example - define a new command with several actions
 
 * Test the above function with @code{ivy-occur}::
+
 Commands
 
 * File Name Completion::
 * Buffer Name Completion::
 * Counsel commands::
 
+
+
 API
 
 * Required arguments for @code{ivy-read}::
@@ -172,13 +190,14 @@ complications with branch-introducing custom macros.
 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.
+selected candidate with @code{>}, instead of highlighting the selected
+candidate with the @code{ivy-current-match} face (see
address@hidden). Or take the customization of actions, say
+after the candidate function is selected. @kbd{RET} uses
address@hidden to describe the function, whereas
address@hidden d} jumps to that function's definition in the code. The
address@hidden prefix can be uniformly used with characters like @kbd{d} to
+group similar actions.
 @end indentedblock
 @subsubheading Discoverability
 @indentedblock
@@ -200,6 +219,7 @@ from Ivy's development repository.
 
 Emacs 24.3.1 is the oldest version to run Ivy. Emacs 24.5.1 is the
 oldest version that runs Ivy with fancy faces display.
+
 @menu
 * Installing from Emacs Package Manager::
 * Installing from the Git repository::
@@ -225,7 +245,7 @@ for adding MELPA to the list of package archives:
 @end lisp
 
 After this do @kbd{M-x} @code{package-refresh-contents} @kbd{RET}, followed by
address@hidden @code{package-install} @kbd{RET} @code{swiper} @kbd{RET}.
address@hidden @code{package-install} @kbd{RET} @code{counsel} @kbd{RET}.
 
 For package manager details, see @ref{Packages,,,emacs,}.
 
@@ -279,6 +299,7 @@ First enable Ivy completion everywhere:
 @end lisp
 
 Note: @code{ivy-mode} can be toggled on and off with @kbd{M-x} @code{ivy-mode}.
+
 @menu
 * Basic customization::
 @end menu
@@ -290,7 +311,6 @@ Here are some basic settings particularly useful for new 
Ivy users:
 
 @lisp
 (setq ivy-use-virtual-buffers t)
-(setq ivy-height 10)
 (setq ivy-count-format "(%d/%d) ")
 @end lisp
 
@@ -323,7 +343,7 @@ The recommended key bindings are:
      (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 "<f1> l") 'counsel-find-library)
      (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
      (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
 @end lisp
@@ -362,10 +382,11 @@ described under their respective commands.
 A key feature of @code{ivy-minibuffer-map} is its full editing capability
 where the familiar @kbd{C-a}, @kbd{C-f}, @kbd{M-d}, @kbd{M-DEL}, @kbd{M-b}, 
@kbd{M-w}, @kbd{C-k},
 @kbd{C-y} key bindings work the same as in @code{fundamental-mode}.
+
 @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 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 the minibuffer input::
 * Other key bindings::
 * Hydra in the minibuffer::
@@ -523,9 +544,10 @@ 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
address@hidden, @code{counsel-git-grep}, @code{counsel-ag}, or
address@hidden lists. Just hold @kbd{C-M-n} for rapid-fire default
-action on each successive element of the list.
address@hidden, @code{counsel-git-grep}, @code{counsel-ag},
address@hidden, or @code{counsel-locate} lists. Just hold
address@hidden for rapid-fire default action on each successive element
+of the list.
 @end indentedblock
 @subsubheading @kbd{C-M-p} (@code{ivy-previous-line-and-call})
 @vindex ivy-previous-line-and-call
@@ -840,6 +862,7 @@ entry on @code{ivy-re-builders-alist}.
 @item
 @code{ivy--regex}.
 @end enumerate
+
 @menu
 * ivy--regex-plus::
 * ivy--regex-ignore-order::
@@ -1124,6 +1147,7 @@ The second action copies the current candidate to the 
kill ring.
 
 Then in any completion session, @kbd{M-o y} invokes @code{ivy-yank-action}, and
 @kbd{M-o i} invokes @code{ivy-copy-to-buffer-action}.
+
 @menu
 * How to undo adding the two actions::
 * How to add actions to a specific command::
@@ -1176,6 +1200,7 @@ Use the command name as the key:
 
 The number 1 above is the index of the default action. Each
 action has its own string description for easy selection.
+
 @menu
 * Test the above function with @code{ivy-occur}::
 @end menu
@@ -1219,7 +1244,7 @@ headings with similar names to appreciate @code{ivy-mode}.
 @end indentedblock
 @subsubheading @code{magit}
 @indentedblock
-Magit requries this setting for ivy completion:
+Magit requires this setting for ivy completion:
 
 @lisp
      (setq magit-completing-read-function 'ivy-completing-read)
@@ -1231,7 +1256,7 @@ It uses ivy by default if Ivy is installed.
 @end indentedblock
 @subsubheading @code{projectile}
 @indentedblock
-Projectile requires this seeting for ivy completion:
+Projectile requires this setting for ivy completion:
 
 @lisp
      (setq projectile-completion-system 'ivy)
@@ -1239,7 +1264,7 @@ Projectile requires this seeting for ivy completion:
 @end indentedblock
 @subsubheading @code{helm-make}
 @indentedblock
-Helm-make requires this seeting for ivy completion.
+Helm-make requires this setting for ivy completion.
 
 @lisp
      (setq helm-make-completion-method 'ivy)
@@ -1258,7 +1283,7 @@ Helm-make requires this seeting for ivy completion.
 @node File Name Completion
 @section File Name Completion
 
-Since file name completion is ubiquitious, Ivy provides extra
+Since file name completion is ubiquitous, Ivy provides extra
 bindings that work here:
 
 
@@ -1323,6 +1348,10 @@ host and user names.
 For @code{/ssh:user@@} input, completes the domain name.
 
 @kbd{C-i} works in a similar way to the default completion.
+
+You can also get sudo access for the current directory by
+inputting @code{/sudo::} @kbd{RET}. Using @code{/sudo:} (i.e. single colon 
instead of
+double) will result in a completion session for the desired user.
 @end indentedblock
 @subsubheading History
 @indentedblock
@@ -1343,7 +1372,7 @@ Adding this to Emacs init file:
 @lisp
      (setq ivy-use-virtual-buffers t)
 @end lisp
-will add additional virual buffers to the buffers list for recent
+will add additional virtual buffers to the buffers list for recent
 files. Selecting such virtual buffers, which are highlighted with
 @code{ivy-virtual} face, will open the corresponding file.
 @end defopt
@@ -1376,6 +1405,7 @@ two required arguments and many optional arguments that 
can be passed
 by a key. The optional @code{:action} argument is highly recommended for
 features such as multi-actions, non-exiting actions, @code{ivy-occur} and
 @code{ivy-resume}.
+
 @menu
 * Required arguments for @code{ivy-read}::
 * Optional arguments for @code{ivy-read}::
@@ -1478,7 +1508,7 @@ Is a function that takes a string and returns a valid 
regex. See
 @indentedblock
 Is a function that takes a regex string and a list of strings and
 returns a list of strings matching the regex. Any ordinary Emacs
-matching function will suffice, yet finely tuned mathing
+matching function will suffice, yet finely tuned matching
 functions can be used. See @code{counsel-find-file} for an example
 usage.
 @end indentedblock
@@ -1669,4 +1699,4 @@ we want to kill the running process created by
 
 @printindex ky
 
address@hidden
address@hidden
\ No newline at end of file
diff --git a/packages/ivy/ivy-hydra.el b/packages/ivy/ivy-hydra.el
index 44f8754..d4b8e5f 100644
--- a/packages/ivy/ivy-hydra.el
+++ b/packages/ivy/ivy-hydra.el
@@ -1,8 +1,12 @@
 ;;; ivy-hydra.el --- Additional key bindings for Ivy  -*- lexical-binding: t 
-*-
 
-;; Copyright (C) 2015  Free Software Foundation, Inc.
+;; Copyright (C) 2015-2017  Free Software Foundation, Inc.
 
-;; Author: Oleh Krehel
+;; Author: Oleh Krehel <address@hidden>
+;; URL: https://github.com/abo-abo/swiper
+;; Version: 0.9.0
+;; Package-Requires: ((emacs "24.1") (ivy "0.9.0") (hydra "0.13.4"))
+;; Keywords: completion, matching, bindings
 
 ;; This file is part of GNU Emacs.
 
@@ -26,23 +30,8 @@
 ;; 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'")))))))
+(require 'hydra)
 
 (defun ivy--matcher-desc ()
   (if (eq ivy--regex-function
@@ -88,6 +77,27 @@ _h_ ^+^ _l_ | _d_one      ^ ^  | _o_ops   | _m_: matcher 
%-5s(ivy--matcher-desc)
         (lambda (_) (find-function 'hydra-ivy/body)))
        :exit t))
 
+(defun ivy-dispatching-done-hydra ()
+  "Select one of the available actions and call `ivy-done'."
+  (interactive)
+  (let ((actions (ivy-state-action ivy-last)))
+    (if (null (ivy--actionp actions))
+        (ivy-done)
+      (funcall
+       (eval
+        `(defhydra ivy-read-action (:color teal)
+           "action"
+           ,@(mapcar (lambda (x)
+                       (list (nth 0 x)
+                             `(progn
+                                (ivy-set-action ',(nth 1 x))
+                                (ivy-done))
+                             (nth 2 x)))
+                     (cdr actions))
+           ("M-o" nil "back")))))))
+
+(define-key ivy-minibuffer-map (kbd "M-o") 'ivy-dispatching-done-hydra)
+
 (provide 'ivy-hydra)
 
 ;;; ivy-hydra.el ends here
diff --git a/packages/ivy/ivy-test.el b/packages/ivy/ivy-test.el
index 40dae48..8961ae4 100644
--- a/packages/ivy/ivy-test.el
+++ b/packages/ivy/ivy-test.el
@@ -1,6 +1,6 @@
 ;;; ivy-test.el --- tests for ivy
 
-;; Copyright (C) 2015  Free Software Foundation, Inc.
+;; Copyright (C) 2015-2017  Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel
 
@@ -88,7 +88,7 @@
               (ivy-read "test" '(("foo" . "bar"))
                :action (lambda (x) (prin1 x))))
             "f C-m")
-           "\"bar\""))
+           "(#(\"foo\" 0 1 (idx 0)) . \"bar\")"))
   (should (equal
            (ivy-with
             '(with-output-to-string
@@ -137,11 +137,11 @@
 
 (ert-deftest ivy--regex-fuzzy ()
   (should (string= (ivy--regex-fuzzy "tmux")
-                   "\\(t\\).*\\(m\\).*\\(u\\).*\\(x\\)"))
+                   "\\(t\\).*?\\(m\\).*?\\(u\\).*?\\(x\\)"))
   (should (string= (ivy--regex-fuzzy "^tmux")
-                   "^\\(t\\).*\\(m\\).*\\(u\\).*\\(x\\)"))
+                   "^\\(t\\).*?\\(m\\).*?\\(u\\).*?\\(x\\)"))
   (should (string= (ivy--regex-fuzzy "^tmux$")
-                   "^\\(t\\).*\\(m\\).*\\(u\\).*\\(x\\)$"))
+                   "^\\(t\\).*?\\(m\\).*?\\(u\\).*?\\(x\\)$"))
   (should (string= (ivy--regex-fuzzy "")
                    ""))
   (should (string= (ivy--regex-fuzzy "^")
@@ -169,7 +169,9 @@
   (should (equal (ivy--regex-ignore-order "one two !three four")
                  '(("one" . t) ("two" . t) ("three") ("four"))))
   (should (equal (ivy--regex-ignore-order "!three four")
-                 '(("" . t) (("three") ("four"))))))
+                 '(("" . t) (("three") ("four")))))
+  (should (equal (ivy--regex-ignore-order "foo[ bar[xy]")
+                 '(("foo\\[" . t) ("bar[xy]" . t)))))
 
 (ert-deftest ivy--format ()
   (should (string= (let ((ivy--index 10)
@@ -204,3 +206,224 @@
   (should (equal (counsel-unquote-regex-parens
                   (ivy--regex "(foo bar"))
                  "(\\(foo).*?(bar)")))
+
+(ert-deftest colir-color-parse ()
+  (should (equal (colir-color-parse "#ab1234")
+                 ;; (color-name-to-rgb "#ab1234")
+                 '(0.6705882352941176
+                   0.07058823529411765
+                   0.20392156862745098))))
+
+
+;;* prefix arg tests
+;;** tests with no prefix
+(ert-deftest ivy-no-prefix-arg ()
+  "Tests with no prefix arg."
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-m")
+           nil))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-j")
+           nil))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-M-j")
+           nil))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-M-m")
+           nil))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-M-n")
+           nil))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-M-p")
+           nil))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "M-o o")
+           nil))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "TAB TAB")
+           nil)))
+
+;;** tests with one prefix
+(ert-deftest ivy-one-prefix-arg ()
+  "Tests with no prefix arg."
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-u C-m")
+           '(4)))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-u C-j")
+           '(4)))
+  ;; C-M-j does not pass a prefix on.
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-u C-M-j")
+           nil))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-u C-M-m")
+           '(4)))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-u C-M-n")
+           '(4)))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-u C-M-p")
+           '(4)))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "C-u M-o o")
+           '(4)))
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action
+               '(1 ("o" (lambda (x)
+                          (setq res ivy-current-prefix-arg)))
+                 ("p" (lambda (x)
+                        (setq res ivy-current-prefix-arg)))))
+              res)
+            "C-u M-o p")
+           '(4)))
+  ;; TAB TAB does not pass prefix arg
+  (should (equal
+           (ivy-with
+            '(let (res)
+              (ivy-read "pattern: " '("blue" "yellow")
+               :action (lambda (x)
+                         (setq res ivy-current-prefix-arg)))
+              res)
+            "TAB TAB")
+           nil)))
+
+
+(ert-deftest ivy-numeric-prefix-arg ()
+  (should (equal
+           (ivy-with
+            '(let (res)
+               (ivy-read "pattern: " '("blue" "yellow")
+                         :action (lambda (x)
+                                   (setq res ivy-current-prefix-arg)))
+               res)
+            "M-1 M-2 M-3 C-m")
+           123))
+  (should (equal
+           (ivy-with
+            '(let (res)
+               (ivy-read "pattern: " '("blue" "yellow")
+                         :action (lambda (x)
+                                   (setq res ivy-current-prefix-arg)))
+               res)
+            "C-u 123 C-m")
+           123)))
+
+(ert-deftest ivy-re-match ()
+  (should (ivy-re-match '(("counsel" . t)) "(defun counsel"))
+  (should (ivy-re-match '(("defun" . t) ("counsel" . t)) "(defun counsel"))
+  (should (ivy-re-match '(("counsel" . t) ("defun" . t)) "(defun counsel"))
+  (should (not (ivy-re-match '(("counsel" . nil) ("defun" . t)) "(defun 
counsel")))
+  (should (not (ivy-re-match '(("defun" . t) ("counsel" . nil)) "(defun 
counsel"))))
+
+(ert-deftest ivy-read-preselect ()
+  (should (equal
+           (ivy-with
+            '(ivy-read "test: "
+              (list "abc" "default" "def")
+              :preselect 1)
+            "RET")
+           "default"))
+  (should (equal
+           (ivy-with
+            '(ivy-read "test: "
+              (list "abc" "default" "def")
+              :preselect "defa")
+            "RET")
+           "default")))
+
+(provide 'ivy-test)
diff --git a/packages/ivy/ivy.el b/packages/ivy/ivy.el
index 7a49c24..d4b1e65 100644
--- a/packages/ivy/ivy.el
+++ b/packages/ivy/ivy.el
@@ -1,10 +1,10 @@
 ;;; ivy.el --- Incremental Vertical completYon -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015  Free Software Foundation, Inc.
+;; Copyright (C) 2015-2017  Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel <address@hidden>
 ;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.8.0
+;; Version: 0.9.0
 ;; Package-Requires: ((emacs "24.1"))
 ;; Keywords: matching
 
@@ -39,6 +39,7 @@
 ;;; Code:
 (require 'cl-lib)
 (require 'ffap)
+(require 'ivy-overlay)
 
 ;;* Customization
 (defgroup ivy nil
@@ -102,7 +103,10 @@
   "Face used by Ivy for highlighting modified file visiting buffers.")
 
 (defface ivy-remote
-  '((t :foreground "#110099"))
+  '((((class color) (background light))
+     :foreground "#110099")
+    (((class color) (background dark))
+     :foreground "#7B6BFF"))
   "Face used by Ivy for highlighting remotes in the alternatives.")
 
 (defface ivy-virtual
@@ -169,6 +173,27 @@ Only \"./\" and \"../\" apply here. They appear in reverse 
order."
   "When non-nil, add `recentf-mode' and bookmarks to `ivy-switch-buffer'."
   :type 'boolean)
 
+(defcustom ivy-display-function nil
+  "Decide where to display the candidates.
+This function takes a string with the current matching candidates
+and has to display it somewhere.
+See https://github.com/abo-abo/swiper/wiki/ivy-display-function.";
+  :type '(choice
+          (const :tag "Minibuffer" nil)
+          (const :tag "LV" ivy-display-function-lv)
+          (const :tag "Popup" ivy-display-function-popup)
+          (const :tag "Overlay" ivy-display-function-overlay)))
+
+(defvar ivy-display-functions-alist
+  '((ivy-completion-in-region . ivy-display-function-overlay))
+  "An alist for customizing `ivy-display-function'.")
+
+(defcustom ivy-completing-read-handlers-alist
+  '((tmm-menubar . completing-read-default)
+    (tmm-shortcut . completing-read-default))
+  "An alist of handlers to replace `completing-read' in `ivy-mode'."
+  :type '(alist :key-type function :value-type function))
+
 (defvar ivy--actions-list nil
   "A list of extra actions per command.")
 
@@ -177,6 +202,23 @@ Only \"./\" and \"../\" apply here. They appear in reverse 
order."
   (setq ivy--actions-list
         (plist-put ivy--actions-list cmd actions)))
 
+(defun ivy-add-actions (cmd actions)
+  "Add CMD extra exit points to ACTIONS."
+  (setq ivy--actions-list
+        (plist-put ivy--actions-list cmd
+                   (delete-dups
+                    (append
+                     actions
+                     (plist-get ivy--actions-list cmd))))))
+
+(defvar ivy--prompts-list nil)
+
+(defun ivy-set-prompt (caller prompt-fn)
+  "Associate CALLER with PROMPT-FN.
+PROMPT-FN is a function of no arguments that returns a prompt string."
+  (setq ivy--prompts-list
+        (plist-put ivy--prompts-list caller prompt-fn)))
+
 (defvar ivy--display-transformers-list nil
   "A list of str->str transformers per command.")
 
@@ -212,13 +254,17 @@ Example:
       (cl-subseq recentf-list 0 20))
 
     (ivy-set-sources
-     \\='counsel-locate
-     \\='((small-recentf)
-       (original-source)))
-"
+     'counsel-locate
+     '((small-recentf)
+       (original-source)))"
   (setq ivy--sources-list
         (plist-put ivy--sources-list cmd sources)))
 
+(defvar ivy-current-prefix-arg nil
+  "Prefix arg to pass to actions.
+This is a global variable that is set by ivy functions for use in
+action functions.")
+
 ;;* Keymap
 (require 'delsel)
 (defvar ivy-minibuffer-map
@@ -234,6 +280,7 @@ Example:
     (define-key map (kbd "C-r") 'ivy-reverse-i-search)
     (define-key map (kbd "SPC") 'self-insert-command)
     (define-key map [remap delete-backward-char] 'ivy-backward-delete-char)
+    (define-key map [remap backward-delete-char-untabify] 
'ivy-backward-delete-char)
     (define-key map [remap backward-kill-word] 'ivy-backward-kill-word)
     (define-key map [remap delete-char] 'ivy-delete-char)
     (define-key map [remap forward-char] 'ivy-forward-char)
@@ -245,9 +292,11 @@ Example:
     (define-key map (kbd "C-g") 'minibuffer-keyboard-quit)
     (define-key map [remap scroll-up-command] 'ivy-scroll-up-command)
     (define-key map [remap scroll-down-command] 'ivy-scroll-down-command)
+    (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-r") '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)
@@ -260,6 +309,7 @@ Example:
     (define-key map (kbd "C-M-a") 'ivy-read-action)
     (define-key map (kbd "C-c C-o") 'ivy-occur)
     (define-key map (kbd "C-c C-a") 'ivy-toggle-ignore)
+    (define-key map (kbd "C-c C-s") 'ivy-rotate-sort)
     (define-key map [remap describe-mode] 'ivy-help)
     map)
   "Keymap used in the minibuffer.")
@@ -279,6 +329,8 @@ Example:
   prompt collection
   predicate require-match initial-input
   history preselect keymap update-fn sort
+  ;; The frame in which `ivy-read' was called
+  frame
   ;; The window in which `ivy-read' was called
   window
   ;; The buffer in which `ivy-read' was called
@@ -293,7 +345,9 @@ Example:
   dynamic-collection
   ;; A lambda that transforms candidates only for display
   display-transformer-fn
-  caller)
+  directory
+  caller
+  current)
 
 (defvar ivy-last (make-ivy-state)
   "The last parameters passed to `ivy-read'.
@@ -301,7 +355,15 @@ Example:
 This should eventually become a stack so that you could use
 `ivy-read' recursively.")
 
+(defvar ivy-recursive-last nil)
+
+(defvar ivy-recursive-restore t
+  "When non-nil, restore the above state when exiting the minibuffer.
+This variable is let-bound to nil by functions that take care of
+the restoring themselves.")
+
 (defsubst ivy-set-action (action)
+  "Set the current `ivy-last' field to ACTION."
   (setf (ivy-state-action ivy-last) action))
 
 (defun ivy-thing-at-point ()
@@ -335,9 +397,6 @@ of `history-length'.")
 (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.")
 
@@ -351,12 +410,12 @@ Otherwise, store nil.")
 (defvar ivy--extra-candidates '((original-source))
   "Store candidates added by the extra sources.
 
-This is an internal-use alist. Each key is a function name, or
+This is an internal-use alist.  Each key is a function name, or
 original-source (which represents where the current dynamic
 candidates should go).
 
 Each value is an evaluation of the function, in case of static
-sources. These values will subsequently be filtered on `ivy-text'.
+sources.  These values will subsequently be filtered on `ivy-text'.
 
 This variable is set by `ivy-read' and used by `ivy--set-candidates'.")
 
@@ -391,16 +450,26 @@ When non-nil, it should contain at least one %d.")
 (defvar ivy--regex-function 'ivy--regex
   "Current function for building a regex.")
 
+(defvar ivy--highlight-function 'ivy--highlight-default
+  "Current function for formatting the candidates.")
+
 (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.")
+  "The total amount of candidates when :dynamic-collection is non-nil.")
 
 (defvar ivy--old-text ""
   "Store old `ivy-text' for dynamic completion.")
 
-(defvar ivy-case-fold-search 'auto
+(defcustom ivy-case-fold-search-default 'auto
+  "The default value for `ivy-case-fold-search'."
+  :type '(choice
+          (const :tag "Auto" auto)
+          (const :tag "Always" always)
+          (const :tag "Never" nil)))
+
+(defvar ivy-case-fold-search ivy-case-fold-search-default
   "Store the current overriding `case-fold-search'.")
 
 (defvar Info-current-file)
@@ -445,11 +514,12 @@ When non-nil, it should contain at least one %d.")
 
 (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)))
+  (insert
+   (setf (ivy-state-current ivy-last)
+         (if (and ivy--directory
+                  (not (eq (ivy-state-history ivy-last) 'grep-files-history)))
+             (expand-file-name text ivy--directory)
+           text)))
   (setq ivy-exit 'done)
   (exit-minibuffer))
 
@@ -457,12 +527,13 @@ When non-nil, it should contain at least one %d.")
 (defun ivy-done ()
   "Exit the minibuffer with the selected candidate."
   (interactive)
+  (setq ivy-current-prefix-arg current-prefix-arg)
   (delete-minibuffer-contents)
   (cond ((or (> ivy--length 0)
              ;; the action from `ivy-dispatching-done' may not need a
              ;; candidate at all
              (eq this-command 'ivy-dispatching-done))
-         (ivy--done ivy--current))
+         (ivy--done (ivy-state-current ivy-last)))
         ((memq (ivy-state-collection ivy-last)
                '(read-file-name-internal internal-complete-buffer))
          (if (or (not (eq confirm-nonexistent-file-or-buffer t))
@@ -485,12 +556,12 @@ When non-nil, it should contain at least one %d.")
 (defun ivy-read-action-format-default (actions)
   "Create a docstring from ACTIONS.
 
-ACTIONS is a list. Each list item is a list of 3 items:
+ACTIONS is a list.  Each list item is a list of 3 items:
 key (a string), cmd and doc (a string)."
   (format "%s\n%s\n"
           (if (eq this-command 'ivy-read-action)
               "Select action: "
-            ivy--current)
+            (ivy-state-current ivy-last))
           (mapconcat
            (lambda (x)
              (format "%s: %s"
@@ -511,7 +582,7 @@ selection, non-nil otherwise."
     (if (null (ivy--actionp actions))
         t
       (let* ((hint (funcall ivy-read-action-format-function (cdr actions)))
-             (resize-mini-windows 'grow-only)
+             (resize-mini-windows t)
              (key (string (read-key hint)))
              (action-idx (cl-position-if
                           (lambda (x) (equal (car x) key))
@@ -526,20 +597,28 @@ selection, non-nil otherwise."
                (setcar actions (1+ action-idx))
                (ivy-set-action actions)))))))
 
+(defun ivy-shrink-after-dispatching ()
+  "Shrink the window after dispatching when action list is too large."
+  (let ((window (selected-window)))
+    (window-resize window (- ivy-height (window-height window)))))
+
 (defun ivy-dispatching-done ()
   "Select one of the available actions and call `ivy-done'."
   (interactive)
   (when (ivy-read-action)
-    (ivy-done)))
+    (ivy-done))
+  (ivy-shrink-after-dispatching))
 
 (defun ivy-dispatching-call ()
   "Select one of the available actions and call `ivy-call'."
   (interactive)
+  (setq ivy-current-prefix-arg current-prefix-arg)
   (let ((actions (copy-sequence (ivy-state-action ivy-last))))
     (unwind-protect
          (when (ivy-read-action)
            (ivy-call))
-      (ivy-set-action actions))))
+      (ivy-set-action actions)))
+  (ivy-shrink-after-dispatching))
 
 (defun ivy-build-tramp-name (x)
   "Reconstruct X into a path.
@@ -557,12 +636,13 @@ Is is a cons cell, related to 
`tramp-get-completion-function'."
   "Exit the minibuffer with the selected candidate.
 When ARG is t, exit with current text, ignoring the candidates."
   (interactive "P")
+  (setq ivy-current-prefix-arg current-prefix-arg)
   (cond (arg
          (ivy-immediate-done))
         (ivy--directory
          (ivy--directory-done))
         ((eq (ivy-state-collection ivy-last) 'Info-read-node-name-1)
-         (if (member ivy--current '("(./)" "(../)"))
+         (if (member (ivy-state-current ivy-last) '("(./)" "(../)"))
              (ivy-quit-and-run
               (ivy-read "Go to file: " 'read-file-name-internal
                         :action (lambda (x)
@@ -583,10 +663,16 @@ When ARG is t, exit with current text, ignoring the 
candidates."
        (ivy--exhibit))
       ((and
         (> ivy--length 0)
-        (not (string= ivy--current "./"))
-        (setq dir (ivy-expand-file-if-directory ivy--current)))
+        (not (string= (ivy-state-current ivy-last) "./"))
+        (setq dir (ivy-expand-file-if-directory (ivy-state-current ivy-last))))
        (ivy--cd dir)
        (ivy--exhibit))
+      ((and (not (string= ivy-text ""))
+            (ignore-errors (file-exists-p ivy-text)))
+       (if (file-directory-p ivy-text)
+           (ivy--cd (expand-file-name
+                     (file-name-as-directory ivy-text) ivy--directory))
+         (ivy-done)))
       ((or (and (equal ivy--directory "/")
                 (string-match "\\`[^/]+:.*:.*\\'" ivy-text))
            (string-match "\\`/[^/]+:.*:.*\\'" ivy-text))
@@ -597,8 +683,8 @@ When ARG is t, exit with current text, ignoring the 
candidates."
                         ivy-text))
                       ((string-match
                         "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
-                        ivy--current)
-                       (setq ivy-text ivy--current))))
+                        (ivy-state-current ivy-last))
+                       (setq ivy-text (ivy-state-current ivy-last)))))
            (string-match
             "\\`/\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
             ivy-text))
@@ -671,11 +757,13 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
          (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))))
+                              (if (ivy-state-dynamic-collection ivy-last)
+                                  ivy--all-candidates
+                                (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
@@ -689,11 +777,13 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
            t))))
 
 (defun ivy-immediate-done ()
-  "Exit the minibuffer with the current input."
+  "Exit the minibuffer with current input instead of current candidate."
   (interactive)
   (delete-minibuffer-contents)
-  (insert (setq ivy--current
-                (if ivy--directory
+  (insert (setf (ivy-state-current ivy-last)
+                (if (and ivy--directory
+                         (not (eq (ivy-state-history ivy-last)
+                                  'grep-files-history)))
                     (expand-file-name ivy-text ivy--directory)
                   ivy-text)))
   (setq ivy-exit 'done)
@@ -708,25 +798,26 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
     (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)))))
+      (let ((default-directory (ivy-state-directory 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-state-current ivy-last))
+         :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-local ivy-calling nil
   "When non-nil, call the current action when `ivy--index' changes.")
@@ -849,22 +940,32 @@ If the input is empty, select the previous history 
element instead."
 
 (defun ivy--actionp (x)
   "Return non-nil when X is a list of actions."
-  (and x (listp x) (not (eq (car x) 'closure))))
+  (and x (listp x) (not (memq (car x) '(closure lambda)))))
+
+(defcustom ivy-action-wrap nil
+  "When non-nil, `ivy-next-action' and `ivy-prev-action' wrap."
+  :type 'boolean)
 
 (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))))))
+      (let ((len (1- (length action)))
+            (idx (car action)))
+        (if (>= idx len)
+            (when ivy-action-wrap
+              (setf (car action) 1))
+          (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)
+      (if (<= (car action) 1)
+          (when ivy-action-wrap
+            (setf (car action) (1- (length action))))
         (cl-decf (car action))))))
 
 (defun ivy-action-name ()
@@ -887,26 +988,60 @@ Example use:
      ;; do whatever with str - the corresponding file will not be opened
      )")
 
+(defun ivy-recursive-restore ()
+  (when (and ivy-recursive-last
+             ivy-recursive-restore
+             (not (eq ivy-last ivy-recursive-last)))
+    (ivy--reset-state (setq ivy-last ivy-recursive-last))))
+
 (defun ivy-call ()
   "Call the current action without exiting completion."
   (interactive)
+  (unless
+      (or
+       ;; this is needed for testing in ivy-with which seems to call ivy-call
+       ;; again, and this-command is nil in that case.
+       (null this-command)
+       (memq this-command '(ivy-done
+                            ivy-alt-done
+                            ivy-dispatching-done)))
+    (setq ivy-current-prefix-arg current-prefix-arg))
   (unless ivy-inhibit-action
     (let ((action (ivy--get-action ivy-last)))
       (when action
         (let* ((collection (ivy-state-collection ivy-last))
-               (x (cond ((and (consp collection)
-                              (consp (car collection))
-                              (cdr (assoc ivy--current collection))))
-                        ((equal ivy--current "")
-                         ivy-text)
-                        (t
-                         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)))))))))
+               (x (cond
+                    ;; Alist type.
+                    ((and (consp collection)
+                          (consp (car collection))
+                          ;; Previously, the cdr of the selected
+                          ;; candidate would be returned.  Now, the
+                          ;; whole candidate is returned.
+                          (let (idx)
+                            (if (setq idx (get-text-property
+                                           0 'idx (ivy-state-current 
ivy-last)))
+                                (nth idx collection)
+                              (assoc (ivy-state-current ivy-last)
+                                     collection)))))
+                    (ivy--directory
+                     (expand-file-name
+                      (ivy-state-current ivy-last)
+                      ivy--directory))
+                    ((equal (ivy-state-current ivy-last) "")
+                     ivy-text)
+                    (t
+                     (ivy-state-current ivy-last)))))
+          (if (eq action 'identity)
+              (funcall action x)
+            (select-window (ivy--get-window ivy-last))
+            (prog1 (with-current-buffer (ivy-state-buffer ivy-last)
+                     (unwind-protect (funcall action x)
+                       (ivy-recursive-restore)))
+              (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.
@@ -992,7 +1127,7 @@ If so, move to that directory, while keeping only the file 
name."
                 'ivy-index))))
     (when idx
       (ivy--exhibit)
-      (setq ivy--index idx))))
+      (ivy-set-index idx))))
 
 (defun ivy--cd (dir)
   "When completing file names, move to directory DIR."
@@ -1000,7 +1135,7 @@ If so, move to that directory, while keeping only the 
file name."
       (error "Unexpected")
     (setq ivy--old-cands nil)
     (setq ivy--old-re nil)
-    (setq ivy--index 0)
+    (ivy-set-index 0)
     (setq ivy--all-candidates
           (ivy--sorted-files (setq ivy--directory dir)))
     (setq ivy-text "")
@@ -1130,6 +1265,17 @@ Prioritize directories."
         nil
       (string< x y))))
 
+(declare-function ido-file-extension-lessp "ido")
+
+(defun ivy-sort-file-function-using-ido (x y)
+  "Compare two files X and Y using `ido-file-extensions-order'.
+
+This function is suitable as a replacement for
+`ivy-sort-file-function-default' in `ivy-sort-functions-alist'."
+  (if (and (bound-and-true-p ido-file-extensions-order))
+      (ido-file-extension-lessp x y)
+    (ivy-sort-file-function-default x y)))
+
 (defcustom ivy-sort-functions-alist
   '((read-file-name-internal . ivy-sort-file-function-default)
     (internal-complete-buffer . nil)
@@ -1144,6 +1290,10 @@ 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'.
 
+A list can be used to associate multiple sorting functions with a
+collection. The car of the list is the current sort
+function. This list can be rotated with `ivy-rotate-sort'.
+
 The entry associated with t is used for all fall-through cases.
 
 See also `ivy-sort-max-size'."
@@ -1156,9 +1306,25 @@ See also `ivy-sort-max-size'."
                  (const :tag "Plain sort" string-lessp)
                  (const :tag "File sort" ivy-sort-file-function-default)
                  (const :tag "No sort" nil)
-                 (function :tag "Custom function")))
+                 (function :tag "Custom function")
+                 (repeat (function :tag "Custom function"))))
   :group 'ivy)
 
+(defun ivy--sort-function (collection)
+  "Retrieve sort function from `ivy-sort-functions-alist'"
+  (cdr (assoc collection ivy-sort-functions-alist)))
+
+(defun ivy-rotate-sort ()
+  "Rotate through sorting functions available for current collection.
+This only has an effect if multiple sorting functions are
+specified for the current collection in
+`ivy-sort-functions-alist'."
+  (interactive)
+  (let ((cell (assoc (ivy-state-collection ivy-last) 
ivy-sort-functions-alist)))
+    (when (consp (cdr cell))
+      (setcdr cell `(,@(cddr cell) ,(cadr cell)))
+      (ivy--reset-state ivy-last))))
+
 (defvar ivy-index-functions-alist
   '((swiper . ivy-recompute-index-swiper)
     (swiper-multi . ivy-recompute-index-swiper)
@@ -1193,6 +1359,11 @@ 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-highlight-functions-alist
+  '((ivy--regex-ignore-order . ivy--highlight-ignore-order)
+    (ivy--regex-fuzzy . ivy--highlight-fuzzy))
+  "An alist of highlighting functions for each regex buidler function.")
+
 (defvar ivy-initial-inputs-alist
   '((org-refile . "^")
     (org-agenda-refile . "^")
@@ -1208,17 +1379,20 @@ like.")
   "Sorting won't be done for collections larger than this."
   :type 'integer)
 
-(defun ivy--sorted-files (dir)
+(defun ivy--sorted-files (dir &optional predicate)
   "Return the list of files in DIR.
+When PREDICATE is not nil, use it to filter the result.
 Directories come first."
   (let* ((default-directory dir)
-         (seq (all-completions "" 'read-file-name-internal))
+         (seq (condition-case nil
+                  (all-completions "" 'read-file-name-internal)
+                (error
+                 (directory-files dir))))
          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)))
+      (when (eq (setq sort-fn (ivy--sort-function 'read-file-name-internal))
                 #'ivy-sort-file-function-default)
         (setq seq (mapcar (lambda (x)
                             (propertize x 'dirp (string-match-p "/\\'" x)))
@@ -1227,19 +1401,18 @@ Directories come first."
         (setq seq (cl-sort seq sort-fn)))
       (dolist (dir ivy-extra-directories)
         (push dir seq))
-      seq)))
-
-(defvar ivy-recursive-restore t
-  "When non-nil, restore the above state when exiting the minibuffer.
-This variable is let-bound to nil by functions that take care of
-the restoring themselves.")
+      (if predicate
+          (cl-remove-if-not predicate seq)
+        seq))))
 
 ;;** Entry Point
+;;;###autoload
 (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)
+                      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
@@ -1250,9 +1423,18 @@ escape it with %%. See also `ivy-count-format'.
 COLLECTION is either a list of strings, a function, an alist, or
 a hash table.
 
+PREDICATE is applied to filter out the COLLECTION immediately.
+This argument is for `completing-read' compat.
+
+When REQUIRE-MATCH is non-nil, only members of COLLECTION can be
+selected, i.e. custom text.
+
 If INITIAL-INPUT is not nil, then insert that input in the
 minibuffer initially.
 
+HISTORY is a name of a variable to hold the completion session
+history.
+
 KEYMAP is composed with `ivy-minibuffer-map'.
 
 If PRESELECT is not nil, then select the corresponding candidate
@@ -1308,11 +1490,14 @@ customizations apply to the current completion session."
                           (list (car source) (funcall (car source)))
                           ivy--extra-candidates))))))
       (setq ivy--extra-candidates '((original-source)))))
-  (let ((recursive-ivy-last (and (active-minibuffer-window) ivy-last))
+  (let ((ivy-recursive-last (and (active-minibuffer-window) ivy-last))
         (transformer-fn
          (plist-get ivy--display-transformers-list
                     (or caller (and (functionp collection)
-                                    collection)))))
+                                    collection))))
+        (ivy-display-function
+         (unless (window-minibuffer-p)
+           (cdr (assoc caller ivy-display-functions-alist)))))
     (setq ivy-last
           (make-ivy-state
            :prompt prompt
@@ -1326,6 +1511,7 @@ customizations apply to the current completion session."
            :update-fn update-fn
            :sort sort
            :action action
+           :frame (selected-frame)
            :window (selected-window)
            :buffer (current-buffer)
            :unwind unwind
@@ -1333,6 +1519,7 @@ customizations apply to the current completion session."
            :matcher matcher
            :dynamic-collection dynamic-collection
            :display-transformer-fn transformer-fn
+           :directory default-directory
            :caller caller))
     (ivy--reset-state ivy-last)
     (prog1
@@ -1342,10 +1529,11 @@ customizations apply to the current completion session."
                (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))))
+                      (resize-mini-windows
+                       (cond
+                         ((display-graphic-p) nil)
+                         ((null resize-mini-windows) 'grow-only)
+                         (t resize-mini-windows))))
                  (read-from-minibuffer
                   prompt
                   (ivy-state-initial-input ivy-last)
@@ -1354,27 +1542,28 @@ customizations apply to the current completion session."
                   hist)
                  (when (eq ivy-exit 'done)
                    (let ((item (if ivy--directory
-                                   ivy--current
+                                   (ivy-state-current ivy-last)
                                  ivy-text)))
                      (unless (equal item "")
                        (set hist (cons (propertize item 'ivy-index ivy--index)
                                        (delete item
                                                (cdr (symbol-value hist))))))))
-                 ivy--current))
+                 (ivy-state-current ivy-last)))
           (remove-hook 'post-command-hook #'ivy--exhibit)
+          (ivy-overlay-cleanup)
           (when (setq unwind (ivy-state-unwind ivy-last))
             (funcall unwind))
           (unless (eq ivy-exit 'done)
-            (when recursive-ivy-last
-              (ivy--reset-state (setq ivy-last recursive-ivy-last)))))
+            (ivy-recursive-restore)))
       (ivy-call)
-      (when (and recursive-ivy-last
-                 ivy-recursive-restore)
-        (ivy--reset-state (setq ivy-last recursive-ivy-last))))))
+      (when (> (length (ivy-state-current ivy-last)) 0)
+        (remove-text-properties 0 1 '(idx) (ivy-state-current ivy-last))))))
 
 (defun ivy--reset-state (state)
   "Reset the ivy to STATE.
 This is useful for recursive `ivy-read'."
+  (unless (equal (selected-frame) (ivy-state-frame state))
+    (select-window (active-minibuffer-window)))
   (let ((prompt (or (ivy-state-prompt state) ""))
         (collection (ivy-state-collection state))
         (predicate (ivy-state-predicate state))
@@ -1390,7 +1579,7 @@ This is useful for recursive `ivy-read'."
       (setq initial-input (cdr (assoc this-command
                                       ivy-initial-inputs-alist))))
     (setq ivy--directory nil)
-    (setq ivy-case-fold-search 'auto)
+    (setq ivy-case-fold-search ivy-case-fold-search-default)
     (setq ivy--regex-function
           (or re-builder
               (and (functionp collection)
@@ -1407,6 +1596,15 @@ This is useful for recursive `ivy-read'."
     (setq ivy-text "")
     (setq ivy-calling nil)
     (setq ivy-use-ignore ivy-use-ignore-default)
+    (let (reb)
+      (setq ivy--highlight-function
+            (if (and (eq ivy--regex-function 'swiper--re-builder)
+                     (setq reb (cdr (assoc t ivy-re-builders-alist)))
+                     (setq reb (cdr (assoc reb 
ivy-highlight-functions-alist))))
+                reb
+              (or (cdr (assoc ivy--regex-function
+                              ivy-highlight-functions-alist))
+                  #'ivy--highlight-default))))
     (let (coll sort-fn)
       (cond ((eq collection 'Info-read-node-name-1)
              (if (equal Info-current-file "dir")
@@ -1417,11 +1615,31 @@ This is useful for recursive `ivy-read'."
                                 :test #'equal)))
                (setq coll (all-completions "" collection predicate))))
             ((eq collection 'read-file-name-internal)
-             (if (and initial-input (file-directory-p initial-input))
-                 (progn
-                   (setq ivy--directory initial-input)
-                   (setq initial-input nil))
-               (setq ivy--directory default-directory))
+             (setq ivy--directory default-directory)
+             (when (and initial-input
+                        (not (equal initial-input "")))
+               (cond ((file-directory-p initial-input)
+                      (when (and (eq this-command 'dired-do-copy)
+                                 (equal (file-name-nondirectory initial-input)
+                                        ""))
+                        (setf (ivy-state-preselect state) (setq preselect 
nil)))
+                      (setq ivy--directory initial-input)
+                      (setq initial-input nil)
+                      (when preselect
+                        (let ((preselect-directory
+                               (file-name-directory preselect)))
+                          (when (and preselect-directory
+                                     (not (equal
+                                           (expand-file-name
+                                            preselect-directory)
+                                           (expand-file-name ivy--directory))))
+                            (setf (ivy-state-preselect state)
+                                  (setq preselect nil))))))
+                     ((ignore-errors
+                        (file-exists-p (file-name-directory initial-input)))
+                      (setq ivy--directory (file-name-directory initial-input))
+                      (setf (ivy-state-preselect state)
+                            (file-name-nondirectory initial-input)))))
              (require 'dired)
              (when preselect
                (let ((preselect-directory (file-name-directory preselect)))
@@ -1432,7 +1650,7 @@ This is useful for recursive `ivy-read'."
                  (setf
                   (ivy-state-preselect state)
                   (setq preselect (file-name-nondirectory preselect)))))
-             (setq coll (ivy--sorted-files ivy--directory))
+             (setq coll (ivy--sorted-files ivy--directory predicate))
              (when initial-input
                (unless (or require-match
                            (equal initial-input default-directory)
@@ -1445,10 +1663,27 @@ This is useful for recursive `ivy-read'."
              (setq coll (ivy--buffer-list "" ivy-use-virtual-buffers 
predicate)))
             (dynamic-collection
              (setq coll (funcall collection ivy-text)))
+            ((and (consp collection) (listp (car collection)))
+             (if (and sort (setq sort-fn (ivy--sort-function caller)))
+                 (progn
+                   (setq sort nil)
+                   (setq coll (mapcar #'car
+                                      (cl-sort
+                                       (copy-sequence collection)
+                                       sort-fn))))
+               (setq collection
+                     (setf (ivy-state-collection ivy-last)
+                           (cl-remove-if-not predicate collection)))
+               (setq coll (all-completions "" collection)))
+             (let ((i 0))
+               (ignore-errors
+                 ;; cm can be read-only
+                 (dolist (cm coll)
+                   (add-text-properties 0 1 `(idx ,i) cm)
+                   (cl-incf i)))))
             ((or (functionp collection)
                  (byte-code-function-p collection)
                  (vectorp collection)
-                 (and (consp collection) (listp (car collection)))
                  (hash-table-p collection)
                  (and (listp collection) (symbolp (car collection))))
              (setq coll (all-completions "" collection predicate)))
@@ -1456,17 +1691,17 @@ This is useful for recursive `ivy-read'."
              (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 sort-fn (ivy--sort-function collection)))
+            (when (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 (and (not (eq history 'org-refile-history))
+                     (<= (length coll) ivy-sort-max-size)
+                     (setq sort-fn (ivy--sort-function caller)))
+            (setq coll (cl-sort (copy-sequence coll) sort-fn)))))
       (setq coll (ivy--set-candidates coll))
       (when preselect
-        (unless (or (and require-match
+        (unless (or (not (stringp preselect))
+                    (and require-match
                          (not (eq collection 'internal-complete-buffer)))
                     dynamic-collection
                     (let ((re (regexp-quote preselect)))
@@ -1477,23 +1712,23 @@ This is useful for recursive `ivy-read'."
       (setq ivy--old-cands nil)
       (when (integerp preselect)
         (setq ivy--old-re "")
-        (setq ivy--index preselect))
+        (ivy-set-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))))
+        (ivy-set-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
           (if (region-active-p)
@@ -1501,31 +1736,33 @@ This is useful for recursive `ivy-read'."
                (region-beginning)
                (region-end))
             (ivy-thing-at-point)))
-    (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
-                 prompt)))
+    (setq ivy--prompt (ivy-add-prompt-count prompt))
     (setf (ivy-state-initial-input ivy-last) initial-input)))
 
+(defun ivy-add-prompt-count (prompt)
+  (cond ((string-match "%.*d" prompt)
+         prompt)
+        ((null ivy-count-format)
+         (error
+          "`ivy-count-format' can't be nil.  Set it to \"\" 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
+         prompt)))
+
 ;;;###autoload
 (defun ivy-completing-read (prompt collection
                             &optional predicate require-match initial-input
@@ -1543,37 +1780,38 @@ INITIAL-INPUT is a string 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 (or (assoc this-command ivy-sort-functions-alist)
-                              (assoc t ivy-sort-functions-alist))))
-                (if sort
-                    (cdr sort)
-                  t)))))
+  (let ((handler (assoc this-command ivy-completing-read-handlers-alist)))
+    (if handler
+        (funcall (cdr handler)
+                 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 (and collection 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 t
+                :caller (cond ((called-interactively-p 'any)
+                               this-command)
+                              ((and collection (symbolp collection))
+                               collection))))))
 
 (defvar ivy-completion-beg nil
   "Completion bounds start.")
@@ -1581,32 +1819,56 @@ INHERIT-INPUT-METHOD is currently ignored."
 (defvar ivy-completion-end nil
   "Completion bounds end.")
 
+(declare-function mc/all-fake-cursors "ext:multiple-cursors-core")
+
 (defun ivy-completion-in-region-action (str)
   "Insert STR, erasing the previous one.
 The previous string is between `ivy-completion-beg' and `ivy-completion-end'."
+  (when (consp str)
+    (setq str (cdr str)))
   (when (stringp str)
-    (with-ivy-window
+    (let ((fake-cursors (and (featurep 'multiple-cursors)
+                             (mc/all-fake-cursors)))
+          (pt (point))
+          (beg ivy-completion-beg)
+          (end ivy-completion-end))
       (when ivy-completion-beg
         (delete-region
          ivy-completion-beg
          ivy-completion-end))
       (setq ivy-completion-beg
             (move-marker (make-marker) (point)))
-      (insert str)
+      (insert (substring-no-properties str))
       (setq ivy-completion-end
-            (move-marker (make-marker) (point))))))
+            (move-marker (make-marker) (point)))
+      (save-excursion
+        (dolist (cursor fake-cursors)
+          (goto-char (overlay-start cursor))
+          (delete-region (+ (point) (- beg pt))
+                         (+ (point) (- end pt)))
+          (insert (substring-no-properties str))
+          ;; manually move the fake cursor
+          (move-overlay cursor (point) (1+ (point)))
+          (move-marker (overlay-get cursor 'point) (point))
+          (move-marker (overlay-get cursor 'mark) (point)))))))
 
 (defun ivy-completion-common-length (str)
   "Return the length of the first `completions-common-part' face in STR."
   (let ((pos 0)
-        (len (length str)))
+        (len (length str))
+        face-sym)
     (while (and (<= pos len)
-                (let ((prop (get-text-property pos 'face str)))
+                (let ((prop (or (prog1 (get-text-property
+                                        pos 'face str)
+                                  (setq face-sym 'face))
+                                (prog1 (get-text-property
+                                        pos 'font-lock-face str)
+                                  (setq face-sym 'font-lock-face)))))
                   (not (eq 'completions-common-part
                            (if (listp prop) (car prop) prop)))))
       (setq pos (1+ pos)))
     (if (< pos len)
-        (or (next-single-property-change pos 'face str) len)
+        (or (next-single-property-change pos face-sym str) len)
       0)))
 
 (defun ivy-completion-in-region (start end collection &optional predicate)
@@ -1615,34 +1877,39 @@ The previous string is between `ivy-completion-beg' and 
`ivy-completion-end'."
          (str (buffer-substring-no-properties start end))
          (completion-ignore-case case-fold-search)
          (comps
-          (completion-all-completions str collection predicate (- end start))))
+          (completion-all-completions str collection predicate (- end start)))
+         (ivy--prompts-list (if (window-minibuffer-p)
+                                ivy--prompts-list
+                              '(ivy-completion-in-region (lambda nil)))))
     (if (null comps)
         (message "No matches")
-      (nconc comps nil)
-      (setq ivy-completion-beg (- end (ivy-completion-common-length (car 
comps))))
-      (setq ivy-completion-end end)
-      (if (null (cdr comps))
-          (if (string= str (car comps))
-              (message "Sole match")
-            (setf (ivy-state-window ivy-last) (selected-window))
-            (ivy-completion-in-region-action
-             (substring-no-properties
-              (car comps))))
-        (let* ((w (1+ (floor (log (length comps) 10))))
-               (ivy-count-format (if (string= ivy-count-format "")
-                                     ivy-count-format
-                                   (format "%%-%dd " w)))
-               (prompt (format "(%s): " str)))
-          (and
-           (ivy-read (if (string= ivy-count-format "")
-                         prompt
-                       (replace-regexp-in-string "%" "%%" prompt))
-                     ;; remove 'completions-first-difference face
-                     (mapcar #'substring-no-properties comps)
-                     :predicate predicate
-                     :action #'ivy-completion-in-region-action
-                     :require-match t)
-           t))))))
+      (let ((len (min (ivy-completion-common-length (car comps))
+                      (length str))))
+        (nconc comps nil)
+        (setq ivy-completion-beg (- end len))
+        (setq ivy-completion-end end)
+        (if (null (cdr comps))
+            (if (string= str (car comps))
+                (message "Sole match")
+              (setf (ivy-state-window ivy-last) (selected-window))
+              (ivy-completion-in-region-action
+               (substring-no-properties
+                (car comps))))
+          (let* ((w (1+ (floor (log (length comps) 10))))
+                 (ivy-count-format (if (string= ivy-count-format "")
+                                       ivy-count-format
+                                     (format "%%-%dd " w)))
+                 (prompt (format "(%s): " str)))
+            (and
+             (ivy-read (if (string= ivy-count-format "")
+                           prompt
+                         (replace-regexp-in-string "%" "%%" prompt))
+                       ;; remove 'completions-first-difference face
+                       (mapcar #'substring-no-properties comps)
+                       :predicate predicate
+                       :action #'ivy-completion-in-region-action
+                       :caller 'ivy-completion-in-region)
+             t)))))))
 
 (defcustom ivy-do-completion-in-region t
   "When non-nil `ivy-mode' will set `completion-in-region-function'."
@@ -1686,6 +1953,29 @@ Minibuffer bindings:
 
 ;;* Implementation
 ;;** Regex
+(defun ivy-re-match (re-seq str)
+  "Return non-nil if RE-SEQ matches STR.
+
+RE-SEQ is a list of (RE . MATCH-P).
+
+RE is a regular expression.
+
+MATCH-P is t when RE should match STR and nil when RE should not
+match STR.
+
+Each element of RE-SEQ must match for the funtion to return true.
+
+This concept is used to generalize regular expressions for
+`ivy--regex-plus' and `ivy--regex-ignore-order'."
+  (let ((res t)
+        re)
+    (while (and res (setq re (pop re-seq)))
+      (setq res
+            (if (cdr re)
+                (string-match-p (car re) str)
+              (not (string-match-p (car re) str)))))
+    res))
+
 (defvar ivy--regex-hash
   (make-hash-table :test #'equal)
   "Store pre-computed regex.")
@@ -1758,16 +2048,27 @@ When GREEDY is non-nil, join words in a greedy way."
                             ".*?")))))
                     ivy--regex-hash)))))
 
+(defun ivy--legal-regex-p (str)
+  "Return t if STR is valid regular expression."
+  (condition-case nil
+      (progn
+        (string-match-p str "")
+        t)
+    (invalid-regexp nil)))
+
 (defun ivy--regex-ignore-order--part (str &optional discard)
   "Re-build regex from STR by splitting at spaces.
-Ignore the order of each group."
+Ignore the order of each group. If any substring is not a valid
+regex, treat it as a literal string."
   (let* ((subs (split-string str " +" t))
          (len (length subs)))
     (cl-case len
       (0
        "")
       (t
-       (mapcar (lambda (x) (cons x (not discard)))
+       (mapcar (lambda (s)
+                 (cons (if (ivy--legal-regex-p s) s (regexp-quote s))
+                       (not discard)))
                subs)))))
 
 (defun ivy--regex-ignore-order (str)
@@ -1817,7 +2118,8 @@ Insert .* between each char."
                   (mapconcat
                    (lambda (x)
                      (format "\\(%c\\)" x))
-                   (string-to-list (match-string 2 str)) ".*")
+                   (string-to-list (match-string 2 str))
+                   ".*?")
                   (match-string 3 str))
         (setq ivy--subexps (length (match-string 2 str))))
     str))
@@ -1842,7 +2144,11 @@ depending on the number of candidates."
     (setq truncate-lines t))
   (setq-local max-mini-window-height ivy-height)
   (when ivy-fixed-height-minibuffer
-    (set-window-text-height (selected-window) ivy-height))
+    (set-window-text-height (selected-window)
+                            (+ ivy-height
+                               (if ivy-add-newline-after-prompt
+                                   1
+                                 0))))
   (add-hook 'post-command-hook #'ivy--exhibit nil t)
   ;; show completions with empty input
   (ivy--exhibit))
@@ -1860,9 +2166,39 @@ depending on the number of candidates."
     (goto-char (minibuffer-prompt-end))
     (delete-region (line-end-position) (point-max))))
 
+(defun ivy-cleanup-string (str)
+  "Remove unwanted text properties from STR."
+  (remove-text-properties 0 (length str) '(field) str)
+  str)
+
+(defvar ivy-set-prompt-text-properties-function
+  'ivy-set-prompt-text-properties-default
+  "Function to set the text properties of the default ivy prompt.
+Called with two arguments, PROMPT and STD-PROPS.
+The returned value should be the updated PROMPT.")
+
+(defun ivy-set-prompt-text-properties-default (prompt std-props)
+  (ivy--set-match-props prompt "confirm"
+                        `(face ivy-confirm-face ,@std-props))
+  (ivy--set-match-props prompt "match required"
+                        `(face ivy-match-required-face ,@std-props))
+  prompt)
+
+(defun ivy-prompt ()
+  "Return the current prompt."
+  (let ((fn (plist-get ivy--prompts-list (ivy-state-caller ivy-last))))
+    (if fn
+        (condition-case nil
+            (funcall fn)
+          (error
+           (warn "`counsel-prompt-function' should take 0 args")
+           ;; old behavior
+           (funcall fn (ivy-state-prompt ivy-last))))
+      ivy--prompt)))
+
 (defun ivy--insert-prompt ()
   "Update the prompt according to `ivy--prompt'."
-  (when ivy--prompt
+  (when (setq ivy--prompt (ivy-prompt))
     (unless (memq this-command '(ivy-done ivy-alt-done ivy-partial-or-done
                                  counsel-find-symbol))
       (setq ivy--prompt-extra ""))
@@ -1900,33 +2236,41 @@ depending on the number of candidates."
         (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 ((len-n (length n-str))
+                (len-d (length d-str))
+                (ww (window-width)))
+            (setq n-str
+                  (cond ((> (+ len-n len-d) ww)
+                         (concat n-str "\n" d-str "\n"))
+                        ((> (+ len-n len-d (length ivy-text)) ww)
+                         (concat n-str d-str "\n"))
+                        (t
+                         (concat n-str d-str)))))
           (when ivy-add-newline-after-prompt
             (setq n-str (concat n-str "\n")))
           (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))))
+              (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))
+          (setq n-str (funcall ivy-set-prompt-text-properties-function
+                               n-str 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."
+(defun ivy--set-match-props (str match props &optional subexp)
+  "Set STR text properties for regexp group SUBEXP that match MATCH to PROPS.
+If SUBEXP is nil, the text properties are applied to the whole match."
+  (when (null subexp)
+    (setq subexp 0))
   (when (string-match match str)
     (set-text-properties
-     (match-beginning 0)
-     (match-end 0)
+     (match-beginning subexp)
+     (match-end subexp)
      props
      str)))
 
@@ -1934,17 +2278,12 @@ depending on the number of candidates."
 
 (defun ivy--sort-maybe (collection)
   "Sort COLLECTION if needed."
-  (let ((sort (ivy-state-sort ivy-last))
-        entry)
+  (let ((sort (ivy-state-sort ivy-last)))
     (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))))))
+      (let ((sort-fn (or (and (functionp sort) sort)
+                         (ivy--sort-function (ivy-state-collection ivy-last))
+                         (ivy--sort-function t))))
         (if (functionp sort-fn)
             (cl-sort (copy-sequence collection) sort-fn)
           collection)))))
@@ -1957,19 +2296,31 @@ depending on the number of candidates."
                   (string-match "\\`[[:alpha:]]:/" default-directory))
              (ivy--cd (match-string 0 default-directory))
            (ivy--cd "/")))
+        ((string-match "\\`/ssh:" ivy-text)
+         (ivy--cd (file-name-directory ivy-text)))
         ((string-match "[[:alpha:]]:/\\'" ivy-text)
          (let ((drive-root (match-string 0 ivy-text)))
            (when (file-exists-p drive-root)
              (ivy--cd drive-root))))
+        ((and (file-exists-p ivy-text)
+              (not (string= ivy-text "/"))
+              (file-directory-p ivy-text))
+         (ivy--cd ivy-text))
         ((and (or (> ivy--index 0)
                   (= ivy--length 1)
                   (not (string= ivy-text "/")))
               (let ((default-directory ivy--directory))
                 (and
-                 (not (equal ivy--current ""))
-                 (file-directory-p ivy--current)
-                 (file-exists-p ivy--current))))
-         (ivy--cd (expand-file-name ivy--current ivy--directory)))))
+                 (not (equal (ivy-state-current ivy-last) ""))
+                 (file-directory-p (ivy-state-current ivy-last))
+                 (file-exists-p (ivy-state-current ivy-last)))))
+         (ivy--cd
+          (expand-file-name (ivy-state-current ivy-last) ivy--directory)))))
+
+(defcustom ivy-magic-tilde t
+  "When non-nil, ~ will move home when selecting files.
+Otherwise, ~/ will move home."
+  :type 'boolean)
 
 (defun ivy--exhibit ()
   "Insert Ivy completions display.
@@ -1992,10 +2343,12 @@ Should be run via minibuffer `post-command-hook'."
             (ivy--insert-minibuffer
              (ivy--format ivy--all-candidates))))
       (cond (ivy--directory
-             (if (string-match "/\\'" ivy-text)
-                 (ivy--magic-file-slash)
-               (if (string-match "\\`~\\'" ivy-text)
-                   (ivy--cd (expand-file-name "~/")))))
+             (cond ((or (string= "~/" ivy-text)
+                        (and (string= "~" ivy-text)
+                             ivy-magic-tilde))
+                    (ivy--cd (expand-file-name "~/")))
+                   ((string-match "/\\'" ivy-text)
+                    (ivy--magic-file-slash))))
             ((eq (ivy-state-collection ivy-last) 'internal-complete-buffer)
              (when (or (and (string-match "\\` " ivy-text)
                             (not (string-match "\\` " ivy--old-text)))
@@ -2018,6 +2371,7 @@ Should be run via minibuffer `post-command-hook'."
   "Insert TEXT into minibuffer with appropriate cleanup."
   (let ((resize-mini-windows nil)
         (update-fn (ivy-state-update-fn ivy-last))
+        (old-mark (marker-position (mark-marker)))
         deactivate-mark)
     (ivy--cleanup)
     (when update-fn
@@ -2025,12 +2379,17 @@ Should be run via minibuffer `post-command-hook'."
     (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))))
+      (if ivy-display-function
+          (funcall ivy-display-function text)
+        (let ((buffer-undo-list t))
+          (save-excursion
+            (forward-line 1)
+            (insert text)))))
     (when (display-graphic-p)
-      (ivy--resize-minibuffer-to-fit))))
+      (ivy--resize-minibuffer-to-fit))
+    ;; prevent region growing due to text remove/add
+    (when (region-active-p)
+      (set-mark old-mark))))
 
 (defun ivy--resize-minibuffer-to-fit ()
   "Resize the minibuffer window size to fit the text in the minibuffer."
@@ -2040,9 +2399,11 @@ Should be run via minibuffer `post-command-hook'."
           (let ((text-height (cdr (window-text-pixel-size)))
                 (body-height (window-body-height nil t)))
             (when (> text-height body-height)
-              ;; Note: the size increment needs to be at least 
frame-char-height,
-              ;; otherwise resizing won't do anything.
-              (let ((delta (max (- text-height body-height) 
(frame-char-height))))
+              ;; Note: the size increment needs to be at least
+              ;; frame-char-height, otherwise resizing won't do
+              ;; anything.
+              (let ((delta (max (- text-height body-height)
+                                (frame-char-height))))
                 (window-resize nil delta nil t t))))
         (let ((text-height (count-screen-lines))
               (body-height (window-body-height)))
@@ -2080,18 +2441,22 @@ Should be run via minibuffer `post-command-hook'."
   '(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:
+  "Toggle the case folding between nil and auto/always.
 
-- when the input is all lower case, `case-fold-search' is t
-- otherwise nil.
+If auto, `case-fold-search' is t, when the input is all lower case,
+otherwise nil.
 
-You can toggle this to make `case-fold-search' nil regardless of input."
+If always, `case-fold-search' is always t, regardless of the input.
+
+Otherwise `case-fold-search' is always nil, regardless of the input.
+
+In any completion session, the case folding starts in
+`ivy-case-fold-search-default'."
   (interactive)
   (setq ivy-case-fold-search
         (if ivy-case-fold-search
             nil
-          'auto))
+          (or ivy-case-fold-search-default 'auto)))
   ;; reset cache so that the candidate list updates
   (setq ivy--old-re nil))
 
@@ -2126,7 +2491,8 @@ CANDIDATES are assumed to be static."
              (matcher (ivy-state-matcher ivy-last))
              (case-fold-search
               (and ivy-case-fold-search
-                   (string= name (downcase name))))
+                   (or (eq ivy-case-fold-search 'always)
+                       (string= name (downcase name)))))
              (cands (cond
                       (matcher
                        (funcall matcher re candidates))
@@ -2147,14 +2513,22 @@ CANDIDATES are assumed to be static."
                           ivy--old-cands)))
                       (t
                        (ivy--re-filter re candidates)))))
-        (ivy--recompute-index name re-str cands)
+        (if (memq (cdr (assoc (ivy-state-caller ivy-last)
+                              ivy-index-functions-alist))
+                  '(ivy-recompute-index-swiper
+                    ivy-recompute-index-swiper-async))
+            (progn
+              (ivy--recompute-index name re-str cands)
+              (setq ivy--old-cands (ivy--sort name cands)))
+          (setq ivy--old-cands (ivy--sort name cands))
+          (ivy--recompute-index name re-str ivy--old-cands))
         (setq ivy--old-re
-              (if (eq ivy--regex-function 'ivy--regex-ignore-order)
+              (if (eq ivy--highlight-function 'ivy--highlight-ignore-order)
                   re
-                (if cands
+                (if ivy--old-cands
                     re-str
                   "")))
-        (setq ivy--old-cands (ivy--sort name cands))))))
+        ivy--old-cands))))
 
 (defun ivy--set-candidates (x)
   "Update `ivy--all-candidates' with X."
@@ -2170,7 +2544,9 @@ CANDIDATES are assumed to be static."
                    res))))
     (setq ivy--all-candidates res)))
 
-(defcustom ivy-sort-matches-functions-alist '((t . nil))
+(defcustom ivy-sort-matches-functions-alist
+  '((t . nil)
+    (ivy-switch-buffer . ivy-sort-function-buffer))
   "An alist of functions for sorting matching candidates.
 
 Unlike `ivy-sort-functions-alist', which is used to sort the
@@ -2193,7 +2569,7 @@ The alist VAL is a sorting function with the signature of
            (function :tag "Custom sort function"))))
 
 (defun ivy--sort-files-by-date (_name candidates)
-  "Re-soft CANDIDATES according to file modification date."
+  "Re-sort CANDIDATES according to file modification date."
   (let ((default-directory ivy--directory))
     (cl-sort (copy-sequence candidates)
              (lambda (f1 f2)
@@ -2201,6 +2577,8 @@ The alist VAL is a sorting function with the signature of
                 (nth 5 (file-attributes f2))
                 (nth 5 (file-attributes f1)))))))
 
+(defvar ivy--flx-featurep (require 'flx nil 'noerror))
+
 (defun ivy--sort (name candidates)
   "Re-sort CANDIDATES by NAME.
 All CANDIDATES are assumed to match NAME."
@@ -2208,7 +2586,7 @@ All CANDIDATES are assumed to match NAME."
                  (when (functionp (ivy-state-collection ivy-last))
                    (ivy-state-collection ivy-last))))
         fun)
-    (cond ((and (require 'flx nil 'noerror)
+    (cond ((and ivy--flx-featurep
                 (eq ivy--regex-function 'ivy--regex-fuzzy))
            (ivy--flx-sort name candidates))
           ((setq fun (cdr (or (assoc key ivy-sort-matches-functions-alist)
@@ -2233,62 +2611,100 @@ Prefix matches to NAME are put ahead of the list."
        (nreverse res-prefix)
        (nreverse res-noprefix)))))
 
+(defvar ivy--virtual-buffers nil
+  "Store the virtual buffers alist.")
+
+(defun ivy-sort-function-buffer (name candidates)
+  "Re-sort CANDIDATES, a list of buffer names that contain NAME.
+Sort open buffers before virtual buffers, and prefix matches
+before substring matches."
+  (if (or (string-match "^\\^" name) (string= name ""))
+      candidates
+    (let* ((base-re (funcall ivy--regex-function name))
+           (base-re (if (consp base-re) (caar base-re) base-re))
+           (re-prefix (concat "^\\*" base-re))
+           res-prefix
+           res-noprefix
+           res-virtual-prefix
+           res-virtual-noprefix)
+      (unless (cl-find-if (lambda (s) (string-match re-prefix s)) candidates)
+        (setq re-prefix (concat "^" base-re)))
+      (dolist (s candidates)
+        (cond
+          ((and (assoc s ivy--virtual-buffers) (string-match re-prefix s))
+           (push s res-virtual-prefix))
+          ((assoc s ivy--virtual-buffers)
+           (push s res-virtual-noprefix))
+          ((string-match re-prefix s)
+           (push s res-prefix))
+          (t
+           (push s res-noprefix))))
+      (nconc
+       (nreverse res-prefix)
+       (nreverse res-noprefix)
+       (nreverse res-virtual-prefix)
+       (nreverse res-virtual-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 name) 0)
-                                   (eq ?^ (aref name 0)))
-                              (substring name 1)
-                            name) 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)))
-                  ivy--old-cands
-                  (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)))))
+      (ivy-set-index
+       (or
+        (cl-position (if (and (> (length name) 0)
+                              (eq ?^ (aref name 0)))
+                         (substring name 1)
+                       name) cands
+                       :test #'equal)
+        (and ivy--directory
+             (cl-position
+              (concat re-str "/") cands
+              :test #'equal))
+        (and (eq caller 'ivy-switch-buffer)
+             (> (length name) 0)
+             0)
+        (and (not (string= name ""))
+             (not (and ivy--flx-featurep
+                       (eq ivy--regex-function 'ivy--regex-fuzzy)
+                       (< (length cands) 200)))
+             ivy--old-cands
+             (cl-position (nth ivy--index ivy--old-cands)
+                          cands))
+        (funcall func re-str cands))))
+    (when (or (string= name "")
+              (string= name "^"))
+      (ivy-set-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
-           (1- (length cands))))
-      (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)))))
+  (condition-case nil
+      (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
+               (1- (length cands))))
+          (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 'swiper-line-number c)))
+                  (setq res i))
+                (cl-incf i))
+              res))))
+    (error 0)))
 
 (defun ivy-recompute-index-swiper-async (_re-str cands)
   (if (null ivy--old-cands)
@@ -2335,42 +2751,88 @@ Prefix matches to NAME are put ahead of the list."
 When the amount of matching candidates exceeds this limit, then
 no sorting is done.")
 
+(defun ivy--flx-propertize (x)
+  "X is (cons (flx-score STR ...) STR)."
+  (let ((str (copy-sequence (cdr x)))
+        (i 0)
+        (last-j -2))
+    (dolist (j (cdar x))
+      (unless (eq j (1+ last-j))
+        (cl-incf i))
+      (setq last-j j)
+      (ivy-add-face-text-property
+       j (1+ j)
+       (nth (1+ (mod (+ i 2) (1- (length ivy-minibuffer-faces))))
+            ivy-minibuffer-faces)
+       str))
+    str))
+
 (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) ivy-flx-limit))
-          (let* ((flx-name (if (string-match "^\\^" name)
-                               (substring name 1)
-                             name))
-                 (cands-with-score
-                  (delq nil
-                        (mapcar
-                         (lambda (x)
-                           (let ((score (flx-score x flx-name ivy--flx-cache)))
-                             (and score
-                                  (cons score x))))
-                         cands))))
-            (if cands-with-score
-                (mapcar (lambda (x)
-                          (let ((str (copy-sequence (cdr x)))
-                                (i 0)
-                                (last-j -2))
-                            (dolist (j (cdar x))
-                              (unless (eq j (1+ last-j))
-                                (cl-incf i))
-                              (setq last-j j)
-                              (ivy-add-face-text-property
-                               j (1+ j)
-                               (nth (1+ (mod (+ i 2) (1- (length 
ivy-minibuffer-faces))))
-                                    ivy-minibuffer-faces)
-                               str))
-                            str))
-                        (sort cands-with-score
-                              (lambda (x y)
-                                (> (caar x) (caar y)))))
-              cands))
-        cands)
+      (let* (
+             ;; an optimized regex for fuzzy matching
+             ;; "abc" → "\\`[^a]*a[^b]*b[^c]*c"
+             (fuzzy-regex (if (= (elt name 0) ?^)
+                              (concat "^"
+                                      (regexp-quote (substring name 1 2))
+                                      (mapconcat
+                                       (lambda (x)
+                                         (setq x (string x))
+                                         (concat "[^" x "]*" (regexp-quote x)))
+                                       (substring name 2)
+                                       ""))
+                            (concat "^"
+                                    (mapconcat
+                                     (lambda (x)
+                                       (setq x (string x))
+                                       (concat "[^" x "]*" (regexp-quote x)))
+                                     name
+                                     ""))))
+
+             ;; strip off the leading "^" for flx matching
+             (flx-name (if (string-match "^\\^" name)
+                           (substring name 1)
+                         name))
+
+             (cands-left)
+             (cands-to-sort))
+
+        ;; filter out non-matching candidates
+        (dolist (cand cands)
+          (when (string-match fuzzy-regex cand)
+            (push cand cands-left)))
+
+        ;; pre-sort the candidates by length before partitioning
+        (setq cands-left (sort cands-left
+                               (lambda (c1 c2)
+                                 (< (length c1)
+                                    (length c2)))))
+
+        ;; partition the candidates into sorted and unsorted groups
+        (dotimes (_n (min (length cands-left) ivy-flx-limit))
+          (push (pop cands-left) cands-to-sort))
+
+        (append
+         ;; compute all of the flx scores in one pass and sort
+         (mapcar #'car
+                 (sort (mapcar
+                        (lambda (cand)
+                          (cons cand
+                                (car (flx-score cand
+                                                flx-name
+                                                ivy--flx-cache))))
+                        cands-to-sort)
+                       (lambda (c1 c2)
+                         ;; break ties by length
+                         (if (/= (cdr c1) (cdr c2))
+                             (> (cdr c1)
+                                (cdr c2))
+                           (< (length (car c1))
+                              (length (car c2)))))))
+
+         ;; add the unsorted candidates
+         cands-left))
     (error
      cands)))
 
@@ -2439,48 +2901,65 @@ SEPARATOR is used to join the candidates."
     (font-lock-append-text-property
      start end 'face face str)))
 
-(defun ivy--format-minibuffer-line (str)
+(defun ivy--highlight-ignore-order (str)
+  "Highlight STR, using the ignore-order method."
+  (when (consp ivy--old-re)
+    (let ((i 1))
+      (dolist (re ivy--old-re)
+        (when (string-match (car re) str)
+          (ivy-add-face-text-property
+           (match-beginning 0) (match-end 0)
+           (nth (1+ (mod (+ i 2) (1- (length ivy-minibuffer-faces))))
+                ivy-minibuffer-faces)
+           str))
+        (cl-incf i))))
+  str)
+
+(defun ivy--highlight-fuzzy (str)
+  "Highlight STR, using the fuzzy method."
+  (if ivy--flx-featurep
+      (let ((flx-name (if (string-match "^\\^" ivy-text)
+                          (substring ivy-text 1)
+                        ivy-text)))
+        (ivy--flx-propertize
+         (cons (flx-score str flx-name ivy--flx-cache) str)))
+    (ivy--highlight-default str)))
+
+(defun ivy--highlight-default (str)
+  "Highlight STR, using the default method."
+  (unless ivy--old-re
+    (setq ivy--old-re (funcall ivy--regex-function ivy-text)))
   (let ((start
          (if (and (memq (ivy-state-caller ivy-last)
-                        '(counsel-git-grep counsel-ag counsel-pt))
+                        '(counsel-git-grep counsel-ag counsel-rg counsel-pt))
                   (string-match "^[^:]+:[^:]+:" str))
              (match-end 0)
-           0))
-        (str (copy-sequence str)))
-    (cond ((eq ivy--regex-function 'ivy--regex-ignore-order)
-           (when (consp ivy--old-re)
-             (let ((i 1))
-               (dolist (re ivy--old-re)
-                 (when (string-match (car re) str)
-                   (ivy-add-face-text-property
-                    (match-beginning 0) (match-end 0)
-                    (nth (1+ (mod (+ i 2) (1- (length ivy-minibuffer-faces))))
-                         ivy-minibuffer-faces)
-                    str))
-                 (cl-incf i)))))
-          ((and (eq ivy-display-style 'fancy)
-                (not (eq ivy--regex-function 'ivy--regex-fuzzy)))
-           (unless ivy--old-re
-             (setq ivy--old-re (funcall ivy--regex-function ivy-text)))
-           (ignore-errors
-             (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)))))
-                     (ivy-add-face-text-property
-                      (match-beginning i) (match-end i)
-                      face str))
-                   (cl-incf i)))))))
-    str))
+           0)))
+    (ignore-errors
+      (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)))))
+              (ivy-add-face-text-property
+               (match-beginning i) (match-end i)
+               face str))
+            (cl-incf i))))))
+  str)
+
+(defun ivy--format-minibuffer-line (str)
+  (if (eq ivy-display-style 'fancy)
+      (funcall ivy--highlight-function (copy-sequence str))
+    (copy-sequence str)))
 
 (ivy-set-display-transformer
  'counsel-find-file 'ivy-read-file-transformer)
@@ -2497,9 +2976,9 @@ SEPARATOR is used to join the candidates."
 CANDS is a list of strings."
   (setq ivy--length (length cands))
   (when (>= ivy--index ivy--length)
-    (setq ivy--index (max (1- ivy--length) 0)))
+    (ivy-set-index (max (1- ivy--length) 0)))
   (if (null cands)
-      (setq ivy--current "")
+      (setf (ivy-state-current ivy-last) "")
     (let* ((half-height (/ ivy-height 2))
            (start (max 0 (- ivy--index half-height)))
            (end (min (+ start (1- ivy-height)) ivy--length))
@@ -2507,7 +2986,7 @@ CANDS is a list of strings."
            (cands (cl-subseq cands start end))
            (index (- ivy--index start))
            transformer-fn)
-      (setq ivy--current (copy-sequence (nth index cands)))
+      (setf (ivy-state-current ivy-last) (copy-sequence (nth index cands)))
       (when (setq transformer-fn (ivy-state-display-transformer-fn ivy-last))
         (with-ivy-window
           (setq cands (mapcar transformer-fn cands))))
@@ -2519,9 +2998,6 @@ CANDS is a list of strings."
         (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
@@ -2537,26 +3013,36 @@ CANDS is a list of strings."
   (unless recentf-mode
     (recentf-mode 1))
   (let ((bookmarks (and (boundp 'bookmark-alist)
-                        bookmark-alist))
-        virtual-buffers name)
+                        (copy-sequence bookmark-alist)))
+        virtual-buffers)
     (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)))
+                   (copy-sequence recentf-list)
+                   (delq nil (mapcar
+                              (lambda (bookmark)
+                                (let (file)
+                                  (when (setq file (assoc 'filename bookmark))
+                                    (unless (string= (cdr file)
+                                                     "   - no file -")
+                                      (cons (car bookmark)
+                                            (cdr file))))))
+                              bookmarks))))
+      (let ((file-name (if (stringp head)
+                           head
+                         (cdr head)))
+            name)
+        (setq name
+              (if (eq ivy-virtual-abbreviate 'name)
+                  (file-name-nondirectory file-name)
+                (expand-file-name file-name)))
+        (when (equal name "")
+          (if (consp head)
+              (setq name (car head))
+            (setq name (file-name-nondirectory
+                        (directory-file-name file-name)))))
+        (and (not (equal name ""))
+             (null (get-file-buffer file-name))
+             (not (assoc name virtual-buffers))
+             (push (cons name file-name) virtual-buffers))))
     (when virtual-buffers
       (dolist (comp virtual-buffers)
         (put-text-property 0 (length (car comp))
@@ -2569,6 +3055,11 @@ CANDS is a list of strings."
   "List of regexps or functions matching buffer names to ignore."
   :type '(repeat (choice regexp function)))
 
+(defvar ivy-switch-buffer-faces-alist '((dired-mode . ivy-subdir)
+                                        (org-mode . org-level-4))
+  "Store face customizations for `ivy-switch-buffer'.
+Each KEY is `major-mode', each VALUE is a face name.")
+
 (defun ivy--buffer-list (str &optional virtual predicate)
   "Return the buffers that match STR.
 When VIRTUAL is non-nil, add virtual buffers."
@@ -2577,10 +3068,16 @@ When VIRTUAL is non-nil, add virtual buffers."
     (mapcar
      (lambda (x)
        (if (with-current-buffer x
-             (file-remote-p
-              (abbreviate-file-name default-directory)))
+             (and default-directory
+                  (file-remote-p
+                   (abbreviate-file-name default-directory))))
            (propertize x 'face 'ivy-remote)
-         x))
+         (let ((face (with-current-buffer x
+                       (cdr (assoc major-mode
+                                   ivy-switch-buffer-faces-alist)))))
+           (if face
+               (propertize x 'face face)
+             x))))
      (all-completions str 'internal-complete-buffer predicate))
     (and virtual
          (ivy--virtual-buffers)))))
@@ -2610,6 +3107,80 @@ TREE is a nested list with the following valid cars:
 
 TREE can be nested multiple times to have mulitple window splits.")
 
+(defun ivy-default-view-name ()
+  (let* ((default-view-name
+          (concat "{} "
+                  (mapconcat #'identity
+                             (cl-sort
+                              (mapcar (lambda (w)
+                                        (with-current-buffer (window-buffer w)
+                                          (if (buffer-file-name)
+                                              (file-name-nondirectory
+                                               (buffer-file-name))
+                                            (buffer-name))))
+                                      (window-list))
+                              #'string<)
+                             " ")))
+         (view-name-re (concat "\\`"
+                               (regexp-quote default-view-name)
+                               " \\([0-9]+\\)"))
+         old-view)
+    (cond ((setq old-view
+                 (cl-find-if
+                  (lambda (x)
+                    (string-match view-name-re (car x)))
+                  ivy-views))
+           (format "%s %d"
+                   default-view-name
+                   (1+ (string-to-number
+                        (match-string 1 (car old-view))))))
+          ((assoc default-view-name ivy-views)
+           (concat default-view-name " 1"))
+          (t
+           default-view-name))))
+
+(defun ivy-push-view ()
+  "Push the current window tree on `ivy-views'.
+Currently, the split configuration (i.e. horizonal or vertical)
+and point positions are saved, but the split positions aren't.
+Use `ivy-pop-view' to delete any item from `ivy-views'."
+  (interactive)
+  (let* ((view (cl-labels
+                   ((ft (tr)
+                      (if (consp tr)
+                          (if (eq (car tr) t)
+                              (cons 'vert
+                                    (mapcar #'ft (cddr tr)))
+                            (cons 'horz
+                                  (mapcar #'ft (cddr tr))))
+                        (with-current-buffer (window-buffer tr)
+                          (cond ((buffer-file-name)
+                                 (list 'file (buffer-file-name) (point)))
+                                ((eq major-mode 'dired-mode)
+                                 (list 'file default-directory (point)))
+                                (t
+                                 (list 'buffer (buffer-name) (point))))))))
+                 (ft (car (window-tree)))))
+         (view-name (ivy-read "Name view: " nil
+                              :initial-input (ivy-default-view-name))))
+    (when view-name
+      (push (list view-name view) ivy-views))))
+
+(defun ivy-pop-view-action (view)
+  "Delete VIEW from `ivy-views'."
+  (setq ivy-views (delete view ivy-views))
+  (setq ivy--all-candidates
+        (delete (car view) ivy--all-candidates))
+  (setq ivy--old-cands nil))
+
+(defun ivy-pop-view ()
+  "Delete a view to delete from `ivy-views'."
+  (interactive)
+  (ivy-read "Pop view: " ivy-views
+            :preselect (caar ivy-views)
+            :action #'ivy-pop-view-action
+            :caller 'ivy-pop-view))
+
 (defun ivy-source-views ()
   (mapcar #'car ivy-views))
 
@@ -2620,21 +3191,31 @@ TREE can be nested multiple times to have mulitple 
window splits.")
 
 (defun ivy-set-view-recur (view)
   (cond ((eq (car view) 'vert)
-         (let ((wnd1 (selected-window))
-               (wnd2 (split-window-vertically)))
+         (let* ((wnd1 (selected-window))
+                (wnd2 (split-window-vertically))
+                (views (cdr view))
+                (v (pop views)))
            (with-selected-window wnd1
-             (ivy-set-view-recur (nth 1 view)))
-           (with-selected-window wnd2
-             (ivy-set-view-recur (nth 2 view)))))
+             (ivy-set-view-recur v))
+           (while (setq v (pop views))
+             (with-selected-window wnd2
+               (ivy-set-view-recur v))
+             (when views
+               (setq wnd2 (split-window-vertically))))))
         ((eq (car view) 'horz)
-         (let ((wnd1 (selected-window))
-               (wnd2 (split-window-horizontally)))
+         (let* ((wnd1 (selected-window))
+                (wnd2 (split-window-horizontally))
+                (views (cdr view))
+                (v (pop views)))
            (with-selected-window wnd1
-             (ivy-set-view-recur (nth 1 view)))
-           (with-selected-window wnd2
-             (ivy-set-view-recur (nth 2 view)))))
+             (ivy-set-view-recur v))
+           (while (setq v (pop views))
+             (with-selected-window wnd2
+               (ivy-set-view-recur v))
+             (when views
+               (setq wnd2 (split-window-horizontally))))))
         ((eq (car view) 'file)
-         (let* ((name (cadr view))
+         (let* ((name (nth 1 view))
                 (virtual (assoc name ivy--virtual-buffers))
                 buffer)
            (cond ((setq buffer (get-buffer name))
@@ -2642,11 +3223,17 @@ TREE can be nested multiple times to have mulitple 
window splits.")
                  (virtual
                   (find-file (cdr virtual)))
                  ((file-exists-p name)
-                  (find-file name)))))
+                  (find-file name))))
+         (when (and (> (length view) 2)
+                    (numberp (nth 2 view)))
+           (goto-char (nth 2 view))))
         ((eq (car view) 'buffer)
-         (switch-to-buffer (cadr view)))
+         (switch-to-buffer (nth 1 view))
+         (when (and (> (length view) 2)
+                    (numberp (nth 2 view)))
+           (goto-char (nth 2 view))))
         ((eq (car view) 'sexp)
-         (eval (cadr view)))))
+         (eval (nth 1 view)))))
 
 (defun ivy--switch-buffer-action (buffer)
   "Switch to BUFFER.
@@ -2662,7 +3249,10 @@ BUFFER may be a string or nil."
                (find-file (cdr virtual)))
               (view
                (delete-other-windows)
-               (ivy-set-view-recur (cadr view)))
+               (let (
+                     ;; silence "Directory has changed on disk"
+                     (inhibit-message t))
+                 (ivy-set-view-recur (cadr view))))
               (t
                (switch-to-buffer
                 buffer nil 'force-same-window)))))))
@@ -2695,7 +3285,7 @@ BUFFER may be a string or nil."
     "kill")
    ("j"
     ivy--switch-buffer-other-window-action
-    "other")
+    "other window")
    ("r"
     ivy--rename-buffer-action
     "rename")))
@@ -2756,21 +3346,13 @@ Skip buffers that match `ivy-ignore-buffers'."
   "Switch to another buffer in another window."
   (interactive)
   (ivy-read "Switch to buffer in other window: " 'internal-complete-buffer
+            :matcher #'ivy--switch-buffer-matcher
             :preselect (buffer-name (other-buffer (current-buffer)))
             :action #'ivy--switch-buffer-other-window-action
             :keymap ivy-switch-buffer-map
             :caller 'ivy-switch-buffer-other-window))
 
-;;;###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)))
-            :caller 'ivy-recentf))
+(define-obsolete-function-alias 'ivy-recentf 'counsel-recentf "0.8.0")
 
 (defun ivy-yank-word ()
   "Pull next word from buffer into search string."
@@ -2804,9 +3386,9 @@ 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)))
+           (string-match "/$" (ivy-state-current ivy-last)))
+      (insert (substring (ivy-state-current ivy-last) 0 -1))
+    (insert (ivy-state-current ivy-last))))
 
 (defun ivy-toggle-fuzzy ()
   "Toggle the re builder between `ivy--regex-fuzzy' and `ivy--regex-plus'."
@@ -2849,7 +3431,7 @@ 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 "RET") 'ivy-occur-press-and-switch)
     (define-key map (kbd "j") 'ivy-occur-next-line)
     (define-key map (kbd "k") 'ivy-occur-previous-line)
     (define-key map (kbd "h") 'backward-char)
@@ -2892,7 +3474,8 @@ When `ivy-calling' isn't nil, call `ivy-occur-press'."
 (define-derived-mode ivy-occur-mode fundamental-mode "Ivy-Occur"
   "Major mode for output from \\[ivy-occur].
 
-\\{ivy-occur-mode-map}")
+\\{ivy-occur-mode-map}"
+  (setq-local view-read-only nil))
 
 (defvar ivy-occur-grep-mode-map
   (let ((map (copy-keymap ivy-occur-mode-map)))
@@ -2903,7 +3486,10 @@ When `ivy-calling' isn't nil, call `ivy-occur-press'."
 (define-derived-mode ivy-occur-grep-mode grep-mode "Ivy-Occur"
   "Major mode for output from \\[ivy-occur].
 
-\\{ivy-occur-grep-mode-map}")
+\\{ivy-occur-grep-mode-map}"
+  (setq-local view-read-only nil)
+  (when (fboundp 'wgrep-setup)
+    (wgrep-setup)))
 
 (defvar ivy--occurs-list nil
   "A list of custom occur generators per command.")
@@ -2924,7 +3510,9 @@ When `ivy-calling' isn't nil, call `ivy-occur-press'."
        highlight
        help-echo "mouse-1: call ivy-action")
      str)
-    (insert str "\n")))
+    (insert str "\n"))
+  (goto-char (point-min))
+  (forward-line 4))
 
 (defun ivy-occur ()
   "Stop completion and put the current matches into a new buffer.
@@ -2954,6 +3542,7 @@ There is no limit on the number of *ivy-occur* buffers."
               (funcall occur-fn)
             (ivy-occur-mode)
             (insert (format "%d candidates:\n" (length ivy--old-cands)))
+            (read-only-mode)
             (ivy--occur-insert-lines
              (mapcar
               (lambda (cand) (concat "    " cand))
@@ -2982,11 +3571,13 @@ updated original buffer."
                (error "buffer was killed"))
              (let ((inhibit-read-only t))
                (erase-buffer)
-               (funcall (plist-get ivy--occurs-list caller) t))))
-          ((memq caller '(counsel-git-grep counsel-grep counsel-ag))
+               (funcall (plist-get ivy--occurs-list caller) t)
+               (ivy-occur-grep-mode))))
+          ((memq caller '(counsel-git-grep counsel-grep counsel-ag counsel-rg))
            (let ((inhibit-read-only t))
              (erase-buffer)
-             (funcall (plist-get ivy--occurs-list caller)))))))
+             (funcall (plist-get ivy--occurs-list caller)))))
+    (setq ivy-occur-last ivy-last)))
 
 (declare-function wgrep-change-to-wgrep-mode "ext:wgrep")
 
@@ -3038,7 +3629,7 @@ EVENT gives the mouse position."
           (beginning-of-line)
           (looking-at "\\(?:./\\|    \\)\\(.*\\)$"))
     (when (memq (ivy-state-caller ivy-occur-last)
-                '(swiper counsel-git-grep counsel-grep counsel-ag
+                '(swiper counsel-git-grep counsel-grep counsel-ag counsel-rg
                   counsel-describe-function counsel-describe-variable))
       (let ((window (ivy-state-window ivy-occur-last)))
         (when (or (null (window-live-p window))
@@ -3060,7 +3651,7 @@ EVENT gives the mouse position."
         (funcall action
                  (if (and (consp coll)
                           (consp (car coll)))
-                     (cdr (assoc str coll))
+                     (assoc str coll)
                    str))
         (if (memq (ivy-state-caller ivy-last)
                   '(swiper counsel-git-grep counsel-grep))
@@ -3073,16 +3664,22 @@ EVENT gives the mouse position."
                (selected-window))
               (when (timerp ivy-occur-timer)
                 (cancel-timer ivy-occur-timer))
-              (setq ivy-occur-timer (run-at-time 1.0 nil 
'swiper--cleanup))))))))
-
-(defvar ivy-help-file (let ((default-directory
-                             (if load-file-name
-                                 (file-name-directory load-file-name)
-                               default-directory)))
-                        (if (file-exists-p "ivy-help.org")
-                            (expand-file-name "ivy-help.org")
-                          (if (file-exists-p "doc/ivy-help.org")
-                              (expand-file-name "doc/ivy-help.org"))))
+              (setq ivy-occur-timer
+                    (run-at-time 1.0 nil 'swiper--cleanup))))))))
+
+(defun ivy-occur-press-and-switch ()
+  (interactive)
+  (ivy-occur-press)
+  (select-window (ivy--get-window ivy-occur-last)))
+
+(defconst ivy-help-file (let ((default-directory
+                               (if load-file-name
+                                   (file-name-directory load-file-name)
+                                 default-directory)))
+                          (if (file-exists-p "ivy-help.org")
+                              (expand-file-name "ivy-help.org")
+                            (if (file-exists-p "doc/ivy-help.org")
+                                (expand-file-name "doc/ivy-help.org"))))
   "The file for `ivy-help'.")
 
 (defun ivy-help ()
diff --git a/packages/ivy/swiper.el b/packages/ivy/swiper.el
index 7c99a13..3974326 100644
--- a/packages/ivy/swiper.el
+++ b/packages/ivy/swiper.el
@@ -1,11 +1,11 @@
 ;;; swiper.el --- Isearch with an overview. Oh, man! -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015  Free Software Foundation, Inc.
+;; Copyright (C) 2015-2017  Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel <address@hidden>
 ;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.8.0
-;; Package-Requires: ((emacs "24.1") (ivy "0.8.0"))
+;; Version: 0.9.0
+;; Package-Requires: ((emacs "24.1") (ivy "0.9.0"))
 ;; Keywords: matching
 
 ;; This file is part of GNU Emacs.
@@ -31,11 +31,6 @@
 ;;
 ;; It can double as a quick `regex-builder', although only single
 ;; lines will be matched.
-;;
-;; It also provides `ivy-mode': a global minor mode that uses the
-;; matching back end of `swiper' for all matching on your system,
-;; including file matching. You can use it in place of `ido-mode'
-;; (can't have both on at once).
 
 ;;; Code:
 (require 'ivy)
@@ -77,6 +72,16 @@
   "Only highlight matches for regexps at least this long."
   :type 'integer)
 
+(defcustom swiper-include-line-number-in-search nil
+  "Include line number in text of search candidates."
+  :type 'boolean
+  :group 'swiper)
+
+(defcustom swiper-goto-start-of-match nil
+  "When non-nil, go to the start of the match, not its end."
+  :type 'boolean
+  :group 'swiper)
+
 (defvar swiper-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "M-q") 'swiper-query-replace)
@@ -109,6 +114,28 @@
            (perform-replace from to
                             t t nil)))))))
 
+(defun swiper-all-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 `swiper-all-map'")
+    (let* ((enable-recursive-minibuffers t)
+           (from (ivy--regex ivy-text))
+           (to (query-replace-read-to from "Query replace" t)))
+      (swiper--cleanup)
+      (ivy-exit-with-action
+       (lambda (_)
+         (let ((wnd-conf (current-window-configuration))
+               (inhibit-message t))
+           (unwind-protect
+                (dolist (cand ivy--old-cands)
+                  (let ((buffer (get-text-property 0 'buffer cand)))
+                    (switch-to-buffer buffer)
+                    (goto-char (point-min))
+                    (perform-replace from to t t nil)))
+             (set-window-configuration wnd-conf))))))))
+
 (defvar avy-background)
 (defvar avy-all-windows)
 (defvar avy-style)
@@ -117,6 +144,7 @@
 (declare-function avy--process "ext:avy")
 (declare-function avy--overlay-post "ext:avy")
 (declare-function avy-action-goto "ext:avy")
+(declare-function avy-candidate-beg "ext:avy")
 (declare-function avy--done "ext:avy")
 (declare-function avy--make-backgrounds "ext:avy")
 (declare-function avy-window-list "ext:avy")
@@ -130,12 +158,32 @@
 (defun swiper-avy ()
   "Jump to one of the current swiper candidates."
   (interactive)
+  (unless (require 'avy nil 'noerror)
+    (error "Package avy isn't installed"))
   (unless (string= ivy-text "")
     (let* ((avy-all-windows nil)
+           ;; We'll have overlapping overlays, so we sort all the
+           ;; overlays in the visible region by their start, and then
+           ;; throw out non-Swiper overlays or overlapping Swiper
+           ;; overlays.
+           (visible-overlays (cl-sort (with-ivy-window
+                                        (overlays-in (window-start)
+                                                     (window-end)))
+                                      #'< :key #'overlay-start))
+           (min-overlay-start 0)
+           (overlays-for-avy (cl-remove-if-not
+                              (lambda (ov)
+                                (when (and (>= (overlay-start ov)
+                                               min-overlay-start)
+                                           (memq (overlay-get ov 'face)
+                                                 swiper-faces))
+                                  (setq min-overlay-start (overlay-start ov))))
+                              visible-overlays))
            (candidates (append
-                        (with-ivy-window
-                          (avy--regex-candidates
-                           (ivy--regex ivy-text)))
+                        (mapcar (lambda (ov)
+                                  (cons (overlay-start ov)
+                                        (overlay-get ov 'window)))
+                                overlays-for-avy)
                         (save-excursion
                           (save-restriction
                             (narrow-to-region (window-start) (window-end))
@@ -168,7 +216,7 @@
             (ivy-done)
             (ivy-call))
         (ivy-quit-and-run
-         (avy-action-goto (caar candidate)))))))
+         (avy-action-goto (avy-candidate-beg candidate)))))))
 
 (declare-function mc/create-fake-cursor-at-point "ext:multiple-cursors-core")
 (declare-function multiple-cursors-mode "ext:multiple-cursors-core")
@@ -198,13 +246,17 @@
     (recenter-top-bottom arg)))
 
 (defvar swiper-font-lock-exclude
-  '(package-menu-mode
+  '(bookmark-bmenu-mode
+    package-menu-mode
     gnus-summary-mode
     gnus-article-mode
     gnus-group-mode
     emms-playlist-mode
     emms-stream-mode
     erc-mode
+    forth-mode
+    forth-block-mode
+    nix-mode
     org-agenda-mode
     dired-mode
     jabber-chat-mode
@@ -226,6 +278,9 @@
     twittering-mode
     vc-dir-mode
     rcirc-mode
+    circe-channel-mode
+    circe-server-mode
+    circe-query-mode
     sauron-mode
     w3m-mode)
   "List of major-modes that are incompatible with font-lock-ensure.")
@@ -302,11 +357,15 @@ numbers; replaces calculating the width from buffer line 
count."
                            (buffer-substring
                             (point)
                             (line-end-position)))))))
-              (remove-text-properties 0 (length str) '(field) str)
-              (put-text-property 0 1 'display
-                                 (format swiper--format-spec
-                                         (cl-incf line-number))
-                                 str)
+              (setq str (ivy-cleanup-string str))
+              (let ((line-number-str
+                     (format swiper--format-spec (cl-incf line-number))))
+                (if swiper-include-line-number-in-search
+                    (setq str (concat line-number-str str))
+                  (put-text-property
+                   0 1 'display line-number-str str))
+                (put-text-property
+                 0 1 'swiper-line-number line-number-str str))
               (push str candidates))
             (funcall advancer 1))
           (nreverse candidates))))))
@@ -322,10 +381,12 @@ When non-nil, INITIAL-INPUT is the initial search 
pattern."
   (swiper--ivy (swiper--candidates) initial-input))
 
 (declare-function string-trim-right "subr-x")
+(defvar swiper--current-window-start nil)
 
 (defun swiper-occur (&optional revert)
   "Generate a custom occur buffer for `swiper'.
 When REVERT is non-nil, regenerate the current *ivy-occur* buffer."
+  (require 'subr-x)
   (let* ((buffer (ivy-state-buffer ivy-last))
          (fname (propertize
                  (with-ivy-window
@@ -341,7 +402,7 @@ When REVERT is non-nil, regenerate the current *ivy-occur* 
buffer."
                            fname
                            (propertize
                             (string-trim-right
-                             (get-text-property 0 'display s))
+                             (get-text-property 0 'swiper-line-number s))
                             'face 'compilation-line-number)
                            (substring s 1)))
                  (if (null revert)
@@ -356,6 +417,7 @@ When REVERT is non-nil, regenerate the current *ivy-occur* 
buffer."
     (unless (eq major-mode 'ivy-occur-grep-mode)
       (ivy-occur-grep-mode)
       (font-lock-mode -1))
+    (setq swiper--current-window-start nil)
     (insert (format "-*- mode:grep; default-directory: %S -*-\n\n\n"
                     default-directory))
     (insert (format "%d candidates:\n" (length cands)))
@@ -368,40 +430,59 @@ When REVERT is non-nil, regenerate the current 
*ivy-occur* buffer."
 
 (ivy-set-occur 'swiper 'swiper-occur)
 
-(declare-function evil-jumper--set-jump "ext:evil-jumper")
+(declare-function evil-set-jump "ext:evil-jumps")
 
 (defvar swiper--current-line nil)
 (defvar swiper--current-match-start nil)
+(defvar swiper--point-min nil)
+(defvar swiper--point-max nil)
 
 (defun swiper--init ()
   "Perform initialization common to both completion methods."
   (setq swiper--current-line nil)
   (setq swiper--current-match-start nil)
+  (setq swiper--current-window-start nil)
   (setq swiper--opoint (point))
-  (when (bound-and-true-p evil-jumper-mode)
-    (evil-jumper--set-jump)))
+  (setq swiper--point-min (point-min))
+  (setq swiper--point-max (point-max))
+  (when (bound-and-true-p evil-mode)
+    (evil-set-jump)))
+
+(declare-function char-fold-to-regexp "char-fold")
 
 (defun swiper--re-builder (str)
   "Transform STR into a swiper regex.
 This is the regex used in the minibuffer where candidates have
 line numbers. For the buffer, use `ivy--regex' instead."
-  (replace-regexp-in-string
-   "\t" "    "
-   (cond
-     ((equal str "")
-      "")
-     ((equal str "^")
-      (setq ivy--subexps 0)
-      ".")
-     ((string-match "^\\^" str)
-      (setq ivy--old-re "")
-      (let ((re (ivy--regex-plus (substring str 1))))
-        (if (zerop ivy--subexps)
-            (prog1 (format "^ ?\\(%s\\)" re)
-              (setq ivy--subexps 1))
-          (format "^ %s" re))))
-     (t
-      (ivy--regex-plus str)))))
+  (let* ((re-builder
+          (or (cdr (assoc 'swiper ivy-re-builders-alist))
+              (cdr (assoc t ivy-re-builders-alist))))
+         (re (cond
+               ((equal str "")
+                "")
+               ((equal str "^")
+                (setq ivy--subexps 0)
+                ".")
+               ((string-match "^\\^" str)
+                (setq ivy--old-re "")
+                (let ((re (funcall re-builder (substring str 1))))
+                  (if (zerop ivy--subexps)
+                      (prog1 (format "^ ?\\(%s\\)" re)
+                        (setq ivy--subexps 1))
+                    (format "^ %s" re))))
+               ((eq (bound-and-true-p search-default-mode) 
'char-fold-to-regexp)
+                (mapconcat #'char-fold-to-regexp (ivy--split str) ".*"))
+               (t
+                (funcall re-builder str)))))
+    (cond ((stringp re)
+           (replace-regexp-in-string "\t" "    " re))
+          ((and (consp re)
+                (consp (car re)))
+           (setf (caar re)
+                 (replace-regexp-in-string "\t" "    " (caar re)))
+           re)
+          (t
+           (error "unexpected")))))
 
 (defvar swiper-history nil
   "History for `swiper'.")
@@ -412,7 +493,6 @@ line numbers. For the buffer, use `ivy--regex' instead."
 (defun swiper--ivy (candidates &optional initial-input)
   "Select one of CANDIDATES and move there.
 When non-nil, INITIAL-INPUT is the initial search pattern."
-  (interactive)
   (swiper--init)
   (setq swiper-invocation-face
         (plist-get (text-properties-at (point)) 'face))
@@ -495,12 +575,13 @@ Matched candidates should have `swiper-invocation-face'."
   "Called when `ivy' input is updated."
   (with-ivy-window
     (swiper--cleanup)
-    (when (> (length ivy--current) 0)
-      (let* ((re (replace-regexp-in-string
-                  "    " "\t"
-                  (funcall ivy--regex-function ivy-text)))
+    (when (> (length (ivy-state-current ivy-last)) 0)
+      (let* ((re (funcall ivy--regex-function ivy-text))
              (re (if (stringp re) re (caar re)))
-             (str (get-text-property 0 'display ivy--current))
+             (re (replace-regexp-in-string
+                  "    " "\t"
+                  re))
+             (str (get-text-property 0 'swiper-line-number (ivy-state-current 
ivy-last)))
              (num (if (string-match "^[0-9]+" str)
                       (string-to-number (match-string 0 str))
                     0)))
@@ -509,7 +590,7 @@ Matched candidates should have `swiper-invocation-face'."
             (unless (if swiper--current-line
                         (eq swiper--current-line num)
                       (eq (line-number-at-pos) num))
-              (goto-char (point-min))
+              (goto-char swiper--point-min)
               (if swiper-use-visual-line
                   (line-move (1- num))
                 (forward-line (1- num))))
@@ -527,8 +608,12 @@ Matched candidates should have `swiper-invocation-face'."
                                      (line-end-position))
             (unless (and (>= (point) (window-start))
                          (<= (point) (window-end (ivy-state-window ivy-last) 
t)))
-              (recenter))))
-        (swiper--add-overlays re)))))
+              (recenter))
+            (setq swiper--current-window-start (window-start))))
+        (swiper--add-overlays
+         re
+         (max (window-start) swiper--point-min)
+         (min (window-end (selected-window) t) swiper--point-max))))))
 
 (defun swiper--add-overlays (re &optional beg end wnd)
   "Add overlays for RE regexp in visible part of the current buffer.
@@ -555,35 +640,55 @@ WND, when specified is the window."
                           (point))))
            (end (or end (save-excursion
                           (forward-line wh)
-                          (point)))))
+                          (point))))
+           (case-fold-search (and ivy-case-fold-search
+                                  (string= re (downcase re)))))
       (when (>= (length re) swiper-min-highlight)
         (save-excursion
           (goto-char beg)
           ;; RE can become an invalid regexp
           (while (and (ignore-errors (re-search-forward re end t))
                       (> (- (match-end 0) (match-beginning 0)) 0))
-            (let ((i 0))
-              (while (<= i ivy--subexps)
-                (when (match-beginning i)
-                  (let ((overlay (make-overlay (match-beginning i)
-                                               (match-end i)))
-                        (face
-                         (cond ((zerop ivy--subexps)
-                                (cadr swiper-faces))
-                               ((zerop i)
-                                (car swiper-faces))
-                               (t
-                                (nth (1+ (mod (+ i 2) (1- (length 
swiper-faces))))
-                                     swiper-faces)))))
-                    (push overlay swiper--overlays)
-                    (overlay-put overlay 'face face)
-                    (overlay-put overlay 'window wnd)
-                    (overlay-put overlay 'priority i)))
-                (cl-incf i)))))))))
+            (swiper--add-overlay (match-beginning 0) (match-end 0)
+                                 (if (zerop ivy--subexps)
+                                     (cadr swiper-faces)
+                                   (car swiper-faces))
+                                 wnd 0)
+            (let ((i 1)
+                  (j 0))
+              (while (<= (cl-incf j) ivy--subexps)
+                (let ((bm (match-beginning j))
+                      (em (match-end j)))
+                  (while (and (< j ivy--subexps)
+                              (= em (match-beginning (+ j 1))))
+                    (setq em (match-end (cl-incf j))))
+                  (swiper--add-overlay
+                   bm em
+                   (nth (1+ (mod (+ i 2) (1- (length swiper-faces))))
+                        swiper-faces)
+                   wnd i)
+                  (cl-incf i))))))))))
+
+(defun swiper--add-overlay (beg end face wnd priority)
+  (let ((overlay (make-overlay beg end)))
+    (push overlay swiper--overlays)
+    (overlay-put overlay 'face face)
+    (overlay-put overlay 'window wnd)
+    (overlay-put overlay 'priority priority)))
+
+(defcustom swiper-action-recenter nil
+  "When non-nil, recenter after exiting `swiper'."
+  :type 'boolean)
+(defvar evil-search-module)
+(defvar evil-ex-search-pattern)
+(defvar evil-ex-search-persistent-highlight)
+(defvar evil-ex-search-direction)
+(declare-function evil-ex-search-activate-highlight "evil-ex")
+
 
 (defun swiper--action (x)
   "Goto line X."
-  (let ((ln (1- (read (or (get-text-property 0 'display x)
+  (let ((ln (1- (read (or (get-text-property 0 'swiper-line-number x)
                           (and (string-match ":\\([0-9]+\\):.*\\'" x)
                                (match-string-no-properties 1 x))))))
         (re (ivy--regex ivy-text)))
@@ -593,13 +698,18 @@ WND, when specified is the window."
         (unless (equal (current-buffer)
                        (ivy-state-buffer ivy-last))
           (switch-to-buffer (ivy-state-buffer ivy-last)))
-        (goto-char (point-min))
+        (goto-char swiper--point-min)
         (funcall (if swiper-use-visual-line
                      #'line-move
                    #'forward-line)
                  ln)
-        (re-search-forward re (line-end-position) t)
+        (when (and (re-search-forward re (line-end-position) t) 
swiper-goto-start-of-match)
+          (goto-char (match-beginning 0)))
         (swiper--ensure-visible)
+        (cond (swiper-action-recenter
+               (recenter))
+              (swiper--current-window-start
+               (set-window-start (selected-window) 
swiper--current-window-start)))
         (when (/= (point) swiper--opoint)
           (unless (and transient-mark-mode mark-active)
             (when (eq ivy-exit 'done)
@@ -608,9 +718,15 @@ WND, when specified is the window."
         (add-to-history
          'regexp-search-ring
          re
-         regexp-search-ring-max)))))
+         regexp-search-ring-max)
+        (when (and (bound-and-true-p evil-mode)
+                   (eq evil-search-module 'evil-search))
+          (add-to-history 'evil-ex-search-history re)
+          (setq evil-ex-search-pattern (list re t t))
+          (setq evil-ex-search-direction 'forward)
+          (when evil-ex-search-persistent-highlight
+            (evil-ex-search-activate-highlight evil-ex-search-pattern)))))))
 
-;; (define-key isearch-mode-map (kbd "C-o") 'swiper-from-isearch)
 (defun swiper-from-isearch ()
   "Invoke `swiper' from isearch."
   (interactive)
@@ -635,26 +751,170 @@ WND, when specified is the window."
 Run `swiper' for those buffers."
   (interactive)
   (setq swiper-multi-buffers nil)
-  (ivy-read (swiper-multi-prompt)
-            'internal-complete-buffer
-            :action 'swiper-multi-action-1)
+  (let ((ivy-use-virtual-buffers nil))
+    (ivy-read (swiper-multi-prompt)
+              'internal-complete-buffer
+              :action 'swiper-multi-action-1))
   (ivy-read "Swiper: " swiper-multi-candidates
             :action 'swiper-multi-action-2
             :unwind #'swiper--cleanup
             :caller 'swiper-multi))
 
+(defun swiper-multi-action-1 (x)
+  (if (member x swiper-multi-buffers)
+      (progn
+        (setq swiper-multi-buffers (delete x swiper-multi-buffers)))
+    (unless (equal x "")
+      (setq swiper-multi-buffers (append swiper-multi-buffers (list x)))))
+  (let ((prompt (swiper-multi-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))
+         (setq swiper-multi-candidates
+               (swiper--multi-candidates
+                (mapcar #'get-buffer swiper-multi-buffers))))
+        ((eq this-command 'ivy-call)
+         (with-selected-window (active-minibuffer-window)
+           (delete-minibuffer-contents)))))
+
+(defun swiper-multi-action-2 (x)
+  (when (> (length x) 0)
+    (let ((buffer-name (get-text-property 0 'buffer x)))
+      (when buffer-name
+        (with-ivy-window
+          (switch-to-buffer buffer-name)
+          (goto-char (point-min))
+          (forward-line (1- (read (get-text-property 0 'swiper-line-number 
x))))
+          (re-search-forward
+           (ivy--regex ivy-text)
+           (line-end-position) t)
+          (isearch-range-invisible (line-beginning-position)
+                                   (line-end-position))
+          (unless (eq ivy-exit 'done)
+            (swiper--cleanup)
+            (swiper--add-overlays (ivy--regex ivy-text))))))))
+
+(defun swiper-all-buffer-p (buffer)
+  "Return non-nil if BUFFER should be considered by `swiper-all'."
+  (let ((major-mode (with-current-buffer buffer major-mode)))
+    (cond
+     ;; Ignore TAGS buffers, they tend to add duplicate results.
+     ((eq major-mode #'tags-table-mode) nil)
+     ;; Always consider dired buffers, even though they're not backed
+     ;; by a file.
+     ((eq major-mode #'dired-mode) t)
+     ;; Always consider stash buffers too, as they may have
+     ;; interesting content not present in any buffers. We don't #'
+     ;; quote to satisfy the byte-compiler.
+     ((eq major-mode 'magit-stash-mode) t)
+     ;; Otherwise, only consider the file if it's backed by a file.
+     (t (buffer-file-name buffer)))))
+
+;;* `swiper-all'
+(defun swiper-all-function (str)
+  (if (and (< (length str) 3))
+      (list "" (format "%d chars more" (- 3 (length ivy-text))))
+    (let* ((buffers (cl-remove-if-not #'swiper-all-buffer-p (buffer-list)))
+           (re-full (funcall ivy--regex-function str))
+           re re-tail
+           cands match
+           (case-fold-search
+            (and ivy-case-fold-search
+                 (string= str (downcase str)))))
+      (if (stringp re-full)
+          (setq re re-full)
+        (setq re (caar re-full))
+        (setq re-tail (cdr re-full)))
+      (dolist (buffer buffers)
+        (with-current-buffer buffer
+          (save-excursion
+            (goto-char (point-min))
+            (while (re-search-forward re nil t)
+              (setq match (if (memq major-mode '(org-mode dired-mode))
+                              (buffer-substring-no-properties
+                               (line-beginning-position)
+                               (line-end-position))
+                            (buffer-substring
+                             (line-beginning-position)
+                             (line-end-position))))
+              (put-text-property
+               0 1 'buffer
+               (buffer-name)
+               match)
+              (put-text-property 0 1 'point (point) match)
+              (when (or (null re-tail) (ivy-re-match re-tail match))
+                (push match cands))))))
+      (setq ivy--old-re re-full)
+      (if (null cands)
+          (list "")
+        (setq ivy--old-cands (nreverse cands))))))
+
+(defvar swiper-window-width 80)
+
+(defun swiper--all-format-function (cands)
+  (let* ((ww swiper-window-width)
+         (col2 1)
+         (cands-with-buffer
+          (mapcar (lambda (s)
+                    (let ((buffer (get-text-property 0 'buffer s)))
+                      (setq col2 (max col2 (length buffer)))
+                      (cons s buffer))) cands))
+         (col1 (- ww 4 col2)))
+    (setq cands
+          (mapcar (lambda (x)
+                    (if (cdr x)
+                        (let ((s (ivy--truncate-string (car x) col1)))
+                          (concat
+                           s
+                           (make-string
+                            (max 0
+                                 (- ww (string-width s) (length (cdr x))))
+                            ?\ )
+                           (cdr x)))
+                      (car x)))
+                  cands-with-buffer))
+    (ivy--format-function-generic
+     (lambda (str)
+       (ivy--add-face str 'ivy-current-match))
+     (lambda (str)
+       str)
+     cands
+     "\n")))
+
+(defvar swiper-all-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "M-q") 'swiper-all-query-replace)
+    map)
+  "Keymap for `swiper-all'.")
+
 (defun swiper-all ()
   "Run `swiper' for all opened buffers."
   (interactive)
-  (ivy-read "Swiper: " (swiper--multi-candidates
-                        (cl-remove-if-not
-                         #'buffer-file-name
-                         (buffer-list)))
-            :action 'swiper-multi-action-2
-            :unwind #'swiper--cleanup
-            :update-fn (lambda ()
-                         (swiper-multi-action-2 ivy--current))
-            :caller 'swiper-multi))
+  (let* ((swiper-window-width (- (frame-width) (if (display-graphic-p) 0 1)))
+         (ivy-format-function #'swiper--all-format-function))
+    (ivy-read "swiper-all: " 'swiper-all-function
+              :action 'swiper-all-action
+              :unwind #'swiper--cleanup
+              :update-fn (lambda ()
+                           (swiper-all-action (ivy-state-current ivy-last)))
+              :dynamic-collection t
+              :keymap swiper-all-map
+              :caller 'swiper-multi)))
+
+(defun swiper-all-action (x)
+  (when (> (length x) 0)
+    (let ((buffer-name (get-text-property 0 'buffer x)))
+      (when buffer-name
+        (with-ivy-window
+          (switch-to-buffer buffer-name)
+          (goto-char (get-text-property 0 'point x))
+          (isearch-range-invisible (line-beginning-position)
+                                   (line-end-position))
+          (unless (eq ivy-exit 'done)
+            (swiper--cleanup)
+            (swiper--add-overlays (ivy--regex ivy-text))))))))
 
 (defun swiper--multi-candidates (buffers)
   (let* ((ww (window-width))
@@ -688,38 +948,6 @@ Run `swiper' for those buffers."
         nil))
     res))
 
-(defun swiper-multi-action-1 (x)
-  (if (member x swiper-multi-buffers)
-      (progn
-        (setq swiper-multi-buffers (delete x swiper-multi-buffers)))
-    (unless (equal x "")
-      (setq swiper-multi-buffers (append swiper-multi-buffers (list x)))))
-  (let ((prompt (swiper-multi-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))
-         (setq swiper-multi-candidates
-               (swiper--multi-candidates
-                (mapcar #'get-buffer swiper-multi-buffers))))
-        ((eq this-command 'ivy-call)
-         (delete-minibuffer-contents))))
-
-(defun swiper-multi-action-2 (x)
-  (let ((buf-space (get-text-property (1- (length x)) 'display x)))
-    (with-ivy-window
-      (when (string-match "\\` *\\([^ ]+\\)\\'" buf-space)
-        (switch-to-buffer (match-string 1 buf-space))
-        (goto-char (point-min))
-        (forward-line (1- (read (get-text-property 0 'display x))))
-        (re-search-forward
-         (ivy--regex ivy-text)
-         (line-end-position) t)
-        (unless (eq ivy-exit 'done)
-          (swiper--cleanup)
-          (swiper--add-overlays (ivy--regex ivy-text)))))))
-
 (provide 'swiper)
 
 ;;; swiper.el ends here
diff --git a/targets/obsolete-config.el b/targets/obsolete-config.el
new file mode 100644
index 0000000..8d79b70
--- /dev/null
+++ b/targets/obsolete-config.el
@@ -0,0 +1,4 @@
+(add-to-list 'load-path default-directory)
+(require 'counsel)
+(setq counsel-prompt-function 'counsel-prompt-function-default)
+(byte-compile-file (expand-file-name "targets/obsolete-config.el"))



reply via email to

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