branch: master
commit f2a09664bddff377dffec651b403d078c835300a
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Add ivy-partial: partial complete without exiting
* ivy.el (ivy-partial-or-done): Forward to `ivy-partial'.
(ivy-partial): New defun.
If you want a different style of completion for "TAB", do this in your
config:
(define-key ivy-minibuffer-map (kbd "TAB") 'ivy-partial)
Fixes #85
Fixes #86
---
ivy.el | 41 ++++++++++++++++++++++++-----------------
1 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/ivy.el b/ivy.el
index 9adeae0..48dde66 100644
--- a/ivy.el
+++ b/ivy.el
@@ -271,23 +271,30 @@ candidate."
(interactive)
(if (eq this-command last-command)
(ivy-alt-done)
- (let* ((parts (or (split-string ivy-text " " t) (list "")))
- (postfix (car (last parts)))
- (completion-ignore-case t)
- (new (try-completion postfix
- (mapcar (lambda (str) (substring str
(string-match postfix str)))
- ivy--old-cands))))
- (if new
- (progn
- (delete-region (minibuffer-prompt-end) (point-max))
- (setcar (last parts) new)
- (insert (mapconcat #'identity parts " ")
- (if ivy-tab-space " " "")))
- (when (and (eq confirm-nonexistent-file-or-buffer t)
- (memq (ivy-state-collection ivy-last)
- '(read-file-name-internal
- internal-complete-buffer)))
- (ivy-done))))))
+ (unless (ivy-partial)
+ (when (and (eq confirm-nonexistent-file-or-buffer t)
+ (memq (ivy-state-collection ivy-last)
+ '(read-file-name-internal
+ internal-complete-buffer)))
+ (ivy-done)))))
+
+(defun ivy-partial ()
+ "Complete the minibuffer text as much as possible."
+ (interactive)
+ (let* ((parts (or (split-string ivy-text " " t) (list "")))
+ (postfix (car (last parts)))
+ (completion-ignore-case t)
+ (new (try-completion postfix
+ (mapcar (lambda (str) (substring str
(string-match postfix str)))
+ ivy--old-cands))))
+ (cond ((eq new t)
+ nil)
+ (new
+ (delete-region (minibuffer-prompt-end) (point-max))
+ (setcar (last parts) new)
+ (insert (mapconcat #'identity parts " ")
+ (if ivy-tab-space " " ""))
+ t))))
(defun ivy-immediate-done ()
"Exit the minibuffer with the current input."