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

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

[elpa] externals/ivy a39971a 1/4: Merge branch 'master' into externals/i


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy a39971a 1/4: Merge branch 'master' into externals/ivy
Date: Tue, 9 Mar 2021 14:39:17 -0500 (EST)

branch: externals/ivy
commit a39971a242f0d07b5e98d4eda39df0fdde4ee914
Merge: aeaa5d4 e005666
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Merge branch 'master' into externals/ivy
---
 .dir-locals.el                                     |    2 +-
 .elpaignore                                        |   19 +-
 .travis.yml                                        |    6 +-
 CONTRIBUTING.org                                   |    1 +
 Makefile                                           |    8 +-
 README.md                                          |    1 +
 colir.el                                           |    2 +-
 doc/Changelog.org                                  |  508 ++++-
 doc/ivy-ox.el                                      |    2 +-
 doc/ivy.org                                        |   32 +-
 doc/ivy.texi                                       |   41 +-
 doc/scripts.el                                     |    2 +-
 ivy-faces.el                                       |  138 ++
 ivy-hydra.el                                       |  133 --
 ivy-overlay.el                                     |   21 +-
 ivy-test.el                                        |  393 +++-
 ivy.el                                             | 2055 +++++++++++---------
 .../single-match-directories/a/file_in_a.txt       |    0
 .../single-match-directories/ba/file_in_ba.txt     |    0
 19 files changed, 2213 insertions(+), 1151 deletions(-)

diff --git a/.dir-locals.el b/.dir-locals.el
index 3d5e818..4e7d231 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -8,7 +8,7 @@
   (sentence-end-double-space . t))
  (emacs-lisp-mode
   (indent-tabs-mode . nil)
-  (outline-regexp . ";;[;*]+[\s\t]+")
+  (outline-regexp . ";;\\([;*]+ [^\s\t\n]\\|###autoload\\)\\|(")
   ;; extra config here: 
https://github.com/abo-abo/oremacs/blob/github/modes/ora-elisp-style-guide.el
   ;; (lisp-indent-function . common-lisp-indent-function)
   ))
diff --git a/.elpaignore b/.elpaignore
index 0f36850..d48618b 100644
--- a/.elpaignore
+++ b/.elpaignore
@@ -1,6 +1,15 @@
-doc/ivy-help.org
-doc/Changelog.org
-doc/gpl-3.0.txt
-doc/fdl-1.3.txt
-ivy-test.el
+.github
+targets
 tests
+
+CONTRIBUTING.org
+Makefile
+elpa.el
+ivy-test.el
+
+doc/Makefile
+doc/fdl-1.3.txt
+doc/gpl-3.0.txt
+doc/ivy.org
+doc/ivy-ox.el
+doc/scripts.el
diff --git a/.travis.yml b/.travis.yml
index a050e89..07570b1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,15 +1,13 @@
 language: emacs-lisp
 env:
-  - EVM_EMACS=emacs-24.3-travis
   - EVM_EMACS=emacs-24.5-travis
   - EVM_EMACS=emacs-25.3-travis
-  - EVM_EMACS=emacs-26.2-travis
-  - EVM_EMACS=emacs-git-snapshot-travis
+  - EVM_EMACS=emacs-26.3-travis-linux-xenial
+  - EVM_EMACS=emacs-git-snapshot-travis-linux-xenial
 
 before_install:
   - 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
 
diff --git a/CONTRIBUTING.org b/CONTRIBUTING.org
index 8d30208..6fcc727 100644
--- a/CONTRIBUTING.org
+++ b/CONTRIBUTING.org
@@ -49,6 +49,7 @@ warning:
 
 Before submitting a change, run:
 - =make compile= - check for new compilation warnings
+- =make deps= - install dependencies for testing
 - =make test= - check for failing tests
 - =make checkdoc= - check documentation guidelines
 
diff --git a/Makefile b/Makefile
index 8cf9c54..c5ee6c3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,4 @@
 emacs ?= emacs
-elmake = $(emacs) -batch -l makefi.el -f
 
 LOAD = -l elpa.el -l colir.el -l ivy-overlay.el -l ivy.el -l swiper.el -l 
counsel.el
 RM ?= rm -f
@@ -16,18 +15,15 @@ checkdoc:
        $(emacs) -batch -l targets/checkdoc.el
 
 compile:
-       $(emacs) -batch -L . -f batch-byte-compile colir.el ivy-overlay.el 
ivy.el swiper.el counsel.el
+       $(emacs) -batch -l elpa.el -L . -f batch-byte-compile colir.el 
ivy-faces.el ivy-overlay.el ivy.el ivy-avy.el swiper.el counsel.el
 
 plain:
        $(emacs) --version
-       $(emacs) -Q $(LOAD) -l targets/plain.el
+       $(emacs) -Q -l elpa.el -l targets/plain.el
 
 obsolete:
        $(emacs) -batch -l targets/obsolete-config.el
 
-update-issues:
-       $(elmake) update-issues
-
 clean:
        $(RM) *.elc
 
diff --git a/README.md b/README.md
index 658504f..f1ce587 100644
--- a/README.md
+++ b/README.md
@@ -61,6 +61,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> o") 'counsel-describe-symbol)
 (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)
diff --git a/colir.el b/colir.el
index 9e61273..09b4f5c 100644
--- a/colir.el
+++ b/colir.el
@@ -1,6 +1,6 @@
 ;;; colir.el --- Color blending library -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2019  Free Software Foundation, Inc.
+;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel <ohwoeowho@gmail.com>
 
diff --git a/doc/Changelog.org b/doc/Changelog.org
index 587997b..3557215 100644
--- a/doc/Changelog.org
+++ b/doc/Changelog.org
@@ -1,6 +1,6 @@
 #+TITLE: Ivy CHANGELOG
 #+OPTIONS: H:4 num:nil toc:3
-#+SETUPFILE: ~/git/org-html-themes/setup/theme-readtheorg.setup
+#+SETUPFILE: ~/git/Emacs/org-html-themes/setup/theme-readtheorg.setup
 #+HTML_HEAD: <link rel="stylesheet" type="text/css" href="css/kbd-style.css"/>
 
 * 0.6.0
