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

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

[elpa] master fd27465 014/272: counsel.el (counsel-git): Fix window sele


From: Oleh Krehel
Subject: [elpa] master fd27465 014/272: counsel.el (counsel-git): Fix window selection
Date: Mon, 25 Apr 2016 10:13:14 +0000

branch: master
commit fd27465819b085290ca172cc3ac11401dd082d80
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-git): Fix window selection
    
    * counsel.el (counsel--git-dir): New defvar.
    (counsel-git): Update.
    (counsel-git-action): New defun. Use `with-ivy-window', so that each new
    file chosen with e.g. "C-M-n" is selected in the same window.
---
 counsel.el |   21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/counsel.el b/counsel.el
index 062d95c..69b43a7 100644
--- a/counsel.el
+++ b/counsel.el
@@ -331,22 +331,29 @@
       #'cl-caddr
       (cider-sync-request:complete str ":same")))))
 
+(defvar counsel--git-dir nil
+  "Store the base git directory.")
+
 ;;;###autoload
 (defun counsel-git ()
   "Find file in the current Git repository."
   (interactive)
-  (let* ((default-directory (locate-dominating-file
-                             default-directory ".git"))
+  (setq counsel--git-dir (expand-file-name
+                          (locate-dominating-file
+                           default-directory ".git")))
+  (let* ((default-directory counsel--git-dir)
          (cands (split-string
                  (shell-command-to-string
                   "git ls-files --full-name --")
                  "\n"
-                 t))
-         (action `(lambda (x)
-                    (let ((default-directory ,default-directory))
-                      (find-file x)))))
+                 t)))
     (ivy-read "Find file: " cands
-              :action action)))
+              :action #'counsel-git-action)))
+
+(defun counsel-git-action (x)
+  (with-ivy-window
+    (let ((default-directory counsel--git-dir))
+      (find-file x))))
 
 (defvar counsel--git-grep-dir nil
   "Store the base git directory.")



reply via email to

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