[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 6a098c6 15/19: Add ivy-mode
From: |
Oleh Krehel |
Subject: |
[elpa] master 6a098c6 15/19: Add ivy-mode |
Date: |
Thu, 16 Apr 2015 12:18:14 +0000 |
branch: master
commit 6a098c66a915a26d59bb87e34678094c5ceac18c
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add ivy-mode
* ivy.el (ivy-completing-read): New defun.
(ivy-mode): New global minor mode.
---
ivy.el | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/ivy.el b/ivy.el
index b1fd85c..3ac5931 100644
--- a/ivy.el
+++ b/ivy.el
@@ -231,6 +231,44 @@ UPDATE-FN is called each time the current candidate(s) is
changed."
(when ivy--action
(funcall ivy--action))))))
+(defun ivy-completing-read (prompt collection
+ &optional predicate _require-match initial-input
+ &rest _ignore)
+ "Read a string in the minibuffer, with completion.
+
+This is an interface that conforms to `completing-read', so that
+it can be used for `completing-read-function'.
+
+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.
+INITIAL-INPUT is a string that can be inserted into the minibuffer initially.
+
+The history, defaults and input-method arguments are ignored for now."
+ (cond ((functionp collection)
+ (error "Function as a collection unsupported"))
+ ((hash-table-p collection)
+ (error "Hash table as a collection unsupported"))
+ ((listp (car collection))
+ (setq collection (mapcar #'car collection))))
+ (when predicate
+ (setq collection (cl-remove-if-not predicate collection)))
+ (ivy-read prompt collection initial-input))
+
+;;;###autoload
+(define-minor-mode ivy-mode
+ "Toggle Ivy mode on or off.
+With ARG, turn Ivy mode on if arg is positive, off otherwise.
+Turning on Ivy mode will set `completing-read-function' to
+`ivy-completing-read'."
+ :group 'ivy
+ :global t
+ (if ivy-mode
+ (setq completing-read-function 'ivy-completing-read)
+ (setq completing-read-function 'completing-read-default)))
+
(defvar ivy--action nil
"Store a function to call at the end of `ivy--read'.")
- [elpa] master 841d59b 01/19: "C-s" should forward to "C-n" etc, (continued)
- [elpa] master 841d59b 01/19: "C-s" should forward to "C-n" etc, Oleh Krehel, 2015/04/16
- [elpa] master 609577e 12/19: Fix invalid package header line, Oleh Krehel, 2015/04/16
- [elpa] master e816884 03/19: Default ARG to 1 for arrows, Oleh Krehel, 2015/04/16
- [elpa] master a8a1f65 02/19: Add numeric arguments to arrows, Oleh Krehel, 2015/04/16
- [elpa] master 0477214 08/19: Fix `ivy-backward-delete-char-function', Oleh Krehel, 2015/04/16
- [elpa] master 6dd1068 04/19: swiper.el (swiper-query-replace): Enable recursive minibuffers, Oleh Krehel, 2015/04/16
- [elpa] master 3b78e0e 18/19: swiper.el: Bump version, Oleh Krehel, 2015/04/16
- [elpa] master 22139ae 19/19: Merge commit '3b78e0e503f4763f8a2d77eeacfc91213ec5532e' from swiper, Oleh Krehel, 2015/04/16
- [elpa] master c59752b 16/19: Update sorting order, make sure that perfect match is selected, Oleh Krehel, 2015/04/16
- [elpa] master 75aa14d 17/19: Fix thing-at-point in describe-function and -variable, Oleh Krehel, 2015/04/16
- [elpa] master 6a098c6 15/19: Add ivy-mode,
Oleh Krehel <=
- [elpa] master 592b692 07/19: Add defcustom for ivy-backward-delete-char, Oleh Krehel, 2015/04/16
- [elpa] master 048f479 13/19: Add four more commands, Oleh Krehel, 2015/04/16
- [elpa] master be452cc 14/19: swiper.el (swiper-font-lock-ensure): Exclude org-agenda-mode, Oleh Krehel, 2015/04/16
- [elpa] master ba0590f 09/19: counsel.el: Update comments, Oleh Krehel, 2015/04/16