@@ -4710,7 +4710,7 @@ Make swiper occur wgrep work for narrowed buffers. See 
[[https://github.com/abo-
 
 Don't setq-local el:ivy--directory. See 
[[https://github.com/abo-abo/swiper/issues/1866][#1866]].
 
-Don't hightlight the file name part. See 
[[https://github.com/abo-abo/swiper/issues/2073][#2073]].
+Don't highlight the file name part. See 
[[https://github.com/abo-abo/swiper/issues/2073][#2073]].
 
 Fix missing line numbers. See 
[[https://github.com/abo-abo/swiper/issues/2076][#2076]].
 
@@ -5193,3 +5193,507 @@ See 
[[https://github.com/abo-abo/swiper/issues/2132][#2132]].
 :END:
 See [[https://github.com/abo-abo/swiper/issues/2125][#2125]].
 -----
+* 0.13.0
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0
+:END:
+-----
+** Fixes
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fixes
+:END:
+-----
+*** counsel--async-last-command
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel--async-last-command
+:END:
+New variable. Store the last command ran by el:counsel--async-command.
+-----
+*** counsel--async-last-error-string
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel--async-last-error-string
+:END:
+New variable. If a command that relies on el:counsel--async-command returns 
non-0, store
+the output here. See [[https://github.com/abo-abo/swiper/issues/2160][#2160]].
+-----
+*** counsel-cd
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel-cd
+:END:
+Fix for el:counsel-ag. See 
[[https://github.com/abo-abo/swiper/issues/2261][#2261]].
+-----
+*** counsel-compile
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel-compile
+:END:
+Delete duplicates. Favor project root over el:default-directory. See 
[[https://github.com/abo-abo/swiper/issues/2253][#2253]].
+-----
+*** counsel-compile-env-pattern
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel-compile-env-pattern
+:END:
+Fix regex typo. See [[https://github.com/abo-abo/swiper/issues/2193][#2193]].
+-----
+*** counsel-file-jump
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel-file-jump
+:END:
+Use temp buffer instead of el:split-string. See 
[[https://github.com/abo-abo/swiper/issues/2120][#2120]].
+
+Make el:counsel--find-return-list work with or without the "./" prefix. See 
[[https://github.com/abo-abo/swiper/issues/2196][#2196]].
+-----
+*** counsel-git-grep-action
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel-git-grep-action
+:END:
+Check the result of el:re-search-forward. See 
[[https://github.com/abo-abo/swiper/issues/2209][#2209]].
+-----
+*** counsel-imenu
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel-imenu
+:END:
+Work with =:update-fn 'auto=. See 
[[https://github.com/abo-abo/swiper/issues/2188][#2188]].
+-----
+*** counsel-locate-cmd-es
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel-locate-cmd-es
+:END:
+Encode the command to local codepage. See 
[[https://github.com/abo-abo/swiper/issues/2278][#2278]].
+-----
+*** counsel-mark-ring
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel-mark-ring
+:END:
+Refactor. See [[https://github.com/abo-abo/swiper/issues/2237][#2237]].
+
+Add the latest mark to selection. See 
[[https://github.com/abo-abo/swiper/issues/2252][#2252]].
+
+Go to actual point instead of line. See 
[[https://github.com/abo-abo/swiper/issues/2254][#2254]].
+
+Fix highlight line. See 
[[https://github.com/abo-abo/swiper/issues/2255][#2255]].
+
+Handle read-only strings. See 
[[https://github.com/abo-abo/swiper/issues/2258][#2258]], 
[[https://github.com/abo-abo/swiper/issues/2262][#2262]].
+-----
+*** counsel-M-x
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel-m-x
+:END:
+Respect el:counsel-describe-function-function. See 
[[https://github.com/abo-abo/swiper/issues/2251][#2251]].
+-----
+*** counsel--py-action
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel--py-action
+:END:
+Don't auto-insert parens. See 
[[https://github.com/abo-abo/swiper/issues/2229][#2229]].
+-----
+*** counsel-rg-base-command
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-counsel-rg-base-command
+:END:
+Don't include directory on non-Windows. See  
[[https://github.com/abo-abo/swiper/issues/795][#795]], 
[[https://github.com/abo-abo/swiper/issues/2180][#2180]].
+
+Ensure =/= is the path-separator on Windows. See 
[[https://github.com/abo-abo/swiper/issues/2279][#2279]].
+-----
+*** Documentation
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-documentation
+:END:
+=ivy.info= is not installed from GNU ELPA. See 
[[https://github.com/abo-abo/swiper/issues/697][#697]].
+
+Fix typo. See [[https://github.com/abo-abo/swiper/issues/2170][#2170]].
+
+Fix el:ivy-read docstring. See 
[[https://github.com/abo-abo/swiper/issues/2201][#2201]].
+
+Add full text of licences. See 
[[https://github.com/abo-abo/swiper/issues/2206][#2206]].
+
+Document the marking feature. See 
[[https://github.com/abo-abo/swiper/issues/2214][#2214]].
+
+Update GFDL licence. See 
[[https://github.com/abo-abo/swiper/issues/2187][#2187]].
+
+Ivy now requires at least Emacs-24.5 (released on 2015-04-10). Up from 
Emacs-24.1
+(released 2012-06-10).
+-----
+*** hydra-ivy
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-hydra-ivy
+:END:
+Use el:ivy-read-action-by-key. See 
[[https://github.com/abo-abo/swiper/issues/2239][#2239]], 
[[https://github.com/abo-abo/swiper/issues/2250][#2250]].
+-----
+*** ivy
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy
+:END:
+Lazy load el:ffap. See 
[[https://github.com/abo-abo/swiper/issues/2215][#2215]].
+-----
+*** ivy-completion-in-region
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy-completion-in-region
+:END:
+Add workaround for el:package-menu-filter. See 
[[https://github.com/abo-abo/swiper/issues/2244][#2244]].
+-----
+*** ivy--directory-done
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy--directory-done
+:END:
+Handle ~/ C-j~ on remote. See 
[[https://github.com/abo-abo/swiper/issues/2205][#2205]].
+-----
+*** ivy-dispatching-done-hydra
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy-dispatching-done-hydra
+:END:
+Fix for el:ivy-resume. Modify the action list non-desctructively. See 
[[https://github.com/abo-abo/swiper/issues/2195][#2195]].
+-----
+*** ivy--done
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy--done
+:END:
+Check if given a string. See 
[[https://github.com/abo-abo/swiper/issues/2200][#2200]].
+-----
+*** ivy-immediate-done
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy-immediate-done
+:END:
+Add el:copy-sequence to fix el:read-directory-name. See 
[[https://github.com/abo-abo/swiper/issues/1170][#1170]], 
[[https://github.com/abo-abo/swiper/issues/2149][#2149]], 
[[https://github.com/abo-abo/swiper/issues/2165][#2165]].
+
+Fix for when ~C-j~ changed cwd. See 
[[https://github.com/abo-abo/swiper/issues/2165][#2165]].
+
+Fix parent dirs for el:read-directory-name. See 
[[https://github.com/abo-abo/swiper/issues/2165][#2165]], 
[[https://github.com/abo-abo/swiper/issues/2198][#2198]].
+-----
+*** ivy--input
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy--input
+:END:
+Fix point moving in TRAMP sessions sometimes. See 
[[https://github.com/abo-abo/swiper/issues/2160][#2160]].
+
+Fix for el:ediff. See [[https://github.com/abo-abo/swiper/issues/2175][#2175]].
+-----
+*** ivy--magic-file-slash
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy--magic-file-slash
+:END:
+Make less aggressive. Check that the prompt is not selected before performing 
the
+ivy-magic-slash-non-match-cd-selected action. See 
[[https://github.com/abo-abo/swiper/issues/2240][#2240]].
+-----
+*** ivy-occur
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy-occur
+:END:
+Set up for el:next-error. See 
[[https://github.com/abo-abo/swiper/issues/1354][#1354]], 
[[https://github.com/abo-abo/swiper/issues/2257][#2257]].
+-----
+*** ivy-occur-revert-buffer
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy-occur-revert-buffer
+:END:
+Don't error if the el:swiper buffer was killed.
+-----
+*** ivy-overlay-show-after
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy-overlay-show-after
+:END:
+Check window height better. See 
[[https://github.com/abo-abo/swiper/issues/2161][#2161]].
+-----
+*** ivy-partial
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy-partial
+:END:
+Fix trailing space issue. See 
[[https://github.com/abo-abo/swiper/issues/2103][#2103]].
+
+Use el:ivy--filter in place of el:all-completions. See 
[[https://github.com/abo-abo/swiper/issues/2199][#2199]].
+-----
+*** ivy-read
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy-read
+:END:
+Fix conflict with an existing el:read-key session. See 
[[https://github.com/abo-abo/swiper/issues/2230][#2230]].
+-----
+*** ivy-resume
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy-resume
+:END:
+Restore use-ignore setting. See 
[[https://github.com/abo-abo/swiper/issues/2179][#2179]].
+-----
+*** ivy-yank-word
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-ivy-yank-word
+:END:
+Handle case fold. See [[https://github.com/abo-abo/swiper/issues/2194][#2194]].
+-----
+*** swiper
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-swiper
+:END:
+Fix overlay faces using el:ivy--regex-ignore-order. See 
[[https://github.com/abo-abo/swiper/issues/2162][#2162]].
+
+Fix symbol bounds with el:char-fold-to-regexp. See 
[[https://github.com/abo-abo/swiper/issues/2177][#2177]].
+-----
+*** swiper-isearch
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-swiper-isearch
+:END:
+Improve matching. See [[https://github.com/abo-abo/swiper/issues/2154][#2154]].
+
+Fix for el:ivy-resume. See 
[[https://github.com/abo-abo/swiper/issues/2153][#2153]], 2154.
+
+Make el:swiper-isearch-function work with el:ivy--regex-ignore-order. See 
[[https://github.com/abo-abo/swiper/issues/2155][#2155]].
+
+Fix return value. See [[https://github.com/abo-abo/swiper/issues/2163][#2163]].
+
+Fix regexes for el:ivy--regex-ignore-order. See 
[[https://github.com/abo-abo/swiper/issues/2164][#2164]].
+
+Fix scroll on ~RET~. See 
[[https://github.com/abo-abo/swiper/issues/2159][#2159]].
+
+Set el:case-fold-search. See 
[[https://github.com/abo-abo/swiper/issues/2226][#2226]].
+-----
+*** swiper-isearch-action
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-swiper-isearch-action
+:END:
+Make el:ivy-previous-line-or-history work. See 
[[https://github.com/abo-abo/swiper/issues/2158][#2158]].
+-----
+*** swiper-occur
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-swiper-occur
+:END:
+Fix for el:wgrep. See [[https://github.com/abo-abo/swiper/issues/2156][#2156]].
+-----
+*** swiper-query-replace
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-swiper-query-replace
+:END:
+For for "^$" search term. See 
[[https://github.com/abo-abo/swiper/issues/2232][#2232]].
+-----
+*** swiper-recenter-top-bottom
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-swiper-recenter-top-bottom
+:END:
+Now works for el:swiper-isearch.
+-----
+*** swiper-thing-at-point
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-swiper-thing-at-point
+:END:
+Fix for el:swiper-isearch. See 
[[https://github.com/abo-abo/swiper/issues/2157][#2157]].
+-----
+*** Tests
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-fx-tests
+:END:
+Keep the test files in worktree instead of in a =test= branch. See 
[[https://github.com/abo-abo/swiper/issues/2187][#2187]].
+
+Fix tests using file names on Windows. See 
[[https://github.com/abo-abo/swiper/issues/2217][#2217]].
+-----
+** New Features
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-new-features
+:END:
+-----
+*** counsel-dired
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-counsel-dired
+:END:
+Filter to directories only. See 
[[https://github.com/abo-abo/swiper/issues/2275][#2275]].
+-----
+*** counsel-dired-jump-args
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-counsel-dired-jump-args
+:END:
+The variable is now a list. See 
[[https://github.com/abo-abo/swiper/issues/2120][#2120]].
+-----
+*** counsel-file-jump-args
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-counsel-file-jump-args
+:END:
+The variable is now a list. See 
[[https://github.com/abo-abo/swiper/issues/2120][#2120]].
+-----
+*** counsel-find-file
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-counsel-find-file
+:END:
+Use =~~= to move to the local home directory from remote.  Using =/ RET ~= is 
still an option,
+but more cumbersome. This also works for =/sudo::=. See 
[[https://github.com/abo-abo/swiper/issues/2276][#2276]].
+
+Use el:file-name-at-point-functions. See 
[[https://github.com/abo-abo/swiper/issues/1446][#1446]], 
[[https://github.com/abo-abo/swiper/issues/2181][#2181]], 
[[https://github.com/abo-abo/swiper/issues/2184][#2184]].
+
+Use el:dired-current-directory if in el:dired. See 
[[https://github.com/abo-abo/swiper/issues/2274][#2274]].
+
+Bind ~M-o R~ to el:find-file-read-only. See 
[[https://github.com/abo-abo/swiper/issues/2236][#2236]].
+-----
+*** counsel-find-file-mkdir-action
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-counsel-find-file-mkdir-action
+:END:
+Make parents too. See [[https://github.com/abo-abo/swiper/issues/2178][#2178]].
+-----
+*** counsel-git-grep
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-counsel-git-grep
+:END:
+Use ~C-x C-d~ to switch current directory. See 
[[https://github.com/abo-abo/swiper/issues/2259][#2259]].
+
+Works with el:ivy--regex-fuzzy. el:ivy-occur works as well. See 
[[https://github.com/abo-abo/swiper/issues/2243][#2243]].
+
+Nicer message when no match was found. See 
[[https://github.com/abo-abo/swiper/issues/2265][#2265]].
+-----
+*** counsel-M-x
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-counsel-m-x
+:END:
+Propertize names of active modes with el:counsel-active-mode. See 
[[https://github.com/abo-abo/swiper/issues/2189][#2189]], 
[[https://github.com/abo-abo/swiper/issues/2258][#2258]].
+
+Some commands are intended to be called only via their key binding. Make them 
disappear
+from el:counsel-M-x like this:
+#+begin_src elisp
+(put 'counsel-find-symbol 'no-counsel-M-x t)
+#+end_src
+See [[https://github.com/abo-abo/swiper/issues/2270][#2270]].
+-----
+*** counsel-package
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-counsel-package
+:END:
+Refresh contents automatically.
+-----
+*** counsel-rg
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-counsel-rg
+:END:
+Ivy will add "-i" appropriately, based on el:ivy-case-fold-search-default.
+You should remove the "-S" flag from el:counsel-rg-base-command if you 
customized it.
+
+When in el:dired, operate on marked files. This also applies to ivy-occur 
buffers of
+el:counsel-find-file and el:counsel-git.
+-----
+*** counsel-switch-buffer
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-counsel-switch-buffer
+:END:
+Add actions. See [[https://github.com/abo-abo/swiper/issues/2233][#2233]].
+-----
+*** ivy-configure
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-ivy-configure
+:END:
+New function to configure many things at once. Example:
+#+begin_src elisp
+(ivy-configure 'counsel-find-file
+  :occur #'counsel-find-file-occur
+  :display-transformer-fn #'ivy-read-file-transformer)
+#+end_src
+Instead of configuring many alists separately using the =:caller= key of 
el:ivy-read,
+configure everything together.
+-----
+*** ivy-ffap-url-functions
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-ivy-ffap-url-functions
+:END:
+Add el:vc-git-log-view-mode.
+-----
+*** ivy-partial
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-ivy-partial
+:END:
+Obey el:completion-cycle-threshold. See 
[[https://github.com/abo-abo/swiper/issues/2225][#2225]].
+-----
+*** ivy-partial-or-done
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-ivy-partial-or-done
+:END:
+Work with el:completion-cycle-threshold. See 
[[https://github.com/abo-abo/swiper/issues/2225][#2225]].
+If you set this to an integer, and the amount of candidates is less than that 
number,
+pressing ~TAB~ will cycle to the next candidate.
+-----
+*** ivy-pre-prompt-function
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-ivy-pre-prompt-function
+:END:
+When non-nil, add strings before the el:ivy-read prompt. See 
[[https://github.com/abo-abo/swiper/issues/2185][#2185]].
+-----
+*** ivy-read
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-ivy-read
+:END:
+New API for asynchronous calls. See 
[[https://github.com/abo-abo/swiper/issues/2263][#2263]].
+
+To use it, pass to el:ivy-read: =:dynamic-collection t=, and a collection 
function that
+takes a user input string, starts some asynchronous process based on that 
input, and
+returns 0. The 0 return result tells Ivy that no candidates were returned; 
instead,
+el:ivy-update-candidates is used in the async callback.
+
+See el:counsel-google for a reference implementation.
+-----
+*** ivy-read-action-function
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-ivy-read-action-function
+:END:
+New defcustom that allows you to read the action via: key, or Ivy, or Hydra. 
See [[https://github.com/abo-abo/swiper/issues/2176][#2176]].
+-----
+*** ivy-restrict-to-matches
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-ivy-restrict-to-matches
+:END:
+Work for dynamic collection. See 
[[https://github.com/abo-abo/swiper/issues/2168][#2168]].
+-----
+*** ivy-update-fns-alist
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-ivy-update-fns-alist
+:END:
+Allow to customize =:update-fn=. See 
[[https://github.com/abo-abo/swiper/issues/2188][#2188]].
+Example:
+#+begin_src elisp
+(ivy-configure 'counsel-imenu
+  :update-fn 'auto)
+#+end_src
+-----
+*** ivy-use-virtual-buffers
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-ivy-use-virtual-buffers
+:END:
+Allow to choose between: recent files, or bookmarks, or both, or none. See 
[[https://github.com/abo-abo/swiper/issues/2169][#2169]], 
[[https://github.com/abo-abo/swiper/issues/2172][#2172]].
+-----
+*** swiper-goto-start-of-match
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-swiper-goto-start-of-match
+:END:
+Also works for el:counsel-grep and el:counsel-git-grep. See 
[[https://github.com/abo-abo/swiper/issues/2209][#2209]].
+-----
+*** swiper-isearch
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nf-swiper-isearch
+:END:
+Bind ~M-o w~ to copy the current line.
+-----
+** New Commands
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-new-commands
+:END:
+-----
+*** counsel-buffer-or-recentf
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nc-counsel-buffer-or-recentf
+:END:
+Lists buffers visiting files (highlighted) then the recentf file list. See 
[[https://github.com/abo-abo/swiper/issues/2182][#2182]].
+-----
+*** counsel-fonts
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nc-counsel-fonts
+:END:
+Show a list of all supported font families for a particular frame. See 
[[https://github.com/abo-abo/swiper/issues/2220][#2220]].
+-----
+*** counsel-google
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nc-counsel-google
+:END:
+Asynchronously query the Google predictive search API.
+-----
+*** counsel-major
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nc-counsel-major
+:END:
+Switch el:major-mode. See 
[[https://github.com/abo-abo/swiper/issues/378][#378]].
+-----
+*** counsel-slime-repl-history
+:PROPERTIES:
+:CUSTOM_ID: 0.13.0-nc-counsel-slime-repl-history
+:END:
+Browse Slime REPL history. See 
[[https://github.com/abo-abo/swiper/issues/2234][#2234]].
+-----
diff --git a/doc/ivy-ox.el b/doc/ivy-ox.el
index 22ab7a4..09e345f 100644
--- a/doc/ivy-ox.el
+++ b/doc/ivy-ox.el
@@ -1,6 +1,6 @@
 ;;; ivy-ox.el --- org-export settings for Ivy -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2018  Free Software Foundation, Inc.
+;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel
 
diff --git a/doc/ivy.org b/doc/ivy.org
index a49569d..6589dfb 100644
--- a/doc/ivy.org
+++ b/doc/ivy.org
@@ -58,7 +58,7 @@ ivy-ox.el then ~C-c C-e i t~ in the ivy.org buffer.
 :CUSTOM_ID: copying
 :END:
 #+TEXINFO: @ifnottex
-Ivy manual, version 0.12.0
+Ivy manual, version 0.13.2
 
 Ivy is an interactive interface for completion in Emacs. Emacs uses
 completion mechanism in a variety of contexts: code, menus, commands,
@@ -70,7 +70,7 @@ final candidate is either through simple keyboard character 
inputs or
 through powerful regular expressions.
 #+TEXINFO: @end ifnottex
 
-Copyright (C) 2015-2019 Free Software Foundation, Inc.
+Copyright (C) 2015--2021 Free Software Foundation, Inc.
 
 #+BEGIN_QUOTE
 Permission is granted to copy, distribute and/or modify this document
@@ -148,15 +148,18 @@ version that runs Ivy with fancy faces display.
 :CUSTOM_ID: installing-from-emacs-package-manager
 :END:
 
-~M-x~ =package-install= ~RET~ =ivy= ~RET~
+~M-x~ =package-install= ~RET~ =counsel= ~RET~
 
-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.
+Ivy is installed as part of the =counsel= package, which is available
+from two different package archives, GNU ELPA and MELPA.  For the
+latest stable version, use the GNU ELPA archives.  For current hourly
+builds, use the MELPA archives.
+
+Ivy is split into three packages: =ivy=, =swiper= and =counsel=; by
+installing =counsel=, the other two are brought in as dependencies.
+If you are not interested in the extra functionality provided by
+=swiper= and =counsel=, you can install only =ivy=.
 
-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
@@ -402,13 +405,17 @@ extends usability of lists in Emacs.
 :END:
 
 For repeatedly applying multiple actions or acting on multiple
-candidates, Ivy does not close the minibuffer between commands. It
+candidates, Ivy does not close the minibuffer between commands.  It
 keeps the minibuffer open for applying subsequent actions.
 
 Adding an extra meta key to the normal key chord invokes the special
 version of the regular commands that enables applying multiple
 actions.
 
+Note that these operations are supported only by completion sessions
+that use the =ivy-read= API, rather than the built-in
+=completing-read=.
+
 - ~C-M-m~ (=ivy-call=) ::
      Is the non-exiting version of ~C-m~ (=ivy-done=).
 
@@ -445,6 +452,7 @@ actions.
      exit.
 
      Useful after an accidental ~C-m~ (=ivy-done=).
+     Use it with =universal-argument= to resume any previous session.
 
 *** Key bindings that alter the minibuffer input
 :PROPERTIES:
@@ -824,6 +832,8 @@ installed.
      The default behavior is to quit the completion after ~DEL~ -- a
      handy key to invoke after mistakenly triggering a completion.
 
+     Another common option is =ignore=, which does nothing.
+
 ** Actions
 :PROPERTIES:
 :CUSTOM_ID: actions
@@ -1024,6 +1034,8 @@ bindings that work here:
 - ~/~ (=self-insert-command=) ::
      If the current input matches an existing directory name exactly,
      switch the completion to that directory.
+- ~C-M-y~ (=ivy-insert-current-full=) ::
+     Insert the current full path, in case you want to edit a part of it.
 - ~M-r~ (=ivy-toggle-regexp-quote=) ::
      Toggle between input as regexp or not.
 
diff --git a/doc/ivy.texi b/doc/ivy.texi
index 1b4a3b9..a31f420 100644
--- a/doc/ivy.texi
+++ b/doc/ivy.texi
@@ -8,7 +8,7 @@
 
 @copying
 @ifnottex
-Ivy manual, version 0.12.0
+Ivy manual, version 0.13.2
 
 Ivy is an interactive interface for completion in Emacs. Emacs uses
 completion mechanism in a variety of contexts: code, menus, commands,
@@ -20,7 +20,7 @@ final candidate is either through simple keyboard character 
inputs or
 through powerful regular expressions.
 @end ifnottex
 
-Copyright (C) 2015-2019 Free Software Foundation, Inc.
+Copyright (C) 2015--2021 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -29,6 +29,7 @@ or any later version published by the Free Software 
Foundation;
 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
 A copy of the license is included in the section entitled "GNU
 Free Documentation License".
+
 @end quotation
 @end copying
 
@@ -214,15 +215,18 @@ version that runs Ivy with fancy faces display.
 @node Installing from Emacs Package Manager
 @section Installing from Emacs Package Manager
 
-@kbd{M-x} @code{package-install} @kbd{RET} @code{ivy} @kbd{RET}
+@kbd{M-x} @code{package-install} @kbd{RET} @code{counsel} @kbd{RET}
+
+Ivy is installed as part of the @code{counsel} package, which is available
+from two different package archives, GNU ELPA and MELPA@.  For the
+latest stable version, use the GNU ELPA archives.  For current hourly
+builds, use the MELPA archives.
 
-Ivy is installed as part of @code{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.
+Ivy is split into three packages: @code{ivy}, @code{swiper} and 
@code{counsel}; by
+installing @code{counsel}, the other two are brought in as dependencies.
+If you are not interested in the extra functionality provided by
+@code{swiper} and @code{counsel}, you can install only @code{ivy}.
 
-For current hourly builds, use the MELPA archives. In MELPA, Ivy is
-split into three packages: @code{ivy}, @code{swiper} and @code{counsel}; you 
can simply
-install @code{counsel} which will bring in the other two as dependencies.
 See the code below for adding MELPA to the list of package archives:
 
 @lisp
@@ -513,13 +517,17 @@ keystrokes followed by @kbd{C-m}.
 @subsection Key bindings for multiple selections and actions, keep minibuffer 
open
 
 For repeatedly applying multiple actions or acting on multiple
-candidates, Ivy does not close the minibuffer between commands. It
+candidates, Ivy does not close the minibuffer between commands.  It
 keeps the minibuffer open for applying subsequent actions.
 
 Adding an extra meta key to the normal key chord invokes the special
 version of the regular commands that enables applying multiple
 actions.
 
+Note that these operations are supported only by completion sessions
+that use the @code{ivy-read} API, rather than the built-in
+@code{completing-read}.
+
 @subsubheading @kbd{C-M-m} (@code{ivy-call})
 @vindex ivy-call
 @kindex C-M-m
@@ -570,6 +578,7 @@ Recalls the state of the completion session just before its 
last
 exit.
 
 Useful after an accidental @kbd{C-m} (@code{ivy-done}).
+Use it with @code{universal-argument} to resume any previous session.
 @end indentedblock
 
 @node Key bindings that alter the minibuffer input
@@ -1097,6 +1106,8 @@ i.e., when @kbd{DEL} is typed at the beginning of the 
minibuffer.
 
 The default behavior is to quit the completion after @kbd{DEL} -- a
 handy key to invoke after mistakenly triggering a completion.
+
+Another common option is @code{ignore}, which does nothing.
 @end defopt
 
 @node Actions
@@ -1356,6 +1367,12 @@ Switch to the home directory.
 If the current input matches an existing directory name exactly,
 switch the completion to that directory.
 @end indentedblock
+@subsubheading @kbd{C-M-y} (@code{ivy-insert-current-full})
+@vindex ivy-insert-current-full
+@kindex C-M-y
+@indentedblock
+Insert the current full path, in case you want to edit a part of it.
+@end indentedblock
 @subsubheading @kbd{M-r} (@code{ivy-toggle-regexp-quote})
 @vindex ivy-toggle-regexp-quote
 @kindex M-r
@@ -1801,12 +1818,12 @@ then retrieves that value and displays it.
 @end itemize
 
 @node Variable Index
-@unnumbered Variable Index
+@chapter Variable Index
 
 @printindex vr
 
 @node Keystroke Index
-@unnumbered Keystroke Index
+@chapter Keystroke Index
 
 @printindex ky
 
diff --git a/doc/scripts.el b/doc/scripts.el
index edde14c..23bf461 100644
--- a/doc/scripts.el
+++ b/doc/scripts.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2020  Free Software Foundation, Inc.
+;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
 (setq org-confirm-babel-evaluate nil)
 (defun org-to-texi (fname)
   (find-file fname)
diff --git a/ivy-faces.el b/ivy-faces.el
new file mode 100644
index 0000000..bedb9cb
--- /dev/null
+++ b/ivy-faces.el
@@ -0,0 +1,138 @@
+;;; ivy-faces.el --- Faces for Ivy -*- lexical-binding: t -*-
+
+;; Copyright (C) 2020-2021 Free Software Foundation, Inc.
+
+;; Author: Oleh Krehel <ohwoeowho@gmail.com>
+;; 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 <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; Code:
+
+(defgroup ivy-faces nil
+  "Font-lock faces for `ivy'."
+  :group 'ivy
+  :group 'faces)
+
+(defface ivy-current-match
+  '((((class color) (background light))
+     :background "#1a4b77" :foreground "white" :extend t)
+    (((class color) (background dark))
+     :background "#65a7e2" :foreground "black" :extend t))
+  "Face used by Ivy for highlighting the current match.")
+
+(defface ivy-minibuffer-match-highlight
+  '((t :inherit highlight))
+  "Face used by Ivy for highlighting the match under the cursor.")
+
+(defface ivy-minibuffer-match-face-1
+  '((((class color) (background light))
+     :background "#d3d3d3")
+    (((class color) (background dark))
+     :background "#555555"))
+  "The background face for `ivy' minibuffer matches.")
+
+(defface ivy-minibuffer-match-face-2
+  '((((class color) (background light))
+     :background "#e99ce8" :weight bold)
+    (((class color) (background dark))
+     :background "#777777" :weight bold))
+  "Face for `ivy' minibuffer matches numbered 1 modulo 3.")
+
+(defface ivy-minibuffer-match-face-3
+  '((((class color) (background light))
+     :background "#bbbbff" :weight bold)
+    (((class color) (background dark))
+     :background "#7777ff" :weight bold))
+  "Face for `ivy' minibuffer matches numbered 2 modulo 3.")
+
+(defface ivy-minibuffer-match-face-4
+  '((((class color) (background light))
+     :background "#ffbbff" :weight bold)
+    (((class color) (background dark))
+     :background "#8a498a" :weight bold))
+  "Face for `ivy' minibuffer matches numbered 3 modulo 3.")
+
+(defface ivy-confirm-face
+  '((t :foreground "ForestGreen" :inherit minibuffer-prompt))
+  "Face used by Ivy for a confirmation prompt.")
+
+(defface ivy-match-required-face
+  '((t :foreground "red" :inherit minibuffer-prompt))
+  "Face used by Ivy for a match required prompt.")
+
+(defface ivy-subdir
+  '((t :inherit dired-directory))
+  "Face used by Ivy for highlighting subdirs in the alternatives.")
+
+(defface ivy-org
+  '((t :inherit org-level-4))
+  "Face used by Ivy for highlighting Org buffers in the alternatives.")
+
+(defface ivy-modified-buffer
+  '((t :inherit default))
+  "Face used by Ivy for highlighting modified file visiting buffers.")
+
+(defface ivy-modified-outside-buffer
+  '((t :inherit default))
+  "Face used by Ivy for highlighting file visiting buffers modified outside 
Emacs.")
+
+(defface ivy-remote
+  '((((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
+  '((t :inherit font-lock-builtin-face))
+  "Face used by Ivy for matching virtual buffer names.")
+
+(defface ivy-action
+  '((t :inherit font-lock-builtin-face))
+  "Face used by Ivy for displaying keys in `ivy-read-action'.")
+
+(defface ivy-highlight-face
+  '((t :inherit highlight))
+  "Face used by Ivy to highlight certain candidates.")
+
+(defface ivy-prompt-match
+  '((t :inherit ivy-current-match))
+  "Face used by Ivy for highlighting the selected prompt line.")
+
+(defface ivy-separator
+  '((t :inherit font-lock-doc-face))
+  "Face for multiline source separator.")
+
+(defface ivy-grep-info
+  '((t :inherit compilation-info))
+  "Face for highlighting grep information such as file names.")
+
+(defface ivy-grep-line-number
+  '((t :inherit compilation-line-number))
+  "Face for displaying line numbers in grep messages.")
+
+(defface ivy-completions-annotations
+  '((t :inherit completions-annotations))
+  "Face for displaying completion annotations.")
+
+(defface ivy-yanked-word
+  '((t :inherit highlight))
+  "Face used to highlight yanked word.")
+
+(provide 'ivy-faces)
+
+;;; ivy-faces.el ends here
diff --git a/ivy-hydra.el b/ivy-hydra.el
deleted file mode 100644
index ce31f2b..0000000
--- a/ivy-hydra.el
+++ /dev/null
@@ -1,133 +0,0 @@
-;;; ivy-hydra.el --- Additional key bindings for Ivy  -*- lexical-binding: t 
-*-
-
-;; Copyright (C) 2015-2019  Free Software Foundation, Inc.
-
-;; Author: Oleh Krehel <ohwoeowho@gmail.com>
-;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.13.0
-;; Package-Requires: ((emacs "24.5") (ivy "0.13.0") (hydra "0.15.0"))
-;; Keywords: convenience
-
-;; This file is part of GNU Emacs.
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; For a full copy of the GNU General Public License
-;; see <https://www.gnu.org/licenses/>.
-
-;;; Commentary:
-
-;; This package provides the `hydra-ivy/body' command, which is a
-;; quasi-prefix map, with many useful bindings.  These bindings are
-;; shorter than usual, using mostly unprefixed keys.
-
-;;; Code:
-
-(require 'ivy)
-(require 'hydra)
-
-(defun ivy--matcher-desc ()
-  "Return description of `ivy--regex-function'."
-  (let ((cell (assq ivy--regex-function ivy-preferred-re-builders)))
-    (if cell
-        (cdr cell)
-      "other")))
-
-(defhydra hydra-ivy (:hint nil
-                     :color pink)
-  "
-^ ^ ^ ^ ^ ^ | ^Call^      ^ ^  | ^Cancel^ | ^Options^ | Action _w_/_s_/_a_: 
%-14s(ivy-action-name)
-^-^-^-^-^-^-+-^-^---------^-^--+-^-^------+-^-^-------+-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------
-^ ^ _k_ ^ ^ | _f_ollow occ_U_r | _i_nsert | _c_: calling %-5s(if ivy-calling 
\"on\" \"off\") _C_ase-fold: %-10`ivy-case-fold-search
-_h_ ^+^ _l_ | _d_one      ^ ^  | _o_ops   | _M_: matcher 
%-5s(ivy--matcher-desc)^^^^^^^^^^^^ _T_runcate: %-11`truncate-lines
-^ ^ _j_ ^ ^ | _g_o        ^ ^  | ^ ^      | _<_/_>_: 
shrink/grow^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _D_efinition of this menu
-"
-  ;; arrows
-  ("h" ivy-beginning-of-buffer)
-  ("j" ivy-next-line)
-  ("k" ivy-previous-line)
-  ("l" ivy-end-of-buffer)
-  ;; mark
-  ("m" ivy-mark)
-  ("u" ivy-unmark)
-  ("DEL" ivy-unmark-backward)
-  ("t" ivy-toggle-marks)
-  ;; actions
-  ("o" keyboard-escape-quit :exit t)
-  ("r" ivy-dispatching-done-hydra :exit t)
-  ("C-g" keyboard-escape-quit :exit t)
-  ("i" nil)
-  ("C-o" nil)
-  ("f" ivy-alt-done :exit nil)
-  ("C-j" ivy-alt-done :exit nil)
-  ("d" ivy-done :exit t)
-  ("g" ivy-call)
-  ("C-m" ivy-done :exit t)
-  ("c" ivy-toggle-calling)
-  ("M" ivy-rotate-preferred-builders)
-  (">" ivy-minibuffer-grow)
-  ("<" ivy-minibuffer-shrink)
-  ("w" ivy-prev-action)
-  ("s" ivy-next-action)
-  ("a" (let ((ivy-read-action-function #'ivy-read-action-by-key))
-         (ivy-read-action)))
-  ("T" (setq truncate-lines (not truncate-lines)))
-  ("C" ivy-toggle-case-fold)
-  ("U" ivy-occur :exit t)
-  ("D" (ivy-exit-with-action
-        (lambda (_) (find-function 'hydra-ivy/body)))
-       :exit t))
-
-(defvar ivy-dispatching-done-columns 2
-  "Number of columns to use if the hint does not fit on one line.")
-
-(defvar ivy-dispatching-done-idle nil
-  "When non-nil, the hint will be delayed by this many seconds.")
-
-(defvar ivy-dispatching-done-hydra-exit-keys '(("M-o" nil "back")
-                                               ("C-g" nil))
-  "Keys that can be used to exit `ivy-dispatching-done-hydra'.")
-
-(defun ivy-dispatching-done-hydra ()
-  "Select one of the available actions and call `ivy-done'."
-  (interactive)
-  (let* ((actions (ivy-state-action ivy-last))
-         (extra-actions ivy-dispatching-done-hydra-exit-keys)
-         (doc (concat "action: "
-                      (mapconcat
-                       (lambda (x) (format "[%s] %s" (nth 0 x) (nth 2 x)))
-                       (append (cdr actions)
-                               extra-actions) ", ")))
-         (estimated-len (length doc))
-         (n-columns (if (> estimated-len (window-width))
-                        ivy-dispatching-done-columns
-                      nil))
-         (i 0))
-    (if (null (ivy--actionp actions))
-        (ivy-done)
-      (funcall
-       (eval
-        `(defhydra ivy-read-action (:color teal :columns ,n-columns :idle 
,ivy-dispatching-done-idle)
-           "action"
-           ,@(mapcar (lambda (x)
-                       (list (nth 0 x)
-                             `(progn
-                                (setcar (ivy-state-action ivy-last) ,(cl-incf 
i))
-                                (ivy-done))
-                             (nth 2 x)))
-                     (cdr actions))
-           ,@extra-actions))))))
-
-(setq ivy-read-action-function (lambda (_) (ivy-dispatching-done-hydra)))
-
-(provide 'ivy-hydra)
-
-;;; ivy-hydra.el ends here
diff --git a/ivy-overlay.el b/ivy-overlay.el
index 7a77bcf..f537358 100644
--- a/ivy-overlay.el
+++ b/ivy-overlay.el
@@ -1,6 +1,6 @@
 ;;; ivy-overlay.el --- Overlay display functions for Ivy  -*- lexical-binding: 
t -*-
 
-;; Copyright (C) 2016-2019  Free Software Foundation, Inc.
+;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel <ohwoeowho@gmail.com>
 ;; Keywords: convenience
@@ -26,6 +26,9 @@
 
 ;;; Code:
 
+(eval-when-compile
+  (require 'subr-x))
+
 (defface ivy-cursor
   '((((class color) (background light))
      :background "black" :foreground "white")
@@ -73,7 +76,7 @@ Then attach the overlay to the character before point."
       (progn
         (move-overlay ivy-overlay-at (1- (point)) (line-end-position))
         (overlay-put ivy-overlay-at 'invisible nil))
-    (let ((available-height (count-lines (point) (window-end nil t))))
+    (let ((available-height (- (window-height) (count-lines (window-start) 
(point)) 1)))
       (unless (>= available-height ivy-height)
         (recenter (- (window-height) ivy-height 2))))
     (setq ivy-overlay-at (make-overlay (1- (point)) (line-end-position)))
@@ -90,11 +93,9 @@ Then attach the overlay to the character before point."
 (defvar ivy-last)
 (defvar ivy-text)
 (defvar ivy-completion-beg)
-(declare-function ivy-add-face-text-property "ivy")
 (declare-function ivy--get-window "ivy")
 (declare-function ivy-state-current "ivy")
 (declare-function ivy-state-window "ivy")
-(declare-function ivy--remove-prefix "ivy")
 
 (defun ivy-overlay-impossible-p (_str)
   (or
@@ -115,8 +116,8 @@ Hide the minibuffer contents and cursor."
         (save-excursion
           (forward-line 1)
           (insert str)))
-    (ivy-add-face-text-property (minibuffer-prompt-end) (point-max)
-                                '(:foreground "white"))
+    (add-face-text-property (minibuffer-prompt-end) (point-max)
+                            '(:foreground "white"))
     (setq cursor-type nil)
     (with-selected-window (ivy--get-window ivy-last)
       (when cursor-type
@@ -132,21 +133,21 @@ Hide the minibuffer contents and cursor."
               (and (> (length str) 0)
                    (list "\n"
                          (ivy-left-pad
-                          (ivy--remove-prefix "\n" str)
+                          (string-remove-prefix "\n" str)
                           (+
                            (if (and (eq major-mode 'org-mode)
                                     (bound-and-true-p org-indent-mode))
                                (if (org-at-heading-p)
                                    (1- (org-current-level))
-                                 (* org-indent-indentation-per-level 
(org-current-level)))
+                                 (* org-indent-indentation-per-level (or 
(org-current-level) 1)))
                              0)
                            (save-excursion
                              (when ivy-completion-beg
                                (goto-char ivy-completion-beg))
                              (current-column)))))))))
         (let ((cursor-offset (1+ (length ivy-text))))
-          (ivy-add-face-text-property cursor-offset (1+ cursor-offset)
-                                      'ivy-cursor overlay-str t))
+          (add-face-text-property cursor-offset (1+ cursor-offset)
+                                  'ivy-cursor t overlay-str))
         (ivy-overlay-show-after overlay-str)))))
 
 (provide 'ivy-overlay)
diff --git a/ivy-test.el b/ivy-test.el
index c15cf2f..2062b81 100644
--- a/ivy-test.el
+++ b/ivy-test.el
@@ -1,6 +1,6 @@
 ;;; ivy-test.el --- tests for ivy -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2019  Free Software Foundation, Inc.
+;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel
 
@@ -26,29 +26,39 @@
 
 ;;; Code:
 
-(defvar require-features nil)
+(defvar ivy-empty "tests/find-file/empty-dir/")
 
-(defadvice require (before ivy-tests-require-hook (feature &rest _) activate)
-  "Record the requires into `require-features'."
-  (push feature require-features))
+(defvar ivy-features nil
+  "Like `features' but for Ivy testing purposes.")
 
-(require 'ert)
-(require 'colir)
+(defvar ivy-read-hist nil)
+
+(defun ivy-test--record-feature (feature &rest _)
+  "Record FEATURE in `ivy-features'.
+Intended as :after-while advice for `require'."
+  (add-to-list 'ivy-features feature nil #'eq))
+
+(advice-add 'require :after-while #'ivy-test--record-feature)
 
 ;; Useful for #'ivy-read-remap.  It must arrive before (require 'ivy).
 (define-key global-map (kbd "<S-right>") #'end-of-buffer)
 
-(require 'ivy)
+(require 'colir)
 (require 'counsel)
+(require 'ivy)
+
+(require 'ert)
 
 (message "%s" (emacs-version))
 
+(setq ivy-last (make-ivy-state))
+
 (ert-deftest ivy--lazy-load-ffap--ffap-url-p ()
-  (should (not (memq 'ffap require-features)))
+  (should (not (memq 'ffap ivy-features)))
   (should (not (fboundp 'ffap-url-p)))
   (should (string= (ivy-ffap-url-p "https://foo.org";)
                    "https://foo.org";))
-  (should (memq 'ffap require-features))
+  (should (memq 'ffap ivy-features))
   (should (fboundp 'ffap-url-p)))
 
 (defvar ivy-expr nil
@@ -80,7 +90,7 @@ Since `execute-kbd-macro' doesn't pick up a let-bound 
`default-directory'.")
       (unwind-protect
            (progn
              (when dir
-               (setq dir (expand-file-name dir (counsel-locate-git-root))))
+               (setq dir (expand-file-name dir)))
              (setq ivy-eval-dir dir)
              (execute-kbd-macro
               (vconcat (kbd "C-c e")
@@ -93,18 +103,6 @@ Since `execute-kbd-macro' doesn't pick up a let-bound 
`default-directory'.")
   (setq this-command cmd)
   (apply #'command-execute cmd args))
 
-(defadvice symbol-function (around no-void-function activate)
-  "Suppress void-function errors.
-
-This advice makes `symbol-function' return nil when called on a
-symbol with no function rather than throwing a void-function
-error. On Emacs 24.4 and above, this has no effect, because
-`symbol-function' already does this, but on 24.3 and earlier, it
-will bring the behavior in line with the newer Emacsen."
-  (condition-case nil
-      ad-do-it
-    (void-function nil)))
-
 (ert-deftest ivy-partial-1 ()
   (should (equal
            (ivy-with '(ivy-read "test: " '("case" "Case"))
@@ -179,7 +177,29 @@ will bring the behavior in line with the newer Emacsen."
   (should (equal (ivy-with
                   '(ivy-read "x: " '("one" "two" ("three" . "four")))
                   "th C-m")
-                 "three")))
+                 "three"))
+  (should (equal (ivy-with
+                  '(ivy-read "x: "
+                    (lambda (_input)
+                      '(("one" . 1)
+                        ("two" . 2)))
+                    :dynamic-collection t
+                    :action (lambda (choice)
+                              (message "%s" choice)))
+                  "C-m")
+                 "one")))
+
+(ert-deftest ivy-read-history ()
+  (should (equal (progn
+                   (setq ivy-read-hist '("c" "b" "a"))
+                   (ivy-with '(ivy-read "test: " '("c" "d") :history 
'ivy-read-hist) "RET")
+                   ivy-read-hist)
+                 '("c" "b" "a")))
+  (should (equal (progn
+                   (setq ivy-read-hist '("cdef" "b" "a"))
+                   (ivy-with '(ivy-read "test: " '("cdef" "g") :history 
'ivy-read-hist) "cd RET")
+                   ivy-read-hist)
+                 '("cd" "cdef" "b" "a"))))
 
 (ert-deftest ivy-read-sort-alist ()
   (should (equal (ivy-with '(let ((coll '(("b" . "1") ("a" . "2"))))
@@ -189,6 +209,65 @@ will bring the behavior in line with the newer Emacsen."
                            "C-m")
                  '(("b" . "1") ("a" . "2")))))
 
+(ert-deftest ivy-read-alist-multi-cands ()
+  (should
+   (equal
+    (ivy-with '(let (acc)
+                 (ivy-read "test: "
+                           '(("Key 1" . "Data 1") ("Key 2" . "Data 2"))
+                           :action (lambda (x) (push x acc)))
+                 acc)
+              "M-a RET")
+    '(("Key 2" . "Data 2")
+      ("Key 1" . "Data 1"))))
+  (should
+   (equal
+    (ivy-with
+     '(let (res)
+        (ivy-read "test: "
+                  '(("Key 1" . "Data 1") ("Key 2" . "Data 2"))
+                  :action (lambda (x) (push x res))
+                  :multi-action (lambda (xs) (setq res xs)))
+
+        res)
+     "M-a RET")
+    '(("Key 1" . "Data 1")
+      ("Key 2" . "Data 2")))))
+
+(ert-deftest ivy-read-multi-action-1 ()
+  (should (equal (let ((res nil))
+                   (ivy-add-actions 'test-ivy-read-multi-action-1
+                                    (list (list "a" (lambda (x) (push x res)) 
"action-a")))
+                   (ivy-with
+                    '(ivy-read "test: " '("x" "y")
+                               :action (lambda (x) (message "Default: %s" x))
+                               :multi-action (lambda (xs) (message "Default: 
%S" xs))
+                               :caller 'test-ivy-read-multi-action-1)
+                    "M-a M-o a")
+                   res)
+                 '("y" "x"))))
+
+(ert-deftest ivy-read-multi-action-2 ()
+  (should (equal (let ((res nil))
+                   (ivy-add-actions 'test-ivy-read-multi-action-2
+                                    (list (list "a"
+                                                (lambda (x) (push x res))
+                                                "action-a"
+                                                (lambda (xs) (push xs res)))))
+                   (ivy-with
+                    '(ivy-read "test: " '("x" "y")
+                               :action (lambda (x) (message "Default: %s" x))
+                               :multi-action (lambda (_xs) (message "default"))
+                               :caller 'test-ivy-read-multi-action-2)
+                    "M-a M-o a")
+                   res)
+                 '(("x" "y")))))
+
+(ert-deftest ivy-read-sort-def ()
+  (should (equal (ivy-with '(ivy-read "Test: " '("1" "2") :def '("a" "b" "c"))
+                           "C-m")
+                 "a")))
+
 (ert-deftest ivy-read-remap ()
   (should (equal
            (ivy-with '(ivy-read "pattern: " '("blue" "yellow" "red"))
@@ -197,12 +276,13 @@ will bring the behavior in line with the newer Emacsen."
 
 (ert-deftest swiper--re-builder ()
   (setq swiper--width 4)
+  (setf (ivy-state-caller ivy-last) 'swiper)
   (should (string= (swiper--re-builder "^")
-                   "."))
+                   "^ "))
   (should (string= (swiper--re-builder "^a")
-                   "^ ?\\(a\\)"))
+                   "^ a"))
   (should (string= (swiper--re-builder "^a b")
-                   "^ \\(a\\).*?\\(b\\)"))
+                   "\\(^ a\\).*?\\(b\\)"))
   (should
    (string-match-p
     "\\`\\\\_<.*\\\\_>\\'"
@@ -230,7 +310,27 @@ will bring the behavior in line with the newer Emacsen."
                    "your  king.")))
   (should (equal (ivy--split "^[^ ]") '("^[^ ]")))
   (should (equal (ivy--split "^[^ ] bar") '("^[^ ]" "bar")))
-  (should (equal (ivy--split "defun [^ ]+") '("defun" "[^ ]+"))))
+  (should (equal (ivy--split "defun [^ ]+") '("defun" "[^ ]+")))
+  (should (equal (ivy--split "[^ ]+ -> .*")
+                 '("[^ ]+" "->" ".*")))
+  (should (equal (ivy--split "[^ \n]+ \\( ->\\)")
+                 '("[^ \n]+" "\\( ->\\)")))
+  (should (equal (ivy--split "abc[^ \n]+\\( ->\\)")
+                 '("abc[^ \n]+" "\\( ->\\)")))
+  (should (equal (ivy--split "abc[^ \n]+\\( -> \\)def")
+                 '("abc[^ \n]+" "\\( -> \\)" "def")))
+  (should (equal (ivy--split "\\(?:interactive\\|swiper\\) 
\\(?:list\\|symbol\\)")
+                 '("\\(?:interactive\\|swiper\\)" "\\(?:list\\|symbol\\)")))
+  (should (equal (ivy--split "\\([^ \n]+\\)\\( -> \\).*")
+                 '("\\([^ \n]+\\)"
+                   "\\( -> \\)"
+                   ".*")))
+  (should (equal (ivy--split "[^ ]\\( -> \\).*")
+                 '("[^ ]" "\\( -> \\)" ".*")))
+  (should (equal (ivy--split "[ab][cd]") '("[ab][cd]")))
+  (should (equal (ivy--split "[a b][c d]") '("[a b][c d]")))
+  (should (equal (ivy--split "[ab] [cd]") '("[ab]" "[cd]")))
+  (should (equal (ivy--split "[a b] [c d]") '("[a b]" "[c d]"))))
 
 (ert-deftest ivy--regex ()
   (should (equal (ivy--regex
@@ -246,7 +346,12 @@ will bring the behavior in line with the newer Emacsen."
                   ".org")
                  "\\.org"))
   (should (equal (ivy--regex "foo\\") "foo"))
-  (should (equal (ivy--regex "foo\\|") "foo")))
+  (should (equal (ivy--regex "foo\\|") "foo"))
+  (should (equal (ivy--regex "[^ \n]+\\( -> \\).*")
+                 "\\([^ \n]+\\)\\( -> \\).*?\\(.*\\)"))
+  (should (equal (ivy--regex "\\([^ \\n]+\\)\\( -> \\).*")
+                 "\\([^ \\n]+\\)\\( -> \\).*?\\(.*\\)"))
+  (should (equal (ivy--regex "\\\\") "\\\\")))
 
 (ert-deftest ivy--split-negation ()
   (should (equal (ivy--split-negation "") ()))
@@ -293,13 +398,9 @@ will bring the behavior in line with the newer Emacsen."
   (should (equal (ivy--regex-plus "add path\\!") "\\(add\\).*?\\(path!\\)")))
 
 (ert-deftest ivy-partial-2 ()
-  (when (fboundp 'read--expression)
-    (should
-     (equal
-      (ivy-with '(read--expression "Eval: "
-                  "'s-c-t-st")
-                "<tab> C-m")
-      '(quote shell-command-to-string)))))
+  (should (equal (ivy-with '(read--expression "Eval: " "'s-c-t-st")
+                           "<tab> C-m")
+                 '(quote shell-command-to-string))))
 
 (ert-deftest ivy--regex-fuzzy ()
   (should (string= (ivy--regex-fuzzy "tmux")
@@ -374,7 +475,6 @@ will bring the behavior in line with the newer Emacsen."
                      90 96 (face ivy-current-match read-only nil)))))
 
 (ert-deftest ivy--filter ()
-  (setq ivy-last (make-ivy-state))
   (should (equal (ivy--filter "the" '("foo" "the" "The"))
                  '("the" "The")))
   (should (equal (ivy--filter "The" '("foo" "the" "The"))
@@ -416,6 +516,18 @@ will bring the behavior in line with the newer Emacsen."
      (insert ,text)
      ,@body))
 
+(ert-deftest ivy-backward-kill-word ()
+  (should (string= (ivy-with
+                    '(ivy-read "test: " nil
+                      :initial-input "one two three")
+                    "M-DEL M-DEL C-M-j")
+                   "one "))
+  (should (string= (ivy-with
+                    '(ivy-read "test: " nil
+                      :initial-input "one two three")
+                    "M-DEL M-DEL M-DEL C-y C-M-j")
+                   "one two three")))
+
 (ert-deftest counsel-url-expand ()
   "Test ffap expansion using `counsel-url-expansions-alist'."
   ;; no expansions defined
@@ -424,8 +536,8 @@ will bring the behavior in line with the newer Emacsen."
   (let ((counsel-url-expansions-alist
          '(("^foo$" . "https://foo.com/%s";)
            ("^issue\\([0-9]+\\)" . (lambda (word)
-                                     (concat "https://foo.com/issues/";
-                                             (match-string 1 word)))))))
+                                 (concat "https://foo.com/issues/";
+                                         (match-string 1 word)))))))
     ;; no match
     (should (equal (ivy--string-buffer
                     "foobar"
@@ -774,6 +886,20 @@ will bring the behavior in line with the newer Emacsen."
             "C-M-i")
            "(nconc")))
 
+(ert-deftest ivy-completing-read ()
+  (should (equal (ivy-with '(ivy-completing-read
+                             "Test: " '(("1" . "a") ("2" . "b")))
+                           "RET")
+                 "1"))
+  (should (equal (progn
+                   (setq ivy-read-hist '("foo"))
+                   (ivy-with
+                    '(completing-read "test: " '("foo" "bar" "baz") nil t nil
+                      'ivy-read-hist)
+                    "fo RET")
+                   ivy-read-hist)
+                 '("foo"))))
+
 (ert-deftest ivy-completing-read-def-handling ()
   ;; DEF in COLLECTION
   (should
@@ -951,6 +1077,12 @@ will bring the behavior in line with the newer Emacsen."
 
 (ert-deftest ivy-read-directory-name ()
   (ivy-mode 1)
+  (unless (file-exists-p ivy-empty)
+    (make-directory ivy-empty))
+  (should (equal (expand-file-name ivy-empty)
+                 (ivy-with
+                  '(read-directory-name "cd: " ivy-empty nil t)
+                  "RET")))
   (should
    (equal (expand-file-name "/tmp/")
           (ivy-with
@@ -975,6 +1107,26 @@ will bring the behavior in line with the newer Emacsen."
            "DEL C-M-j"
            :dir "/tmp"))))
 
+(ert-deftest ivy-read-file-name-initial-input ()
+  (let ((fname (expand-file-name "ivy.el")))
+    (should (string=
+             fname
+             (ivy-with
+              `(ivy-read "Find file: " 'read-file-name-internal
+                         :predicate 'file-exists-p
+                         :require-match 'confirm-after-completion
+                         :initial-input ,fname
+                         :preselect ,fname
+                         :def ,fname
+                         :history 'file-name-history
+                         :keymap nil
+                         :sort t
+                         :dynamic-collection nil
+                         :caller 'read-file-name-internal
+                         :action (lambda (x) x))
+              "RET"))))
+  (should (string= (ivy-state-initial-input ivy-last) "ivy.el")))
+
 (ert-deftest ivy-counsel-read-directory-name ()
   (should
    (equal (expand-file-name "/tmp/")
@@ -1089,14 +1241,14 @@ a buffer visiting a file."
   ;; negative lookahead: lines with "ivy", without "-"
   (should
    (string=
-    (let ((counsel--regex-look-around t)
-          (ivy--regex-function 'ivy--regex-plus))
+    (cl-letf ((counsel--regex-look-around t)
+              ((ivy-state-re-builder ivy-last) #'ivy--regex-plus))
       (counsel--grep-regex "ivy ! -"))
     "^(?=.*ivy)(?!.*-)"))
   (should
    (string=
-    (let ((counsel--regex-look-around t)
-          (ivy--regex-function 'ivy--regex-fuzzy))
+    (cl-letf ((counsel--regex-look-around t)
+              ((ivy-state-re-builder ivy-last) #'ivy--regex-fuzzy))
       (counsel--grep-regex "ivy"))
     "(i)[^v\n]*(v)[^y\n]*(y)")))
 
@@ -1136,6 +1288,16 @@ a buffer visiting a file."
            (and (buffer-name temp-buffer)
                 (kill-buffer temp-buffer)))))))
 
+(ert-deftest swiper-query-replace ()
+  (dolist (re-builder '(regexp-quote ivy--regex ivy--regex-plus 
ivy--regex-fuzzy ivy--regex-ignore-order))
+    (dolist (swiper-cmd '(swiper swiper-isearch))
+      (let ((ivy-re-builders-alist `((t . ,re-builder))))
+        (should (equal (ivy-with-text
+                        "|foo bar"
+                        (global-set-key (kbd "C-s") swiper-cmd)
+                        ("C-s" "foo" "M-q" "asdf" "C-j" "y"))
+                       "asdf| bar"))))))
+
 (ert-deftest swiper-thing-at-point ()
   (should
    (string=
@@ -1289,11 +1451,9 @@ a buffer visiting a file."
     "Foo\nfoo|\nFOO\n")))
 
 (ert-deftest ivy-swiper-wgrep ()
-  :expected-result (if (and (= emacs-major-version 24)
-                            (<= emacs-minor-version 3))
-                       ;; `wgrep' requires at least 24.5
-                       :failed
-                     :passed)
+  ;; `wgrep' requires Emacs 25 or later.
+  (skip-unless (and (>= emacs-major-version 25)
+                    (require 'wgrep nil t)))
   (dolist (search-cmd '(swiper swiper-isearch))
     (should
      (string=
@@ -1317,18 +1477,19 @@ a buffer visiting a file."
     (insert
      "line0\nline1\nline line\nline line\nline5")
     (let* ((input "li")
-           (cands (swiper--isearch-function input))
+           (cands (progn
+                    (ivy-set-text input)
+                    (swiper--isearch-function input)))
            (len (length cands)))
       (should (equal cands '(3 9 15 20 25 30 35)))
       (dotimes (index len)
-        (should (string= (substring-no-properties
-                          (swiper--isearch-format
-                           index len
-                           cands
-                           input
-                           (nth index cands)
-                           (current-buffer)))
-                         "line0\nline1\nline line\nline line\nline5"))))))
+        (should (equal (swiper--isearch-format
+                        index len
+                        cands
+                        input
+                        (nth index cands)
+                        (current-buffer))
+                       '("line0" "line1" "line line" "line line" "line5")))))))
 
 (ert-deftest ivy-use-selectable-prompt ()
   (let ((ivy-use-selectable-prompt t)
@@ -1394,12 +1555,43 @@ a buffer visiting a file."
                         :dir "tests/find-file/directories-with-spaces/"))
              "tests/find-file/directories-with-spaces/bar baz ii/file2"))))
 
+(ert-deftest counsel-find-file-single-match-directories ()
+  (dolist (ivy-re-builders-alist '(((t . ivy--regex-plus))
+                                   ((t . ivy--regex-ignore-order))))
+    (should (string= (let ((ivy-extra-directories nil))
+                       (file-relative-name
+                        (ivy-with '(counsel-find-file) "a TAB TAB TAB"
+                                  :dir 
"tests/find-file/single-match-directories/")))
+                     
"tests/find-file/single-match-directories/a/file_in_a.txt"))
+    (should (string= (let ((ivy-extra-directories nil))
+                       (file-relative-name
+                        (ivy-with '(counsel-find-file) "b TAB TAB TAB"
+                                  :dir 
"tests/find-file/single-match-directories/")))
+                     
"tests/find-file/single-match-directories/ba/file_in_ba.txt"))))
+
+(ert-deftest counsel--split-string-with-eol-cr ()
+  (should
+   (equal (counsel--split-string "one\rtwo")
+          '("one" "two"))))
+
+(ert-deftest counsel--split-string-with-eol-lf ()
+  (should
+     (equal (counsel--split-string "one\ntwo")
+            '("one" "two"))))
+
+(ert-deftest counsel--split-string-with-eol-crlf ()
+  (should
+     (equal (counsel--split-string "one\r\ntwo")
+            '("one" "two"))))
+
 (ert-deftest ivy-avy ()
-  (when (require 'avy nil t)
-    (let ((enable-recursive-minibuffers t)
-          (read-numbers '(ivy-read "test: " (mapcar #'number-to-string 
(number-sequence 1 100)))))
+  (skip-unless (require 'avy nil t))
+  (require 'ivy-avy)
+  (let ((enable-recursive-minibuffers t)
+        (read-numbers '(ivy-read "test: " (mapcar #'number-to-string
+                                                  (number-sequence 1 100)))))
       (should (string= (ivy-with read-numbers "C-' a") "1"))
-      (should (string= (ivy-with read-numbers "C-v C-' d") "7")))))
+      (should (string= (ivy-with read-numbers "C-v C-' d") "7"))))
 
 (ert-deftest ivy--yank-handle-case-fold ()
   (should (string=
@@ -1417,6 +1609,85 @@ a buffer visiting a file."
                      (ivy--handle-directory "/sudo::"))
                    "/sudo::/tmp/")))
 
+(ert-deftest ivy--handle-full-path-yank-on-remote ()
+  (should
+   (string=
+    (let ((ivy--directory "/ssh:dev:/bin/"))
+      (ivy--expand-file-name "/etc/hosts"))
+    "/ssh:dev:/etc/hosts")))
+
+(ert-deftest ivy-inhibit-action ()
+  (should (equal (ivy-with
+                  '(let ((ivy-inhibit-action #'identity))
+                    (ivy-read "pattern: " '(("a" . 1) ("b" . 2))))
+                  "C-m")
+                 '("a" . 1)))
+  (should (equal (ivy-with
+                  '(let ((ivy-inhibit-action #'cdr))
+                    (ivy-read "pattern: " '(("a" . 1) ("b" . 2))))
+                  "C-n C-m")
+                 2)))
+
+(ert-deftest ivy-empty-directory-open ()
+  (unless (file-exists-p ivy-empty)
+    (make-directory ivy-empty))
+  (should (string= (file-relative-name
+                    (ivy-with '(counsel-find-file)
+                              "RET"
+                              :dir ivy-empty))
+                   ivy-empty)))
+
+(ert-deftest counsel--split-command-args ()
+  (should (equal
+           (counsel--split-command-args "require -- -g*.el")
+           '("-g*.el" . "require")))
+  (should (equal
+           (counsel--split-command-args "-g*.el -- require")
+           '("-g*.el" . "require")))
+  (should (equal
+           (counsel--split-command-args "counsel--format")
+           '("" . "counsel--format"))))
+
+(ert-deftest ivy--preselect-index ()
+  "Test `ivy--preselect-index' behavior."
+  (should (eql (ivy--preselect-index nil ()) 0))
+  (should (eql (ivy--preselect-index nil '(nil)) 0))
+  (should (eql (ivy--preselect-index nil '(t)) 0))
+  (should (eql (ivy--preselect-index nil '(t nil)) 1))
+  (should (eql (ivy--preselect-index 0 ()) 0))
+  (should (eql (ivy--preselect-index 0 '(0)) 0))
+  (should (eql (ivy--preselect-index 0 '(1)) 0))
+  (should (eql (ivy--preselect-index 0 '(1 0)) 1))
+  (should (eql (ivy--preselect-index 0 '(a)) 0))
+  (should (eql (ivy--preselect-index 1 '(a)) 1))
+  (should (eql (ivy--preselect-index "" ()) 0))
+  (should (eql (ivy--preselect-index "" '("")) 0))
+  (should (eql (ivy--preselect-index "" '("a")) 0))
+  (should (eql (ivy--preselect-index "a+" '("a")) 0))
+  (should (eql (ivy--preselect-index "a+" '("b" "a")) 1)))
+
+(ert-deftest ivy-multi-resume ()
+  (let ((ivy-last ivy-last)
+        ivy-text ivy--all-candidates ivy--sessions)
+    (ivy-with '(ivy-read "A: " '(a123 b456 c789) :caller 'test-a :action 
#'ignore)
+              "b4 RET")
+    (ivy-with '(ivy-read "A: " '(d123 e456 f789) :caller 'test-b)
+              "d1 RET")
+    (ivy-with '(ivy-read "A: " '(g123 h456 k789) :action #'ignore
+                         :extra-props '(:session test-c))
+              "k7 RET")
+    (should (equal ivy-text "k7"))
+    (should (equal (mapcar #'car ivy--sessions) '(test-c test-a)))
+    (should (equal (ivy-with '(let ((current-prefix-arg '(4)))
+                               (ivy-resume))
+                             "test-a RET RET")
+                   "b456"))
+    (should (equal ivy-text "b4"))
+
+    (should (equal (ivy-with '(ivy-resume 'test-c) "RET")
+                   "k789"))
+    (should (equal ivy-text "k7"))))
+
 (defun ivy-test-run-tests ()
   (let ((test-sets
          '(
diff --git a/ivy.el b/ivy.el
index 04ef620..4cfe3e3 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1,10 +1,10 @@
 ;;; ivy.el --- Incremental Vertical completYon -*- lexical-binding: t -*-
 
-;; Copyright (C) 2015-2019  Free Software Foundation, Inc.
+;; Copyright (C) 2015-2021 Free Software Foundation, Inc.
 
 ;; Author: Oleh Krehel <ohwoeowho@gmail.com>
 ;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.13.1
+;; Version: 0.13.2
 ;; Package-Requires: ((emacs "24.5"))
 ;; Keywords: matching
 
@@ -38,130 +38,21 @@
 
 ;;; Code:
 
-(require 'cl-lib)
-(require 'ivy-overlay)
 (require 'colir)
+(require 'ivy-overlay)
+(require 'ivy-faces)
+
+(require 'cl-lib)
 (require 'ring)
 
+(eval-when-compile
+  (require 'subr-x))
+
 ;;* Customization
 (defgroup ivy nil
   "Incremental vertical completion."
   :group 'convenience)
 
-(defgroup ivy-faces nil
-  "Font-lock faces for `ivy'."
-  :group 'ivy
-  :group 'faces)
-
-(defface ivy-current-match
-  '((((class color) (background light))
-     :background "#1a4b77" :foreground "white")
-    (((class color) (background dark))
-     :background "#65a7e2" :foreground "black"))
-  "Face used by Ivy for highlighting the current match.")
-
-(defface ivy-minibuffer-match-highlight
-  '((t :inherit highlight))
-  "Face used by Ivy for highlighting the match under the cursor.")
-
-(defface ivy-minibuffer-match-face-1
-  '((((class color) (background light))
-     :background "#d3d3d3")
-    (((class color) (background dark))
-     :background "#555555"))
-  "The background face for `ivy' minibuffer matches.")
-
-(defface ivy-minibuffer-match-face-2
-  '((((class color) (background light))
-     :background "#e99ce8" :weight bold)
-    (((class color) (background dark))
-     :background "#777777" :weight bold))
-  "Face for `ivy' minibuffer matches numbered 1 modulo 3.")
-
-(defface ivy-minibuffer-match-face-3
-  '((((class color) (background light))
-     :background "#bbbbff" :weight bold)
-    (((class color) (background dark))
-     :background "#7777ff" :weight bold))
-  "Face for `ivy' minibuffer matches numbered 2 modulo 3.")
-
-(defface ivy-minibuffer-match-face-4
-  '((((class color) (background light))
-     :background "#ffbbff" :weight bold)
-    (((class color) (background dark))
-     :background "#8a498a" :weight bold))
-  "Face for `ivy' minibuffer matches numbered 3 modulo 3.")
-
-(defface ivy-confirm-face
-  '((t :foreground "ForestGreen" :inherit minibuffer-prompt))
-  "Face used by Ivy for a confirmation prompt.")
-
-(defface ivy-match-required-face
-  '((t :foreground "red" :inherit minibuffer-prompt))
-  "Face used by Ivy for a match required prompt.")
-
-(defface ivy-subdir
-  '((t :inherit dired-directory))
-  "Face used by Ivy for highlighting subdirs in the alternatives.")
-
-(defface ivy-org
-  '((t :inherit org-level-4))
-  "Face used by Ivy for highlighting Org buffers in the alternatives.")
-
-(defface ivy-modified-buffer
-  '((t :inherit default))
-  "Face used by Ivy for highlighting modified file visiting buffers.")
-
-(defface ivy-modified-outside-buffer
-  '((t :inherit default))
-  "Face used by Ivy for highlighting file visiting buffers modified outside 
Emacs.")
-
-(defface ivy-remote
-  '((((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
-  '((t :inherit font-lock-builtin-face))
-  "Face used by Ivy for matching virtual buffer names.")
-
-(defface ivy-action
-  '((t :inherit font-lock-builtin-face))
-  "Face used by Ivy for displaying keys in `ivy-read-action'.")
-
-(defface ivy-highlight-face
-  '((t :inherit highlight))
-  "Face used by Ivy to highlight certain candidates.")
-
-(defface ivy-prompt-match
-  '((t :inherit ivy-current-match))
-  "Face used by Ivy for highlighting the selected prompt line.")
-
-(defface ivy-separator
-  '((t :inherit font-lock-doc-face))
-  "Face for multiline source separator.")
-
-(defface ivy-grep-info
-  '((t :inherit compilation-info))
-  "Face for highlighting grep information such as file names.")
-
-(defface ivy-grep-line-number
-  '((t :inherit compilation-line-number))
-  "Face for displaying line numbers in grep messages.")
-
-(defface ivy-completions-annotations
-  '((t :inherit completions-annotations))
-  "Face for displaying completion annotations.")
-
-(defface ivy-yanked-word
-  '((t :inherit highlight))
-  "Face used to highlight yanked word.")
-
-;; Set default customization `:group' to `ivy' for the rest of the file.
-(setcdr (assoc load-file-name custom-current-group-alist) 'ivy)
-
 (defcustom ivy-height 10
   "Number of lines for the minibuffer window.
 
@@ -192,17 +83,13 @@ Set this to \"(%d/%d) \" to display both the index and the 
count."
   "When non-nil, wrap around after the first and the last candidate."
   :type 'boolean)
 
-(defcustom ivy-display-style (and (fboundp 'add-face-text-property) 'fancy)
+(defcustom ivy-display-style 'fancy
   "The style for formatting the minibuffer.
 
 By default, the matched strings are copied as is.
 
 The fancy display style highlights matching parts of the regexp,
-a behavior similar to `swiper'.
-
-This setting depends on `add-face-text-property' - a C function
-available since Emacs 24.4.  Fancy style will render poorly in
-earlier versions of Emacs."
+a behavior similar to `swiper'."
   :type '(choice
           (const :tag "Plain" nil)
           (const :tag "Fancy" fancy)))
@@ -212,7 +99,8 @@ earlier versions of Emacs."
 The usual reason for `ivy-backward-delete-char' to fail is when
 there is no text left to delete, i.e., when it is called at the
 beginning of the minibuffer.
-The default setting provides a quick exit from completion."
+The default setting provides a quick exit from completion.
+Another common option is `ignore', which does nothing."
   :type '(choice
           (const :tag "Exit completion" abort-recursive-edit)
           (const :tag "Do nothing" ignore)
@@ -250,8 +138,8 @@ Examples of properties include associated `:cleanup' 
functions.")
     (t . nil))
   "An alist for customizing where to display the candidates.
 
-Each key is a caller symbol. When the value is nil (the default),
-the candidates are shown in the minibuffer. Otherwise, the value
+Each key is a caller symbol.  When the value is nil (the default),
+the candidates are shown in the minibuffer.  Otherwise, the value
 is a function which takes a string argument comprising the
 current matching candidates and displays it somewhere.
 
@@ -321,23 +209,30 @@ ACTIONS that have the same key."
 
 (defun ivy--compute-extra-actions (action caller)
   "Add extra actions to ACTION based on CALLER."
-  (let ((extra-actions (cl-delete-duplicates
-                        (append (plist-get ivy--actions-list t)
-                                (plist-get ivy--actions-list this-command)
-                                (plist-get ivy--actions-list caller))
-                        :key #'car :test #'equal)))
-    (if extra-actions
-        (cond ((functionp action)
-               `(1
-                 ("o" ,action "default")
-                 ,@extra-actions))
-              ((null action)
-               `(1
-                 ("o" identity "default")
-                 ,@extra-actions))
-              (t
-               (delete-dups (append action extra-actions))))
-      action)))
+  (let* ((extra-actions (cl-delete-duplicates
+                         (append (plist-get ivy--actions-list t)
+                                 (plist-get ivy--actions-list this-command)
+                                 (plist-get ivy--actions-list caller))
+                         :key #'car :test #'equal))
+         (override-default (assoc "o" extra-actions)))
+    (cond (override-default
+           (cons 1 (cons override-default
+                         (cl-delete "o" extra-actions
+                                    :key #'car :test #'equal))))
+          ((not extra-actions)
+           action)
+          ((functionp action)
+           `(1
+             ("o" ,action "default")
+             ,@extra-actions))
+          ((null action)
+           `(1
+             ("o" identity "default")
+             ,@extra-actions))
+          (t
+           (cons (car action)
+                 (cl-delete-duplicates (cdr (append action extra-actions))
+                                       :key #'car :test #'equal :from-end 
t))))))
 
 (defvar ivy--prompts-list nil)
 
@@ -347,7 +242,7 @@ 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
+(defvar ivy--display-transformers-alist nil
   "A list of str->str transformers per command.")
 
 (defun ivy-set-display-transformer (cmd transformer)
@@ -359,8 +254,8 @@ plus some extra information.
 
 This lambda is called only on the `ivy-height' candidates that
 are about to be displayed, not on the whole collection."
-  (setq ivy--display-transformers-list
-        (plist-put ivy--display-transformers-list cmd transformer)))
+  (declare (obsolete "Use `ivy-configure' :display-transformer-fn" 
"<2020-05-20 Wed>"))
+  (ivy--alist-set 'ivy--display-transformers-alist cmd transformer))
 
 (defvar ivy--sources-list nil
   "A list of extra sources per command.")
@@ -406,69 +301,73 @@ action functions.")
 
 ;;* Keymap
 (require 'delsel)
+(defun ivy-define-key (keymap key def)
+  "Forward to (`define-key' KEYMAP KEY DEF).
+Remove DEF from `counsel-M-x' list."
+  (put def 'no-counsel-M-x t)
+  (define-key keymap key def))
+
 (defvar ivy-minibuffer-map
   (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-m") 'ivy-done)
+    (ivy-define-key map (kbd "C-m") 'ivy-done)
     (define-key map [down-mouse-1] 'ignore)
-    (define-key map [mouse-1] 'ivy-mouse-done)
-    (define-key map [mouse-3] 'ivy-mouse-dispatching-done)
-    (define-key map (kbd "C-M-m") 'ivy-call)
-    (define-key map (kbd "C-j") 'ivy-alt-done)
-    (define-key map (kbd "C-M-j") 'ivy-immediate-done)
-    (define-key map (kbd "TAB") 'ivy-partial-or-done)
-    (define-key map [remap next-line] 'ivy-next-line)
-    (define-key map [remap previous-line] 'ivy-previous-line)
-    (define-key map (kbd "C-s") 'ivy-next-line-or-history)
-    (define-key map (kbd "C-r") 'ivy-reverse-i-search)
+    (ivy-define-key map [mouse-1] 'ivy-mouse-done)
+    (ivy-define-key map [mouse-3] 'ivy-mouse-dispatching-done)
+    (ivy-define-key map (kbd "C-M-m") 'ivy-call)
+    (ivy-define-key map (kbd "C-j") 'ivy-alt-done)
+    (ivy-define-key map (kbd "C-M-j") 'ivy-immediate-done)
+    (ivy-define-key map (kbd "TAB") 'ivy-partial-or-done)
+    (ivy-define-key map [remap next-line] 'ivy-next-line)
+    (ivy-define-key map [remap previous-line] 'ivy-previous-line)
+    (ivy-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)
-    (define-key map (kbd "<right>") 'ivy-forward-char)
-    (define-key map [remap kill-word] 'ivy-kill-word)
-    (define-key map [remap beginning-of-buffer] 'ivy-beginning-of-buffer)
-    (define-key map [remap end-of-buffer] 'ivy-end-of-buffer)
-    (define-key map (kbd "M-n") 'ivy-next-history-element)
-    (define-key map (kbd "M-p") 'ivy-previous-history-element)
+    (ivy-define-key map [remap delete-backward-char] 'ivy-backward-delete-char)
+    (ivy-define-key map [remap backward-delete-char-untabify] 
'ivy-backward-delete-char)
+    (ivy-define-key map [remap backward-kill-word] 'ivy-backward-kill-word)
+    (ivy-define-key map [remap delete-char] 'ivy-delete-char)
+    (ivy-define-key map [remap forward-char] 'ivy-forward-char)
+    (ivy-define-key map (kbd "<right>") 'ivy-forward-char)
+    (ivy-define-key map [remap kill-word] 'ivy-kill-word)
+    (ivy-define-key map [remap beginning-of-buffer] 'ivy-beginning-of-buffer)
+    (ivy-define-key map [remap end-of-buffer] 'ivy-end-of-buffer)
+    (ivy-define-key map (kbd "M-n") 'ivy-next-history-element)
+    (ivy-define-key map (kbd "M-p") 'ivy-previous-history-element)
     (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 "<next>") 'ivy-scroll-up-command)
-    (define-key map (kbd "<prior>") '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-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-M-y") 'ivy-insert-current-full)
-    (define-key map (kbd "C-o") 'hydra-ivy/body)
-    (define-key map (kbd "M-o") 'ivy-dispatching-done)
-    (define-key map (kbd "C-M-o") 'ivy-dispatching-call)
-    (define-key map [remap kill-line] 'ivy-kill-line)
-    (define-key map [remap kill-whole-line] 'ivy-kill-whole-line)
-    (define-key map (kbd "S-SPC") 'ivy-restrict-to-matches)
-    (define-key map [remap kill-ring-save] 'ivy-kill-ring-save)
-    (define-key map (kbd "C-'") 'ivy-avy)
-    (define-key map (kbd "C-M-a") 'ivy-read-action)
-    (define-key map (kbd "C-c C-o") 'ivy-occur)
-    (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)
-    (define-key map "$" 'ivy-magic-read-file-env)
+    (ivy-define-key map [remap scroll-up-command] 'ivy-scroll-up-command)
+    (ivy-define-key map [remap scroll-down-command] 'ivy-scroll-down-command)
+    (ivy-define-key map (kbd "<next>") 'ivy-scroll-up-command)
+    (ivy-define-key map (kbd "<prior>") 'ivy-scroll-down-command)
+    (ivy-define-key map (kbd "C-v") 'ivy-scroll-up-command)
+    (ivy-define-key map (kbd "M-v") 'ivy-scroll-down-command)
+    (ivy-define-key map (kbd "C-M-n") 'ivy-next-line-and-call)
+    (ivy-define-key map (kbd "C-M-p") 'ivy-previous-line-and-call)
+    (ivy-define-key map (kbd "M-a") 'ivy-toggle-marks)
+    (ivy-define-key map (kbd "M-r") 'ivy-toggle-regexp-quote)
+    (ivy-define-key map (kbd "M-j") 'ivy-yank-word)
+    (ivy-define-key map (kbd "M-i") 'ivy-insert-current)
+    (ivy-define-key map (kbd "C-M-y") 'ivy-insert-current-full)
+    (ivy-define-key map (kbd "C-o") 'hydra-ivy/body)
+    (ivy-define-key map (kbd "M-o") 'ivy-dispatching-done)
+    (ivy-define-key map (kbd "C-M-o") 'ivy-dispatching-call)
+    (ivy-define-key map [remap kill-line] 'ivy-kill-line)
+    (ivy-define-key map [remap kill-whole-line] 'ivy-kill-whole-line)
+    (ivy-define-key map (kbd "S-SPC") 'ivy-restrict-to-matches)
+    (ivy-define-key map [remap kill-ring-save] 'ivy-kill-ring-save)
+    (ivy-define-key map (kbd "C-M-a") 'ivy-read-action)
+    (ivy-define-key map (kbd "C-c C-o") 'ivy-occur)
+    (ivy-define-key map (kbd "C-c C-a") 'ivy-toggle-ignore)
+    (ivy-define-key map (kbd "C-c C-s") 'ivy-rotate-sort)
+    (ivy-define-key map [remap describe-mode] 'ivy-help)
+    (ivy-define-key map "$" 'ivy-magic-read-file-env)
     map)
   "Keymap used in the minibuffer.")
 (autoload 'hydra-ivy/body "ivy-hydra" "" t)
+(autoload 'ivy-hydra-read-action "ivy-hydra" "" t)
 
 (defvar ivy-mode-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [remap switch-to-buffer]
-      'ivy-switch-buffer)
-    (define-key map [remap switch-to-buffer-other-window]
-      'ivy-switch-buffer-other-window)
+    (ivy-define-key map [remap switch-to-buffer] 'ivy-switch-buffer)
+    (ivy-define-key map [remap switch-to-buffer-other-window] 
'ivy-switch-buffer-other-window)
     map)
   "Keymap for `ivy-mode'.")
 
@@ -507,6 +406,9 @@ action functions.")
 This should eventually become a stack so that you could use
 `ivy-read' recursively.")
 
+(defvar ivy--sessions nil
+  "Alist mapping session symbols to `ivy-state' objects.")
+
 (defvar ivy-recursive-last nil)
 
 (defvar ivy-recursive-restore t
@@ -520,6 +422,8 @@ the restoring themselves.")
 
 (defvar inhibit-message)
 
+(defvar ffap-machine-p-known)
+
 (defun ivy-thing-at-point ()
   "Return a string that corresponds to the current thing at point."
   (substring-no-properties
@@ -531,7 +435,8 @@ the restoring themselves.")
         (buffer-substring-no-properties beg (min end eol))))
      ((thing-at-point 'url))
      ((and (eq (ivy-state-collection ivy-last) #'read-file-name-internal)
-           (let ((inhibit-message t))
+           (let ((inhibit-message t)
+                 (ffap-machine-p-known 'reject))
              (run-hook-with-args-until-success 
'file-name-at-point-functions))))
      ((let ((s (thing-at-point 'symbol)))
         (and (stringp s)
@@ -552,12 +457,27 @@ of `history-length'.")
 (defvar ivy--directory nil
   "Current directory when completing file names.")
 
+(defvar ivy--directory-hist nil
+  "Store the history of directories.
+This allows RET to reverse consecutive DEL.")
+
 (defvar ivy--length 0
   "Store the amount of viable candidates.")
 
 (defvar ivy-text ""
   "Store the user's string as it is typed in.")
 
+(defvar ivy-regex ""
+  "Store the regex value that corresponds to `ivy-text'.")
+
+(defvar ivy--regex-function 'ivy--regex
+  "Current function for building a regex.")
+
+(defun ivy-set-text (str)
+  "Set `ivy-text' to STR."
+  (setq ivy-text str)
+  (setq ivy-regex (funcall ivy--regex-function ivy-text)))
+
 (defvar ivy--index 0
   "Store the index of the current candidate.")
 
@@ -614,9 +534,6 @@ Either a string or a list for `ivy-re-match'.")
 (defvar ivy--old-cands nil
   "Store the candidates matched by `ivy--old-re'.")
 
-(defvar ivy--regex-function 'ivy--regex
-  "Current function for building a regex.")
-
 (defvar ivy--highlight-function 'ivy--highlight-default
   "Current function for formatting the candidates.")
 
@@ -661,11 +578,12 @@ functionality, e.g. as seen in `isearch'."
 (defvar ivy-case-fold-search ivy-case-fold-search-default
   "Store the current overriding `case-fold-search'.")
 
-(defvar ivy-more-chars-alist
+(defcustom ivy-more-chars-alist
   '((t . 3))
   "Map commands to their minimum required input length.
 That is the number of characters prompted for before fetching
-candidates.  The special key t is used as a fallback.")
+candidates.  The special key t is used as a fallback."
+  :type '(alist :key-type symbol :value-type integer))
 
 (defun ivy-more-chars ()
   "Return two fake candidates prompting for at least N input.
@@ -685,18 +603,6 @@ N is obtained from `ivy-more-chars-alist'."
   "Like `string=', but obeys `case-fold-search'."
   (eq t (compare-strings s1 nil nil s2 nil nil case-fold-search)))
 
-(eval-and-compile
-  (unless (fboundp 'defvar-local)
-    (defmacro defvar-local (var val &optional docstring)
-      "Define VAR as a buffer-local variable with default value VAL."
-      (declare (debug defvar) (doc-string 3))
-      (list 'progn (list 'defvar var val docstring)
-            (list 'make-variable-buffer-local (list 'quote var)))))
-  (unless (fboundp 'setq-local)
-    (defmacro setq-local (var val)
-      "Set variable VAR to value VAL in current buffer."
-      (list 'set (list 'make-local-variable (list 'quote var)) val))))
-
 (defmacro ivy-quit-and-run (&rest body)
   "Quit the minibuffer and run BODY afterwards."
   (declare (indent 0))
@@ -709,13 +615,13 @@ N is obtained from `ivy-more-chars-alist'."
                       ,@body)))
      (abort-recursive-edit)))
 
-(defun ivy-exit-with-action (action)
+(defun ivy-exit-with-action (action &optional exit-code)
   "Quit the minibuffer and call ACTION afterwards."
   (ivy-set-action
    `(lambda (x)
       (funcall ',action x)
       (ivy-set-action ',(ivy-state-action ivy-last))))
-  (setq ivy-exit 'done)
+  (setq ivy-exit (or exit-code 'done))
   (exit-minibuffer))
 
 (defmacro with-ivy-window (&rest body)
@@ -725,17 +631,26 @@ N is obtained from `ivy-more-chars-alist'."
   `(with-selected-window (ivy--get-window ivy-last)
      ,@body))
 
+(defun ivy--expand-file-name (text)
+  (cond
+    ((eq (ivy-state-history ivy-last) 'grep-files-history)
+     text)
+    (ivy--directory
+     (if (and (string-match-p "^/" text) (file-remote-p ivy--directory))
+         (let ((parts (split-string ivy--directory ":")))
+           (concat (nth 0 parts) ":" (nth 1 parts) ":" text))
+       (expand-file-name text ivy--directory)))
+    (t
+     text)))
+
 (defun ivy--done (text)
   "Insert TEXT and exit minibuffer."
   (if (member (ivy-state-prompt ivy-last) '("Create directory: " "Make 
directory: "))
       (ivy-immediate-done)
-    (if (stringp 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))))
+    (when (stringp text)
+      (insert
+       (setf (ivy-state-current ivy-last)
+             (ivy--expand-file-name text))))
     (setq ivy-exit 'done)
     (exit-minibuffer)))
 
@@ -782,19 +697,21 @@ candidate, not the prompt."
       (ivy-immediate-done)
     (setq ivy-current-prefix-arg current-prefix-arg)
     (delete-minibuffer-contents)
-    (cond ((or (> ivy--length 0)
+    (cond ((and (= ivy--length 0)
+                (eq this-command 'ivy-dispatching-done))
+           (ivy--done ivy-text))
+          ((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-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))
-                   (equal " (confirm)" ivy--prompt-extra))
-               (ivy--done ivy-text)
-             (setq ivy--prompt-extra " (confirm)")
-             (insert ivy-text)
-             (ivy--exhibit)))
+          ((and (memq (ivy-state-collection ivy-last)
+                      '(read-file-name-internal internal-complete-buffer))
+                (eq confirm-nonexistent-file-or-buffer t)
+                (not (string= " (confirm)" ivy--prompt-extra)))
+           (setq ivy--prompt-extra " (confirm)")
+           (insert ivy-text)
+           (ivy--exhibit))
           ((memq (ivy-state-require-match ivy-last)
                  '(nil confirm confirm-after-completion))
            (ivy--done ivy-text))
@@ -805,10 +722,10 @@ candidate, not the prompt."
 
 (defvar ivy-mouse-1-tooltip
   "Exit the minibuffer with the selected candidate."
-  "The doc visible in the tooltip for mouse-1 binding in the minibuffer")
+  "The doc visible in the tooltip for mouse-1 binding in the minibuffer.")
 (defvar ivy-mouse-3-tooltip
   "Display alternative actions."
-  "The doc visible in the tooltip for mouse-3 binding in the minibuffer")
+  "The doc visible in the tooltip for mouse-3 binding in the minibuffer.")
 
 (defun ivy-mouse-offset (event)
   "Compute the offset between the candidate at point and the selected one."
@@ -841,8 +758,11 @@ candidate, not the prompt."
       (ivy--exhibit)
       (ivy-dispatching-done))))
 
-(defvar ivy-read-action-format-function 'ivy-read-action-format-default
-  "Function used to transform the actions list into a docstring.")
+(defcustom ivy-read-action-format-function 'ivy-read-action-format-default
+  "Function used to transform the actions list into a docstring."
+  :type '(radio
+          (function-item ivy-read-action-format-default)
+          (function-item ivy-read-action-format-columns)))
 
 (defun ivy-read-action-format-default (actions)
   "Create a docstring from ACTIONS.
@@ -863,12 +783,51 @@ key (a string), cmd and doc (a string)."
            actions
            "\n")))
 
+(defun ivy-read-action-format-columns (actions)
+  "Create a docstring from ACTIONS, using several columns if needed to 
preserve `ivy-height'.
+
+ACTIONS is a list.  Each list item is a list of 3 items: key (a
+string), cmd and doc (a string)."
+  (let ((length (length actions))
+        (i 0)
+        (max-rows (- ivy-height 1))
+        rows cols col lwidth rwidth)
+    (while (< i length)
+      (setq col (cl-subseq actions i (min length (cl-incf i max-rows))))
+      (setq lwidth (apply 'max (mapcar (lambda (x)
+                                         (length (nth 0 x)))
+                                       col)))
+      (setq rwidth (apply 'max (mapcar (lambda (x)
+                                         (length (nth 2 x)))
+                                       col)))
+      (setq col (mapcar (lambda (x)
+                          (format (format "%%%ds: %%-%ds" lwidth rwidth)
+                                  (propertize (car x) 'face 'ivy-action)
+                                  (nth 2 x)))
+                        col))
+      (cond
+        ((null rows)
+         (setq rows (length col)))
+        ((< (length col) rows)
+         (setq col (append col (make-list (- rows (length col)) "")))))
+      (push col cols))
+    (format "%s\n%s\n"
+            (if (eq this-command 'ivy-read-action)
+                "Select action: "
+              (ivy-state-current ivy-last))
+            (mapconcat 'identity
+                       (apply 'cl-mapcar
+                              (lambda (&rest args)
+                                (mapconcat 'identity args " | "))
+                              (nreverse cols))
+                       "\n"))))
+
 (defcustom ivy-read-action-function #'ivy-read-action-by-key
   "Function used to read an action."
   :type '(radio
           (function-item ivy-read-action-by-key)
           (function-item ivy-read-action-ivy)
-          (function-item ivy-read-action-hydra)))
+          (function-item ivy-hydra-read-action)))
 
 (defun ivy-read-action ()
   "Change the action to one of the available ones.
@@ -879,10 +838,14 @@ selection, non-nil otherwise."
   (let ((actions (ivy-state-action ivy-last)))
     (if (not (ivy--actionp actions))
         t
-      (funcall ivy-read-action-function actions))))
+      (let ((ivy--directory ivy--directory))
+        (funcall ivy-read-action-function actions)))))
+
+(defvar set-message-function)
 
 (defun ivy-read-action-by-key (actions)
-  (let* ((hint (funcall ivy-read-action-format-function (cdr actions)))
+  (let* ((set-message-function nil)
+         (hint (funcall ivy-read-action-format-function (cdr actions)))
          (resize-mini-windows t)
          (key "")
          action-idx)
@@ -891,9 +854,9 @@ selection, non-nil otherwise."
                                     (string-prefix-p key (car x)))
                                   (cdr actions)))
                 (not (string= key (car (nth action-idx (cdr actions))))))
-      (setq key (concat key (string (read-key hint)))))
+      (setq key (concat key (key-description (vector (read-key hint))))))
     (ivy-shrink-after-dispatching)
-    (cond ((member key '("" ""))
+    (cond ((member key '("ESC" "C-g" "M-o"))
            nil)
           ((null action-idx)
            (message "%s is not bound" key)
@@ -903,39 +866,51 @@ selection, non-nil otherwise."
            (setcar actions (1+ action-idx))
            (ivy-set-action actions)))))
 
+(defvar ivy-marked-candidates nil
+  "List of marked candidates.
+Use `ivy-mark' to populate this.
+
+When this list is non-nil at the end of the session, the action
+will be called for each element of this list.")
+
 (defun ivy-read-action-ivy (actions)
   "Select an action from ACTIONS using Ivy."
   (let ((enable-recursive-minibuffers t))
     (if (and (> (minibuffer-depth) 1)
              (eq (ivy-state-caller ivy-last) 'ivy-read-action-ivy))
         (minibuffer-keyboard-quit)
-      (ivy-read (format "action (%s): " (ivy-state-current ivy-last))
-                (cl-mapcar
-                 (lambda (a i) (cons (format "[%s] %s" (nth 0 a) (nth 2 a)) i))
-                 (cdr actions) (number-sequence 1 (length (cdr actions))))
-                :action (lambda (a)
-                          (setcar actions (cdr a))
-                          (ivy-set-action actions))
-                :caller 'ivy-read-action-ivy))))
+      (let ((ivy-marked-candidates ivy-marked-candidates))
+        (ivy-read (format "action (%s): " (ivy-state-current ivy-last))
+                  (cl-mapcar
+                   (lambda (a i) (cons (format "[%s] %s" (nth 0 a) (nth 2 a)) 
i))
+                   (cdr actions) (number-sequence 1 (length (cdr actions))))
+                  :action (lambda (a)
+                            (setcar actions (cdr a))
+                            (ivy-set-action actions))
+                  :caller 'ivy-read-action-ivy)))))
 
 (defun ivy-shrink-after-dispatching ()
   "Shrink the window after dispatching when action list is too large."
-  (window-resize nil (- ivy-height (window-height))))
+  (when (window-minibuffer-p)
+    (window-resize nil (- ivy-height (window-height)))))
 
 (defun ivy-dispatching-done ()
   "Select one of the available actions and call `ivy-done'."
   (interactive)
-  (when (ivy-read-action)
-    (ivy-done))
+  (let ((ivy-exit 'ivy-dispatching-done))
+    (when (ivy-read-action)
+      (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))))
+  (let ((actions (copy-sequence (ivy-state-action ivy-last)))
+        (old-ivy-text ivy-text))
     (unwind-protect
          (when (ivy-read-action)
+           (ivy-set-text old-ivy-text)
            (ivy-call))
       (ivy-set-action actions)))
   (ivy-shrink-after-dispatching))
@@ -953,6 +928,16 @@ Is is a cons cell, related to 
`tramp-get-completion-function'."
 (declare-function Info-read-node-name-1 "info")
 (declare-function tramp-get-completion-function "tramp")
 
+(defcustom ivy-alt-done-functions-alist nil
+  "Customize what `ivy-alt-done' does per-collection."
+  :type '(alist :key-type symbol :value-type function))
+
+(defun ivy--completing-fname-p ()
+  (eq 'file (cdr (assoc
+                  'category
+                  (ignore-errors
+                    (funcall (ivy-state-collection ivy-last) ivy-text nil 
'metadata))))))
+
 (defun ivy-alt-done (&optional arg)
   "Exit the minibuffer with the selected candidate.
 When ARG is t, exit with current text, ignoring the candidates.
@@ -961,22 +946,25 @@ directory, continue completion from within that directory 
instead
 of exiting.  This function is otherwise like `ivy-done'."
   (interactive "P")
   (setq ivy-current-prefix-arg current-prefix-arg)
-  (cond ((or arg
-             (ivy--prompt-selected-p))
-         (ivy-immediate-done))
-        (ivy--directory
-         (ivy--directory-done))
-        ((eq (ivy-state-collection ivy-last) #'Info-read-node-name-1)
-         (if (member (ivy-state-current ivy-last) '("(./)" "(../)"))
-             (ivy-quit-and-run
-               (ivy-read "Go to file: " #'read-file-name-internal
-                         :action (lambda (x)
-                                   (Info-find-node
-                                    (expand-file-name x ivy--directory)
-                                    "Top"))))
-           (ivy-done)))
-        (t
-         (ivy-done))))
+  (let (alt-done-fn)
+    (cond ((or arg (ivy--prompt-selected-p))
+           (ivy-immediate-done))
+          ((setq alt-done-fn (ivy-alist-setting ivy-alt-done-functions-alist))
+           (funcall alt-done-fn))
+          ((ivy--completing-fname-p)
+           (ivy--directory-done))
+          (t
+           (ivy-done)))))
+
+(defun ivy--info-alt-done ()
+  (if (member (ivy-state-current ivy-last) '("(./)" "(../)"))
+      (ivy-quit-and-run
+        (ivy-read "Go to file: " #'read-file-name-internal
+                  :action (lambda (x)
+                            (Info-find-node
+                             (expand-file-name x ivy--directory)
+                             "Top"))))
+    (ivy-done)))
 
 (defvar ivy-auto-select-single-candidate nil
   "When non-nil, auto-select the candidate if it is the only one.
@@ -1000,62 +988,79 @@ contains a single candidate.")
         ((string= input "/sudo::")
          (concat input ivy--directory))))
 
+(defun ivy--tramp-candidates ()
+  (let ((method (match-string 1 ivy-text))
+        (user (match-string 2 ivy-text))
+        (rest (match-string 3 ivy-text))
+        res)
+    (dolist (x (tramp-get-completion-function method))
+      (setq res (append res (funcall (car x) (cadr x)))))
+    (setq res (delq nil res))
+    (when user
+      (dolist (x res)
+        (setcar x user)))
+    (setq res (delete-dups res))
+    (let* ((old-ivy-last ivy-last)
+           (enable-recursive-minibuffers t)
+           (host (let ((ivy-auto-select-single-candidate nil))
+                   (ivy-read "user@host: "
+                             (mapcar #'ivy-build-tramp-name res)
+                             :initial-input rest))))
+      (setq ivy-last old-ivy-last)
+      (when host
+        (setq ivy--directory "/")
+        (ivy--cd (concat "/" method ":" host ":/"))))))
+
 (defun ivy--directory-done ()
   "Handle exit from the minibuffer when completing file names."
   (let ((dir (ivy--handle-directory ivy-text)))
-    (cond
-      (dir
-       (let ((inhibit-message t))
-         (ivy--cd dir)))
-      ((ivy--directory-enter))
-      ((unless (string= ivy-text "")
-         (let ((file (expand-file-name
-                      (if (> ivy--length 0) (ivy-state-current ivy-last) 
ivy-text)
-                      ivy--directory)))
-           (when (ignore-errors (file-exists-p file))
-             (if (file-directory-p file)
-                 (ivy--cd (file-name-as-directory file))
-               (ivy-done))
-             ivy-text))))
-      ((or (and (equal ivy--directory "/")
-                (string-match-p "\\`[^/]+:.*:.*\\'" ivy-text))
-           (string-match-p "\\`/[^/]+:.*:.*\\'" ivy-text))
-       (ivy-done))
-      ((or (and (equal ivy--directory "/")
-                (cond ((string-match
-                        "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
-                        ivy-text)
-                       (setq ivy-text (ivy-state-current ivy-last)))
-                      ((string-match
-                        "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
-                        (ivy-state-current ivy-last))
-                       (setq ivy-text (ivy-state-current ivy-last)))))
-           (string-match
-            "\\`/\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
-            ivy-text))
-       (let ((method (match-string 1 ivy-text))
-             (user (match-string 2 ivy-text))
-             (rest (match-string 3 ivy-text))
-             res)
-         (dolist (x (tramp-get-completion-function method))
-           (setq res (append res (funcall (car x) (cadr x)))))
-         (setq res (delq nil res))
-         (when user
-           (dolist (x res)
-             (setcar x user)))
-         (setq res (delete-dups res))
-         (let* ((old-ivy-last ivy-last)
-                (enable-recursive-minibuffers t)
-                (host (let ((ivy-auto-select-single-candidate nil))
-                        (ivy-read "user@host: "
-                                  (mapcar #'ivy-build-tramp-name res)
-                                  :initial-input rest))))
-           (setq ivy-last old-ivy-last)
-           (when host
-             (setq ivy--directory "/")
-             (ivy--cd (concat "/" method ":" host ":"))))))
-      (t
-       (ivy-done)))))
+    (cond ((equal (ivy-state-current ivy-last) (ivy-state-def ivy-last))
+           (ivy-done))
+          ((and (ivy-state-require-match ivy-last)
+                (equal ivy-text "")
+                (null ivy--old-cands))
+           (ivy-immediate-done))
+          (dir
+           (let ((inhibit-message t))
+             (ivy--cd dir)))
+          ((ivy--directory-enter))
+          ((unless (string= ivy-text "")
+             ;; Obsolete since 26.1 and removed in 28.1.
+             (defvar tramp-completion-mode)
+             (with-no-warnings
+               (let* ((tramp-completion-mode t)
+                      (file (expand-file-name
+                             (if (> ivy--length 0) (ivy-state-current 
ivy-last) ivy-text)
+                             ivy--directory)))
+                 (when (ignore-errors (file-exists-p file))
+                   (if (file-directory-p file)
+                       (ivy--cd (file-name-as-directory file))
+                     (ivy-done))
+                   ivy-text)))))
+          ((or (and (equal ivy--directory "/")
+                    (string-match-p "\\`[^/]+:.*:.*\\'" ivy-text))
+               (string-match-p "\\`/[^/]+:.*:.*\\'" ivy-text))
+           (ivy-done))
+          ((ivy--tramp-prefix-p)
+           (ivy--tramp-candidates))
+          (t
+           (ivy-done)))))
+
+(defun ivy--tramp-prefix-p ()
+  (or (and (equal ivy--directory "/")
+           (cond ((string-match
+                   "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
+                   ivy-text)
+                  (save-match-data
+                    (ivy-set-text (ivy-state-current ivy-last))))
+                 ((string-match
+                   "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
+                   (ivy-state-current ivy-last))
+                  (save-match-data
+                    (ivy-set-text (ivy-state-current ivy-last))))))
+      (string-match
+       "\\`/\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
+       ivy-text)))
 
 (defun ivy-expand-file-if-directory (file-name)
   "Expand FILE-NAME as directory.
@@ -1078,7 +1083,8 @@ When this directory doesn't exist, return nil."
 If the text hasn't changed as a result, forward to `ivy-alt-done'."
   (interactive)
   (cond
-    ((and completion-cycle-threshold (< (length ivy--all-candidates) 
completion-cycle-threshold))
+    ((and (numberp completion-cycle-threshold)
+          (< (length ivy--all-candidates) completion-cycle-threshold))
      (let ((ivy-wrap t))
        (ivy-next-line)))
     ((and (eq (ivy-state-collection ivy-last) #'read-file-name-internal)
@@ -1088,7 +1094,7 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
      (let ((default-directory ivy--directory)
            dir)
        (minibuffer-complete)
-       (setq ivy-text (ivy--input))
+       (ivy-set-text (ivy--input))
        (when (setq dir (ivy-expand-file-if-directory ivy-text))
          (ivy--cd dir))))
     (t
@@ -1097,18 +1103,14 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
                    (eq ivy--length 1))
            (ivy-alt-done))))))
 
-(defun ivy--remove-prefix (prefix string)
-  "Compatibility shim for `string-remove-prefix'."
-  (if (string-prefix-p prefix string)
-      (substring string (length prefix))
-    string))
-
 (defun ivy--partial-cd-for-single-directory ()
   (when (and
          (eq (ivy-state-collection ivy-last) #'read-file-name-internal)
          (= 1 (length
                (ivy--re-filter
-                (funcall ivy--regex-function ivy-text) ivy--all-candidates)))
+                (funcall ivy--regex-function
+                         (concat "^" (string-remove-prefix "^" ivy-text)))
+                ivy--all-candidates)))
          (let ((default-directory ivy--directory))
            (file-directory-p (ivy-state-current ivy-last))))
     (ivy--directory-done)))
@@ -1121,7 +1123,7 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
          (postfix (car tail))
          (case-fold-search (ivy--case-fold-p ivy-text))
          (completion-ignore-case case-fold-search)
-         (new (try-completion (ivy--remove-prefix "^" postfix)
+         (new (try-completion (string-remove-prefix "^" postfix)
                               (if (ivy-state-dynamic-collection ivy-last)
                                   ivy--all-candidates
                                 (mapcar (lambda (str)
@@ -1137,11 +1139,11 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
                    (if (= (string-to-char postfix) ?^)
                        (concat "^" new)
                      new))
-           (insert
-            (setq ivy-text
-                  (concat
-                   (mapconcat #'identity parts " ")
-                   (and ivy-tab-space (not (= (length ivy--old-cands) 1)) " 
"))))
+           (ivy-set-text
+            (concat
+             (mapconcat #'identity parts " ")
+             (and ivy-tab-space (not (= (length ivy--old-cands) 1)) " ")))
+           (insert ivy-text)
            (ivy--partial-cd-for-single-directory)
            t))))
 
@@ -1177,14 +1179,41 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
   (setq ivy-exit 'done)
   (exit-minibuffer))
 
+(defun ivy--restore-session (&optional session)
+  "Resume a recorded completion SESSION, if any exists."
+  (when ivy--sessions
+    (unless session
+      (setq session (intern
+                     (let ((ivy-last ivy-last)
+                           ivy--all-candidates
+                           ivy-text)
+                       (ivy-read "Choose ivy session: "
+                                 ivy--sessions
+                                 :require-match t)))))
+    (setq ivy-last (or (cdr (assq session ivy--sessions))
+                       ivy-last)))
+  (let ((data (plist-get (ivy-state-extra-props ivy-last) :ivy-data)))
+    (when data
+      (setq ivy--all-candidates (plist-get data :all-candidates))
+      (setq ivy-text (plist-get data :text)))))
+
 ;;;###autoload
-(defun ivy-resume ()
-  "Resume the last completion session."
+(defun ivy-resume (&optional session)
+  "Resume the last completion session, or SESSION if non-nil.
+With a prefix arg, try to restore a recorded completion session,
+if one exists."
   (interactive)
-  (if (null (ivy-state-action ivy-last))
+  (when (or current-prefix-arg session)
+    (ivy--restore-session session))
+
+  (if (or (null (ivy-state-action ivy-last))
+          (eq (ivy--get-action ivy-last) #'identity))
       (user-error "The last session isn't compatible with `ivy-resume'")
     (when (memq (ivy-state-caller ivy-last)
-                '(swiper swiper-isearch swiper-backward 
swiper-isearch-backward))
+                '(swiper
+                  swiper-isearch swiper-backward
+                  swiper-isearch-backward
+                  counsel-grep))
       (switch-to-buffer (ivy-state-buffer ivy-last)))
     (with-current-buffer (ivy-state-buffer ivy-last)
       (let ((default-directory (ivy-state-directory ivy-last))
@@ -1240,20 +1269,6 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
   (ivy-set-index (max (1+ (- ivy--index ivy-height))
                       0)))
 
-(defun ivy-minibuffer-grow ()
-  "Grow the minibuffer window by 1 line."
-  (interactive)
-  (setq-local max-mini-window-height
-              (cl-incf ivy-height)))
-
-(defun ivy-minibuffer-shrink ()
-  "Shrink the minibuffer window by 1 line."
-  (interactive)
-  (when (> ivy-height 2)
-    (setq-local max-mini-window-height
-                (cl-decf ivy-height))
-    (window-resize nil -1)))
-
 (defun ivy-next-line (&optional arg)
   "Move cursor vertically down ARG candidates."
   (interactive "p")
@@ -1269,9 +1284,10 @@ If the text hasn't changed as a result, forward to 
`ivy-alt-done'."
   "Move cursor vertically down ARG candidates.
 If the input is empty, select the previous history element instead."
   (interactive "p")
-  (if (string= ivy-text "")
-      (ivy-previous-history-element 1)
-    (ivy-next-line arg)))
+  (let ((orig-index ivy--index))
+    (ivy-next-line arg)
+    (when (and (string= ivy-text "") (= ivy--index orig-index))
+      (ivy-previous-history-element 1))))
 
 (defun ivy-previous-line (&optional arg)
   "Move cursor vertically up ARG candidates."
@@ -1289,9 +1305,10 @@ If the input is empty, select the previous history 
element instead."
   "Move cursor vertically up ARG candidates.
 If the input is empty, select the previous history element instead."
   (interactive "p")
-  (when (string= ivy-text "")
-    (ivy-previous-history-element 1))
-  (ivy-previous-line arg))
+  (let ((orig-index ivy--index))
+    (ivy-previous-line arg)
+    (when (and (string= ivy-text "") (= ivy--index orig-index))
+      (ivy-previous-history-element 1))))
 
 (defun ivy-toggle-calling ()
   "Flip `ivy-calling'."
@@ -1318,6 +1335,18 @@ If the input is empty, select the previous history 
element instead."
           action
         (cadr (nth (car action) action))))))
 
+(defun ivy--get-multi-action (state)
+  "Get the multi-action function from STATE."
+  (let* ((action (ivy-state-action state))
+         (multi-action
+          (and (listp action)
+               (not (eq (car action) 'lambda))
+               (nth 3 (nth (car action) action)))))
+    (if multi-action
+        multi-action
+      (when (eq (car action) 1)
+        (ivy-state-multi-action state)))))
+
 (defun ivy--get-window (state)
   "Get the window from STATE."
   (if (ivy-state-p state)
@@ -1385,16 +1414,48 @@ See variable `ivy-recursive-restore' for further 
information."
              (not (eq ivy-last ivy-recursive-last)))
     (ivy--reset-state (setq ivy-last ivy-recursive-last))))
 
-(defvar ivy-marked-candidates nil
-  "List of marked candidates.
-Use `ivy-mark' to populate this.
-
-When this list is non-nil at the end of the session, the action
-will be called for each element of this list.")
-
 (defvar ivy-mark-prefix ">"
   "Prefix used by `ivy-mark'.")
 
+(defun ivy--call-marked (action)
+  (let* ((prefix-len (length ivy-mark-prefix))
+         (marked-candidates
+          (mapcar
+           (lambda (s)
+             (let ((cand (substring s prefix-len)))
+               (if ivy--directory
+                   (expand-file-name cand ivy--directory)
+                 cand)))
+           ivy-marked-candidates))
+         (multi-action (ivy--get-multi-action ivy-last)))
+    (if multi-action
+        (let ((default-directory (ivy-state-directory ivy-last)))
+          (funcall multi-action (mapcar #'ivy--call-cand marked-candidates)))
+      (dolist (c marked-candidates)
+        (let ((default-directory (ivy-state-directory ivy-last)))
+          (funcall action (ivy--call-cand c)))))))
+
+(defun ivy--call-cand (current)
+  (let ((collection (ivy-state-collection ivy-last)))
+    (cond
+     ;; Alist type.
+     ((and (consp (car-safe collection))
+           ;; Previously, the cdr of the selected
+           ;; candidate would be returned.  Now, the
+           ;; whole candidate is returned.
+           (let ((idx (get-text-property 0 'idx current)))
+             (if idx
+                 (progn
+                   (ivy--remove-props current 'idx)
+                   (nth idx collection))
+               (assoc current collection)))))
+     (ivy--directory
+      (expand-file-name current ivy--directory))
+     ((equal current "")
+      ivy-text)
+     (t
+      current))))
+
 (defun ivy-call ()
   "Call the current action without exiting completion."
   (interactive)
@@ -1405,54 +1466,32 @@ will be called for each element of this list.")
                                ivy-alt-done
                                ivy-dispatching-done))
     (setq ivy-current-prefix-arg current-prefix-arg))
-  (let ((action
-         (if (functionp ivy-inhibit-action)
-             ivy-inhibit-action
-           (and (not ivy-inhibit-action)
-                (ivy--get-action ivy-last)))))
-    (when action
-      (let* ((collection (ivy-state-collection ivy-last))
-             (current (ivy-state-current ivy-last))
-             (x (cond
-                  ;; Alist type.
-                  ((and (consp (car-safe collection))
-                        ;; Previously, the cdr of the selected
-                        ;; candidate would be returned.  Now, the
-                        ;; whole candidate is returned.
-                        (let ((idx (get-text-property 0 'idx current)))
-                          (if idx
-                              (nth idx collection)
-                            (assoc current collection)))))
-                  (ivy--directory
-                   (expand-file-name current ivy--directory))
-                  ((equal current "")
-                   ivy-text)
-                  (t
-                   current))))
-        (if (eq action #'identity)
-            (prog1 x
-              (ivy-recursive-restore))
-          (select-window (ivy--get-window ivy-last))
-          (set-buffer (ivy-state-buffer ivy-last))
-          (prog1 (unwind-protect
-                      (if ivy-marked-candidates
-                          (let ((prefix-len (length ivy-mark-prefix)))
-                            (setq ivy-marked-candidates
-                                  (mapcar (lambda (s) (substring s prefix-len))
-                                          ivy-marked-candidates))
-                            (if (ivy-state-multi-action ivy-last)
-                                (funcall
-                                 (ivy-state-multi-action ivy-last)
-                                 ivy-marked-candidates)
-                              (dolist (c ivy-marked-candidates)
-                                (let ((default-directory (ivy-state-directory 
ivy-last)))
-                                  (funcall action c)))))
-                        (funcall action x))
-                   (ivy-recursive-restore))
-            (unless (or (eq ivy-exit 'done)
-                        (minibuffer-window-active-p (selected-window))
-                        (null (active-minibuffer-window)))
-              (select-window (active-minibuffer-window)))))))))
+  (let* ((action
+          (if (functionp ivy-inhibit-action)
+              ivy-inhibit-action
+            (and (not ivy-inhibit-action)
+                 (ivy--get-action ivy-last))))
+         (current (ivy-state-current ivy-last))
+         (x (ivy--call-cand current))
+         (res
+          (cond
+           ((null action)
+            current)
+           (t
+            (select-window (ivy--get-window ivy-last))
+            (set-buffer (ivy-state-buffer ivy-last))
+            (prog1 (unwind-protect
+                       (if ivy-marked-candidates
+                           (ivy--call-marked action)
+                         (funcall action x))
+                     (ivy-recursive-restore))
+              (unless (or (eq ivy-exit 'done)
+                          (minibuffer-window-active-p (selected-window))
+                          (null (active-minibuffer-window)))
+                (select-window (active-minibuffer-window))))))))
+    (if ivy-inhibit-action
+        res
+      current)))
 
 (defun ivy-call-and-recenter ()
   "Call action and recenter window according to the selected candidate."
@@ -1531,7 +1570,8 @@ If so, move to that directory, while keeping only the 
file name."
                            :initial-value nil))))
           (ivy-exit-with-action
            (lambda (_)
-             (ivy-ffap-url-fetcher url)))
+             (ivy-ffap-url-fetcher url))
+           'no-update-history)
         (setq input (expand-file-name input))
         (let ((file (file-name-nondirectory input))
               (dir (expand-file-name (file-name-directory input))))
@@ -1556,23 +1596,25 @@ If so, move to that directory, while keeping only the 
file name."
 
 (defun ivy--cd (dir)
   "When completing file names, move to directory DIR."
-  (if (null ivy--directory)
-      (error "Unexpected")
-    (setq ivy--old-cands nil)
-    (setq ivy--old-re nil)
-    (ivy-set-index 0)
-    (setq ivy--all-candidates
-          (append
-           (ivy--sorted-files (setq ivy--directory dir))
-           (when (and (string= dir "/") (featurep 'tramp))
-             (sort
-              (mapcar
-               (lambda (s) (substring s 1))
-               (tramp-get-completion-methods ""))
-              #'string<))))
-    (setq ivy-text "")
-    (setf (ivy-state-directory ivy-last) dir)
-    (delete-minibuffer-contents)))
+  (if (ivy--completing-fname-p)
+      (progn
+        (push dir ivy--directory-hist)
+        (setq ivy--old-cands nil)
+        (setq ivy--old-re nil)
+        (ivy-set-index 0)
+        (setq ivy--all-candidates
+              (append
+               (ivy--sorted-files (setq ivy--directory dir))
+               (when (and (string= dir "/") (featurep 'tramp))
+                 (sort
+                  (mapcar
+                   (lambda (s) (substring s 1))
+                   (tramp-get-completion-methods ""))
+                  #'string<))))
+        (ivy-set-text "")
+        (setf (ivy-state-directory ivy-last) dir)
+        (delete-minibuffer-contents))
+    (error "Unexpected")))
 
 (defun ivy--parent-dir (filename)
   "Return parent directory of absolute FILENAME."
@@ -1633,9 +1675,12 @@ minibuffer."
         (ivy--cd (ivy--parent-dir (expand-file-name ivy--directory)))
         (ivy--exhibit))
     (ignore-errors
-      (let ((pt (point)))
+      (let ((pt (point))
+            (last-command (if (eq last-command 'ivy-backward-kill-word)
+                              'kill-region
+                            last-command)))
         (forward-word -1)
-        (delete-region (point) pt)))))
+        (kill-region pt (point))))))
 
 (defvar ivy--regexp-quote #'regexp-quote
   "Store the regexp quoting state.")
@@ -1644,16 +1689,9 @@ minibuffer."
   "Toggle the regexp quoting."
   (interactive)
   (setq ivy--old-re nil)
-  (cl-rotatef ivy--regex-function ivy--regexp-quote))
-
-(defvar avy-all-windows)
-(defvar avy-action)
-(defvar avy-keys)
-(defvar avy-keys-alist)
-(defvar avy-style)
-(defvar avy-styles-alist)
-(declare-function avy-process "ext:avy")
-(declare-function avy--style-fn "ext:avy")
+  (cl-rotatef ivy--regex-function ivy--regexp-quote)
+  (setq ivy--old-text "")
+  (setq ivy-regex (funcall ivy--regex-function ivy-text)))
 
 (defcustom ivy-format-functions-alist
   '((t . ivy-format-function-default))
@@ -1668,68 +1706,6 @@ This string is inserted into the minibuffer."
            (const :tag "Full line" ivy-format-function-line)
            (function :tag "Custom function"))))
 
-(eval-after-load 'avy
-  '(add-to-list 'avy-styles-alist '(ivy-avy . pre)))
-
-(defun ivy--avy-candidates ()
-  (let (candidates)
-    (save-excursion
-      (save-restriction
-        (narrow-to-region
-         (window-start)
-         (window-end))
-        (goto-char (point-min))
-        (forward-line)
-        (while (< (point) (point-max))
-          (push
-           (cons (point)
-                 (selected-window))
-           candidates)
-          (forward-line))))
-    (nreverse candidates)))
-
-(defun ivy--avy-action (pt)
-  (when (number-or-marker-p pt)
-    (let ((bnd (ivy--minibuffer-index-bounds
-                ivy--index ivy--length ivy-height)))
-      (ivy--done
-       (substring-no-properties
-        (nth (+ (car bnd) (- (line-number-at-pos pt) 2)) ivy--old-cands))))))
-
-(defun ivy--avy-handler-function (char)
-  (let (cmd)
-    (cond ((memq char '(27 ?\C-g))
-           ;; exit silently
-           (throw 'done 'abort))
-          ((memq (setq cmd (lookup-key ivy-minibuffer-map (vector char)))
-                 '(ivy-scroll-up-command
-                   ivy-scroll-down-command))
-           (funcall cmd)
-           (ivy--exhibit)
-           (throw 'done 'exit))
-          ;; ignore wrong key
-          (t
-           (throw 'done 'restart)))))
-
-(defvar avy-handler-function)
-
-(defun ivy-avy ()
-  "Jump to one of the current ivy candidates."
-  (interactive)
-  (unless (require 'avy nil 'noerror)
-    (error "Package avy isn't installed"))
-  (let* ((avy-all-windows nil)
-         (avy-keys (or (cdr (assq 'ivy-avy avy-keys-alist))
-                       avy-keys))
-         (avy-style (or (cdr (assq 'ivy-avy avy-styles-alist))
-                        avy-style))
-         (avy-action #'identity)
-         (avy-handler-function #'ivy--avy-handler-function)
-         res)
-    (while (eq (setq res (avy-process (ivy--avy-candidates))) t))
-    (when res
-      (ivy--avy-action res))))
-
 (defun ivy-sort-file-function-default (x y)
   "Compare two files X and Y.
 Prioritize directories."
@@ -1771,7 +1747,7 @@ See also `ivy-sort-max-size'."
                (const :tag "Fall-through" t)
                (symbol :tag "Collection"))
     :value-type (choice
-                 (const :tag "Plain sort" string-lessp)
+                 (const :tag "Plain sort" ivy-string<)
                  (const :tag "File sort" ivy-sort-file-function-default)
                  (const :tag "File sort using Ido" ido-file-extension-lessp)
                  (const :tag "No sort" nil)
@@ -1794,17 +1770,19 @@ specified for the current collection in
 `ivy-sort-functions-alist'."
   (interactive)
   (let ((cell (or (assq (ivy-state-collection ivy-last) 
ivy-sort-functions-alist)
-                  (assq (ivy-state-caller ivy-last) 
ivy-sort-functions-alist))))
+                  (assq (ivy-state-caller ivy-last) ivy-sort-functions-alist)
+                  (assq t ivy-sort-functions-alist))))
     (when (consp (cdr cell))
       (setcdr cell (nconc (cddr cell) (list (cadr cell))))
       (ivy--reset-state ivy-last))))
 
-(defvar ivy-index-functions-alist
+(defcustom ivy-index-functions-alist
   '((t . ivy-recompute-index-zero))
   "An alist of index recomputing functions for each collection function.
 When the input changes, the appropriate function returns an
 integer - the index of the matched candidate that should be
-selected.")
+selected."
+  :type '(alist :key-type symbol :value-type function))
 
 (defvar ivy-re-builders-alist
   '((t . ivy--regex-plus))
@@ -1872,34 +1850,61 @@ May supersede `ivy-initial-inputs-alist'."
            (const :tag "Off" nil)
            (const :tag "Call action on change" auto))))
 
-(defvar ivy-unwind-fns-alist nil
-  "An alist associating commands to their :unwind values.")
+(defcustom ivy-unwind-fns-alist nil
+  "An alist associating commands to their :unwind values."
+  :type '(alist :key-type symbol :value-type function))
+
+(defcustom ivy-init-fns-alist nil
+  "An alist associating commands to their :init values.
+An :init is a function with no arguments.
+`ivy-read' calls it to initialize."
+  :type '(alist :key-type symbol :value-type function))
 
 (defun ivy--alist-set (alist-sym key val)
-  (let ((cell (assoc key (symbol-value alist-sym))))
-    (if cell
-        (setcdr cell val)
-      (set alist-sym (cons (cons key val)
-                           (symbol-value alist-sym))))))
+  (let ((curr-val (symbol-value alist-sym))
+        (customized-val (get alist-sym 'customized-value))
+        (default-val (eval (car (get alist-sym 'standard-value)))))
+    ;; when the value was set by `customize-set-variable', don't touch it
+    (unless customized-val
+      ;; only works if the value wasn't customized by the user
+      (when (or (null default-val) (equal curr-val default-val))
+        (let ((cell (assoc key curr-val)))
+          (if cell
+              (setcdr cell val)
+            (set alist-sym (cons (cons key val)
+                                 (symbol-value alist-sym)))))
+        (when default-val
+          (put alist-sym 'standard-value
+               (list (list 'quote (symbol-value alist-sym)))))))))
 
 (declare-function counsel-set-async-exit-code "counsel")
 
+(defvar ivy--parents-alist nil
+  "Configure parent caller for child caller.
+The child caller inherits and can override the settings of the parent.")
+
 (cl-defun ivy-configure (caller
                          &key
-                           initial-input
-                           height
-                           occur
-                           update-fn
-                           unwind-fn
-                           index-fn
-                           sort-fn
-                           format-fn
-                           display-transformer-fn
-                           more-chars
-                           grep-p
-                           exit-codes)
+                         parent
+                         initial-input
+                         height
+                         occur
+                         update-fn
+                         init-fn
+                         unwind-fn
+                         index-fn
+                         sort-fn
+                         format-fn
+                         display-fn
+                         display-transformer-fn
+                         alt-done-fn
+                         more-chars
+                         grep-p
+                         exit-codes)
   "Configure `ivy-read' params for CALLER."
   (declare (indent 1))
+  (when parent
+    (ivy--alist-set 'ivy--parents-alist caller parent))
   (when initial-input
     (ivy--alist-set 'ivy-initial-inputs-alist caller initial-input))
   (when height
@@ -1910,14 +1915,20 @@ May supersede `ivy-initial-inputs-alist'."
     (ivy--alist-set 'ivy-update-fns-alist caller update-fn))
   (when unwind-fn
     (ivy--alist-set 'ivy-unwind-fns-alist caller unwind-fn))
+  (when init-fn
+    (ivy--alist-set 'ivy-init-fns-alist caller init-fn))
   (when index-fn
     (ivy--alist-set 'ivy-index-functions-alist caller index-fn))
   (when sort-fn
     (ivy--alist-set 'ivy-sort-functions-alist caller sort-fn))
   (when format-fn
     (ivy--alist-set 'ivy-format-functions-alist caller format-fn))
+  (when display-fn
+    (ivy--alist-set 'ivy-display-functions-alist caller display-fn))
   (when display-transformer-fn
-    (ivy-set-display-transformer caller display-transformer-fn))
+    (ivy--alist-set 'ivy--display-transformers-alist caller 
display-transformer-fn))
+  (when alt-done-fn
+    (ivy--alist-set 'ivy-alt-done-functions-alist caller alt-done-fn))
   (when more-chars
     (ivy--alist-set 'ivy-more-chars-alist caller more-chars))
   (when grep-p
@@ -1933,11 +1944,12 @@ May supersede `ivy-initial-inputs-alist'."
   :type 'integer)
 
 (defalias 'ivy--dirname-p
+  ;; Added in Emacs 25.1.
   (if (fboundp 'directory-name-p)
       #'directory-name-p
     (lambda (name)
       "Return non-nil if NAME ends with a directory separator."
-      (string-match-p "/\\'" name))))
+      (string-suffix-p "/" name))))
 
 (defun ivy--sorted-files (dir)
   "Return the list of files in DIR.
@@ -1968,9 +1980,13 @@ Directories come first."
   "Return the value associated with KEY in ALIST, using `assq'.
 KEY defaults to the last caller of `ivy-read'; if no entry is
 found, it falls back to the key t."
-  (cdr (or (let ((caller (or key (ivy-state-caller ivy-last))))
-             (and caller (assq caller alist)))
-           (assq t alist))))
+  (let ((caller (or key (ivy-state-caller ivy-last))))
+    (or
+     (and caller (cdr (assq caller alist)))
+     (let ((parent (cdr (assq caller ivy--parents-alist))))
+       (when parent
+         (ivy-alist-setting alist parent)))
+     (cdr (assq t alist)))))
 
 (defun ivy--height (caller)
   (let ((v (or (ivy-alist-setting ivy-height-alist caller)
@@ -1987,6 +2003,14 @@ found, it falls back to the key t."
     (remove-list-of-text-properties 0 (length str) props str))
   str)
 
+(defun ivy--update-prompt (prompt)
+  (cond ((equal prompt "Keyword, C-h: ")
+         ;; auto-insert.el
+         "Keyword (C-M-j to end): ")
+        (t
+         ;; misearch.el
+         (replace-regexp-in-string "RET to end" "C-M-j to end" prompt))))
+
 ;;** Entry Point
 ;;;###autoload
 (cl-defun ivy-read (prompt collection
@@ -2056,12 +2080,15 @@ list of candidates, and returns the list of matching 
candidates.
 DYNAMIC-COLLECTION is a boolean specifying whether the list of
 candidates is updated after each input by calling COLLECTION.
 
-EXTRA-PROPS can be used to store collection-specific
-session-specific data.
+EXTRA-PROPS is a plist that can be used to store
+collection-specific session-specific data.
 
 CALLER is a symbol to uniquely identify the caller to `ivy-read'.
 It is used, along with COLLECTION, to determine which
 customizations apply to the current completion session."
+  (let ((init-fn (ivy-alist-setting ivy-init-fns-alist caller)))
+    (when init-fn
+      (funcall init-fn)))
   ;; get un-stuck from an existing `read-key' overriding minibuffer keys
   (when (equal overriding-local-map '(keymap))
     (keyboard-quit))
@@ -2070,13 +2097,12 @@ customizations apply to the current completion session."
          (ivy--display-function
           (when (or ivy-recursive-last
                     (not (window-minibuffer-p)))
-            (ivy-alist-setting ivy-display-functions-alist caller)))
-         result)
+            (ivy-alist-setting ivy-display-functions-alist caller))))
     (setq update-fn (or update-fn (ivy-alist-setting ivy-update-fns-alist 
caller)))
     (setq unwind (or unwind (ivy-alist-setting ivy-unwind-fns-alist caller)))
     (setq ivy-last
           (make-ivy-state
-           :prompt prompt
+           :prompt (ivy--update-prompt prompt)
            :collection collection
            :predicate predicate
            :require-match require-match
@@ -2104,7 +2130,7 @@ customizations apply to the current completion session."
            :re-builder re-builder
            :matcher matcher
            :dynamic-collection dynamic-collection
-           :display-transformer-fn (plist-get ivy--display-transformers-list 
caller)
+           :display-transformer-fn (ivy-alist-setting 
ivy--display-transformers-alist caller)
            :directory default-directory
            :extra-props extra-props
            :caller caller
@@ -2126,30 +2152,50 @@ customizations apply to the current completion session."
                    (setf (ivy-state-current ivy-last)
                          (car ivy--all-candidates))
                    (setq ivy-exit 'done))
-               (read-from-minibuffer
-                prompt
-                (ivy-state-initial-input ivy-last)
-                (make-composed-keymap keymap ivy-minibuffer-map)
-                nil
-                hist))
+               (condition-case err
+                   (read-from-minibuffer
+                    prompt
+                    (ivy-state-initial-input ivy-last)
+                    (make-composed-keymap keymap ivy-minibuffer-map)
+                    nil
+                    hist)
+                 (error
+                  (unless (equal err '(error "Selecting deleted buffer"))
+                    (signal (car err) (cdr err))))))
              (when (eq ivy-exit 'done)
-               (let ((item (if ivy--directory
-                               (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))))))))
-             (setq result (ivy-state-current ivy-last))))
+               (ivy--update-history hist))))
+      (let ((session (or (plist-get extra-props :session)
+                         (unless (or (minibufferp)
+                                     (null (ivy-state-action ivy-last))
+                                     (eq (ivy--get-action ivy-last) 
#'identity))
+                           caller))))
+        (when session
+          (setf (ivy-state-extra-props ivy-last)
+                (plist-put extra-props :ivy-data `(:all-candidates 
,ivy--all-candidates
+                                                   :text ,ivy-text)))
+          (ivy--alist-set 'ivy--sessions session ivy-last)))
       (ivy--cleanup))
-    (ivy-call)
-    (ivy--remove-props (ivy-state-current ivy-last) 'idx)
-    result))
+    (ivy-call)))
+
+(defun ivy--update-history (hist)
+  (let ((item
+         (if (or (string= ivy-text "")
+                 (eq
+                  (plist-get (ivy-state-extra-props ivy-last) :caller)
+                  'ivy-completing-read)
+                 (eq (ivy-state-history ivy-last) 'file-name-history))
+             (ivy-state-current ivy-last)
+           ivy-text)))
+    (cond ((equal item ""))
+          ((stringp item)
+           (set hist (cons (propertize item 'ivy-index ivy--index)
+                           (delete item (symbol-value hist))))))))
 
 (defun ivy--cleanup ()
   ;; Fixes a bug in ESS, #1660
   (put 'post-command-hook 'permanent-local nil)
   (remove-hook 'post-command-hook #'ivy--queue-exhibit)
+  (remove-hook 'window-size-change-functions #'ivy--window-size-changed)
   (let ((cleanup (ivy--display-function-prop :cleanup))
         (unwind (ivy-state-unwind ivy-last)))
     (when (functionp cleanup)
@@ -2186,34 +2232,37 @@ This is useful for recursive `ivy-read'."
          (sort (or (ivy-state-sort state) (assoc caller 
ivy-sort-functions-alist)))
          (initial-input
           (or (ivy-state-initial-input state)
-              (let ((init (cdr (assq caller ivy-initial-inputs-alist))))
-                (cond ((functionp init)
-                       (funcall init))
-                      (t
-                       init)))))
+              (let ((init (ivy-alist-setting ivy-initial-inputs-alist caller)))
+                (if (functionp init) (funcall init) init))))
          (def (ivy-state-def state)))
+    (when (and (eq caller 'swiper-isearch) (buffer-modified-p))
+      (setq preselect nil))
     (setq ivy--extra-candidates (ivy--compute-extra-candidates caller))
     (setq ivy--directory nil)
+    (setq ivy--directory-hist (list default-directory))
     (setq ivy-case-fold-search ivy-case-fold-search-default)
-    (setq ivy--regex-function
-          (or re-builder
-              (and (functionp collection)
-                   (cdr (assq collection ivy-re-builders-alist)))
-              (ivy-alist-setting ivy-re-builders-alist)
-              #'ivy--regex))
+    (setf (ivy-state-re-builder ivy-last)
+          (setq ivy--regex-function
+                (or re-builder
+                    (and (functionp collection)
+                         (cdr (assq collection ivy-re-builders-alist)))
+                    (ivy-alist-setting ivy-re-builders-alist)
+                    #'ivy--regex)))
     (setq ivy--subexps 0)
     (setq ivy--regexp-quote #'regexp-quote)
     (setq ivy--old-text "")
     (setq ivy--full-length nil)
-    (setq ivy-text "")
+    (ivy-set-text (or initial-input ""))
     (setq ivy--index 0)
     (setq ivy-calling nil)
     (setq ivy-use-ignore ivy-use-ignore-default)
     (setf (ivy-state-ignore state) ivy-use-ignore)
     (setq ivy--highlight-function
-          (or (cdr (assq ivy--regex-function ivy-highlight-functions-alist))
+          (or (cdr (assq (ivy-alist-setting ivy-re-builders-alist)
+                         ivy-highlight-functions-alist))
               #'ivy--highlight-default))
-    (let (coll sort-fn)
+    (let ((ivy-recursive-restore nil)
+          coll sort-fn)
       (cond ((eq collection #'Info-read-node-name-1)
              (setq coll
                    (if (equal (bound-and-true-p Info-current-file) "dir")
@@ -2221,7 +2270,7 @@ This is useful for recursive `ivy-read'."
                                (delete-dups
                                 (all-completions "(" collection predicate)))
                      (all-completions "" collection predicate))))
-            ((eq collection #'read-file-name-internal)
+            ((memq collection '(read-file-name-internal 
ffap-read-file-or-url-internal))
              (require 'tramp)
              (when (and (equal def initial-input)
                         (member "./" ivy-extra-directories))
@@ -2267,12 +2316,8 @@ This is useful for recursive `ivy-read'."
                            (equal initial-input default-directory)
                            (equal initial-input ""))
                  (setq coll (cons initial-input coll)))
-               (when (or (not (ivy-state-action ivy-last))
-                         (equal (ivy--get-action ivy-last) 'identity))
-                 (setq initial-input nil))))
+               (setq initial-input (file-name-nondirectory initial-input))))
             ((eq collection #'internal-complete-buffer)
-             (setq prompt
-                   (replace-regexp-in-string "RET to end" "C-M-j to end" 
prompt))
              (setq coll (ivy--buffer-list
                          ""
                          (and ivy-use-virtual-buffers
@@ -2281,7 +2326,9 @@ This is useful for recursive `ivy-read'."
                                                counsel-switch-buffer)))
                          predicate)))
             (dynamic-collection
-             (setq coll (funcall collection (or initial-input ""))))
+             (setq coll (if (and (eq this-command 'ivy-resume) (not 
(buffer-modified-p)))
+                            ivy--all-candidates
+                          (ivy--dynamic-collection-cands (or initial-input 
"")))))
             ((consp (car-safe collection))
              (setq collection (cl-remove-if-not predicate collection))
              (when (and sort (setq sort-fn (ivy--sort-function caller)))
@@ -2306,18 +2353,21 @@ This is useful for recursive `ivy-read'."
              (setq coll (all-completions "" collection predicate))))
       (unless (ivy-state-dynamic-collection ivy-last)
         (setq coll (delete "" coll)))
-      (when def
-        (cond ((stringp (car-safe def))
-               (setq coll (cl-union def coll :test #'equal)))
-              ((and (stringp def) (not (member def coll)))
-               (push def coll))))
       (when (and sort
                  (or (functionp collection)
                      (not (eq history 'org-refile-history)))
                  (setq sort-fn (ivy--sort-function
                                 (if (functionp collection) collection caller)))
+                 (listp coll)
                  (null (nthcdr ivy-sort-max-size coll)))
         (setq coll (sort (copy-sequence coll) sort-fn)))
+      (when def
+        (cond ((stringp (car-safe def))
+               (setq coll
+                     (delete-dups
+                      (append def coll))))
+              ((and (stringp def) (not (member def coll)))
+               (push def coll))))
       (setq coll (ivy--set-candidates coll))
       (setq ivy--old-re nil)
       (setq ivy--old-cands nil)
@@ -2354,18 +2404,18 @@ This is useful for recursive `ivy-read'."
 (defun ivy-add-prompt-count (prompt)
   "Add count information to PROMPT."
   (cond ((null ivy-count-format)
-         (error
-          "`ivy-count-format' can't be nil.  Set it to \"\" instead"))
+         (error "`ivy-count-format' must not be nil; set it to \"\" instead"))
         ((string-match "%d.*\\(%d\\)" ivy-count-format)
-         (let* ((w (1+ (floor (log (max 1 (length ivy--all-candidates)) 10))))
+         (let* ((w
+                  (if (listp ivy--all-candidates)
+                      (1+ (floor (log (max 1 (length ivy--all-candidates)) 
10)))
+                      1))
                 (s (replace-match (format "%%-%dd" w) t t ivy-count-format 1)))
            (string-match "%d" s)
            (concat (replace-match (format "%%%dd" w) t t s)
                    prompt)))
         ((string-match-p "%.*d" ivy-count-format)
          (concat ivy-count-format prompt))
-        (ivy--directory
-         prompt)
         (t
          prompt)))
 
@@ -2385,7 +2435,7 @@ This interface conforms to `completing-read' and can be 
used for
 PROMPT is a string that normally ends in a colon and a space.
 COLLECTION is either a list of strings, an alist, an obarray, or a hash table.
 PREDICATE limits completion to a subset of COLLECTION.
-REQUIRE-MATCH is a boolean value.  See `completing-read'.
+REQUIRE-MATCH is a boolean value or a symbol.  See `completing-read'.
 INITIAL-INPUT is a string inserted into the minibuffer initially.
 HISTORY is a list of previously selected inputs.
 DEF is the default value.
@@ -2412,7 +2462,8 @@ INHERIT-INPUT-METHOD is currently ignored."
       (let ((str (ivy-read
                   prompt collection
                   :predicate predicate
-                  :require-match (and collection require-match)
+                  :require-match (when (and collection require-match)
+                                   require-match)
                   :initial-input (cond ((consp initial-input)
                                         (car initial-input))
                                        ((and (stringp initial-input)
@@ -2427,6 +2478,7 @@ INHERIT-INPUT-METHOD is currently ignored."
                   :history history
                   :keymap nil
                   :dynamic-collection ivy-completing-read-dynamic-collection
+                  :extra-props '(:caller ivy-completing-read)
                   :caller (if (and collection (symbolp collection))
                               collection
                             this-command))))
@@ -2529,9 +2581,6 @@ See `completion-in-region' for further information."
                                       str)))
                                  (t
                                   (substring str (- len))))))
-             (setq ivy--old-re nil)
-             (unless (ivy--filter initial comps)
-               (setq initial nil))
              (delete-region (- end len) end)
              (setq ivy-completion-beg (- end len))
              (setq ivy-completion-end ivy-completion-beg)
@@ -2544,19 +2593,30 @@ See `completion-in-region' for further information."
                (dolist (s comps)
                  ;; Remove face `completions-first-difference'.
                  (ivy--remove-props s 'face))
-               (ivy-read (format "(%s): " str) comps
-                         ;; Predicate was already applied by
-                         ;; `completion-all-completions'.
-                         :predicate nil
-                         :initial-input initial
+               (setq ivy--old-re nil)
+               (unless (ivy--filter initial comps)
+                 (setq initial nil)
+                 (setq predicate nil)
+                 (setq collection comps))
+               (unless (derived-mode-p #'emacs-lisp-mode)
+                 (setq collection comps)
+                 (setq predicate nil))
+               (ivy-read (format "(%s): " str) collection
+                         :predicate predicate
+                         :initial-input (concat
+                                         (and (derived-mode-p 
#'emacs-lisp-mode)
+                                              "^")
+                                         initial)
                          :action #'ivy-completion-in-region-action
                          :unwind (lambda ()
                                    (unless (eq ivy-exit 'done)
                                      (goto-char ivy-completion-beg)
                                      (when initial
                                        (insert initial))))
-                         :caller 'ivy-completion-in-region)
-               t))))))
+                         :caller 'ivy-completion-in-region)))
+           ;; Return value should be non-nil on valid completion;
+           ;; see `completion-in-region'.
+           t))))
 
 (defun ivy-completion-in-region-prompt ()
   "Prompt function for `ivy-completion-in-region'.
@@ -2570,6 +2630,12 @@ See `ivy-set-prompt'."
   "When non-nil `ivy-mode' will set `completion-in-region-function'."
   :type 'boolean)
 
+(defvar ivy--old-crf nil
+  "Store previous value of `completing-read-function'.")
+
+(defvar ivy--old-cirf nil
+  "Store previous value of `completion-in-region-function'.")
+
 ;;;###autoload
 (define-minor-mode ivy-mode
   "Toggle Ivy mode on or off.
@@ -2588,21 +2654,32 @@ Minibuffer bindings:
   :lighter " ivy"
   (if ivy-mode
       (progn
-        (setq completing-read-function 'ivy-completing-read)
+        (unless (eq completing-read-function #'ivy-completing-read)
+          (setq ivy--old-crf completing-read-function)
+          (setq completing-read-function #'ivy-completing-read))
         (when ivy-do-completion-in-region
-          (setq completion-in-region-function 'ivy-completion-in-region)))
-    (setq completing-read-function 'completing-read-default)
-    (setq completion-in-region-function 'completion--in-region)))
+          (unless (eq completion-in-region-function #'ivy-completion-in-region)
+            (setq ivy--old-cirf completion-in-region-function)
+            (setq completion-in-region-function #'ivy-completion-in-region))))
+    (when (eq completing-read-function #'ivy-completing-read)
+      (setq completing-read-function (or ivy--old-crf
+                                         #'completing-read-default))
+      (setq ivy--old-crf nil))
+    (when (eq completion-in-region-function #'ivy-completion-in-region)
+      (setq completion-in-region-function (or ivy--old-cirf
+                                              #'completion--in-region))
+      (setq ivy--old-cirf nil))))
 
 (defun ivy--preselect-index (preselect candidates)
   "Return the index of PRESELECT in CANDIDATES."
-  (cond ((integerp preselect)
-         (if (integerp (car candidates))
-             (cl-position preselect candidates)
-           preselect))
-        ((cl-position preselect candidates :test #'equal))
-        ((ivy--regex-p preselect)
-         (cl-position preselect candidates :test #'string-match-p))))
+  (or (cond ((integerp preselect)
+             (if (integerp (car candidates))
+                 (cl-position preselect candidates)
+               preselect))
+            ((cl-position preselect candidates :test #'equal))
+            ((ivy--regex-p preselect)
+             (cl-position preselect candidates :test #'string-match-p)))
+      0))
 
 ;;* Implementation
 ;;** Regex
@@ -2633,6 +2710,8 @@ This concept is used to generalize regular expressions for
   (make-hash-table :test #'equal)
   "Store pre-computed regex.")
 
+(defvar ivy--input-garbage nil)
+
 (defun ivy--split (str)
   "Split STR into list of substrings bounded by spaces.
 Single spaces act as splitting points.  Consecutive spaces
@@ -2641,40 +2720,72 @@ split.  This allows the literal interpretation of N 
spaces by
 inputting N+1 spaces.  Any substring not constituting a valid
 regexp is passed to `regexp-quote'."
   (let ((len (length str))
-        start0
-        (start1 0)
-        res s
-        match-len)
-    (while (and (string-match " +" str start1)
-                (< start1 len))
-      (if (and (> (match-beginning 0) 2)
-               (string= "[^" (substring
-                              str
-                              (- (match-beginning 0) 2)
-                              (match-beginning 0))))
-          (progn
-            (setq start0 start1)
-            (setq start1 (match-end 0)))
-        (setq match-len (- (match-end 0) (match-beginning 0)))
-        (if (= match-len 1)
-            (progn
-              (when start0
-                (setq start1 start0)
-                (setq start0 nil))
-              (push (substring str start1 (match-beginning 0)) res)
-              (setq start1 (match-end 0)))
-          (setq str (replace-match
-                     (make-string (1- match-len) ?\ )
-                     nil nil str))
-          (setq start0 (or start0 start1))
-          (setq start1 (1- (match-end 0))))))
-    (if start0
-        (push (substring str start0) res)
-      (setq s (substring str start1))
-      (unless (= (length s) 0)
-        (push s res)))
+        (i 0)
+        (start 0)
+        (res nil)
+        match-len
+        end
+        c)
+    (catch 'break
+      (while (< i len)
+        (setq c (aref str i))
+        (cond ((= ?\[ c)
+               (if (setq end (ivy--match-regex-brackets
+                              (substring str i)))
+                   (cl-incf i end)
+                 (setq ivy--input-garbage (substring str i))
+                 (throw 'break nil)))
+              ((= ?\\ c)
+               (if (and (< (1+ i) len) (= ?\( (aref str (1+ i))))
+                   (progn
+                     (when (> i start)
+                       (push (substring str start i) res))
+                     (if (eq (string-match "\\\\([^\0]*?\\\\)" str i) i)
+                         (progn
+                           (push (match-string 0 str) res)
+                           (setq i (match-end 0))
+                           (setq start i))
+                       (setq ivy--input-garbage (substring str i))
+                       (throw 'break nil)))
+                 (cl-incf i)))
+              ((= ?\  c)
+               (string-match " +" str i)
+               (setq match-len (- (match-end 0) (match-beginning 0)))
+               (if (= match-len 1)
+                   (progn
+                     (when (> i start)
+                       (push (substring str start i) res))
+                     (setq start (1+ i)))
+                 (setq str (replace-match
+                            (make-string (1- match-len) ?\ )
+                            nil nil str))
+                 (setq len (length str))
+                 (cl-incf i (1- match-len)))
+               (cl-incf i))
+              (t
+               (cl-incf i)))))
+    (when (< start i)
+      (push (substring str start) res))
     (mapcar #'ivy--regex-or-literal (nreverse res))))
 
+(defun ivy--match-regex-brackets (str)
+  (let ((len (length str))
+        (i 1)
+        (open-count 1)
+        c)
+    (while (and (< i len)
+                (> open-count 0))
+      (setq c (aref str i))
+      (cond ((= c ?\[)
+             (cl-incf open-count))
+            ((= c ?\])
+             (cl-decf open-count)))
+      (cl-incf i))
+    (when (= open-count 0)
+      (if (eq (string-match "[+*?]" str i) i)
+          (match-end 0)
+        i))))
+
 (defun ivy--trim-trailing-re (regex)
   "Trim incomplete REGEX.
 If REGEX ends with \\|, trim it, since then it matches an empty string."
@@ -2704,13 +2815,17 @@ When GREEDY is non-nil, join words in a greedy way."
                              (car subs)))
                         (cons
                          (setq ivy--subexps (length subs))
-                         (mapconcat
-                          (lambda (x)
-                            (if (string-match-p "\\`\\\\([^?].*\\\\)\\'" x)
-                                x
-                              (format "\\(%s\\)" x)))
-                          subs
-                          (if greedy ".*" ".*?")))))
+                         (replace-regexp-in-string
+                          "\\.\\*\\??\\\\( "
+                          "\\( "
+                          (mapconcat
+                           (lambda (x)
+                             (if (string-match-p "\\`\\\\([^?][^\0]*\\\\)\\'" 
x)
+                                 x
+                               (format "\\(%s\\)" x)))
+                           subs
+                           (if greedy ".*" ".*?"))
+                          nil t))))
                     ivy--regex-hash)))))
 
 (defun ivy--regex-p (object)
@@ -2863,6 +2978,7 @@ tries to ensure that it does not change depending on the 
number of candidates."
     (when height
       (set-window-text-height nil height)))
   (add-hook 'post-command-hook #'ivy--queue-exhibit nil t)
+  (add-hook 'window-size-change-functions #'ivy--window-size-changed nil t)
   (let ((hook (ivy-alist-setting ivy-hooks-alist)))
     (when (functionp hook)
       (funcall hook))))
@@ -2996,7 +3112,7 @@ parts beyond their respective faces `ivy-confirm-face' and
         ;; remove the face as well.
         (when ivy--use-selectable-prompt
           (if (= ivy--index -1)
-              (ivy-add-face-text-property
+              (add-face-text-property
                (minibuffer-prompt-end) (line-end-position) 'ivy-prompt-match)
             (remove-list-of-text-properties
              (minibuffer-prompt-end) (line-end-position) '(face))))
@@ -3035,8 +3151,8 @@ Possible choices are 
'ivy-magic-slash-non-match-cd-selected,
   (let (remote)
     (cond
       ;; Windows
-      ((string-match "\\`[[:alpha:]]:/" ivy--directory)
-       (match-string 0 ivy--directory))
+      ;; ((string-match "\\`[[:alpha:]]:/" ivy--directory)
+      ;;  (match-string 0 ivy--directory))
       ;; Remote root if on remote
       ((setq remote (file-remote-p ivy--directory))
        (concat remote "/"))
@@ -3053,7 +3169,8 @@ Possible choices are 
'ivy-magic-slash-non-match-cd-selected,
           (magic (not (string= ivy-text "/"))))
       (cond ((member ivy-text ivy--all-candidates)
              (ivy--cd canonical))
-            ((string-match-p "//\\'" ivy-text)
+            ((and (eq system-type 'windows-nt) (string= ivy-text "//")))
+            ((string-suffix-p "//" ivy-text)
              (ivy--cd
               (ivy--magic-file-doubleslash-directory)))
             ((string-match-p "\\`/ssh:" ivy-text)
@@ -3150,21 +3267,35 @@ Should be run via minibuffer `post-command-hook'."
                'ivy--exhibit)))
     (ivy--exhibit)))
 
+(defalias 'ivy--file-local-name
+  (if (fboundp 'file-local-name)
+      #'file-local-name
+    (lambda (file)
+      (or (file-remote-p file 'localname) file)))
+  "Compatibility shim for `file-local-name'.
+The function was added in Emacs 26.1.")
+
 (defun ivy--magic-tilde-directory (dir)
   "Return an appropriate home for DIR for when ~ or ~/ are entered."
-  (expand-file-name
-   (let (remote)
-     (if (and (setq remote (file-remote-p dir))
-              (let ((local (file-local-name dir)))
-                (not (or (string= "/root/" local)
-                         (string-match-p "/home/\\([^/]+\\)/\\'" local)))))
-         (concat remote "~/")
-       "~/"))))
+  (file-name-as-directory
+   (expand-file-name
+    (let* ((home (expand-file-name (concat (file-remote-p dir) "~/")))
+           (dir-path (ivy--file-local-name dir))
+           (home-path (ivy--file-local-name home)))
+      (if (string= dir-path home-path)
+          "~"
+        home)))))
+
+(defvar ivy--minibuffer-metadata nil)
 
 (defun ivy-update-candidates (cands)
-  (ivy--insert-minibuffer
-   (ivy--format
-    (setq ivy--all-candidates cands))))
+  (let ((ivy--minibuffer-metadata
+         (unless (ivy-state-dynamic-collection ivy-last)
+           (completion-metadata "" minibuffer-completion-table
+                                minibuffer-completion-predicate))))
+    (ivy--insert-minibuffer
+     (ivy--format
+      (setq ivy--all-candidates cands)))))
 
 (defun ivy--exhibit ()
   "Insert Ivy completions display.
@@ -3172,53 +3303,64 @@ Should be run via minibuffer `post-command-hook'."
   (when (memq 'ivy--queue-exhibit post-command-hook)
     (let ((inhibit-field-text-motion nil))
       (constrain-to-field nil (point-max)))
-    (setq ivy-text (ivy--input))
-    (if (ivy-state-dynamic-collection ivy-last)
-        ;; while-no-input would cause annoying
-        ;; "Waiting for process to die...done" message interruptions
-        (let ((inhibit-message t)
-              coll in-progress)
-          (unless (equal ivy--old-text ivy-text)
-            (while-no-input
-              (setq coll (funcall (ivy-state-collection ivy-last) ivy-text))
-              (when (eq coll 0)
-                (setq coll nil)
-                (setq ivy--old-re nil)
-                (setq in-progress t))
-              (setq ivy--all-candidates (ivy--sort-maybe coll))
-              (setq ivy--old-text ivy-text)))
-          (when (eq ivy--all-candidates 0)
-            (setq ivy--all-candidates nil)
-            (setq ivy--old-re nil)
-            (setq in-progress t))
-          (when (or ivy--all-candidates
-                    (and (not (get-process " *counsel*"))
-                         (not in-progress)))
-            (ivy--set-index-dynamic-collection)
-            (ivy--insert-minibuffer
-             (ivy--format ivy--all-candidates))))
-      (cond (ivy--directory
-             (cond ((or (string= "~/" ivy-text)
-                        (and (string= "~" ivy-text)
-                             ivy-magic-tilde))
-                    (ivy--cd (ivy--magic-tilde-directory ivy--directory)))
-                   ((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)))
-                       (and (string-match "\\` " ivy--old-text)
-                            (not (string-match "\\` " ivy-text))))
-               (setq ivy--all-candidates
-                     (if (= (string-to-char ivy-text) ?\s)
-                         (ivy--buffer-list " ")
-                       (ivy--buffer-list "" ivy-use-virtual-buffers)))
-               (setq ivy--old-re nil))))
-      (ivy--insert-minibuffer
-       (with-current-buffer (ivy-state-buffer ivy-last)
-         (ivy--format
-          (ivy--filter ivy-text ivy--all-candidates))))
-      (setq ivy--old-text ivy-text))))
+    (ivy-set-text (ivy--input))
+    (let ((new-minibuffer (ivy--update-minibuffer)))
+      (when new-minibuffer
+        (ivy--insert-minibuffer new-minibuffer)))
+    t))
+
+(defun ivy--dynamic-collection-cands (input)
+  (let ((coll (funcall (ivy-state-collection ivy-last) input)))
+    (if (listp coll)
+        (mapcar (lambda (x) (if (consp x) (car x) x)) coll)
+      coll)))
+
+(defun ivy--update-minibuffer ()
+  (prog1
+      (if (ivy-state-dynamic-collection ivy-last)
+          ;; while-no-input would cause annoying
+          ;; "Waiting for process to die...done" message interruptions
+          (let ((inhibit-message t)
+                coll in-progress)
+            (unless (or (equal ivy--old-text ivy-text)
+                        (eq this-command 'ivy-resume))
+              (while-no-input
+                (setq coll (ivy--dynamic-collection-cands ivy-text))
+                (when (eq coll 0)
+                  (setq coll nil)
+                  (setq ivy--old-re nil)
+                  (setq in-progress t))
+                (setq ivy--all-candidates (ivy--sort-maybe coll))))
+            (when (eq ivy--all-candidates 0)
+              (setq ivy--all-candidates nil)
+              (setq ivy--old-re nil)
+              (setq in-progress t))
+            (when (or ivy--all-candidates
+                      (and (not (get-process " *counsel*"))
+                           (not in-progress)))
+              (ivy--set-index-dynamic-collection)
+              (ivy--format ivy--all-candidates)))
+        (cond (ivy--directory
+               (cond ((or (string= "~/" ivy-text)
+                          (and (string= "~" ivy-text)
+                               ivy-magic-tilde))
+                      (ivy--cd (ivy--magic-tilde-directory ivy--directory)))
+                     ((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)))
+                         (and (string-match "\\` " ivy--old-text)
+                              (not (string-match "\\` " ivy-text))))
+                 (setq ivy--all-candidates
+                       (if (= (string-to-char ivy-text) ?\s)
+                           (ivy--buffer-list " ")
+                         (ivy--buffer-list "" ivy-use-virtual-buffers)))
+                 (setq ivy--old-re nil))))
+        (with-current-buffer (ivy-state-buffer ivy-last)
+          (ivy--format
+           (ivy--filter ivy-text ivy--all-candidates))))
+    (setq ivy--old-text ivy-text)))
 
 (defun ivy-display-function-fallback (str)
   (let ((buffer-undo-list t))
@@ -3249,25 +3391,64 @@ Should be run via minibuffer `post-command-hook'."
         (when (region-active-p)
           (set-mark old-mark))))))
 
+(defvar ivy-auto-shrink-minibuffer nil
+  "When non-nil and the height < `ivy-height', auto-shrink the minibuffer.")
+
+(make-obsolete-variable 'ivy-auto-shrink-minibuffer
+                        'ivy-auto-shrink-minibuffer-alist
+                        "<2020-04-28 Tue>")
+
+(defcustom ivy-auto-shrink-minibuffer-alist nil
+  "An alist to configure auto-shrinking of the minibuffer.
+
+Each key is a caller symbol.  When the value is non-nil, and the
+height < `ivy-height', auto-shrink the minibuffer."
+  :type '(alist
+          :key-type symbol
+          :value-type boolean))
+
+(defun ivy--do-shrink-window ()
+  (let ((h (save-excursion
+             (goto-char (minibuffer-prompt-end))
+             (let ((inhibit-field-text-motion t))
+               (line-number-at-pos)))))
+    (shrink-window (-
+                    (/ (window-body-height nil t)
+                       (frame-char-height))
+                    ivy--length h))))
+
 (defun ivy--resize-minibuffer-to-fit ()
   "Resize the minibuffer window size to fit the text in the minibuffer."
-  (unless (frame-root-window-p (minibuffer-window))
+  (unless (or (frame-root-window-p (minibuffer-window))
+              (memq this-command '(ivy-read-action
+                                   ivy-dispatching-done
+                                   ivy-dispatching-call)))
     (with-selected-window (minibuffer-window)
       (if (fboundp 'window-text-pixel-size)
           (let ((text-height (cdr (window-text-pixel-size)))
                 (body-height (window-body-height nil t)))
-            (when (> text-height body-height)
-              ;; 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))))
+            (cond ((> 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))))
+                     (window-resize nil delta nil t t)))
+                  ((and (or ivy-auto-shrink-minibuffer
+                            (ivy-alist-setting
+                             ivy-auto-shrink-minibuffer-alist))
+                        (< ivy--length ivy-height))
+                   (ivy--do-shrink-window))))
         (let ((text-height (count-screen-lines))
               (body-height (window-body-height)))
           (when (> text-height body-height)
             (window-resize nil (- text-height body-height) nil t)))))))
 
+(defun ivy--window-size-changed (&rest _)
+  "Resize ivy window to fit with current frame's size."
+  (when ivy-mode
+    (ivy--resize-minibuffer-to-fit)))
+
 (defun ivy--add-face (str face)
   "Propertize STR with FACE."
   (let ((len (length str)))
@@ -3276,8 +3457,8 @@ Should be run via minibuffer `post-command-hook'."
           (colir-blend-face-background 0 len face str)
           (let ((foreground (face-foreground face)))
             (when foreground
-              (ivy-add-face-text-property
-               0 len (list :foreground foreground) str))))
+              (add-face-text-property
+               0 len (list :foreground foreground) nil str))))
       (error
        (ignore-errors
          (font-lock-append-text-property 0 len 'face face str)))))
@@ -3288,8 +3469,8 @@ Should be run via minibuffer `post-command-hook'."
 
 (defvar ivy--flx-cache nil)
 
-(eval-after-load 'flx
-  '(setq ivy--flx-cache (flx-make-string-cache)))
+(with-eval-after-load 'flx
+  (setq ivy--flx-cache (flx-make-string-cache)))
 
 (defun ivy-toggle-case-fold ()
   "Toggle `case-fold-search' for Ivy operations.
@@ -3342,6 +3523,8 @@ CANDIDATES are assumed to be static."
              (matcher (ivy-state-matcher ivy-last))
              (case-fold-search (ivy--case-fold-p name))
              (cands (cond
+                      (matcher
+                       (funcall matcher re candidates))
                       ((and ivy--old-re
                             (stringp re)
                             (stringp ivy--old-re)
@@ -3355,8 +3538,6 @@ CANDIDATES are assumed to be static."
                                   '(0 2))
                             ivy--old-cands
                             (ivy--re-filter re ivy--old-cands)))
-                      (matcher
-                       (funcall matcher re candidates))
                       (t
                        (ivy--re-filter re candidates)))))
         (if (memq (cdr (assq (ivy-state-caller ivy-last)
@@ -3366,16 +3547,18 @@ CANDIDATES are assumed to be static."
                     ivy-recompute-index-swiper-async-backward
                     ivy-recompute-index-swiper-backward))
             (progn
-              (ivy--recompute-index name re-str cands)
+              (ivy--recompute-index 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))
+          (ivy--recompute-index re-str ivy--old-cands))
         (setq ivy--old-re re)
         ivy--old-cands))))
 
 (defun ivy--set-candidates (x)
   "Update `ivy--all-candidates' with X."
-  (let (res)
+  (let (res
+        ;; (ivy--recompute-index-inhibit t)
+        )
     (dolist (source ivy--extra-candidates)
       (if (equal source '(original-source))
           (if (null res)
@@ -3385,16 +3568,16 @@ CANDIDATES are assumed to be static."
         (setq res (append
                    (ivy--filter ivy-text (cadr source))
                    res))))
-    (setq ivy--all-candidates res)))
+    (setq ivy--all-candidates
+          (if (cdr ivy--extra-candidates)
+              (delete-dups res)
+            res))))
 
 (defun ivy--shorter-matches-first (_name cands)
   "Sort CANDS according to their length."
-  (if (< (length cands) ivy-sort-max-size)
-      (cl-sort
-       (copy-sequence cands)
-       (lambda (s1 s2)
-         (< (length s1) (length s2))))
-    cands))
+  (if (nthcdr ivy-sort-max-size cands)
+      cands
+    (cl-sort (copy-sequence cands) #'< :key #'length)))
 
 (defcustom ivy-sort-matches-functions-alist
   '((t . nil)
@@ -3511,57 +3694,56 @@ no sorting is done.")
 (defvar ivy--recompute-index-inhibit nil
   "When non-nil, `ivy--recompute-index' is a no-op.")
 
-(defun ivy--recompute-index (name re-str cands)
-  "Recompute index of selected candidate matching NAME.
-RE-STR is the regexp, CANDS are the current candidates."
+(defun ivy--recompute-index (re-str cands)
+  "Recompute index of selected candidate matching RE-STR.
+CANDS are the current candidates."
   (let ((caller (ivy-state-caller ivy-last))
         (func (or (ivy-alist-setting ivy-index-functions-alist)
                   #'ivy-recompute-index-zero))
-        (case-fold-search (ivy--case-fold-p name))
+        (case-fold-search (ivy--case-fold-p re-str))
         (preselect (ivy-state-preselect ivy-last))
         (current (ivy-state-current ivy-last))
-        (empty (string= name "")))
+        (empty (string= re-str "")))
     (unless (or (memq this-command '(ivy-resume ivy-partial-or-done))
                 ivy--recompute-index-inhibit)
-      (ivy-set-index
-       (if (or (string= name "")
-               (and (> (length cands) 10000) (eq func 
#'ivy-recompute-index-zero)))
-           0
-         (or
-          (cl-position (ivy--remove-prefix "^" name)
-                       cands
-                       :test #'ivy--case-fold-string=)
-          (and ivy--directory
-               (cl-position (concat re-str "/")
-                            cands
-                            :test #'ivy--case-fold-string=))
-          (and (eq caller 'ivy-switch-buffer)
-               (not empty)
-               0)
-          (and (not empty)
-               (not (eq caller 'swiper))
-               (not (and ivy--flx-featurep
-                         (eq ivy--regex-function 'ivy--regex-fuzzy)
-                         ;; Limit to configured number of candidates
-                         (null (nthcdr ivy-flx-limit cands))))
-               ;; If there was a preselected candidate, don't try to
-               ;; keep it selected even if the regexp still matches it.
-               ;; See issue #1563.  See also `ivy--preselect-index',
-               ;; which this logic roughly mirrors.
-               (not (or
-                     (and (integerp preselect)
-                          (= ivy--index preselect))
-                     (equal current preselect)
-                     (and (ivy--regex-p preselect)
-                          (stringp current)
-                          (string-match-p preselect current))))
-               ivy--old-cands
-               (cl-position current cands :test #'equal))
-          (funcall func re-str cands)))))
-    (when (or empty (string= name "^"))
-      (ivy-set-index
-       (or (ivy--preselect-index preselect cands)
-           ivy--index)))))
+      (let ((index (cond
+                     ((or empty (string= re-str "^"))
+                      (ivy--preselect-index preselect cands))
+                     ((and (> (length cands) 10000) (eq func 
#'ivy-recompute-index-zero))
+                      0)
+                     ((cl-position (string-remove-prefix "^" re-str)
+                                   cands
+                                   :test #'ivy--case-fold-string=))
+                     ((and (ivy--completing-fname-p)
+                           (cl-position (concat re-str "/")
+                                        cands
+                                        :test #'ivy--case-fold-string=)))
+                     ((and (eq caller 'ivy-switch-buffer)
+                           (not empty))
+                      (or (cl-position current cands :test #'string=)
+                          0))
+                     ((and (not empty)
+                           (not (eq caller 'swiper))
+                           (not (and ivy--flx-featurep
+                                     (eq ivy--regex-function 'ivy--regex-fuzzy)
+                                     ;; Limit to configured number of 
candidates
+                                     (null (nthcdr ivy-flx-limit cands))))
+                           ;; If there was a preselected candidate, don't try 
to
+                           ;; keep it selected even if the regexp still 
matches it.
+                           ;; See issue #1563.  See also 
`ivy--preselect-index',
+                           ;; which this logic roughly mirrors.
+                           (not (or
+                                 (and (integerp preselect)
+                                      (= ivy--index preselect))
+                                 (equal current preselect)
+                                 (and (ivy--regex-p preselect)
+                                      (stringp current)
+                                      (string-match-p preselect current))))
+                           ivy--old-cands
+                           (cl-position current cands :test #'equal)))
+                     ((funcall func re-str cands))
+                     (t 0))))
+        (ivy-set-index index)))))
 
 (defun ivy-recompute-index-swiper (_re-str cands)
   "Recompute index of selected candidate when using `swiper'.
@@ -3670,7 +3852,7 @@ N wraps around, but skips the first element of the list."
       (unless (eq j (1+ last-j))
         (cl-incf i))
       (setq last-j j)
-      (ivy-add-face-text-property j (1+ j) (ivy--minibuffer-face i) str))
+      (add-face-text-property j (1+ j) (ivy--minibuffer-face i) nil str))
     str))
 
 (defun ivy--flx-sort (name cands)
@@ -3763,7 +3945,9 @@ and SEPARATOR is used to join them."
    "\n"))
 
 (defun ivy-format-function-line (cands)
-  "Transform CANDS into a string for minibuffer."
+  "Transform CANDS into a string for minibuffer.
+Note that since Emacs 27, `ivy-current-match' needs to have :extend t 
attribute.
+It has it by default, but the current theme also needs to set it."
   (ivy--format-function-generic
    (lambda (str)
      (ivy--add-face (concat str "\n") 'ivy-current-match))
@@ -3772,31 +3956,16 @@ and SEPARATOR is used to join them."
    cands
    ""))
 
-(defalias 'ivy-add-face-text-property
-  (if (fboundp 'add-face-text-property)
-      (lambda (start end face &optional object append)
-        (add-face-text-property start end face append object))
-    (lambda (start end face &optional object append)
-      (funcall (if append
-                   #'font-lock-append-text-property
-                 #'font-lock-prepend-text-property)
-               start end 'face face object)))
-  "Compatibility shim for `add-face-text-property'.
-Fall back on `font-lock-prepend-text-property' in Emacs versions
-prior to 24.4 (`font-lock-append-text-property' when APPEND is
-non-nil).
-Note: The usual last two arguments are flipped for convenience.")
-
 (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
+          (add-face-text-property
            (match-beginning 0) (match-end 0)
            (ivy--minibuffer-face i)
-           str))
+           nil str))
         (cl-incf i))))
   str)
 
@@ -3804,15 +3973,23 @@ Note: The usual last two arguments are flipped for 
convenience.")
   "Highlight STR, using the fuzzy method."
   (if (and ivy--flx-featurep
            (eq (ivy-alist-setting ivy-re-builders-alist) 'ivy--regex-fuzzy))
-      (let ((flx-name (ivy--remove-prefix "^" ivy-text)))
+      (let ((flx-name (string-remove-prefix "^" ivy-text)))
         (ivy--flx-propertize
          (cons (flx-score str flx-name ivy--flx-cache) str)))
     (ivy--highlight-default str)))
 
+(defcustom ivy-use-group-face-if-no-groups t
+  "If t, and the expression has no subgroups, highlight whole match as a group.
+
+It will then use the second face (first of the \"group\" faces)
+of `ivy-minibuffer-faces'.  Otherwise, always use the first face
+in this case."
+  :type 'boolean)
+
 (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)))
+    (setq ivy--old-re ivy-regex))
   (let ((regexps
          (if (listp ivy--old-re)
              (mapcar #'car (cl-remove-if-not #'cdr ivy--old-re))
@@ -3830,16 +4007,18 @@ Note: The usual last two arguments are flipped for 
convenience.")
               (let ((beg (match-beginning i))
                     (end (match-end i)))
                 (when (and beg end)
-                  (unless (and prev (= prev beg))
+                  (unless (or (and prev (= prev beg))
+                              (zerop i))
                     (cl-incf n))
                   (let ((face
-                         (cond ((zerop ivy--subexps)
+                         (cond ((and ivy-use-group-face-if-no-groups
+                                     (zerop ivy--subexps))
                                 (cadr ivy-minibuffer-faces))
                                ((zerop i)
                                 (car ivy-minibuffer-faces))
                                (t
                                 (ivy--minibuffer-face n)))))
-                    (ivy-add-face-text-property beg end face str))
+                    (add-face-text-property beg end face nil str))
                   (unless (zerop i)
                     (setq prev end))))
               (cl-incf i)))))))
@@ -3859,7 +4038,8 @@ Note: The usual last two arguments are flipped for 
convenience.")
                     (funcall ivy--highlight-function str))
                 str))
          (olen (length str))
-         (annot (plist-get completion-extra-properties :annotation-function)))
+         (annot (or (completion-metadata-get ivy--minibuffer-metadata 
'annotation-function)
+                    (plist-get completion-extra-properties 
:annotation-function))))
     (add-text-properties
      0 olen
      '(mouse-face
@@ -3873,8 +4053,8 @@ Note: The usual last two arguments are flipped for 
convenience.")
      str)
     (when annot
       (setq str (concat str (funcall annot str)))
-      (ivy-add-face-text-property
-       olen (length str) 'ivy-completions-annotations str))
+      (add-face-text-property
+       olen (length str) 'ivy-completions-annotations nil str))
     str))
 
 (defun ivy-read-file-transformer (str)
@@ -3984,7 +4164,7 @@ CANDS is a list of candidates that :display-transformer 
can turn into strings."
       (setq ivy--virtual-buffers (nreverse virtual-buffers))
       (mapcar #'car ivy--virtual-buffers))))
 
-(defcustom ivy-ignore-buffers '("\\` ")
+(defcustom ivy-ignore-buffers '("\\` " "\\`\\*tramp/")
   "List of regexps or functions matching buffer names to ignore."
   :type '(repeat (choice regexp function)))
 
@@ -4000,20 +4180,7 @@ If optional argument PREDICATE is non-nil, use it to 
test each
 possible match.  See `all-completions' for further information."
   (delete-dups
    (nconc
-    (mapcar
-     (lambda (x)
-       (let* ((buf (get-buffer x))
-              (dir (buffer-local-value 'default-directory buf))
-              (face (if (and dir
-                             (ignore-errors
-                               (file-remote-p (abbreviate-file-name dir))))
-                        'ivy-remote
-                      (cdr (assq (buffer-local-value 'major-mode buf)
-                                 ivy-switch-buffer-faces-alist)))))
-         (if face
-             (propertize x 'face face)
-           x)))
-     (all-completions str #'internal-complete-buffer predicate))
+    (all-completions str #'internal-complete-buffer predicate)
     (and virtual
          (ivy--virtual-buffers)))))
 
@@ -4030,10 +4197,13 @@ possible match.  See `all-completions' for further 
information."
 
 The default value is given as an example.
 
-Each element is a list of (NAME TREE).  NAME is a string, it's
+Each element is a list of (NAME VIEW). NAME is a string, it's
 recommended to end it with a distinctive snippet e.g. \"{}\" so
 that it's easy to distinguish the window configurations.
 
+VIEW is either a TREE or a window-configuration (see
+`ivy--get-view-config').
+
 TREE is a nested list with the following valid cars:
 - vert: split the window vertically
 - horz: split the window horizontally
@@ -4075,6 +4245,22 @@ TREE can be nested multiple times to have multiple 
window splits.")
           (t
            default-view-name))))
 
+(defun ivy--get-view-config ()
+  "Get `current-window-configuration' for `ivy-views'."
+  (dolist (w (window-list))
+    (set-window-parameter w 'ivy-view-data
+                          (with-current-buffer (window-buffer w)
+                            (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)))))))
+  (let ((window-persistent-parameters
+         (append window-persistent-parameters
+                 (list (cons 'ivy-view-data t)))))
+    (current-window-configuration)))
+
 (defun ivy-push-view (&optional arg)
   "Push the current window tree on `ivy-views'.
 
@@ -4084,22 +4270,7 @@ Currently, the split configuration (i.e. horizontal 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 "P")
-  (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)))))
+  (let* ((view (ivy--get-view-config))
          (view-name
           (if arg
               (ivy-read "Update view: " ivy-views)
@@ -4137,7 +4308,13 @@ Use `ivy-pop-view' to delete any item from `ivy-views'."
 
 (defun ivy-set-view-recur (view)
   "Set VIEW recursively."
-  (cond ((eq (car view) 'vert)
+  (cond  ((window-configuration-p view)
+          (set-window-configuration view)
+          (dolist (w (window-list))
+            (with-selected-window w
+              (ivy-set-view-recur
+               (window-parameter w 'ivy-view-data)))))
+         ((eq (car view) 'vert)
          (let* ((wnd1 (selected-window))
                 (wnd2 (split-window-vertically))
                 (views (cdr view))
@@ -4252,17 +4429,25 @@ BUFFER may be a string or nil."
   (let ((ivy--recompute-index-inhibit t))
     (ivy--exhibit)))
 
+(defun ivy--kill-current-candidate-buffer ()
+  (setf (ivy-state-preselect ivy-last) ivy--index)
+  (setq ivy--old-re nil)
+  (setq ivy--all-candidates (ivy--buffer-list "" ivy-use-virtual-buffers
+                                              (ivy-state-predicate ivy-last)))
+  (let ((ivy--recompute-index-inhibit t))
+    (ivy--exhibit)))
+
 (defun ivy--kill-buffer-action (buffer)
   "Kill BUFFER."
   (ivy--kill-buffer-or-virtual buffer)
   (unless (buffer-live-p (ivy-state-buffer ivy-last))
     (setf (ivy-state-buffer ivy-last)
           (with-ivy-window (current-buffer))))
-  (ivy--kill-current-candidate))
+  (ivy--kill-current-candidate-buffer))
 
 (defvar ivy-switch-buffer-map
   (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-k") 'ivy-switch-buffer-kill)
+    (ivy-define-key map (kbd "C-k") 'ivy-switch-buffer-kill)
     map))
 
 (defun ivy-switch-buffer-kill ()
@@ -4291,46 +4476,83 @@ Otherwise, forward to `ivy-kill-line'."
 
 (ivy-set-actions
  t
- `(("i" ,(lambda (x) (insert (if (stringp x) x (car x)))) "insert")
-   ("w" ,(lambda (x) (kill-new (if (stringp x) x (car x)))) "copy")))
+ '(("i" ivy--action-insert "insert")
+   ("w" ivy--action-copy "copy")))
+
+(defun ivy--trim-grep-line-number (x)
+  (if (string-match ":[0-9]+:" x)
+      (substring x (match-end 0))
+    x))
+
+(defun ivy--action-insert (x)
+  (insert
+   (if (stringp x)
+       (ivy--trim-grep-line-number x)
+       x (car x))))
+
+(defun ivy--action-copy (x)
+  (kill-new
+   (if (stringp x)
+       (ivy--trim-grep-line-number x)
+     (car x))))
 
 (defun ivy--switch-buffer-matcher (regexp candidates)
   "Return REGEXP matching CANDIDATES.
 Skip buffers that match `ivy-ignore-buffers'."
-  (let ((res (ivy--re-filter regexp candidates)))
-    (if (or (null ivy-use-ignore)
-            (null ivy-ignore-buffers))
-        res
-      (or (cl-remove-if
-           (lambda (buf)
-             (cl-find-if
-              (lambda (f-or-r)
-                (if (functionp f-or-r)
-                    (funcall f-or-r buf)
-                  (string-match-p f-or-r buf)))
-              ivy-ignore-buffers))
-           res)
-          (and (eq ivy-use-ignore t)
-               res)))))
+  (if (string-match-p "^:" ivy-text)
+      (delete-dups
+       (cl-remove-if-not
+        (lambda (s)
+          (let ((b (get-buffer s)))
+            (and b
+                 (string-match-p regexp (buffer-local-value 'default-directory 
b))
+                 (not (string-match-p "^\\*" s)))))
+        candidates))
+    (let ((res (ivy--re-filter regexp candidates)))
+      (if (or (null ivy-use-ignore)
+              (null ivy-ignore-buffers))
+          res
+        (or (cl-remove-if
+             (lambda (buf)
+               (cl-find-if
+                (lambda (f-or-r)
+                  (if (functionp f-or-r)
+                      (funcall f-or-r buf)
+                    (string-match-p f-or-r buf)))
+                ivy-ignore-buffers))
+             res)
+            (and (eq ivy-use-ignore t)
+                 res))))))
 
 (defun ivy-append-face (str face)
   "Append to STR the property FACE."
-  (setq str (copy-sequence str))
-  (ivy-add-face-text-property 0 (length str) face str t)
+  (when face
+    (setq str (copy-sequence str))
+    (add-face-text-property 0 (length str) face t str))
   str)
 
+(defun ivy--remote-buffer-p (buffer)
+  "Return non-nil if BUFFER object is visiting a remote file.
+If that is the case, value is a string identifying the remote
+connection."
+  (let ((dir (buffer-local-value 'default-directory buffer)))
+    (ignore-errors (file-remote-p dir))))
+
 (defun ivy-switch-buffer-transformer (str)
   "Transform candidate STR when switching buffers."
-  (let ((b (get-buffer str)))
-    (if (and b (buffer-file-name b))
-        (cond
-          ((and (not (ignore-errors (file-remote-p (buffer-file-name b))))
-                (not (verify-visited-file-modtime b)))
+  (let ((buf (get-buffer str)))
+    (cond ((not buf) str)
+          ((let ((remote (ivy--remote-buffer-p buf)))
+             (when remote
+               (format "%s (%s)" (ivy-append-face str 'ivy-remote) remote))))
+          ((not (verify-visited-file-modtime buf))
            (ivy-append-face str 'ivy-modified-outside-buffer))
-          ((buffer-modified-p b)
+          ((buffer-modified-p buf)
            (ivy-append-face str 'ivy-modified-buffer))
-          (t str))
-      str)))
+          (t
+           (let* ((mode (buffer-local-value 'major-mode buf))
+                  (face (cdr (assq mode ivy-switch-buffer-faces-alist))))
+             (ivy-append-face str face))))))
 
 (defun ivy-switch-buffer-occur (cands)
   "Occur function for `ivy-switch-buffer' using `ibuffer'.
@@ -4357,8 +4579,8 @@ CANDS are the candidates to be displayed."
             :caller 'ivy-switch-buffer))
 
 (ivy-configure 'ivy-switch-buffer
-  :occur #'ivy-switch-buffer-occur
-  :display-transformer-fn #'ivy-switch-buffer-transformer)
+  :parent 'internal-complete-buffer
+  :occur #'ivy-switch-buffer-occur)
 
 ;;;###autoload
 (defun ivy-switch-view ()
@@ -4380,7 +4602,7 @@ CANDS are the candidates to be displayed."
             :caller 'ivy-switch-buffer-other-window))
 
 (ivy-configure 'ivy-switch-buffer-other-window
-  :occur #'ivy-switch-buffer-occur)
+  :parent 'ivy-switch-buffer)
 
 (defun ivy--yank-handle-case-fold (text)
   (if (and (> (length ivy-text) 0)
@@ -4423,9 +4645,6 @@ words (previous if ARG is negative)."
 If optional ARG is non-nil, pull in the next ARG
 symbols (previous if ARG is negative)."
   (interactive "p")
-  ;; Emacs < 24.4 compatibility
-  (unless (fboundp 'forward-symbol)
-    (require 'thingatpt))
   (ivy--yank-by #'forward-symbol (or arg 1)))
 
 (defun ivy-yank-char (&optional arg)
@@ -4532,6 +4751,19 @@ This list can be rotated with 
`ivy-rotate-preferred-builders'."
       (setq ivy--regex-function 'ivy--regex-plus)
     (setq ivy--regex-function 'ivy--regex-fuzzy)))
 
+(defun ivy--label-and-delete-dups (entries)
+  "Label ENTRIES with history indices."
+  (let ((ht (make-hash-table :test 'equal))
+        (idx 0)
+        entry
+        accum)
+    (while (setq entry (pop entries))
+      (unless (gethash entry ht)
+        (puthash entry t ht)
+        (push `(,entry . ,idx) accum))
+      (cl-incf idx))
+    (nreverse accum)))
+
 (defvar ivy--reverse-i-search-symbol nil
   "Store the history symbol.")
 
@@ -4552,7 +4784,7 @@ This list can be rotated with 
`ivy-rotate-preferred-builders'."
 
 (defvar ivy-reverse-i-search-map
   (let ((map (make-sparse-keymap)))
-    (define-key map (kbd "C-k") 'ivy-reverse-i-search-kill)
+    (ivy-define-key map (kbd "C-k") 'ivy-reverse-i-search-kill)
     map))
 
 (defun ivy-history-contents (history)
@@ -4561,14 +4793,14 @@ A copy is necessary so that we don't clobber any string 
attributes.
 Also set `ivy--reverse-i-search-symbol' to HISTORY."
   (setq ivy--reverse-i-search-symbol history)
   (cond ((symbolp history)
-         (delete-dups
+         (ivy--label-and-delete-dups
           (copy-sequence (symbol-value history))))
         ((ring-p history)
-         (delete-dups
+         (ivy--label-and-delete-dups
           (when (> (ring-size history) 0)
             (ring-elements history))))
         ((sequencep history)
-         (delete-dups
+         (ivy--label-and-delete-dups
           (copy-sequence history)))
         (t
          (error "Expected a symbol, ring, or sequence: %S" history))))
@@ -4582,7 +4814,7 @@ You can also delete an element from history with 
\\[ivy-reverse-i-search-kill]."
   (cond
     ((= (minibuffer-depth) 0)
      (user-error
-      "This command is intended to be called with \"C-r\" from `ivy-read'."))
+      "This command is intended to be called from within `ivy-read'"))
     ;; don't recur
     ((and (> (minibuffer-depth) 1)
           (eq (ivy-state-caller ivy-last) 'ivy-reverse-i-search)))
@@ -4596,7 +4828,7 @@ You can also delete an element from history with 
\\[ivy-reverse-i-search-kill]."
                            (ivy--reset-state
                             (setq ivy-last old-last))
                            (delete-minibuffer-contents)
-                           (insert (substring-no-properties x))
+                           (insert (substring-no-properties (car x)))
                            (ivy--cd-maybe))
                  :caller 'ivy-reverse-i-search)))))
 
@@ -4620,20 +4852,20 @@ 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-and-switch)
-    (define-key map (kbd "j") 'ivy-occur-next-line)
-    (define-key map (kbd "k") 'ivy-occur-previous-line)
+    (ivy-define-key map [mouse-1] 'ivy-occur-click)
+    (ivy-define-key map (kbd "RET") 'ivy-occur-press-and-switch)
+    (ivy-define-key map (kbd "j") 'ivy-occur-next-line)
+    (ivy-define-key map (kbd "k") 'ivy-occur-previous-line)
     (define-key map (kbd "h") 'backward-char)
     (define-key map (kbd "l") 'forward-char)
-    (define-key map (kbd "f") 'ivy-occur-press)
-    (define-key map (kbd "g") 'ivy-occur-revert-buffer)
-    (define-key map (kbd "a") 'ivy-occur-read-action)
-    (define-key map (kbd "o") 'ivy-occur-dispatch)
-    (define-key map (kbd "c") 'ivy-occur-toggle-calling)
+    (ivy-define-key map (kbd "f") 'ivy-occur-press)
+    (ivy-define-key map (kbd "g") 'ivy-occur-revert-buffer)
+    (ivy-define-key map (kbd "a") 'ivy-occur-read-action)
+    (ivy-define-key map (kbd "o") 'ivy-occur-dispatch)
+    (ivy-define-key map (kbd "c") 'ivy-occur-toggle-calling)
     (define-key map (kbd "q") 'quit-window)
     (define-key map (kbd "R") 'read-only-mode)
-    (define-key map (kbd "C-d") 'ivy-occur-delete-candidate)
+    (ivy-define-key map (kbd "C-d") 'ivy-occur-delete-candidate)
     map)
   "Keymap for Ivy Occur mode.")
 
@@ -4711,7 +4943,10 @@ When `ivy-calling' isn't nil, call `ivy-occur-press'."
   (setq n (or n 1))
   (let ((ivy-calling t))
     (cond ((< n 0) (ivy-occur-previous-line (- n)))
-          (t (ivy-occur-next-line n)))))
+          (t (ivy-occur-next-line n))))
+  ;; The window's point overrides the buffer's point every time it's 
redisplayed
+  (dolist (window (get-buffer-window-list nil nil t))
+    (set-window-point window (point))))
 
 (define-derived-mode ivy-occur-mode fundamental-mode "Ivy-Occur"
   "Major mode for output from \\[ivy-occur].
@@ -4721,8 +4956,8 @@ When `ivy-calling' isn't nil, call `ivy-occur-press'."
 
 (defvar ivy-occur-grep-mode-map
   (let ((map (copy-keymap ivy-occur-mode-map)))
-    (define-key map (kbd "C-x C-q") 'ivy-wgrep-change-to-wgrep-mode)
-    (define-key map "w" 'ivy-wgrep-change-to-wgrep-mode)
+    (ivy-define-key map (kbd "C-x C-q") 'ivy-wgrep-change-to-wgrep-mode)
+    (ivy-define-key map "w" 'ivy-wgrep-change-to-wgrep-mode)
     map)
   "Keymap for Ivy Occur Grep mode.")
 
@@ -4761,7 +4996,7 @@ When `ivy-calling' isn't nil, call `ivy-occur-press'."
        highlight
        help-echo "mouse-1: call ivy-action")
      cand)
-    (insert (if (string-match-p "\\`.[/\\]" cand) "" "    ")
+    (insert (if (ivy--starts-with-dotslash cand) "" "    ")
             cand ?\n)))
 
 (defun ivy--occur-default (cands)
@@ -4888,7 +5123,9 @@ EVENT gives the mouse position."
                   (switch-to-buffer buffer)))))))
 
     ((memq (ivy-state-caller ivy-occur-last)
-           '(counsel-describe-function counsel-describe-variable))
+           '(counsel-describe-function
+             counsel-describe-variable
+             counsel-describe-symbol))
      (setf (ivy-state-window ivy-occur-last)
            (selected-window))
      (selected-window))))
@@ -4905,7 +5142,7 @@ EVENT gives the mouse position."
   (ivy--occur-press-update-window)
   (when (save-excursion
           (beginning-of-line)
-          (looking-at "\\(?:./\\|    \\)\\(.*\\)$"))
+          (looking-at "\\(?:.[/\\]\\|    \\)\\(.*\\)$"))
     (let* ((ivy-last ivy-occur-last)
            (ivy-text (ivy-state-text ivy-last))
            (str (buffer-substring
@@ -5013,10 +5250,16 @@ make decisions based on the whole marked list."
 (defun ivy-help ()
   "Help for `ivy'."
   (interactive)
-  (let ((buf (get-buffer "*Ivy Help*")))
+  (let ((buf (get-buffer "*Ivy Help*"))
+        (inhibit-read-only t))
     (unless buf
       (setq buf (get-buffer-create "*Ivy Help*"))
+      (cl-letf (((symbol-function #'help-buffer) (lambda () buf)))
+        (describe-mode))
       (with-current-buffer buf
+        (goto-char (point-min))
+        (insert "* describe-mode\n")
+        (goto-char (point-min))
         (insert-file-contents ivy-help-file)
         (org-mode)
         (setq-local org-hide-emphasis-markers t)
@@ -5046,11 +5289,15 @@ make decisions based on the whole marked list."
 
 (ivy-configure 'read-file-name-internal
   :sort-fn #'ivy-sort-file-function-default
-  :display-transformer-fn #'ivy-read-file-transformer)
+  :display-transformer-fn #'ivy-read-file-transformer
+  :alt-done-fn #'ivy--directory-done)
 
 (ivy-configure 'internal-complete-buffer
   :display-transformer-fn #'ivy-switch-buffer-transformer)
 
+(ivy-configure 'Info-read-node-name-1
+  :alt-done-fn #'ivy--info-alt-done)
+
 (provide 'ivy)
 
 ;;; ivy.el ends here
diff --git a/tests/find-file/single-match-directories/a/file_in_a.txt 
b/tests/find-file/single-match-directories/a/file_in_a.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tests/find-file/single-match-directories/ba/file_in_ba.txt 
b/tests/find-file/single-match-directories/ba/file_in_ba.txt
new file mode 100644
index 0000000..e69de29



reply via email to

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