[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e238286 57/90: "M-n", "M-p", "M-i" should switch directori
From: |
Oleh Krehel |
Subject: |
[elpa] master e238286 57/90: "M-n", "M-p", "M-i" should switch directories when needed |
Date: |
Tue, 30 Jun 2015 07:28:38 +0000 |
branch: master
commit e238286fbfb54a1314e7649c0f801d4a18099735
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
"M-n", "M-p", "M-i" should switch directories when needed
* ivy.el (ivy-previous-history-element):
(ivy-next-history-element):
(ivy-switch-buffer): Call `ivy--cd-maybe'.
(ivy--cd-maybe): New defun. Check if the current input points to a
different directory than `ivy--directory'. If so, `ivy--cd' there.
Fixes #152
---
ivy.el | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/ivy.el b/ivy.el
index b130ec9..ad4fe14 100644
--- a/ivy.el
+++ b/ivy.el
@@ -493,6 +493,7 @@ Call the permanent action if possible."
"Forward to `previous-history-element' with ARG."
(interactive "p")
(previous-history-element arg)
+ (ivy--cd-maybe)
(move-end-of-line 1)
(ivy--maybe-scroll-history))
@@ -500,9 +501,24 @@ Call the permanent action if possible."
"Forward to `next-history-element' with ARG."
(interactive "p")
(next-history-element arg)
+ (ivy--cd-maybe)
(move-end-of-line 1)
(ivy--maybe-scroll-history))
+(defun ivy--cd-maybe ()
+ "Check if the current input points to a different directory.
+If so, move to that directory, while keeping only the file name."
+ (when ivy--directory
+ (let* ((input (expand-file-name (ivy--input)))
+ (file (file-name-nondirectory input))
+ (dir (expand-file-name (file-name-directory input))))
+ (if (string= dir ivy--directory)
+ (progn
+ (delete-minibuffer-contents)
+ (insert file))
+ (ivy--cd dir)
+ (insert file)))))
+
(defun ivy--maybe-scroll-history ()
"If the selected history element has an index, scroll there."
(let ((idx (ignore-errors
@@ -1367,7 +1383,8 @@ BUFFER may be a string or nil."
Don't finish completion."
(interactive)
(delete-minibuffer-contents)
- (insert ivy--current))
+ (insert ivy--current)
+ (ivy--cd-maybe))
(defun ivy-toggle-fuzzy ()
"Toggle the re builder between `ivy--regex-fuzzy' and `ivy--regex-plus'."
- [elpa] master 16fefbc 48/90: ivy-hydra.el (hydra-ivy): Add "C-j" and "C-m" exit points, (continued)
- [elpa] master 16fefbc 48/90: ivy-hydra.el (hydra-ivy): Add "C-j" and "C-m" exit points, Oleh Krehel, 2015/06/30
- [elpa] master 7945ab0 49/90: counsel.el (counsel-M-x): Call smex-rank, Oleh Krehel, 2015/06/30
- [elpa] master 76897c0 46/90: ivy.el (ivy-sort-functions-alist): Work for commands as well, Oleh Krehel, 2015/06/30
- [elpa] master 61bb9e0 50/90: Require TRAMP in time, Oleh Krehel, 2015/06/30
- [elpa] master 9df660c 51/90: swiper.el (swiper-query-replace): Don't miss the first, Oleh Krehel, 2015/06/30
- [elpa] master d47dd9b 52/90: ivy-hydra.el: Improve for hydra not installed, Oleh Krehel, 2015/06/30
- [elpa] master 265f47d 53/90: Swiper should not deactivate-mark, Oleh Krehel, 2015/06/30
- [elpa] master 4cdb80c 54/90: ivy-hydra.el (defhydra): Wrap in eval-when-compile, Oleh Krehel, 2015/06/30
- [elpa] master 1dbdcdc 55/90: counsel.el (counsel-M-x): Fixup, Oleh Krehel, 2015/06/30
- [elpa] master bcc5f45 56/90: counsel.el (counsel-M-x): Fixup smex interaction, Oleh Krehel, 2015/06/30
- [elpa] master e238286 57/90: "M-n", "M-p", "M-i" should switch directories when needed,
Oleh Krehel <=
- [elpa] master 3f41ce6 58/90: Put the file instead of partial input on history, Oleh Krehel, 2015/06/30
- [elpa] master 5e3c635 59/90: Add a set of commands for resizing minibuffer height, Oleh Krehel, 2015/06/30
- [elpa] master 7b91a39 60/90: ivy.el (ivy-kill-line): Add and bind to "C-k", Oleh Krehel, 2015/06/30
- [elpa] master dcf0f64 61/90: Add "^" as initial input to "C-h f" and "C-h v", Oleh Krehel, 2015/06/30
- [elpa] master 1ef7e18 62/90: "M-i" should not switch directories, Oleh Krehel, 2015/06/30
- [elpa] master 46695ac 63/90: Fix non-file completions ability to enter tramp completion, Oleh Krehel, 2015/06/30
- [elpa] master a5e49ff 64/90: Make counsel-M-x respect ivy-format-function, Oleh Krehel, 2015/06/30
- [elpa] master 5fcdfb4 65/90: Add better positioning to counsel-git-grep finalizer, Oleh Krehel, 2015/06/30
- [elpa] master 581d8c0 66/90: Don't cut off "/ssh:foo" input, Oleh Krehel, 2015/06/30
- [elpa] master 513a77e 67/90: ivy.el (ivy-alt-done): Find file if given a full tramp path, Oleh Krehel, 2015/06/30