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

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

[elpa] master 37d371c 05/22: Add a way to exit ignoring the candidates


From: Oleh Krehel
Subject: [elpa] master 37d371c 05/22: Add a way to exit ignoring the candidates
Date: Wed, 22 Apr 2015 19:51:47 +0000

branch: master
commit 37d371c7c7cf9c6724fe5037902d4c78dd8fd3f5
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Add a way to exit ignoring the candidates
    
    * ivy.el (ivy-immediate-done): New commad, currently unbound.
    Exit the minibuffer, ignoring the candidates. Solves the same problem as
    "C-f" in `ido-mode'.
    (ivy-alt-done): With a prefix arg, e.g. "C-u C-j", forward to 
`ivy-immediate-done'.
    
    Re #50
---
 ivy.el |   47 +++++++++++++++++++++++++++++------------------
 1 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/ivy.el b/ivy.el
index 74991fe..d878172 100644
--- a/ivy.el
+++ b/ivy.el
@@ -188,25 +188,36 @@ When non-nil, it should contain one %d.")
          (setq ivy-exit 'done)))
   (exit-minibuffer))
 
-(defun ivy-alt-done ()
-  "Exit the minibuffer with the selected candidate."
+(defun ivy-alt-done (&optional arg)
+  "Exit the minibuffer with the selected candidate.
+When ARG is t, exit with current text, ignoring the candidates."
+  (interactive "P")
+  (if arg
+      (ivy-immediate-done)
+    (let (dir)
+      (cond ((and ivy--directory
+                  (= 0 ivy--index)
+                  (= 0 (length ivy-text)))
+             (ivy-done))
+
+            ((and ivy--directory
+                  (cl-plusp ivy--length)
+                  (file-directory-p
+                   (setq dir (expand-file-name
+                              ivy--current ivy--directory))))
+             (ivy--cd dir)
+             (ivy--exhibit))
+
+            (t
+             (ivy-done))))))
+
+(defun ivy-immediate-done ()
+  "Exit the minibuffer with the current input."
   (interactive)
-  (let (dir)
-    (cond ((and ivy--directory
-                (= 0 ivy--index)
-                (= 0 (length ivy-text)))
-           (ivy-done))
-
-          ((and ivy--directory
-                (cl-plusp ivy--length)
-                (file-directory-p
-                 (setq dir (expand-file-name
-                            ivy--current ivy--directory))))
-           (ivy--cd dir)
-           (ivy--exhibit))
-
-          (t
-           (ivy-done)))))
+  (delete-minibuffer-contents)
+  (insert ivy-text)
+  (setq ivy-exit 'done)
+  (exit-minibuffer))
 
 (defun ivy-beginning-of-buffer ()
   "Select the first completion candidate."



reply via email to

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