[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 0c62f7e 132/167: ivy.el (ivy-alt-done): Split into smaller
From: |
Oleh Krehel |
Subject: |
[elpa] master 0c62f7e 132/167: ivy.el (ivy-alt-done): Split into smaller defuns |
Date: |
Tue, 08 Dec 2015 10:50:31 +0000 |
branch: master
commit 0c62f7e1c1d61c2fb172d1fdded66307288b714b
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy-alt-done): Split into smaller defuns
* ivy.el (ivy--directory-done): New defun.
(ivy-alt-done): Forward to `ivy--directory-done'.
---
ivy.el | 158 +++++++++++++++++++++++++++++++------------------------------
swiper.el | 2 +
2 files changed, 83 insertions(+), 77 deletions(-)
diff --git a/ivy.el b/ivy.el
index f70c54f..9eafaa6 100644
--- a/ivy.el
+++ b/ivy.el
@@ -390,84 +390,88 @@ Is is a cons cell, related to
`tramp-get-completion-function'."
"Exit the minibuffer with the selected candidate.
When ARG is t, exit with current text, ignoring the candidates."
(interactive "P")
+ (cond (arg
+ (ivy-immediate-done))
+ (ivy--directory
+ (ivy--directory-done))
+ ((eq (ivy-state-collection ivy-last) 'Info-read-node-name-1)
+ (if (or (equal ivy--current "(./)")
+ (equal ivy--current "(../)"))
+ (ivy-quit-and-run
+ (ivy-read "Go to file: " 'read-file-name-internal
+ :action (lambda (x)
+ (Info-find-node
+ (expand-file-name x ivy--directory)
+ "Top"))))
+ (ivy-done)))
+ (t
+ (ivy-done))))
+
+(defun ivy--directory-done ()
+ "Handle exit from the minibuffer when completing file names."
(let (dir)
- (cond (arg
- (ivy-immediate-done))
- (ivy--directory
- (cond
- ((equal ivy-text "/sudo::")
- (setq dir (concat ivy-text ivy--directory))
- (ivy--cd dir)
- (ivy--exhibit))
- ((or
- (and
- (not (equal ivy-text ""))
- (ignore-errors
- (file-directory-p
- (setq dir
- (file-name-as-directory
- (expand-file-name
- ivy-text ivy--directory))))))
- (and
- (not (string= ivy--current "./"))
- (cl-plusp ivy--length)
- (ignore-errors
- (file-directory-p
- (setq dir (file-name-as-directory
- (expand-file-name
- ivy--current ivy--directory)))))))
- (ivy--cd dir)
- (ivy--exhibit))
- ((or (and (equal ivy--directory "/")
- (string-match "\\`[^/]+:.*:.*\\'" ivy-text))
- (string-match "\\`/[^/]+:.*:.*\\'" ivy-text))
- (ivy-done))
- ((or (and (equal ivy--directory "/")
- (cond ((string-match
- "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
- ivy-text))
- ((string-match
- "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
- ivy--current)
- (setq ivy-text ivy--current))))
- (string-match
- "\\`/\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
- ivy-text))
- (let ((method (match-string 1 ivy-text))
- (user (match-string 2 ivy-text))
- (rest (match-string 3 ivy-text))
- res)
- (require 'tramp)
- (dolist (x (tramp-get-completion-function method))
- (setq res (append res (funcall (car x) (cadr x)))))
- (setq res (delq nil res))
- (when user
- (dolist (x res)
- (setcar x user)))
- (setq res (cl-delete-duplicates res :test #'equal))
- (let* ((old-ivy-last ivy-last)
- (enable-recursive-minibuffers t)
- (host (ivy-read "Find File: "
- (mapcar #'ivy-build-tramp-name res)
- :initial-input rest)))
- (setq ivy-last old-ivy-last)
- (when host
- (setq ivy--directory "/")
- (ivy--cd (concat "/" method ":" host ":"))))))
- (t
- (ivy-done))))
- ((eq (ivy-state-collection ivy-last) 'Info-read-node-name-1)
- (if (or (equal ivy--current "(./)")
- (equal ivy--current "(../)"))
- (ivy-quit-and-run
- (ivy-read "Go to file: " 'read-file-name-internal
- :action (lambda (x)
- (Info-find-node
- (expand-file-name x ivy--directory)
- "Top"))))
- (ivy-done)))
- (t
- (ivy-done)))))
+ (cond
+ ((equal ivy-text "/sudo::")
+ (setq dir (concat ivy-text ivy--directory))
+ (ivy--cd dir)
+ (ivy--exhibit))
+ ((or
+ (and
+ (not (equal ivy-text ""))
+ (ignore-errors
+ (file-directory-p
+ (setq dir
+ (file-name-as-directory
+ (expand-file-name
+ ivy-text ivy--directory))))))
+ (and
+ (not (string= ivy--current "./"))
+ (cl-plusp ivy--length)
+ (ignore-errors
+ (file-directory-p
+ (setq dir (file-name-as-directory
+ (expand-file-name
+ ivy--current ivy--directory)))))))
+ (ivy--cd dir)
+ (ivy--exhibit))
+ ((or (and (equal ivy--directory "/")
+ (string-match "\\`[^/]+:.*:.*\\'" ivy-text))
+ (string-match "\\`/[^/]+:.*:.*\\'" ivy-text))
+ (ivy-done))
+ ((or (and (equal ivy--directory "/")
+ (cond ((string-match
+ "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
+ ivy-text))
+ ((string-match
+ "\\`\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
+ ivy--current)
+ (setq ivy-text ivy--current))))
+ (string-match
+ "\\`/\\([^/]+?\\):\\(?:\\(.*\\)@\\)?\\(.*\\)\\'"
+ ivy-text))
+ (let ((method (match-string 1 ivy-text))
+ (user (match-string 2 ivy-text))
+ (rest (match-string 3 ivy-text))
+ res)
+ (require 'tramp)
+ (dolist (x (tramp-get-completion-function method))
+ (setq res (append res (funcall (car x) (cadr x)))))
+ (setq res (delq nil res))
+ (when user
+ (dolist (x res)
+ (setcar x user)))
+ (setq res (cl-delete-duplicates res :test #'equal))
+ (let* ((old-ivy-last ivy-last)
+ (enable-recursive-minibuffers t)
+ (host (ivy-read "Find File: "
+ (mapcar #'ivy-build-tramp-name res)
+ :initial-input rest)))
+ (setq ivy-last old-ivy-last)
+ (when host
+ (setq ivy--directory "/")
+ (ivy--cd (concat "/" method ":" host ":"))))))
+ (t
+ (ivy-done)))))
(defcustom ivy-tab-space nil
"When non-nil, `ivy-partial-or-done' should insert a space."
diff --git a/swiper.el b/swiper.el
index b504f19..68f6e32 100644
--- a/swiper.el
+++ b/swiper.el
@@ -241,6 +241,8 @@
(defvar swiper-use-visual-line nil
"When non-nil, use `line-move' instead of `forward-line'.")
+(declare-function outline-show-all "outline")
+
(defun swiper--candidates (&optional numbers-width)
"Return a list of this buffer lines.
- [elpa] master 39e6733 129/167: Improve ivy TRAMP support, (continued)
- [elpa] master 39e6733 129/167: Improve ivy TRAMP support, Oleh Krehel, 2015/12/08
- [elpa] master 63e714c 130/167: Allow access to TRAMP from "// C-j", Oleh Krehel, 2015/12/08
- [elpa] master 85bd44b 125/167: swiper.el: Modify the behavior with org-mode and visual-line-mode, Oleh Krehel, 2015/12/08
- [elpa] master 8fdf210 127/167: Switch to using ivy-exit-with-action, Oleh Krehel, 2015/12/08
- [elpa] master ce6ab7a 135/167: Perform string-match in the original buffer, Oleh Krehel, 2015/12/08
- [elpa] master bc00eaf 137/167: Fix `counsel-ag` on Windows, Oleh Krehel, 2015/12/08
- [elpa] master ed2367b 134/167: swiper.el (swiper--candidates): Require outline, Oleh Krehel, 2015/12/08
- [elpa] master 80d4dde 141/167: Fix broken candidate index in ivy-resume, Oleh Krehel, 2015/12/08
- [elpa] master d9ecd2e 133/167: Fix the preselect for (swiper "one"), Oleh Krehel, 2015/12/08
- [elpa] master 073b071 115/167: Allow to sort files by last modification time., Oleh Krehel, 2015/12/08
- [elpa] master 0c62f7e 132/167: ivy.el (ivy-alt-done): Split into smaller defuns,
Oleh Krehel <=
- [elpa] master 59df2e9 131/167: ivy.el (ivy-alt-done): Refactor, Oleh Krehel, 2015/12/08
- [elpa] master 2bec99d 146/167: Ease production of functions like ivy-format-function-default, Oleh Krehel, 2015/12/08
- [elpa] master c546ae4 150/167: Enable recursive swiper calls, Oleh Krehel, 2015/12/08
- [elpa] master 1bf4ae2 140/167: Warn the user about the behavior of ivy--regex-ignore-order, Oleh Krehel, 2015/12/08
- [elpa] master 99d214d 142/167: Ivy-resume should restore the buffer for swiper, Oleh Krehel, 2015/12/08
- [elpa] master 8abed59 143/167: Add counsel-grep, Oleh Krehel, 2015/12/08
- [elpa] master 3b67044 145/167: Convert ivy formatting functions to dotted pairs., Oleh Krehel, 2015/12/08
- [elpa] master ac09f6b 152/167: Fix the issue caused by recursive swiper calls, Oleh Krehel, 2015/12/08
- [elpa] master a34e532 155/167: swiper.el: Use show-all if outline-show-all isn't there, Oleh Krehel, 2015/12/08
- [elpa] master b57c57d 153/167: Fix the preselect for (swiper "one") again, Oleh Krehel, 2015/12/08