branch: master
commit e016d48e9575c4207f403a87ca2360a79dba5229
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
Allow "TAB" to complete when input starts with "^"
* ivy.el (ivy-partial): Strip "^" when forwarding to `try-completion'.
Afterwards, put it back.
Fixes #138
---
ivy.el | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/ivy.el b/ivy.el
index e2e6243..9faf6af 100644
--- a/ivy.el
+++ b/ivy.el
@@ -337,14 +337,20 @@ If the text hasn't changed as a result, forward to
`ivy-alt-done'."
(let* ((parts (or (split-string ivy-text " " t) (list "")))
(postfix (car (last parts)))
(completion-ignore-case t)
- (new (try-completion postfix
+ (startp (string-match "^\\^" postfix))
+ (new (try-completion (if startp
+ (substring postfix 1)
+ postfix)
(mapcar (lambda (str) (substring str
(string-match postfix str)))
ivy--old-cands))))
(cond ((eq new t) nil)
((string= new ivy-text) nil)
(new
(delete-region (minibuffer-prompt-end) (point-max))
- (setcar (last parts) new)
+ (setcar (last parts)
+ (if startp
+ (concat "^" new)
+ new))
(insert (mapconcat #'identity parts " ")
(if ivy-tab-space " " ""))
t))))