]> code.delx.au - gnu-emacs-elpa/commitdiff
ivy.el (ivy-done): Allow ivy-dispatching-done to exit with no cands
authorOleh Krehel <ohwoeowho@gmail.com>
Mon, 18 Apr 2016 14:23:14 +0000 (16:23 +0200)
committerOleh Krehel <ohwoeowho@gmail.com>
Mon, 18 Apr 2016 14:23:14 +0000 (16:23 +0200)
Example of use:

(defun ivy-recentf-with-last-input (_x)
  (ivy-read "Recentf: " recentf-list
            :action (lambda (f)
                      (with-ivy-window (find-file f)))
            :initial-input ivy-text
            :caller 'ivy-recentf))

(ivy-set-actions t '(("r" ivy-recentf-with-last-input "recentf")))

The input may match no candidates, but it's still good for
`ivy-recentf-with-last-input', since it uses `ivy-text' instead of
`ivy--current'.

ivy.el

diff --git a/ivy.el b/ivy.el
index e07fa53ee664168353d2fb6e1fed248077a895a6..7d705c8af753dcb15adee502c2b814c4591c32df 100644 (file)
--- a/ivy.el
+++ b/ivy.el
@@ -457,7 +457,10 @@ When non-nil, it should contain at least one %d.")
   "Exit the minibuffer with the selected candidate."
   (interactive)
   (delete-minibuffer-contents)
-  (cond ((> ivy--length 0)
+  (cond ((or (> ivy--length 0)
+             ;; the action from `ivy-dispatching-done' may not need a
+             ;; candidate at all
+             (eq this-command 'ivy-dispatching-done))
          (ivy--done ivy--current))
         ((memq (ivy-state-collection ivy-last)
                '(read-file-name-internal internal-complete-buffer))