branch: master
commit 345d95567560d841938267658116f111ca5ce75b
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>

    counsel.el (counsel-fzf-dir-function): Allow to customize
    
    `projectile-project-root' often ends up returning my home dir, which is too 
big
    for fzf.
---
 counsel.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/counsel.el b/counsel.el
index 270cc00..6159021 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1907,6 +1907,17 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
 (defvar counsel--fzf-dir nil
   "Store the base fzf directory.")
 
+(defvar counsel-fzf-dir-function 'counsel-fzf-dir-function-projectile
+  "Function that returns a directory for fzf to use.")
+
+(defun counsel-fzf-dir-function-projectile ()
+  (if (and
+       (fboundp 'projectile-project-p)
+       (fboundp 'projectile-project-root)
+       (projectile-project-p))
+      (projectile-project-root)
+    default-directory))
+
 (defun counsel-fzf-function (str)
   (let ((default-directory counsel--fzf-dir))
     (counsel--async-command
@@ -1924,13 +1935,7 @@ INITIAL-INPUT can be given as the initial minibuffer 
input."
 INITIAL-INPUT can be given as the initial minibuffer input."
   (interactive)
   (counsel-require-program (car (split-string counsel-fzf-cmd)))
-  (setq counsel--fzf-dir
-        (if (and
-             (fboundp 'projectile-project-p)
-             (fboundp 'projectile-project-root)
-             (projectile-project-p))
-            (projectile-project-root)
-          default-directory))
+  (setq counsel--fzf-dir (funcall counsel-fzf-dir-function))
   (ivy-read "> " #'counsel-fzf-function
             :initial-input initial-input
             :re-builder #'ivy--regex-fuzzy

Reply via email to