[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 23ffa25 19/31: Bind "TAB" to do partial completion
From: |
Oleh Krehel |
Subject: |
[elpa] master 23ffa25 19/31: Bind "TAB" to do partial completion |
Date: |
Fri, 01 May 2015 14:28:57 +0000 |
branch: master
commit 23ffa25afc562acb8e26847802bacb4916104e07
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Bind "TAB" to do partial completion
* ivy.el (ivy-minibuffer-map): Update.
(ivy-alt-done): New defun.
(ivy--old-text): Update.
Re #63.
---
ivy.el | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/ivy.el b/ivy.el
index c686157..1b5c9b5 100644
--- a/ivy.el
+++ b/ivy.el
@@ -94,6 +94,7 @@ Only \"./\" and \"../\" apply here. They appear in reverse
order."
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-m") 'ivy-done)
(define-key map (kbd "C-j") 'ivy-alt-done)
+ (define-key map (kbd "TAB") 'ivy-partial-or-done)
(define-key map (kbd "C-n") 'ivy-next-line)
(define-key map (kbd "C-p") 'ivy-previous-line)
(define-key map (kbd "<down>") 'ivy-next-line)
@@ -242,6 +243,26 @@ When ARG is t, exit with current text, ignoring the
candidates."
(ivy--exhibit))
(ivy-done)))))
+(defun ivy-partial-or-done ()
+ "Complete the minibuffer text as much as possible.
+When called twice in a row, exit the minibuffer with the current
+candidate."
+ (interactive)
+ (if (eq this-command last-command)
+ (progn
+ (delete-minibuffer-contents)
+ (insert ivy--current)
+ (setq ivy-exit 'done)
+ (exit-minibuffer))
+ (let* ((parts (split-string ivy-text " " t))
+ (postfix (car (last parts)))
+ (new (try-completion postfix
+ (mapcar (lambda (str) (substring str
(string-match postfix str)))
+ ivy--old-cands))))
+ (delete-region (minibuffer-prompt-end) (point-max))
+ (setcar (last parts) new)
+ (insert (mapconcat #'identity parts " ") " "))))
+
(defun ivy-immediate-done ()
"Exit the minibuffer with the current input."
(interactive)
@@ -723,7 +744,7 @@ Everything after \"!\" should not match."
(defun ivy--insert-prompt ()
"Update the prompt according to `ivy--prompt'."
(when ivy--prompt
- (unless (memq this-command '(ivy-done ivy-alt-done))
+ (unless (memq this-command '(ivy-done ivy-alt-done ivy-partial-or-done))
(setq ivy--prompt-extra ""))
(let (head tail)
(if (string-match "\\(.*\\): $" ivy--prompt)
- [elpa] master 988b78f 08/31: Improve completion history using the propertize trick, (continued)
- [elpa] master 988b78f 08/31: Improve completion history using the propertize trick, Oleh Krehel, 2015/05/01
- [elpa] master eb43e4a 10/31: ivy.el (ivy-alt-done): Treat `ivy-text' with ":" verbatim, Oleh Krehel, 2015/05/01
- [elpa] master 00810d6 11/31: ivy.el (ivy--filter): Fixup, Oleh Krehel, 2015/05/01
- [elpa] master 7f04019 12/31: swiper.el (swiper-font-lock-ensure): Exclude `elfeed-search-mode', Oleh Krehel, 2015/05/01
- [elpa] master 278870e 13/31: Use alpha compositing to add ivy-current-match face, Oleh Krehel, 2015/05/01
- [elpa] master 57de44c 14/31: Makefile: Update, Oleh Krehel, 2015/05/01
- [elpa] master 56d7802 15/31: Add an option for multi-tier regex matching, Oleh Krehel, 2015/05/01
- [elpa] master 7299950 16/31: ivy.el: Fixup docstrings, Oleh Krehel, 2015/05/01
- [elpa] master aa9d4a7 17/31: ivy.el (ivy-re-builders-alist): Improve doc, Oleh Krehel, 2015/05/01
- [elpa] master 0f141f5 18/31: counsel.el (counsel-git-grep): Add optional initial-input, Oleh Krehel, 2015/05/01
- [elpa] master 23ffa25 19/31: Bind "TAB" to do partial completion,
Oleh Krehel <=
- [elpa] master ae2fd1a 21/31: Improve hidden buffer completion further, Oleh Krehel, 2015/05/01
- [elpa] master 5dc26fb 20/31: Improve the completion of hidden buffers, Oleh Krehel, 2015/05/01
- [elpa] master 1332b19 22/31: ivy.el (ivy--exhibit): Fixup last commit, Oleh Krehel, 2015/05/01
- [elpa] master 6b2e95a 24/31: Add gamma-correction to alpha-blending, Oleh Krehel, 2015/05/01
- [elpa] master a868705 23/31: colir.el: Add two additional blend algorithms, Oleh Krehel, 2015/05/01
- [elpa] master 7bd6003 25/31: Update and improve faces, Oleh Krehel, 2015/05/01
- [elpa] master 94b6a83 26/31: Don't error on bad regex, Oleh Krehel, 2015/05/01
- [elpa] master 0dd6c5a 27/31: ivy.el (ivy--regex): Fixup, Oleh Krehel, 2015/05/01
- [elpa] master fc84e0d 28/31: ivy.el (ivy-read): Reset `ivy-text' earlier, Oleh Krehel, 2015/05/01
- [elpa] master 5a1bd78 29/31: Improve TRAMP completion for ivy-mode, Oleh Krehel, 2015/05/01