[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master d45ee54 258/272: Make the slash more magic during file nam
From: |
Oleh Krehel |
Subject: |
[elpa] master d45ee54 258/272: Make the slash more magic during file name completion |
Date: |
Mon, 25 Apr 2016 10:13:29 +0000 |
branch: master
commit d45ee5459a72a664f29ab554d54e7861360d46e9
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Make the slash more magic during file name completion
* ivy.el (ivy--magic-file-slash): Extract from `ivy--exhibit'.
(ivy--exhibit): Update.
Update to the behavior: the slash ("/") will enter a directory even if
its name isn't completely typed out if either:
1. It's the only candidate.
2. The candidate index isn't 0, i.e. "C-n" has been typed at least once.
3. The input isn't "/".
The above rules still allow to keep the old behavior with "//" moving to
root and "/ssh:" opening tramp.
This is an experimental feature, please report if it breaks someone's
workflow.
Re #321.
---
ivy.el | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/ivy.el b/ivy.el
index e3e05b7..e07fa53 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1944,6 +1944,25 @@ depending on the number of candidates."
(cl-sort (copy-sequence collection) sort-fn)
collection)))))
+(defun ivy--magic-file-slash ()
+ (cond ((member ivy-text ivy--all-candidates)
+ (ivy--cd (expand-file-name ivy-text ivy--directory)))
+ ((string-match "//\\'" ivy-text)
+ (if (and default-directory
+ (string-match "\\`[[:alpha:]]:/" default-directory))
+ (ivy--cd (match-string 0 default-directory))
+ (ivy--cd "/")))
+ ((string-match "[[:alpha:]]:/\\'" ivy-text)
+ (let ((drive-root (match-string 0 ivy-text)))
+ (when (file-exists-p drive-root)
+ (ivy--cd drive-root))))
+ ((and (or (> ivy--index 0)
+ (= ivy--length 1)
+ (not (string= ivy-text "/")))
+ (let ((default-directory ivy--directory))
+ (file-directory-p ivy--current)))
+ (ivy--cd (expand-file-name ivy--current ivy--directory)))))
+
(defun ivy--exhibit ()
"Insert Ivy completions display.
Should be run via minibuffer `post-command-hook'."
@@ -1966,17 +1985,7 @@ Should be run via minibuffer `post-command-hook'."
(ivy--format ivy--all-candidates))))
(cond (ivy--directory
(if (string-match "/\\'" ivy-text)
- (if (member ivy-text ivy--all-candidates)
- (ivy--cd (expand-file-name ivy-text ivy--directory))
- (when (string-match "//\\'" ivy-text)
- (if (and default-directory
- (string-match "\\`[[:alpha:]]:/"
default-directory))
- (ivy--cd (match-string 0 default-directory))
- (ivy--cd "/")))
- (when (string-match "[[:alpha:]]:/$" ivy-text)
- (let ((drive-root (match-string 0 ivy-text)))
- (when (file-exists-p drive-root)
- (ivy--cd drive-root)))))
+ (ivy--magic-file-slash)
(if (string-match "\\`~\\'" ivy-text)
(ivy--cd (expand-file-name "~/")))))
((eq (ivy-state-collection ivy-last) 'internal-complete-buffer)
- [elpa] master c4b9e25 249/272: Add much faster scrolling to counsel-grep, (continued)
- [elpa] master c4b9e25 249/272: Add much faster scrolling to counsel-grep, Oleh Krehel, 2016/04/25
- [elpa] master 7f6d39f 193/272: counsel.el (counsel-linux-app-action-file): New action on "M-o f", Oleh Krehel, 2016/04/25
- [elpa] master ac4bedf 175/272: counsel.el (counsel-find-file): Bind "M-o f" to find-file-other-window, Oleh Krehel, 2016/04/25
- [elpa] master 41e2e41 246/272: Clean-up previous change, Oleh Krehel, 2016/04/25
- [elpa] master 90a09fa 086/272: doc/ivy.org: CUSTOM_ID should not end in "?", Oleh Krehel, 2016/04/25
- [elpa] master 6254e88 244/272: Allow a sexp node in ivy-views, Oleh Krehel, 2016/04/25
- [elpa] master e224847 179/272: ivy.el (ivy--reset-state): Fix prompt / require-match issue, Oleh Krehel, 2016/04/25
- [elpa] master 5229ebe 173/272: counsel.el (counsel-prompt-function-dir): Fix format, Oleh Krehel, 2016/04/25
- [elpa] master 8de2930 221/272: ivy.el: Improve "M-n", Oleh Krehel, 2016/04/25
- [elpa] master 6823518 196/272: swiper.el (swiper--candidates): Always remove '(field), Oleh Krehel, 2016/04/25
- [elpa] master d45ee54 258/272: Make the slash more magic during file name completion,
Oleh Krehel <=
- [elpa] master ea79f0e 135/272: New API function ivy-set-display-transformer, Oleh Krehel, 2016/04/25
- [elpa] master b2d2b82 209/272: counsel.el (counsel-grep-action): Improve cleanup, Oleh Krehel, 2016/04/25
- [elpa] master 8c4f595 233/272: Fix remapping commit c9b6e0, Oleh Krehel, 2016/04/25
- [elpa] master 6fae6e0 259/272: counsel.el (counsel-grep-or-swiper): Use swiper when narrowed, Oleh Krehel, 2016/04/25
- [elpa] master 1b4e819 218/272: ivy.el (ivy-next-history-element): Simplify, Oleh Krehel, 2016/04/25
- [elpa] master b5a9dc5 255/272: ivy.el (ivy--reset-state): file-directory-p needs a string, Oleh Krehel, 2016/04/25
- [elpa] master 6fc36b5 210/272: option to add newline after ivy-read prompt, Oleh Krehel, 2016/04/25
- [elpa] master 9899547 235/272: ivy.el (ivy-action): New face, Oleh Krehel, 2016/04/25
- [elpa] master 63b96a1 250/272: Fix counsel-grep-last-line bug, Oleh Krehel, 2016/04/25
- [elpa] master a891df3 264/272: swiper.el (swiper--multi-candidates): Add check, Oleh Krehel, 2016/04/25