[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 0cffcac 1/2: Add require-match functionality
From: |
Oleh Krehel |
Subject: |
[elpa] master 0cffcac 1/2: Add require-match functionality |
Date: |
Thu, 16 Apr 2015 16:45:10 +0000 |
branch: master
commit 0cffcacdb0e0a035aa75f5276ca0c4cba688fc6f
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add require-match functionality
* ivy.el (ivy-require-match): New defvar.
(ivy-done): When nothing matches, and `ivy-require-match' isn't t, use
the current text anyway.
(ivy-completing-read): Update.
---
ivy.el | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/ivy.el b/ivy.el
index f4e368e..bb0306a 100644
--- a/ivy.el
+++ b/ivy.el
@@ -90,12 +90,18 @@ This is usually meant as a quick exit out of the
minibuffer."
Maximum length of the history list is determined by the value
of `history-length', which see.")
+(defvar ivy-require-match t
+ "Store require-match. See `completing-read'.")
+
;;** Commands
(defun ivy-done ()
"Exit the minibuffer with the selected candidate."
(interactive)
(delete-minibuffer-contents)
- (unless (zerop ivy--length)
+ (if (zerop ivy--length)
+ (when (memq ivy-require-match '(nil confirm confirm-after-completion))
+ (insert ivy-text)
+ (setq ivy-exit 'done))
(insert ivy--current)
(setq ivy-exit 'done))
(exit-minibuffer))
@@ -232,7 +238,7 @@ UPDATE-FN is called each time the current candidate(s) is
changed."
(funcall ivy--action))))))
(defun ivy-completing-read (prompt collection
- &optional predicate _require-match initial-input
+ &optional predicate require-match initial-input
_history def _inherit-input-method)
"Read a string in the minibuffer, with completion.
@@ -243,7 +249,7 @@ PROMPT is a string to prompt with; normally it ends in a
colon and a space.
COLLECTION can be a list of strings, an alist, an obarray or a hash table.
PREDICATE limits completion to a subset of COLLECTION.
-_REQUIRE-MATCH is ignored for now.
+REQUIRE-MATCH is stored into `ivy-require-match'. See `completing-read'.
INITIAL-INPUT is a string that can be inserted into the minibuffer initially.
_HISTORY is ignored for now.
DEF is the default value.
@@ -261,6 +267,7 @@ The history, defaults and input-method arguments are
ignored for now."
(setq collection (cl-remove-if-not predicate collection)))
(when (listp def)
(setq def (car def)))
+ (setq ivy-require-match require-match)
(ivy-read prompt collection initial-input nil def))
;;;###autoload
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master 0cffcac 1/2: Add require-match functionality,
Oleh Krehel <=