[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 5a1bd78 29/31: Improve TRAMP completion for ivy-mode
From: |
Oleh Krehel |
Subject: |
[elpa] master 5a1bd78 29/31: Improve TRAMP completion for ivy-mode |
Date: |
Fri, 01 May 2015 14:29:06 +0000 |
branch: master
commit 5a1bd7881f12001acb2fa7f2c3bf9a22ee39f3ab
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Improve TRAMP completion for ivy-mode
* ivy.el (ivy-build-tramp-name): New defun.
(ivy-alt-done): Use arcane TRAMP stuff to complete host names.
Re #59
---
ivy.el | 47 +++++++++++++++++++++++++++++++++--------------
1 files changed, 33 insertions(+), 14 deletions(-)
diff --git a/ivy.el b/ivy.el
index 323fb8a..d279535 100644
--- a/ivy.el
+++ b/ivy.el
@@ -224,6 +224,15 @@ When non-nil, it should contain one %d.")
(setq ivy-exit 'done)))
(exit-minibuffer)))
+(defun ivy-build-tramp-name (x)
+ "Reconstruct X into a path.
+Is is a cons cell, related to `tramp-get-completion-function'."
+ (let ((user (car x))
+ (domain (cadr x)))
+ (if user
+ (concat user "@" domain)
+ domain)))
+
(defun ivy-alt-done (&optional arg)
"Exit the minibuffer with the selected candidate.
When ARG is t, exit with current text, ignoring the candidates."
@@ -231,20 +240,30 @@ When ARG is t, exit with current text, ignoring the
candidates."
(if arg
(ivy-immediate-done)
(let (dir)
- (if (and ivy--directory
- (or
- (and
- (not (string= ivy--current "./"))
- (cl-plusp ivy--length)
- (file-directory-p
- (setq dir (expand-file-name
- ivy--current ivy--directory))))
- (prog1 (string-match ":" ivy-text)
- (setq dir ivy-text))))
- (progn
- (ivy--cd dir)
- (ivy--exhibit))
- (ivy-done)))))
+ (cond ((and ivy--directory
+ (or
+ (and
+ (not (string= ivy--current "./"))
+ (cl-plusp ivy--length)
+ (file-directory-p
+ (setq dir (expand-file-name
+ ivy--current ivy--directory))))))
+ (ivy--cd dir)
+ (ivy--exhibit))
+ ((string-match "\\`/\\([^/]+\\)[:@]\\'" ivy-text)
+ (let ((full-method ivy-text)
+ (method (match-string 1 ivy-text))
+ res)
+ (dolist (x (tramp-get-completion-function method))
+ (setq res (append res (funcall (car x) (cadr x)))))
+ (setq res (delq nil res))
+ (let ((host (ivy-read "Find File: "
+ (mapcar #'ivy-build-tramp-name res))))
+ (when host
+ (setq ivy--directory "/")
+ (ivy--cd (concat full-method host ":"))))))
+ (t
+ (ivy-done))))))
(defun ivy-partial-or-done ()
"Complete the minibuffer text as much as possible.
- [elpa] master 23ffa25 19/31: Bind "TAB" to do partial completion, (continued)
- [elpa] master 23ffa25 19/31: Bind "TAB" to do partial completion, Oleh Krehel, 2015/05/01
- [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 <=
- [elpa] master 5a2e0fd 30/31: Allow for "/ssh:user@" as well as for "/ssh:", Oleh Krehel, 2015/05/01
- [elpa] master 4137447 31/31: Merge commit '5a2e0fd355fea83e3c172402b965a1aa826fcc0c' from swiper, Oleh Krehel, 2015/05/01