emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 66e00ed 034/272: counsel: Add counsel-up-directory to find


From: Oleh Krehel
Subject: [elpa] master 66e00ed 034/272: counsel: Add counsel-up-directory to find-file-map
Date: Mon, 25 Apr 2016 10:13:15 +0000

branch: master
commit 66e00eda6cf0d89280194bd5017392b0fa9b1fd7
Author: justbur <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel: Add counsel-up-directory to find-file-map
    
    New function that moves up to the parent directory and at the same time
    preselects the current directory. This is useful for moving up and down
    a file tree quickly.
    
    Fixes #343
---
 counsel.el |   15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/counsel.el b/counsel.el
index 4a734d4..6a97b70 100644
--- a/counsel.el
+++ b/counsel.el
@@ -457,7 +457,20 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
 
 (declare-function ffap-guesser "ffap")
 
-(defvar counsel-find-file-map (make-sparse-keymap))
+(defvar counsel-find-file-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-DEL") 'counsel-up-directory)
+    (define-key map (kbd "C-<backspace>") 'counsel-up-directory)
+    map))
+
+(defun counsel-up-directory ()
+  "Go to the parent directory preselecting the current one."
+  (interactive)
+  (let ((dir-file-name
+         (directory-file-name (expand-file-name ivy--directory))))
+    (ivy--cd (file-name-directory dir-file-name))
+    (setf (ivy-state-preselect ivy-last)
+          (file-name-as-directory (file-name-nondirectory dir-file-name)))))
 
 ;;;###autoload
 (defun counsel-find-file (&optional initial-input)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]