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

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

[elpa] master 7dc86b3 084/272: Add a lot of sections to the documentatio


From: Oleh Krehel
Subject: [elpa] master 7dc86b3 084/272: Add a lot of sections to the documentation
Date: Mon, 25 Apr 2016 10:13:18 +0000

branch: master
commit 7dc86b3894d67d25b67a89fbfb7059deca4325f8
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Add a lot of sections to the documentation
    
    * doc/ivy-ox.el (org-texinfo-plain-list): Wrap the definition lists in
      @indentedblock.
    
    * doc/ivy.org: Improve the markup in a lot of places, add sections on
    Customization, Actions, Commands and API.
---
 doc/ivy-ox.el |   18 +-
 doc/ivy.org   |  687 +++++++++++++++++++++++++++++++++---
 doc/ivy.texi  | 1089 +++++++++++++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 1622 insertions(+), 172 deletions(-)

diff --git a/doc/ivy-ox.el b/doc/ivy-ox.el
index 9770cad..37c13ec 100644
--- a/doc/ivy-ox.el
+++ b/doc/ivy-ox.el
@@ -123,12 +123,18 @@ contextual information."
                       (t "table"))))
     (if (equal list-type "table")
         (mapconcat (lambda (s)
-                     (if (string-match "\\`User Option @code{\\(.*\\)}$" s)
-                         (format "@defopt address@hidden defopt\n"
-                                 (match-string-no-properties 1 s)
-                                 (string-trim
-                                  (substring s (1+ (match-end 1)))))
-                       (concat "@subsubheading " s)))
+                     (cond ((string-match "\\`User Option @code{\\(.*\\)}$" s)
+                            (format "@defopt address@hidden defopt\n"
+                                    (match-string-no-properties 1 s)
+                                    (string-trim
+                                     (substring s (1+ (match-end 1))))))
+                           ((string-match "\\(.*\\)$" s)
+                            (format "@subsubheading address@hidden@end 
indentedblock"
+                                    (match-string 1 s)
+                                    (string-trim
+                                     (substring s (1+ (match-end 1))))))
+                           (t
+                            (concat "@subsubheading " s))))
                    (split-string (substring-no-properties contents) 
"address@hidden " t)
                    "\n")
       (format "@address@hidden %s"
diff --git a/doc/ivy.org b/doc/ivy.org
index 4927473..d372ebd 100644
--- a/doc/ivy.org
+++ b/doc/ivy.org
@@ -23,6 +23,7 @@ definition lists. The definition list "owns" the following 
text if the
 text is indented by 5 spaces. Use ~C-q~ to indent these
 paragraphs. New paragraphs can also be started, as long as they have
 the 5 spaces indent.
+Definition lists need to be separated from regular lists with two newlines.
 
 For declaring a address@hidden section for =defcustom= or =defvar=, also
 use definition lists. They need to have the following form in order to
@@ -35,6 +36,7 @@ User Option =ivy-wrap= ::
 To name each heading, set its =CUSTOM_ID= property. This can be done
 easily with =worf='s ~C-u L~.
 
+Texinfo export likes to have one empty line before each source block.
 * Copying
 :PROPERTIES:
 :COPYING:  t
@@ -125,6 +127,11 @@ discoverability.
 Install Ivy automatically through Emacs's package manager, or manually
 from Ivy's development repository.
 
+Ivy should run fine on a typical Emacs bundled in your OS's package
+manager, the oldest of which is Emacs 24.3.1.  However, the faces
+display will work much better for Emacs 24.5.1, which is the latest
+stable version.
+
 ** Installing from Emacs Package Manager
 :PROPERTIES:
 :CUSTOM_ID: installing-from-emacs-package-manager
@@ -156,31 +163,34 @@ For package manager details, see [[info:emacs#Packages]].
 :CUSTOM_ID: installing-from-the-git-repository
 :END:
 
-Why install from Git?
+- Why install from Git? ::
 
-- No need to wait for MELPA's hourly builds
-- Easy to revert to previous versions
-- Contribute to Ivy's development; send patches; pull requests
+    - No need to wait for MELPA's hourly builds
+    - Easy to revert to previous versions
+    - Contribute to Ivy's development; send patches; pull requests
 
-*Configuration steps*
 
-First clone the Swiper repository:
-#+begin_src sh
-cd ~/git && git clone https://github.com/abo-abo/swiper
-cd swiper && make compile
-#+end_src
+- Configuration steps ::
+     First clone the Swiper repository:
 
-Then add this to Emacs init:
-#+begin_src elisp
-(add-to-list 'load-path "~/git/swiper/")
-(require 'ivy)
-#+end_src
+     #+begin_src sh
+     cd ~/git && git clone https://github.com/abo-abo/swiper
+     cd swiper && make compile
+     #+end_src
 
-To update the code:
-#+begin_src sh
-git pull
-make
-#+end_src
+     Then add this to Emacs init:
+
+     #+begin_src elisp
+     (add-to-list 'load-path "~/git/swiper/")
+     (require 'ivy)
+     #+end_src
+
+     To update the code:
+
+     #+begin_src sh
+     git pull
+     make
+     #+end_src
 
 * Getting started
 :PROPERTIES:
@@ -197,8 +207,8 @@ Note: =ivy-mode= can be toggled on and off with ~M-x~ 
=ivy-mode=.
 :PROPERTIES:
 :CUSTOM_ID: basic-customization
 :END:
-Here are some basic settings particularly useful for new Ivy
-users:
+Here are some basic settings particularly useful for new Ivy users:
+
 #+begin_src elisp
 (setq ivy-use-virtual-buffers t)
 (setq ivy-height 10)
@@ -220,31 +230,35 @@ documentation.
 The recommended key bindings are:
 
 - Ivy-based interface to standard commands ::
-#+begin_src elisp
-(global-set-key (kbd "C-s") 'swiper)
-(global-set-key (kbd "M-x") 'counsel-M-x)
-(global-set-key (kbd "C-x C-f") 'counsel-find-file)
-(global-set-key (kbd "<f1> f") 'counsel-describe-function)
-(global-set-key (kbd "<f1> v") 'counsel-describe-variable)
-(global-set-key (kbd "<f1> l") 'counsel-load-library)
-(global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
-(global-set-key (kbd "<f2> u") 'counsel-unicode-char)
-#+end_src
+
+     #+begin_src elisp
+     (global-set-key (kbd "C-s") 'swiper)
+     (global-set-key (kbd "M-x") 'counsel-M-x)
+     (global-set-key (kbd "C-x C-f") 'counsel-find-file)
+     (global-set-key (kbd "<f1> f") 'counsel-describe-function)
+     (global-set-key (kbd "<f1> v") 'counsel-describe-variable)
+     (global-set-key (kbd "<f1> l") 'counsel-load-library)
+     (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
+     (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
+     #+end_src
 
 - Ivy-based interface to shell and system tools ::
-#+begin_src elisp
-(global-set-key (kbd "C-c g") 'counsel-git)
-(global-set-key (kbd "C-c j") 'counsel-git-grep)
-(global-set-key (kbd "C-c k") 'counsel-ag)
-(global-set-key (kbd "C-x l") 'counsel-locate)
-(global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
-#+end_src
+
+     #+begin_src elisp
+     (global-set-key (kbd "C-c g") 'counsel-git)
+     (global-set-key (kbd "C-c j") 'counsel-git-grep)
+     (global-set-key (kbd "C-c k") 'counsel-ag)
+     (global-set-key (kbd "C-x l") 'counsel-locate)
+     (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
+     #+end_src
 
 - Ivy-resume and other commands ::
-=ivy-resume= resumes the last Ivy-based completion.
-#+begin_src elisp
-(global-set-key (kbd "C-c C-r") 'ivy-resume)
-#+end_src
+
+     =ivy-resume= resumes the last Ivy-based completion.
+
+     #+begin_src elisp
+     (global-set-key (kbd "C-c C-r") 'ivy-resume)
+     #+end_src
 
 ** Minibuffer key bindings
 :PROPERTIES:
@@ -259,6 +273,12 @@ are described here.
 =ivy-read=. These keys, also active in the minibuffer, are described
 under their respective commands.
 
+An important idea behind =ivy-minibuffer-map=, unlike
+e.g. =isearch-mode-map= or Ido keymap is that the minibuffer is a
+fully capable editing area: bindings like ~C-a~, ~C-f~, ~M-d~,
+~M-DEL~, ~M-b~, ~M-w~, ~C-k~, ~C-y~ all work as if you were in a
+=fundamental-mode= buffer.
+
 *** Key bindings for navigation
 :PROPERTIES:
 :CUSTOM_ID: key-bindings-for-navigation
@@ -284,7 +304,6 @@ under their respective commands.
     Use this variable to adjust the minibuffer height, and therefore
     the scroll size for ~C-v~ and ~M-v~.
 
-
 *** Key bindings for single selection, action, then exit minibuffer
 :PROPERTIES:
 :CUSTOM_ID: key-bindings-for-single-selection-action-then-exit-minibuffer
@@ -317,6 +336,18 @@ extends usability of lists in Emacs.
      Attempts partial completion, extending current input as much as
      possible. ~TAB TAB~ is the same as ~C-j~.
 
+     Example ERT test:
+
+     #+begin_src elisp
+     (should
+      (equal (ivy-with
+              '(progn
+                (ivy-read "Test: " '("can do" "can't, sorry" "other"))
+                ivy-text)
+              "c <tab>")
+             "can"))
+     #+end_src
+
 - ~C-M-j~ (=ivy-immediate-done=) ::
      Exits with /the current input/ instead of /the current candidate/
      (like other commands).
@@ -532,28 +563,49 @@ descriptive names, for example: =*ivy-occur 
counsel-describe-variable
 :CUSTOM_ID: completion-styles
 :END:
 
-Ivy's completion functions rely on the highly configurable regex
-builder.
+Ivy's completion functions rely on a regex builder - a function that
+transforms a string input to a string regex. All current candidates
+simply have to match this regex. Each collection can be assigned its
+own regex builder by customizing =ivy-re-builders-alist=.
+
+The keys of this alist are collection names, and the values are one of:
+- =ivy--regex=
+- =ivy--regex-plus=
+- =ivy--regex-ignore-order=
+- =ivy--regex-fuzzy=
+- =regexp-quote=
+
+There's also a catch-all key =t= that applies to all collections that
+don't have their own key.
 
 The default is:
+
 #+begin_src elisp
 (setq ivy-re-builders-alist
       '((t . ivy--regex-plus)))
 #+end_src
 
-The default =ivy--regex-plus= narrowing is always invoked unless
-specified otherwise. For example, file name completion may have a
-custom completion function:
+For example, here is how to assign a custom regex builder to file name
+completion:
+
 #+begin_src elisp
 (setq ivy-re-builders-alist
       '((read-file-name-internal . ivy--regex-fuzzy)
         (t . ivy--regex-plus)))
 #+end_src
 
-Ivy's flexibility extends to using different styles of completion
-mechanics (regex-builders) for different types of lists. Despite this
-flexibility, Ivy operates within a consistent and uniform interface.
-The main regex-builders currently in Ivy are:
+Here, =read-file-name-internal= is a function passed as the second
+argument to =completing-read= when completing file names.
+
+The regex builder resolution is a follows, in order of priority:
+1. =re-builder= argument passed to =ivy-read=.
+2. =collection= argument passed to =ivy-read= is a function and has an
+   entry on =ivy-re-builders-alist=.
+3. =caller= argument passed to =ivy-read= has an entry on
+   =ivy-re-builders-alist=.
+4. =this-command= has an entry on =ivy-re-builders-alist=.
+5. =t= has an entry on =ivy-re-builders-alist=.
+6. =ivy--regex=.
 
 ** ivy--regex-plus
 :PROPERTIES:
@@ -613,6 +665,535 @@ number of hits.  Yet some searches need these extra hits. 
Ivy sorts
 such large lists using =flx= package's scoring mechanism, if it's
 installed.
 
+In case =ivy--regex-fuzzy= isn't your current regexp builder, you
+toggle it during completion with ~C-o m~.
+
+* Customization
+** Faces
+- =ivy-current-match= ::
+     Highlights the currently selected candidate.
+- =ivy-minibuffer-match-face-1= ::
+     Highlights the background of the match.
+- =ivy-minibuffer-match-face-2= ::
+     Highlights the first (modulo 3) matched group.
+- =ivy-minibuffer-match-face-3= ::
+     Highlights the second (modulo 3) matched group.
+- =ivy-minibuffer-match-face-4= ::
+     Highlights the third (modulo 3) matched group.
+- =ivy-confirm-face= ::
+     Highlights the "(confirm)" part of the prompt.
+
+     Used in conjunction with the built-in
+     =confirm-nonexistent-file-or-buffer= defcustom.  When you set
+     this variable to =t=, you'll have to confirm non-existent files
+     and buffer with another ~RET~ in =ivy-mode=.
+
+     This face will be used to highlight the confirmation prompt.
+
+     For example, use this setting:
+
+     #+begin_src elisp
+     (setq confirm-nonexistent-file-or-buffer t)
+     #+end_src
+
+     Then call =find-file=, enter "eldorado" and press ~RET~ - the
+     prompt will be appended with "(confirm)". Press ~RET~ once more
+     to confirm, or any key to continue the completion.
+- =ivy-match-required-face= ::
+     Highlights the "(match required)" part of the prompt.
+
+     Sometimes, the Emacs functions that call completion specify to it
+     that a match is required, i.e. you can't just type in some random
+     stuff - you have to select one of the candidates given to you.
+     In that case, =ivy-mode= will appropriately change the prompt.
+
+     For example, call =describe-variable=, enter "waldo" and press
+     ~RET~ - the prompt will be appended with "(match required)".
+     Press any key and the prompt warning will disappear.
+- =ivy-subdir= ::
+     Highlights directories when completing file names.
+- =ivy-remote= ::
+     Highlights remote files when completing file names.
+- =ivy-virtual= ::
+     Highlights virtual buffers when completing buffer names.
+
+     Virtual buffers correspond to your bookmarks and the =recentf=
+     list.
+
+     Enable the virtual buffers like this:
+
+     #+begin_src elisp
+     (setq ivy-use-virtual-buffers t)
+     #+end_src
+** Defcustoms
+- User Option =ivy-count-format= ::
+     A string that describes how to show the number of candidates and
+     possibly the current candidate in the prompt.
+
+     By default, the number of matching candidates will be shown as an
+     integer with padding on the right.
+
+     To disable showing the number of candidates:
+
+     #+begin_src elisp
+     (setq ivy-count-format "")
+     #+end_src
+
+     To show the current candidate, in addition to the number of candidates:
+
+     #+begin_src elisp
+     (setq ivy-count-format "(%d/%d) ")
+     #+end_src
+
+     This variable uses =format=-style switches, see the documentation
+     of =format= for more info.
+
+- User Option =ivy-display-style= ::
+     Decides how to highlight the candidates in the minibuffer.
+
+     The default setting is ='fancy= and it's available only for Emacs
+     versions 24.5 or newer.
+
+     Set this to =nil= to get a more plain minibuffer.
+
+- User Option =ivy-on-del-error-function= ::
+     Decides what to do when ~DEL~ (=ivy-backward-delete-char=)
+     throws.
+
+     The default behavior is to quit the completion - this is handy if
+     you invoke the completion by mistake.
+
+** Actions
+*** What are actions?
+An action is a function of a single argument that gets called after
+you select a candidate during completion. The selected candidate is
+passed to this function as a string argument.
+
+- Window context when calling an action ::
+     Currently, the action is executed in the minibuffer window
+     context. This means e.g. that if you call =insert= the text will
+     be inserted into the minibuffer.
+
+     If you want to execute the action in the initial window from
+     which the completion started, use the =with-ivy-window= wrapper
+     macro.
+
+     #+begin_src elisp
+     (defun ivy-insert-action (x)
+       (with-ivy-window
+         (insert x)))
+     #+end_src
+
+*** How can different actions be called?
+- ~C-m~ (=ivy-done=) calls the current/default action.
+- ~M-o~ (=ivy-dispatching-done=) selects among all actions, calls it
+  and exits.
+- ~C-M-o~ (=ivy-dispatching-call=) selects among all actions, calls it
+  and doesn't exit.
+
+*** How can the action list be modified?
+Currently, you can append any amount of your own actions to the
+default list of actions. This can be done either for a specific
+command, or for all commands at once.
+
+Usually, the command has only one default action. The convention is to
+use single letters when selecting a command, and the letter ~o~ is
+designated for the default command. This way, ~M-o o~ should be always
+equivalent to ~C-m~.
+
+*** Example - add two actions to each command
+The first action inserts the current candidate into the Ivy window -
+the window from which =ivy-read= was called.
+
+The second action copies the current candidate to the kill ring.
+
+#+begin_src elisp
+(defun ivy-yank-action (x)
+  (kill-new x))
+
+(defun ivy-copy-to-buffer-action (x)
+  (with-ivy-window
+    (insert x)))
+
+(ivy-set-actions
+ t
+ '(("i" ivy-copy-to-buffer-action "insert")
+   ("y" ivy-yank-action "yank")))
+#+end_src
+
+Now in any completion session you can access =ivy-yank-action= with
+~M-o y~ and =ivy-copy-to-buffer-action= with ~M-o i~.
+
+**** How to undo adding the two actions
+=ivy-set-actions= simply modifies the internal dict with new data, so
+you can set the extra actions list to =nil= by assigning =nil= value
+to the =t= key:
+
+#+begin_src elisp
+(ivy-set-actions t nil)
+#+end_src
+
+**** How to add actions to a specific command
+Use the command name as the key:
+
+#+begin_src elisp
+(ivy-set-actions
+ 'swiper
+ '(("i" ivy-copy-to-buffer-action "insert")
+   ("y" ivy-yank-action "yank")))
+#+end_src
+
+*** Example - define a new command with several actions
+#+begin_src elisp
+(defun my-action-1 (x)
+  (message "action-1: %s" x))
+
+(defun my-action-2 (x)
+  (message "action-2: %s" x))
+
+(defun my-action-3 (x)
+  (message "action-3: %s" x))
+
+(defun my-command-with-3-actions ()
+  (interactive)
+  (ivy-read "test: " '("foo" "bar" "baz")
+            :action '(1
+                      ("o" my-action-1 "action 1")
+                      ("j" my-action-2 "action 2")
+                      ("k" my-action-3 "action 3"))))
+#+end_src
+
+Here, the number determines the index of the default action.  For each
+action, the strings are used to describe it during the selection.
+
+**** Testing out the above function with =ivy-occur=
+To examine each action with each candidate in a key-efficient way, try:
+
+- Call =my-command-with-3-actions=.
+- Press ~C-c C-o~ to close the completion and move to an ivy-occur buffer.
+- Press ~kkk~ to move to the first candidate, since you're likely at the end 
of the buffer.
+- Press ~oo~ to call the first action.
+- Press ~oj~ and ~ok~ to call the second and the third actions.
+- Press ~j~ to move to the next candidate
+- ...
+** Packages
+- =org-mode= ::
+     With the most recent version, =org-mode= will obey
+     =completing-read-function= (which =ivy-mode= sets), so it should
+     work by default.  If you try it for refiling to headings with
+     similar names, you'll really notice how much better =ivy-mode= is
+     at it.
+- =magit= ::
+     This setting is needed to use ivy completion:
+
+     #+begin_src elisp
+     (setq magit-completing-read-function 'ivy-completing-read)
+     #+end_src
+- =find-file-in-project= ::
+     Will use ivy by default if it's available.
+- =projectile= ::
+     This setting is needed to use ivy completion:
+
+     #+begin_src elisp
+     (setq projectile-completion-system 'ivy)
+     #+end_src
+- =helm-make= ::
+     This setting is needed to use ivy completion:
+
+     #+begin_src elisp
+     (setq helm-make-completion-method 'ivy)
+     #+end_src
+
+* Commands
+** File Name Completion
+Since file name completion is so essential, ivy has a few extra
+bindings that work here.
+
+- ~C-j~ (=ivy-alt-done=) ::
+     Use on a directory to restart the completion from that
+     directory. Use it on a file or =./= to exit the completion with
+     the selected candidate.
+- ~DEL~ (=ivy-backward-delete-char=) ::
+     When completing file names, and the current input is empty,
+     restart the completion in the parent directory.
+- ~//~ (=self-insert-command=) ::
+     Switch to the root directory.
+- ~~~ (=self-insert-command=) ::
+     Switch to the home directory.
+- ~/~ (=self-insert-command=) ::
+     If the current input is precisely an existing directory, switch
+     the completion to that directory.
+- ~M-q~ (=ivy-toggle-regexp-quote=) ::
+     Toggle between your input being a regexp and not.
+
+     Since file names tend to include =.=, which matches any char in
+     regexp mode, you might want to switch to matching literally.
+
+- User Option =ivy-extra-directories= ::
+     Decide if you want to see =../= and =./= during file name
+     completion.
+
+     You might want to remove =../=, since selecting it is the same as
+     ~DEL~. On the other hand, having it around makes it possible to
+     navigate anywhere with only ~C-n~, ~C-p~ and ~C-j~.
+
+     Similarly, =./= can be removed as well.
+
+- Using TRAMP ::
+     Completion for TRAMP is supported in a peculiar way. From any
+     directory, with the empty input, inputting =/ssh:= and pressing
+     ~C-j~ (or ~RET~ which is the same thing) will give you a
+     completion for host and user names.
+
+     You can also input =/ssh:address@hidden to get domain completion with
+     user name already selected.
+
+     Described above is a recommended and simple method of
+     interaction. If you find it lacking, you can still use ~C-i~,
+     which does largely the same as the default completion does.
+
+- History ::
+     The history works with ~M-p~, ~M-n~, and ~C-r~, as in all other
+     completion sessions.  A custom history code was implemented for
+     file name completion. This code will cycle you through all
+     previous files that you opened, including the input with which
+     the file was opened. It also works well with TRAMP.
+
+** Buffer Name Completion
+- User Option =ivy-use-virtual-buffers= ::
+     When non-nil, add =recentf-mode= and bookmarks to =ivy-switch-buffer=.
+
+     If you add this to your setup:
+
+     #+begin_src elisp
+     (setq ivy-use-virtual-buffers t)
+     #+end_src
+     when using =ivy-switch-buffer= additional buffers will be
+     appended to your live buffer list. These buffers will be
+     highlighted with the =ivy-virtual= face, and selecting them will
+     open the corresponding file.
+** Counsel commands
+The main advantage of using =counsel-= functions over their basic
+equivalents with =ivy-mode= enabled are the following:
+
+1. You can use everything related to multi-actions and non-exiting actions.
+2. You can use =ivy-resume= to resume your last completion session.
+3. You can customize them further with =ivy-set-actions=, 
=ivy-re-builders-alist=.
+4. You can customize their individual keymaps, like
+   =counsel-describe-map=, =counsel-git-grep-map=, or
+   =counsel-find-file-map=, instead of just customizing
+   =ivy-minibuffer-map= that applies to all completion sessions.
+* API
+The main (and only) entry point is =ivy-read= function. It has only
+two required arguments and many optional arguments that you can pass
+by key. Although the =:action= argument is optional, it's very
+recommended that you use it, otherwise the extra features (as compared
+to the default completion) like multi-actions, non-exiting actions,
+=ivy-occur= and =ivy-resume= will not be possible.
+
+** Required arguments for =ivy-read=
+- =prompt= ::
+     A format string normally ending in a colon and a space.
+
+     =%d= anywhere in the string is replaced by the current number of
+     matching candidates. To use a literal =%= character, escape it as
+     =%%=. See also =ivy-count-format=.
+
+- =collection= ::
+     Either a list of strings, a function, an alist or a hash table.
+
+     In case it's a function, it has to be compatible with
+     =all-completions=.
+
+** Optional arguments for =ivy-read=
+- =predicate= ::
+     A function to filter the initial collection with, compatible with 
=all-completions=.
+- =require-match= ::
+     When non-nil, don't let the user exit with a custom input - it
+     must match one of the candidates.
+- =initial-input= ::
+     A string to be initially inserted into the minibuffer. This
+     argument is included for compatibility with
+     =completing-read=. Consider using the =preselect= argument
+     instead - it's often superior.
+- =history= ::
+     A symbol name to store the history. See =completing-read=.
+- =preselect= ::
+     When it's a string, make the first candidate matching this string
+     initially selected.
+
+     When it's an integer, make the candidate with that index
+     initially selected.
+
+     Every time the input becomes empty, the item corresponding to to
+     =preselect= is selected.
+- =keymap= ::
+     A keymap to be composed with =ivy-minibuffer-map=. This keymap
+     has priority over =ivy-minibuffer-map= and can be modified at any
+     later stage.
+- =update-fn= ::
+     A function to call each time the current candidate is changed.
+     This function takes no arguments and is called in the
+     minibuffer's =post-command-hook=. See =swiper= for an example
+     usage.
+- =sort= ::
+     When non-nil, use =ivy-sort-functions-alist= to sort the given
+     collection. The collection will not be sorted when it's larger
+     than =ivy-sort-max-size=.
+- =action= ::
+     A function to call after a result is selected. Takes a single
+     string argument.
+- =unwind= ::
+     A function with no arguments to call before exiting
+     completion. This function is called even if the completion is
+     interrupted with e.g. ~C-g~. See =swiper= for an example usage.
+- =re-builder= ::
+     A function that takes a string and returns a corresponding regex.
+     See the section on completion styles.
+- =matcher= ::
+     A function that takes a regex and a list of strings and returns a
+     list of strings that "match" the regex. Normally a
+     straightforward function is used. Use this argument to really
+     fine-tune the matching process. See =counsel-find-file= for an
+     example usage.
+- =dynamic-collection= ::
+     When non-nil, =collection= will be used to dynamically generate
+     the candidates each time the input changes, instead of being used
+     once statically with =all-completions= to generate a list of
+     strings. See =counsel-locate= for an example usage.
+- =caller= ::
+     A symbol to uniquely identify the function that called
+     =ivy-read=.  This is useful in all kinds of customization
+     scenarios.
+** Example - =counsel-describe-function=
+This is a typical example of a function with a non-async collection:
+all the strings in the collection are known before the user does any
+input.
+
+Note that only the first two arguments (and the =action=) are really
+important - the rest is just fine-tuning and could be omitted.
+
+The =action= argument could also be omitted - but then =ivy-read=
+would no nothing except returning the string result, which you could
+later use yourself. However, it's recommended that you use the
+=action= argument.
+
+#+begin_src elisp
+(defun counsel-describe-function ()
+  "Forward to `describe-function'."
+  (interactive)
+  (ivy-read "Describe function: "
+            (let (cands)
+              (mapatoms
+               (lambda (x)
+                 (when (fboundp x)
+                   (push (symbol-name x) cands))))
+              cands)
+            :keymap counsel-describe-map
+            :preselect (counsel-symbol-at-point)
+            :history 'counsel-describe-symbol-history
+            :require-match t
+            :sort t
+            :action (lambda (x)
+                      (describe-function
+                       (intern x)))
+            :caller 'counsel-describe-function))
+#+end_src
+
+Here are the interesting features of the above function, in the order that 
they appear:
+
+- The =prompt= argument is a simple string ending in ": ".
+- The =collection= argument evaluates to a (large) list of strings.
+- The =keymap= argument allows for a custom keymap to supplement 
=ivy-minibuffer-map=.
+- The =history= argument ensures that the command has its own history,
+  and doesn't need to share the common history =ivy-history= that all
+  commands without their own history share.
+- The =require-match= is set to =t=, since it doesn't make sense to
+  call =describe-function= on an un-interned symbol.
+- The =sort= argument is set to =t=, since it's usually useful to have
+  functions with similar names be close to each other in the candidate
+  list. However, after loading many packages the collection often
+  exceeds the default value of =ivy-sort-max-size= (30000). The user
+  can customize this variable to decide which is more important: the
+  sorting or the completion start-up time.
+- The =action= argument calls =describe-function= on the interned
+  selected candidate.
+- The =caller= argument identifies this completion session. This is
+  important, since with the collection being a list of strings and not
+  a function name, the only other way for =ivy-read= to identify
+  "who's calling" and to apply the appropriate customizations is to
+  examine =this-command=. But =this-command= would be modified if
+  another command called =counsel-describe-function=.
+** Example - =counsel-locate=
+This is a typical example of a function with an async collection.
+Since we can't pre-compute all the collection items valid for an empty
+input and store them in the memory, the collection function is called
+each time the user updates the input.  However, while the returned
+list of strings is used immediately (usually it's something like
+='("please wait...")=), it's expected of the collection function to
+make a call to =start-process= and update the minibuffer text at some
+point when the process is finished.
+
+Async collections are a good fit for long-running shell commands, like
+=locate=. As soon as there is enough input, a new process is started
+and the old process is killed (since the old input is no longer
+relevant). The user can either type more or wait for the already
+running process to finish and update the minibuffer.
+
+#+begin_src elisp
+(defun counsel-locate-function (str)
+  (if (< (length str) 3)
+      (counsel-more-chars 3)
+    (counsel--async-command
+     (format "locate %s '%s'"
+             (mapconcat #'identity counsel-locate-options " ")
+             (counsel-unquote-regex-parens
+              (ivy--regex str))))
+    '("" "working...")))
+
+;;;###autoload
+(defun counsel-locate (&optional initial-input)
+  "Call the \"locate\" shell command.
+INITIAL-INPUT can be given as the initial minibuffer input."
+  (interactive)
+  (ivy-read "Locate: " #'counsel-locate-function
+            :initial-input initial-input
+            :dynamic-collection t
+            :history 'counsel-locate-history
+            :action (lambda (file)
+                      (with-ivy-window
+                        (when file
+                          (find-file file))))
+            :unwind #'counsel-delete-process
+            :caller 'counsel-locate))
+#+end_src
+
+Here are the interesting features of the above functions, in the order
+that they appear:
+
+- =counsel-locate-function= takes a string argument and returns a list
+  of strings. Note that it's not compatible with =all-completions=,
+  but since we're not using that here, might as well use one argument
+  instead of three.
+- =counsel-more-chars= is a simple function that returns e.g.
+  ='("2 chars more")= asking the user for more input.
+- =counsel--async-command= is a very easy API simplification that
+  takes a single string argument suitable for
+  =shell-command-to-string=. So you could prototype your function as
+  non-async using =shell-command-to-string= and =split-string= to
+  produce a collection, then decide that you want async and simply swap in
+  =counsel--async-command=.
+- =counsel-locate= is an interactive function with optional =initial-input=.
+- =#'counsel-locate-function= is passed as the =collection= argument.
+- =dynamic-collection= argument is set to t, since we have an async collection.
+- =action= argument uses =with-ivy-window= wrapper, since we want to open the
+  selected file in the same window from which =counsel-locate= was
+  called.
+- =unwind= argument is set to =#'counsel-delete-process=: when we press ~C-g~
+  we want to kill the running process created by
+  =counsel--async-command=.
+- =caller= argument identifies this command for easier customization.
+
 * Variable Index
 :PROPERTIES:
 :INDEX:    vr
diff --git a/doc/ivy.texi b/doc/ivy.texi
index 1dbf106..3301b22 100644
--- a/doc/ivy.texi
+++ b/doc/ivy.texi
@@ -63,6 +63,9 @@ modify this GNU manual.''
 * Getting started::
 * Key bindings::
 * Completion styles::
+* Customization::
+* Commands::
+* API::
 * Variable Index::
 
 @detailmenu
@@ -96,6 +99,42 @@ Completion styles
 * ivy--regex-plus::
 * ivy--regex-ignore-order::
 * ivy--regex-fuzzy::
+
+Customization
+
+* Faces::
+* Defcustoms::
+* Actions::
+* Packages::
+
+Actions
+
+* What are actions?::
+* How can different actions be called?::
+* How can the action list be modified?::
+* Example - add two actions to each command::
+* Example - define a new command with several actions::
+
+Example - add two actions to each command
+
+* How to undo adding the two actions::
+* How to add actions to a specific command::
+
+Example - define a new command with several actions
+
+* Testing out the above function with @code{ivy-occur}::
+Commands
+
+* File Name Completion::
+* Buffer Name Completion::
+* Counsel commands::
+
+API
+
+* Required arguments for @code{ivy-read}::
+* Optional arguments for @code{ivy-read}::
+* Example - @code{counsel-describe-function}::
+* Example - @code{counsel-locate}::
 @end detailmenu
 @end menu
 
@@ -111,24 +150,25 @@ Ivy strives for minimalism, simplicity, customizability 
and
 discoverability.
 
 @subsubheading Minimalism
-     Uncluttered minibuffer is minimalism. Ivy shows the completion
address@hidden
+Uncluttered minibuffer is minimalism. Ivy shows the completion
 defaults, the number of matches, and 10 candidate matches below
 the input line. Customize @code{ivy-length} to adjust the number of
 candidate matches displayed in the minibuffer.
-
-
address@hidden indentedblock
 @subsubheading Simplicity
-     Simplicity is about Ivy's behavior in the minibuffer. It is also
address@hidden
+Simplicity is about Ivy's behavior in the minibuffer. It is also
 about the code interface to extend Ivy's functionality. The
 minibuffer area behaves as close to @code{fundamental-mode} as
 possible. @kbd{SPC} inserts a space, for example, instead of being
 bound to the more complex @code{minibuffer-complete-word}. Ivy's code
 uses easy-to-examine global variables; avoids needless
 complications with branch-introducing custom macros.
-
-
address@hidden indentedblock
 @subsubheading Customizability
-     Customizability is about being able to use different methods and
address@hidden
+Customizability is about being able to use different methods and
 interfaces of completion to tailor the selection process. For
 example, adding a custom display function that points to a
 selected candidate with @code{->}, instead of highlighting the
@@ -138,10 +178,10 @@ selected. @kbd{RET} uses @code{counsel-describe-function} 
to describe the
 function, whereas @kbd{M-o d} jumps to that function's definition in
 the code. The @kbd{M-o} prefix can be uniformly used with characters
 like @kbd{d} to group similar actions.
-
-
address@hidden indentedblock
 @subsubheading Discoverability
-     Ivy displays easily discoverable commands through the hydra
address@hidden
+Ivy displays easily discoverable commands through the hydra
 facility.  @kbd{C-o} in the minibuffer displays a hydra menu. It
 opens up within an expanded minibuffer area. Each menu item comes
 with short documentation strings and highlighted one-key
@@ -149,12 +189,18 @@ completions. So discovering even seldom used keys is 
simply a
 matter of @kbd{C-o} in the minibuffer while in the midst of the Ivy
 interaction. This discoverability minimizes exiting Ivy interface
 for documentation look-ups.
address@hidden indentedblock
 
 @node Installation
 @chapter Installation
 
 Install Ivy automatically through Emacs's package manager, or manually
 from Ivy's development repository.
+
+Ivy should run fine on a typical Emacs bundled in your OS's package
+manager, the oldest of which is Emacs 24.3.1.  However, the faces
+display will work much better for Emacs 24.5.1, which is the latest
+stable version.
 @menu
 * Installing from Emacs Package Manager::
 * Installing from the Git repository::
@@ -187,8 +233,8 @@ For package manager details, see @ref{Packages,,,emacs,}.
 @node Installing from the Git repository
 @section Installing from the Git repository
 
-Why install from Git?
-
address@hidden Why install from Git?
address@hidden
 @itemize
 @item
 No need to wait for MELPA's hourly builds
@@ -197,26 +243,32 @@ Easy to revert to previous versions
 @item
 Contribute to Ivy's development; send patches; pull requests
 @end itemize
address@hidden indentedblock
 
address@hidden steps}
 
address@hidden Configuration steps
address@hidden
 First clone the Swiper repository:
+
 @example
 cd ~/git && git clone https://github.com/abo-abo/swiper
 cd swiper && make compile
 @end example
 
 Then add this to Emacs init:
+
 @lisp
 (add-to-list 'load-path "~/git/swiper/")
 (require 'ivy)
 @end lisp
 
 To update the code:
+
 @example
 git pull
 make
 @end example
address@hidden indentedblock
 
 @node Getting started
 @chapter Getting started
@@ -235,8 +287,8 @@ Note: @code{ivy-mode} can be toggled on and off with 
@kbd{M-x} @code{ivy-mode}.
 @node Basic customization
 @section Basic customization
 
-Here are some basic settings particularly useful for new Ivy
-users:
+Here are some basic settings particularly useful for new Ivy users:
+
 @lisp
 (setq ivy-use-virtual-buffers t)
 (setq ivy-height 10)
@@ -261,6 +313,7 @@ documentation.
 The recommended key bindings are:
 
 @subsubheading Ivy-based interface to standard commands
address@hidden
 @lisp
 (global-set-key (kbd "C-s") 'swiper)
 (global-set-key (kbd "M-x") 'counsel-M-x)
@@ -271,8 +324,9 @@ The recommended key bindings are:
 (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
 (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
 @end lisp
-
address@hidden indentedblock
 @subsubheading Ivy-based interface to shell and system tools
address@hidden
 @lisp
 (global-set-key (kbd "C-c g") 'counsel-git)
 (global-set-key (kbd "C-c j") 'counsel-git-grep)
@@ -280,12 +334,15 @@ The recommended key bindings are:
 (global-set-key (kbd "C-x l") 'counsel-locate)
 (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
 @end lisp
-
address@hidden indentedblock
 @subsubheading Ivy-resume and other commands
address@hidden
 @code{ivy-resume} resumes the last Ivy-based completion.
+
 @lisp
 (global-set-key (kbd "C-c C-r") 'ivy-resume)
 @end lisp
address@hidden indentedblock
 
 @node Minibuffer key bindings
 @section Minibuffer key bindings
@@ -297,6 +354,12 @@ are described here.
 @code{swiper} or @code{counsel-M-x} add more through the @code{keymap} 
argument to
 @code{ivy-read}. These keys, also active in the minibuffer, are described
 under their respective commands.
+
+An important idea behind @code{ivy-minibuffer-map}, unlike
+e.g. @code{isearch-mode-map} or Ido keymap is that the minibuffer is a
+fully capable editing area: bindings like @kbd{C-a}, @kbd{C-f}, @kbd{M-d},
address@hidden, @kbd{M-b}, @kbd{M-w}, @kbd{C-k}, @kbd{C-y} all work as if you 
were in a
address@hidden buffer.
 @menu
 * Key bindings for navigation::
 * Key bindings for single selection, action, then exit minibuffer: Key 
bindings for single selection action then exit minibuffer. 
@@ -354,40 +417,54 @@ action to run. This delayed flexibility and customization 
of actions
 extends usability of lists in Emacs.
 
 @subsubheading @kbd{C-m} or @kbd{RET} (@code{ivy-done})
-     Calls the default action and exits the minibuffer.
-
-
address@hidden
+Calls the default action and exits the minibuffer.
address@hidden indentedblock
 @subsubheading @kbd{M-o} (@code{ivy-dispatching-done})
-     Presents all available valid actions from which to choose. When
address@hidden
+Presents all available valid actions from which to choose. When
 there is only one action available, there is no difference
 between @kbd{M-o} and @kbd{C-m}.
-
-
address@hidden indentedblock
 @subsubheading @kbd{C-j} (@code{ivy-alt-done})
-     When completing file names, selects the current directory
address@hidden
+When completing file names, selects the current directory
 candidate and starts a new completion session there. Otherwise,
 it's the same as @code{ivy-done}.
-
-
address@hidden indentedblock
 @subsubheading @kbd{TAB} (@code{ivy-partial-or-done})
-     Attempts partial completion, extending current input as much as
address@hidden
+Attempts partial completion, extending current input as much as
 possible. @kbd{TAB TAB} is the same as @kbd{C-j}.
 
+Example ERT test:
 
address@hidden
+(should
+ (equal (ivy-with
+         '(progn
+           (ivy-read "Test: " '("can do" "can't, sorry" "other"))
+           ivy-text)
+         "c <tab>")
+        "can"))
address@hidden lisp
address@hidden indentedblock
 @subsubheading @kbd{C-M-j} (@code{ivy-immediate-done})
-     Exits with @emph{the current input} instead of @emph{the current 
candidate}
address@hidden
+Exits with @emph{the current input} instead of @emph{the current candidate}
 (like other commands).
 
 This is useful e.g. when you call @code{find-file} to create a new
 file, but the desired name matches an existing file. In that
 case, using @kbd{C-j} would select that existing file, which isn't
 what you want - use this command instead.
-
-
address@hidden indentedblock
 @subsubheading @kbd{C-'} (@code{ivy-avy})
-     Uses avy to select one of the candidates on the current candidate
address@hidden
+Uses avy to select one of the candidates on the current candidate
 page.  This can often be faster than multiple @kbd{C-n} or @kbd{C-p}
 keystrokes followed by @kbd{C-m}.
address@hidden indentedblock
 
 @node Key bindings for multiple selections and actions keep minibuffer open
 @subsection Key bindings for multiple selections and actions, keep minibuffer 
open
@@ -401,104 +478,112 @@ version of the regular commands that enables applying 
multiple
 actions.
 
 @subsubheading @kbd{C-M-m} (@code{ivy-call})
-     Is the non-exiting version of @kbd{C-m} (@code{ivy-done}).
address@hidden
+Is the non-exiting version of @kbd{C-m} (@code{ivy-done}).
 
 Instead of closing the minibuffer, @kbd{C-M-m} allows selecting
 another candidate or another action. For example, @kbd{C-M-m} on
 functions list invokes @code{describe-function}. When combined with
 @kbd{C-n}, function descriptions can be invoked quickly in
 succession.
-
-
address@hidden indentedblock
 @subsubheading @kbd{C-M-o} (@code{ivy-dispatching-call})
-     Is the non-exiting version of @kbd{M-o} (@code{ivy-dispatching-done}).
address@hidden
+Is the non-exiting version of @kbd{M-o} (@code{ivy-dispatching-done}).
 
 For example, during the @code{counsel-rhythmbox} completion, press
 @kbd{C-M-o e} to en-queue the selected candidate, followed by @kbd{C-n
      C-m} to play the next candidate - the current action reverts to
 the default one after @kbd{C-M-o}.
-
-
address@hidden indentedblock
 @subsubheading @kbd{C-M-n} (@code{ivy-next-line-and-call})
-     Combines @kbd{C-n} and @kbd{C-M-m}. Applies an action and moves to next
address@hidden
+Combines @kbd{C-n} and @kbd{C-M-m}. Applies an action and moves to next
 line.
 
 Comes in handy when opening multiple files from
 @code{counsel-find-file}, @code{counsel-git-grep}, @code{counsel-ag}, or
 @code{counsel-locate} lists. Just hold @kbd{C-M-n} for rapid-fire default
 action on each successive element of the list.
-
-
address@hidden indentedblock
 @subsubheading @kbd{C-M-p} (@code{ivy-previous-line-and-call})
-     Combines @kbd{C-p} and @kbd{C-M-m}.
address@hidden
+Combines @kbd{C-p} and @kbd{C-M-m}.
 
 Similar to the above except it moves through the list in the
 other direction.
-
-
address@hidden indentedblock
 @subsubheading @code{ivy-resume}
-     Recalls the state of the completion session just before its last exit.
address@hidden
+Recalls the state of the completion session just before its last exit.
 
 Useful after an accidental @kbd{C-m} (@code{ivy-done}).
address@hidden indentedblock
 
 @node Key bindings that alter the minibuffer input
 @subsection Key bindings that alter the minibuffer input
 
 @subsubheading @kbd{M-n} (@code{ivy-next-history-element})
-     Cycles forward through the Ivy command history.
address@hidden
+Cycles forward through the Ivy command history.
 
 Ivy updates an internal history list after each action. When this
 history list is empty, @kbd{M-n} inserts symbol (or URL) at point
 into the minibuffer.
-
-
address@hidden indentedblock
 @subsubheading @kbd{M-p} (@code{ivy-previous-history-element})
-     Cycles forward through the Ivy command history.
-
-
address@hidden
+Cycles forward through the Ivy command history.
address@hidden indentedblock
 @subsubheading @kbd{M-i} (@code{ivy-insert-current})
-     Inserts the current candidate into the minibuffer.
address@hidden
+Inserts the current candidate into the minibuffer.
 
 Useful for copying and renaming files, for example: @kbd{M-i} to
 insert the original file name string, edit it, and then @kbd{C-m} to
 complete the renaming.
-
-
address@hidden indentedblock
 @subsubheading @kbd{M-j} (@code{ivy-yank-word})
-     Inserts the sub-word at point into the minibuffer.
address@hidden
+Inserts the sub-word at point into the minibuffer.
 
 This is similar to @kbd{C-s C-w} with @code{isearch}. Ivy reserves @kbd{C-w}
 for @code{kill-region}.
-
-
address@hidden indentedblock
 @subsubheading @kbd{S-SPC} (@code{ivy-restrict-to-matches})
-     Deletes the current input, and resets the candidates list to the
address@hidden
+Deletes the current input, and resets the candidates list to the
 currently restricted matches.
 
 This is how Ivy provides narrowing in successive tiers.
-
-
address@hidden indentedblock
 @subsubheading @kbd{C-r} (@code{ivy-reverse-i-search})
-     Starts a recursive completion session through the command's
address@hidden
+Starts a recursive completion session through the command's
 history.
 
 This works just like @kbd{C-r} at the bash command prompt, where the
 completion candidates are the history items. Upon completion, the
 selected candidate string is inserted into the minibuffer.
address@hidden indentedblock
 
 @node Other key bindings
 @subsection Other key bindings
 
 @subsubheading @kbd{M-w} (@code{ivy-kill-ring-save})
-     Copies selected candidates to the kill ring.
address@hidden
+Copies selected candidates to the kill ring.
 
 When the region is active, copies active region instead.
address@hidden indentedblock
 
 @node Hydra in the minibuffer
 @subsection Hydra in the minibuffer
 
 @subsubheading @kbd{C-o} (@code{hydra-ivy/body})
-     Invokes the hydra menu with short key bindings.
address@hidden
+Invokes the hydra menu with short key bindings.
address@hidden indentedblock
 
 Minibuffer editing is disabled when Hydra is active. Instead, you get
 short aliases for the common commands:
@@ -543,73 +628,79 @@ Additionally, you get access to the folowing commands 
that are
 normally not bound:
 
 @subsubheading @kbd{c} (@code{ivy-toggle-calling})
-     Toggle calling the action after each candidate change. This
address@hidden
+Toggle calling the action after each candidate change. This
 effectively modifies @kbd{j} to @kbd{jg}, @kbd{k} to @kbd{kg} etc.
-
-
address@hidden indentedblock
 @subsubheading @kbd{m} (@code{ivy-toggle-fuzzy})
-     Toggle the current regexp matcher.
-
-
address@hidden
+Toggle the current regexp matcher.
address@hidden indentedblock
 @subsubheading @kbd{>} (@code{ivy-minibuffer-grow})
-     Increase @code{ivy-height} for the current minibuffer.
-
-
address@hidden
+Increase @code{ivy-height} for the current minibuffer.
address@hidden indentedblock
 @subsubheading @kbd{<} (@code{ivy-minibuffer-shrink})
-     Decrease @code{ivy-height} for the current minibuffer.
-
-
address@hidden
+Decrease @code{ivy-height} for the current minibuffer.
address@hidden indentedblock
 @subsubheading @kbd{w} (@code{ivy-prev-action})
-     Select the previous action.
-
-
address@hidden
+Select the previous action.
address@hidden indentedblock
 @subsubheading @kbd{s} (@code{ivy-next-action})
-     Select the next action.
-
-
address@hidden
+Select the next action.
address@hidden indentedblock
 @subsubheading @kbd{a} (@code{ivy-read-action})
-     Use a menu to select an action.
-
-
address@hidden
+Use a menu to select an action.
address@hidden indentedblock
 @subsubheading @kbd{C} (@code{ivy-toggle-case-fold})
-     Toggle case folding (matching both upper and lower case
address@hidden
+Toggle case folding (matching both upper and lower case
 characters with lower case input).
address@hidden indentedblock
 
 @node Saving the current completion session to a buffer
 @subsection Saving the current completion session to a buffer
 
 @subsubheading @kbd{C-c C-o} (@code{ivy-occur})
-     Saves the current candidates to a new buffer and exits
address@hidden
+Saves the current candidates to a new buffer and exits
 completion.
address@hidden indentedblock
 
 The new buffer is read-only and has a few useful bindings defined.
 
 @subsubheading @kbd{RET} or @kbd{j} (@code{ivy-occur-press})
-     Call the current action on the selected candidate.
-
-
address@hidden
+Call the current action on the selected candidate.
address@hidden indentedblock
 @subsubheading @kbd{mouse-1} (@code{ivy-occur-click})
-     Call the current action on the selected candidate.
-
-
address@hidden
+Call the current action on the selected candidate.
address@hidden indentedblock
 @subsubheading @kbd{j} (@code{next-line})
-     Move to next line.
-
-
address@hidden
+Move to next line.
address@hidden indentedblock
 @subsubheading @kbd{k} (@code{previous-line})
-     Move to previous line.
-
-
address@hidden
+Move to previous line.
address@hidden indentedblock
 @subsubheading @kbd{a} (@code{ivy-occur-read-action})
-     Read an action and make it current for this buffer.
-
-
address@hidden
+Read an action and make it current for this buffer.
address@hidden indentedblock
 @subsubheading @kbd{o} (@code{ivy-occur-dispatch})
-     Read an action and call it on the selected candidate.
-
-
address@hidden
+Read an action and call it on the selected candidate.
address@hidden indentedblock
 @subsubheading @kbd{q} (@code{quit-window})
-     Bury the current buffer.
address@hidden
+Bury the current buffer.
address@hidden indentedblock
 
 
 Ivy has no limit on the number of active buffers like these.
@@ -621,28 +712,64 @@ descriptive names, for example: @code{*ivy-occur 
counsel-describe-variable
 @node Completion styles
 @chapter Completion styles
 
-Ivy's completion functions rely on the highly configurable regex
-builder.
+Ivy's completion functions rely on a regex builder - a function that
+transforms a string input to a string regex. All current candidates
+simply have to match this regex. Each collection can be assigned its
+own regex builder by customizing @code{ivy-re-builders-alist}.
+
+The keys of this alist are collection names, and the values are one of:
address@hidden
address@hidden
address@hidden
address@hidden
address@hidden
address@hidden
address@hidden
address@hidden
address@hidden
address@hidden
address@hidden
address@hidden itemize
+
+There's also a catch-all key @code{t} that applies to all collections that
+don't have their own key.
 
 The default is:
+
 @lisp
 (setq ivy-re-builders-alist
       '((t . ivy--regex-plus)))
 @end lisp
 
-The default @code{ivy--regex-plus} narrowing is always invoked unless
-specified otherwise. For example, file name completion may have a
-custom completion function:
+For example, here is how to assign a custom regex builder to file name
+completion:
+
 @lisp
 (setq ivy-re-builders-alist
       '((read-file-name-internal . ivy--regex-fuzzy)
         (t . ivy--regex-plus)))
 @end lisp
 
-Ivy's flexibility extends to using different styles of completion
-mechanics (regex-builders) for different types of lists. Despite this
-flexibility, Ivy operates within a consistent and uniform interface.
-The main regex-builders currently in Ivy are:
+Here, @code{read-file-name-internal} is a function passed as the second
+argument to @code{completing-read} when completing file names.
+
+The regex builder resolution is a follows, in order of priority:
address@hidden
address@hidden
address@hidden argument passed to @code{ivy-read}.
address@hidden
address@hidden argument passed to @code{ivy-read} is a function and has an
+entry on @code{ivy-re-builders-alist}.
address@hidden
address@hidden argument passed to @code{ivy-read} has an entry on
address@hidden
address@hidden
address@hidden has an entry on @code{ivy-re-builders-alist}.
address@hidden
address@hidden has an entry on @code{ivy-re-builders-alist}.
address@hidden
address@hidden
address@hidden enumerate
 @menu
 * ivy--regex-plus::
 * ivy--regex-ignore-order::
@@ -701,6 +828,742 @@ number of hits.  Yet some searches need these extra hits. 
Ivy sorts
 such large lists using @code{flx} package's scoring mechanism, if it's
 installed.
 
+In case @code{ivy--regex-fuzzy} isn't your current regexp builder, you
+toggle it during completion with @kbd{C-o m}.
+
address@hidden Customization
address@hidden Customization
+
address@hidden
+* Faces::
+* Defcustoms::
+* Actions::
+* Packages::
address@hidden menu
+
address@hidden Faces
address@hidden Faces
+
address@hidden @code{ivy-current-match}
address@hidden
+Highlights the currently selected candidate.
address@hidden indentedblock
address@hidden @code{ivy-minibuffer-match-face-1}
address@hidden
+Highlights the background of the match.
address@hidden indentedblock
address@hidden @code{ivy-minibuffer-match-face-2}
address@hidden
+Highlights the first (modulo 3) matched group.
address@hidden indentedblock
address@hidden @code{ivy-minibuffer-match-face-3}
address@hidden
+Highlights the second (modulo 3) matched group.
address@hidden indentedblock
address@hidden @code{ivy-minibuffer-match-face-4}
address@hidden
+Highlights the third (modulo 3) matched group.
address@hidden indentedblock
address@hidden @code{ivy-confirm-face}
address@hidden
+Highlights the "(confirm)" part of the prompt.
+
+Used in conjunction with the built-in
address@hidden defcustom.  When you set
+this variable to @code{t}, you'll have to confirm non-existent files
+and buffer with another @kbd{RET} in @code{ivy-mode}.
+
+This face will be used to highlight the confirmation prompt.
+
+For example, use this setting:
+
address@hidden
+(setq confirm-nonexistent-file-or-buffer t)
address@hidden lisp
+
+Then call @code{find-file}, enter "eldorado" and press @kbd{RET} - the
+prompt will be appended with "(confirm)". Press @kbd{RET} once more
+to confirm, or any key to continue the completion.
address@hidden indentedblock
address@hidden @code{ivy-match-required-face}
address@hidden
+Highlights the "(match required)" part of the prompt.
+
+Sometimes, the Emacs functions that call completion specify to it
+that a match is required, i.e. you can't just type in some random
+stuff - you have to select one of the candidates given to you.
+In that case, @code{ivy-mode} will appropriately change the prompt.
+
+For example, call @code{describe-variable}, enter "waldo" and press
address@hidden - the prompt will be appended with "(match required)".
+Press any key and the prompt warning will disappear.
address@hidden indentedblock
address@hidden @code{ivy-subdir}
address@hidden
+Highlights directories when completing file names.
address@hidden indentedblock
address@hidden @code{ivy-remote}
address@hidden
+Highlights remote files when completing file names.
address@hidden indentedblock
address@hidden @code{ivy-virtual}
address@hidden
+Highlights virtual buffers when completing buffer names.
+
+Virtual buffers correspond to your bookmarks and the @code{recentf}
+list.
+
+Enable the virtual buffers like this:
+
address@hidden
+(setq ivy-use-virtual-buffers t)
address@hidden lisp
address@hidden indentedblock
+
address@hidden Defcustoms
address@hidden Defcustoms
+
address@hidden ivy-count-format
+A string that describes how to show the number of candidates and
+possibly the current candidate in the prompt.
+
+By default, the number of matching candidates will be shown as an
+integer with padding on the right.
+
+To disable showing the number of candidates:
+
address@hidden
+(setq ivy-count-format "")
address@hidden lisp
+
+To show the current candidate, in addition to the number of candidates:
+
address@hidden
+(setq ivy-count-format "(%d/%d) ")
address@hidden lisp
+
+This variable uses @code{format}-style switches, see the documentation
+of @code{format} for more info.
address@hidden defopt
+
address@hidden ivy-display-style
+Decides how to highlight the candidates in the minibuffer.
+
+The default setting is @code{'fancy} and it's available only for Emacs
+versions 24.5 or newer.
+
+Set this to @code{nil} to get a more plain minibuffer.
address@hidden defopt
+
address@hidden ivy-on-del-error-function
+Decides what to do when @kbd{DEL} (@code{ivy-backward-delete-char})
+throws.
+
+The default behavior is to quit the completion - this is handy if
+you invoke the completion by mistake.
address@hidden defopt
+
address@hidden Actions
address@hidden Actions
+
address@hidden
+* What are actions?::
+* How can different actions be called?::
+* How can the action list be modified?::
+* Example - add two actions to each command::
+* Example - define a new command with several actions::
address@hidden menu
+
address@hidden What are actions?
address@hidden What are actions?
+
+An action is a function of a single argument that gets called after
+you select a candidate during completion. The selected candidate is
+passed to this function as a string argument.
+
address@hidden Window context when calling an action
address@hidden
+Currently, the action is executed in the minibuffer window
+context. This means e.g. that if you call @code{insert} the text will
+be inserted into the minibuffer.
+
+If you want to execute the action in the initial window from
+which the completion started, use the @code{with-ivy-window} wrapper
+macro.
+
address@hidden
+(defun ivy-insert-action (x)
+  (with-ivy-window
+    (insert x)))
address@hidden lisp
address@hidden indentedblock
+
address@hidden How can different actions be called?
address@hidden How can different actions be called?
+
address@hidden
address@hidden
address@hidden (@code{ivy-done}) calls the current/default action.
address@hidden
address@hidden (@code{ivy-dispatching-done}) selects among all actions, calls it
+and exits.
address@hidden
address@hidden (@code{ivy-dispatching-call}) selects among all actions, calls it
+and doesn't exit.
address@hidden itemize
+
address@hidden How can the action list be modified?
address@hidden How can the action list be modified?
+
+Currently, you can append any amount of your own actions to the
+default list of actions. This can be done either for a specific
+command, or for all commands at once.
+
+Usually, the command has only one default action. The convention is to
+use single letters when selecting a command, and the letter @kbd{o} is
+designated for the default command. This way, @kbd{M-o o} should be always
+equivalent to @kbd{C-m}.
+
address@hidden Example - add two actions to each command
address@hidden Example - add two actions to each command
+
+The first action inserts the current candidate into the Ivy window -
+the window from which @code{ivy-read} was called.
+
+The second action copies the current candidate to the kill ring.
+
address@hidden
+(defun ivy-yank-action (x)
+  (kill-new x))
+
+(defun ivy-copy-to-buffer-action (x)
+  (with-ivy-window
+    (insert x)))
+
+(ivy-set-actions
+ t
+ '(("i" ivy-copy-to-buffer-action "insert")
+   ("y" ivy-yank-action "yank")))
address@hidden lisp
+
+Now in any completion session you can access @code{ivy-yank-action} with
address@hidden y} and @code{ivy-copy-to-buffer-action} with @kbd{M-o i}.
address@hidden
+* How to undo adding the two actions::
+* How to add actions to a specific command::
address@hidden menu
+
address@hidden How to undo adding the two actions
address@hidden How to undo adding the two actions
+
address@hidden simply modifies the internal dict with new data, so
+you can set the extra actions list to @code{nil} by assigning @code{nil} value
+to the @code{t} key:
+
address@hidden
+(ivy-set-actions t nil)
address@hidden lisp
+
address@hidden How to add actions to a specific command
address@hidden How to add actions to a specific command
+
+Use the command name as the key:
+
address@hidden
+(ivy-set-actions
+ 'swiper
+ '(("i" ivy-copy-to-buffer-action "insert")
+   ("y" ivy-yank-action "yank")))
address@hidden lisp
+
address@hidden Example - define a new command with several actions
address@hidden Example - define a new command with several actions
+
address@hidden
+(defun my-action-1 (x)
+  (message "action-1: %s" x))
+
+(defun my-action-2 (x)
+  (message "action-2: %s" x))
+
+(defun my-action-3 (x)
+  (message "action-3: %s" x))
+
+(defun my-command-with-3-actions ()
+  (interactive)
+  (ivy-read "test: " '("foo" "bar" "baz")
+            :action '(1
+                      ("o" my-action-1 "action 1")
+                      ("j" my-action-2 "action 2")
+                      ("k" my-action-3 "action 3"))))
address@hidden lisp
+
+Here, the number determines the index of the default action.  For each
+action, the strings are used to describe it during the selection.
address@hidden
+* Testing out the above function with @code{ivy-occur}::
address@hidden menu
+
address@hidden Testing out the above function with @code{ivy-occur}
address@hidden Testing out the above function with @code{ivy-occur}
+
+To examine each action with each candidate in a key-efficient way, try:
+
address@hidden
address@hidden
+Call @code{my-command-with-3-actions}.
address@hidden
+Press @kbd{C-c C-o} to close the completion and move to an ivy-occur buffer.
address@hidden
+Press @kbd{kkk} to move to the first candidate, since you're likely at the end 
of the buffer.
address@hidden
+Press @kbd{oo} to call the first action.
address@hidden
+Press @kbd{oj} and @kbd{ok} to call the second and the third actions.
address@hidden
+Press @kbd{j} to move to the next candidate
address@hidden
address@hidden
address@hidden itemize
+
address@hidden Packages
address@hidden Packages
+
address@hidden @code{org-mode}
address@hidden
+With the most recent version, @code{org-mode} will obey
address@hidden (which @code{ivy-mode} sets), so it should
+work by default.  If you try it for refiling to headings with
+similar names, you'll really notice how much better @code{ivy-mode} is
+at it.
address@hidden indentedblock
address@hidden @code{magit}
address@hidden
+This setting is needed to use ivy completion:
+
address@hidden
+(setq magit-completing-read-function 'ivy-completing-read)
address@hidden lisp
address@hidden indentedblock
address@hidden @code{find-file-in-project}
address@hidden
+Will use ivy by default if it's available.
address@hidden indentedblock
address@hidden @code{projectile}
address@hidden
+This setting is needed to use ivy completion:
+
address@hidden
+(setq projectile-completion-system 'ivy)
address@hidden lisp
address@hidden indentedblock
address@hidden @code{helm-make}
address@hidden
+This setting is needed to use ivy completion:
+
address@hidden
+(setq helm-make-completion-method 'ivy)
address@hidden lisp
address@hidden indentedblock
+
address@hidden Commands
address@hidden Commands
+
address@hidden
+* File Name Completion::
+* Buffer Name Completion::
+* Counsel commands::
address@hidden menu
+
address@hidden File Name Completion
address@hidden File Name Completion
+
+Since file name completion is so essential, ivy has a few extra
+bindings that work here.
+
address@hidden @kbd{C-j} (@code{ivy-alt-done})
address@hidden
+Use on a directory to restart the completion from that
+directory. Use it on a file or @code{./} to exit the completion with
+the selected candidate.
address@hidden indentedblock
address@hidden @kbd{DEL} (@code{ivy-backward-delete-char})
address@hidden
+When completing file names, and the current input is empty,
+restart the completion in the parent directory.
address@hidden indentedblock
address@hidden @kbd{//} (@code{self-insert-command})
address@hidden
+Switch to the root directory.
address@hidden indentedblock
address@hidden @kbd{~} (@code{self-insert-command})
address@hidden
+Switch to the home directory.
address@hidden indentedblock
address@hidden @kbd{/} (@code{self-insert-command})
address@hidden
+If the current input is precisely an existing directory, switch
+the completion to that directory.
address@hidden indentedblock
address@hidden @kbd{M-q} (@code{ivy-toggle-regexp-quote})
address@hidden
+Toggle between your input being a regexp and not.
+
+Since file names tend to include @code{.}, which matches any char in
+regexp mode, you might want to switch to matching literally.
address@hidden indentedblock
address@hidden ivy-extra-directories
+Decide if you want to see @code{../} and @code{./} during file name
+completion.
+
+You might want to remove @code{../}, since selecting it is the same as
address@hidden On the other hand, having it around makes it possible to
+navigate anywhere with only @kbd{C-n}, @kbd{C-p} and @kbd{C-j}.
+
+Similarly, @code{./} can be removed as well.
address@hidden defopt
+
address@hidden Using TRAMP
address@hidden
+Completion for TRAMP is supported in a peculiar way. From any
+directory, with the empty input, inputting @code{/ssh:} and pressing
address@hidden (or @kbd{RET} which is the same thing) will give you a
+completion for host and user names.
+
+You can also input @code{/ssh:user@@} to get domain completion with
+user name already selected.
+
+Described above is a recommended and simple method of
+interaction. If you find it lacking, you can still use @kbd{C-i},
+which does largely the same as the default completion does.
address@hidden indentedblock
address@hidden History
address@hidden
+The history works with @kbd{M-p}, @kbd{M-n}, and @kbd{C-r}, as in all other
+completion sessions.  A custom history code was implemented for
+file name completion. This code will cycle you through all
+previous files that you opened, including the input with which
+the file was opened. It also works well with TRAMP.
address@hidden indentedblock
+
address@hidden Buffer Name Completion
address@hidden Buffer Name Completion
+
address@hidden ivy-use-virtual-buffers
+When non-nil, add @code{recentf-mode} and bookmarks to 
@code{ivy-switch-buffer}.
+
+If you add this to your setup:
+
address@hidden
+(setq ivy-use-virtual-buffers t)
address@hidden lisp
+when using @code{ivy-switch-buffer} additional buffers will be
+appended to your live buffer list. These buffers will be
+highlighted with the @code{ivy-virtual} face, and selecting them will
+open the corresponding file.
address@hidden defopt
+
address@hidden Counsel commands
address@hidden Counsel commands
+
+The main advantage of using @code{counsel-} functions over their basic
+equivalents with @code{ivy-mode} enabled are the following:
+
address@hidden
address@hidden
+You can use everything related to multi-actions and non-exiting actions.
address@hidden
+You can use @code{ivy-resume} to resume your last completion session.
address@hidden
+You can customize them further with @code{ivy-set-actions}, 
@code{ivy-re-builders-alist}.
address@hidden
+You can customize their individual keymaps, like
address@hidden, @code{counsel-git-grep-map}, or
address@hidden, instead of just customizing
address@hidden that applies to all completion sessions.
address@hidden enumerate
+
address@hidden API
address@hidden API
+
+The main (and only) entry point is @code{ivy-read} function. It has only
+two required arguments and many optional arguments that you can pass
+by key. Although the @code{:action} argument is optional, it's very
+recommended that you use it, otherwise the extra features (as compared
+to the default completion) like multi-actions, non-exiting actions,
address@hidden and @code{ivy-resume} will not be possible.
address@hidden
+* Required arguments for @code{ivy-read}::
+* Optional arguments for @code{ivy-read}::
+* Example - @code{counsel-describe-function}::
+* Example - @code{counsel-locate}::
address@hidden menu
+
address@hidden Required arguments for @code{ivy-read}
address@hidden Required arguments for @code{ivy-read}
+
address@hidden @code{prompt}
address@hidden
+A format string normally ending in a colon and a space.
+
address@hidden anywhere in the string is replaced by the current number of
+matching candidates. To use a literal @code{%} character, escape it as
address@hidden See also @code{ivy-count-format}.
address@hidden indentedblock
address@hidden @code{collection}
address@hidden
+Either a list of strings, a function, an alist or a hash table.
+
+In case it's a function, it has to be compatible with
address@hidden
address@hidden indentedblock
+
address@hidden Optional arguments for @code{ivy-read}
address@hidden Optional arguments for @code{ivy-read}
+
address@hidden @code{predicate}
address@hidden
+A function to filter the initial collection with, compatible with 
@code{all-completions}.
address@hidden indentedblock
address@hidden @code{require-match}
address@hidden
+When non-nil, don't let the user exit with a custom input - it
+must match one of the candidates.
address@hidden indentedblock
address@hidden @code{initial-input}
address@hidden
+A string to be initially inserted into the minibuffer. This
+argument is included for compatibility with
address@hidden Consider using the @code{preselect} argument
+instead - it's often superior.
address@hidden indentedblock
address@hidden @code{history}
address@hidden
+A symbol name to store the history. See @code{completing-read}.
address@hidden indentedblock
address@hidden @code{preselect}
address@hidden
+When it's a string, make the first candidate matching this string
+initially selected.
+
+When it's an integer, make the candidate with that index
+initially selected.
+
+Every time the input becomes empty, the item corresponding to to
address@hidden is selected.
address@hidden indentedblock
address@hidden @code{keymap}
address@hidden
+A keymap to be composed with @code{ivy-minibuffer-map}. This keymap
+has priority over @code{ivy-minibuffer-map} and can be modified at any
+later stage.
address@hidden indentedblock
address@hidden @code{update-fn}
address@hidden
+A function to call each time the current candidate is changed.
+This function takes no arguments and is called in the
+minibuffer's @code{post-command-hook}. See @code{swiper} for an example
+usage.
address@hidden indentedblock
address@hidden @code{sort}
address@hidden
+When non-nil, use @code{ivy-sort-functions-alist} to sort the given
+collection. The collection will not be sorted when it's larger
+than @code{ivy-sort-max-size}.
address@hidden indentedblock
address@hidden @code{action}
address@hidden
+A function to call after a result is selected. Takes a single
+string argument.
address@hidden indentedblock
address@hidden @code{unwind}
address@hidden
+A function with no arguments to call before exiting
+completion. This function is called even if the completion is
+interrupted with e.g. @kbd{C-g}. See @code{swiper} for an example usage.
address@hidden indentedblock
address@hidden @code{re-builder}
address@hidden
+A function that takes a string and returns a corresponding regex.
+See the section on completion styles.
address@hidden indentedblock
address@hidden @code{matcher}
address@hidden
+A function that takes a regex and a list of strings and returns a
+list of strings that "match" the regex. Normally a
+straightforward function is used. Use this argument to really
+fine-tune the matching process. See @code{counsel-find-file} for an
+example usage.
address@hidden indentedblock
address@hidden @code{dynamic-collection}
address@hidden
+When non-nil, @code{collection} will be used to dynamically generate
+the candidates each time the input changes, instead of being used
+once statically with @code{all-completions} to generate a list of
+strings. See @code{counsel-locate} for an example usage.
address@hidden indentedblock
address@hidden @code{caller}
address@hidden
+A symbol to uniquely identify the function that called
address@hidden  This is useful in all kinds of customization
+scenarios.
address@hidden indentedblock
+
address@hidden Example - @code{counsel-describe-function}
address@hidden Example - @code{counsel-describe-function}
+
+This is a typical example of a function with a non-async collection:
+all the strings in the collection are known before the user does any
+input.
+
+Note that only the first two arguments (and the @code{action}) are really
+important - the rest is just fine-tuning and could be omitted.
+
+The @code{action} argument could also be omitted - but then @code{ivy-read}
+would no nothing except returning the string result, which you could
+later use yourself. However, it's recommended that you use the
address@hidden argument.
+
address@hidden
+(defun counsel-describe-function ()
+  "Forward to `describe-function'."
+  (interactive)
+  (ivy-read "Describe function: "
+            (let (cands)
+              (mapatoms
+               (lambda (x)
+                 (when (fboundp x)
+                   (push (symbol-name x) cands))))
+              cands)
+            :keymap counsel-describe-map
+            :preselect (counsel-symbol-at-point)
+            :history 'counsel-describe-symbol-history
+            :require-match t
+            :sort t
+            :action (lambda (x)
+                      (describe-function
+                       (intern x)))
+            :caller 'counsel-describe-function))
address@hidden lisp
+
+Here are the interesting features of the above function, in the order that 
they appear:
+
address@hidden
address@hidden
+The @code{prompt} argument is a simple string ending in ": ".
address@hidden
+The @code{collection} argument evaluates to a (large) list of strings.
address@hidden
+The @code{keymap} argument allows for a custom keymap to supplement 
@code{ivy-minibuffer-map}.
address@hidden
+The @code{history} argument ensures that the command has its own history,
+and doesn't need to share the common history @code{ivy-history} that all
+commands without their own history share.
address@hidden
+The @code{require-match} is set to @code{t}, since it doesn't make sense to
+call @code{describe-function} on an un-interned symbol.
address@hidden
+The @code{sort} argument is set to @code{t}, since it's usually useful to have
+functions with similar names be close to each other in the candidate
+list. However, after loading many packages the collection often
+exceeds the default value of @code{ivy-sort-max-size} (30000). The user
+can customize this variable to decide which is more important: the
+sorting or the completion start-up time.
address@hidden
+The @code{action} argument calls @code{describe-function} on the interned
+selected candidate.
address@hidden
+The @code{caller} argument identifies this completion session. This is
+important, since with the collection being a list of strings and not
+a function name, the only other way for @code{ivy-read} to identify
+"who's calling" and to apply the appropriate customizations is to
+examine @code{this-command}. But @code{this-command} would be modified if
+another command called @code{counsel-describe-function}.
address@hidden itemize
+
address@hidden Example - @code{counsel-locate}
address@hidden Example - @code{counsel-locate}
+
+This is a typical example of a function with an async collection.
+Since we can't pre-compute all the collection items valid for an empty
+input and store them in the memory, the collection function is called
+each time the user updates the input.  However, while the returned
+list of strings is used immediately (usually it's something like
address@hidden'("please wait...")}), it's expected of the collection function to
+make a call to @code{start-process} and update the minibuffer text at some
+point when the process is finished.
+
+Async collections are a good fit for long-running shell commands, like
address@hidden As soon as there is enough input, a new process is started
+and the old process is killed (since the old input is no longer
+relevant). The user can either type more or wait for the already
+running process to finish and update the minibuffer.
+
address@hidden
+(defun counsel-locate-function (str)
+  (if (< (length str) 3)
+      (counsel-more-chars 3)
+    (counsel--async-command
+     (format "locate %s '%s'"
+             (mapconcat #'identity counsel-locate-options " ")
+             (counsel-unquote-regex-parens
+              (ivy--regex str))))
+    '("" "working...")))
+
+;;;###autoload
+(defun counsel-locate (&optional initial-input)
+  "Call the \"locate\" shell command.
+INITIAL-INPUT can be given as the initial minibuffer input."
+  (interactive)
+  (ivy-read "Locate: " #'counsel-locate-function
+            :initial-input initial-input
+            :dynamic-collection t
+            :history 'counsel-locate-history
+            :action (lambda (file)
+                      (with-ivy-window
+                        (when file
+                          (find-file file))))
+            :unwind #'counsel-delete-process
+            :caller 'counsel-locate))
address@hidden lisp
+
+Here are the interesting features of the above functions, in the order
+that they appear:
+
address@hidden
address@hidden
address@hidden takes a string argument and returns a list
+of strings. Note that it's not compatible with @code{all-completions},
+but since we're not using that here, might as well use one argument
+instead of three.
address@hidden
address@hidden is a simple function that returns e.g.
address@hidden'("2 chars more")} asking the user for more input.
address@hidden
address@hidden is a very easy API simplification that
+takes a single string argument suitable for
address@hidden So you could prototype your function as
+non-async using @code{shell-command-to-string} and @code{split-string} to
+produce a collection, then decide that you want async and simply swap in
address@hidden
address@hidden
address@hidden is an interactive function with optional @code{initial-input}.
address@hidden
address@hidden'counsel-locate-function} is passed as the @code{collection} 
argument.
address@hidden
address@hidden argument is set to t, since we have an async collection.
address@hidden
address@hidden argument uses @code{with-ivy-window} wrapper, since we want to 
open the
+selected file in the same window from which @code{counsel-locate} was
+called.
address@hidden
address@hidden argument is set to @code{#'counsel-delete-process}: when we 
press @kbd{C-g}
+we want to kill the running process created by
address@hidden
address@hidden
address@hidden argument identifies this command for easier customization.
address@hidden itemize
+
 @node Variable Index
 @unnumbered Variable Index
 



reply via email to

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