From c878314aa6086b044fb715db41e41ec24834bc25 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 4 Aug 2018 02:28:45 +0200 Subject: [PATCH] Refactor +ivy/projectile-find-file to use counsel counsel-projectile-find-file has other capabilities (like actions and sorting). So we conditionally use projectile-find-file only if the project is large enough to warrant it. --- modules/completion/ivy/autoload/ivy.el | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/completion/ivy/autoload/ivy.el b/modules/completion/ivy/autoload/ivy.el index 5d666cdac..da1c8a4de 100644 --- a/modules/completion/ivy/autoload/ivy.el +++ b/modules/completion/ivy/autoload/ivy.el @@ -210,20 +210,25 @@ search current file. See `+ivy-task-tags' to customize what this searches for." ;;;###autoload (defun +ivy/projectile-find-file () - "A more sensible `projectile-find-file', which will revert to -`counsel-find-file' if invoked from $HOME (usually not what you want), or -`counsel-file-jump' if invoked from a non-project. + "A more sensible `counsel-projectile-find-file', which will revert to +`counsel-find-file' if invoked from $HOME, `counsel-file-jump' if invoked from a +non-project, `projectile-find-file' if in a bug project (more than +`ivy-sort-max-size' files), or `counsel-projectile-find-file' otherwise. -Both are much faster than letting `projectile-find-file' index massive file -trees." +The point of this is to avoid Emacs locking up indexing massive file trees." (interactive) (call-interactively (cond ((or (file-equal-p default-directory "~") (when-let* ((proot (doom-project-root 'nocache))) (file-equal-p proot "~"))) #'counsel-find-file) + ((doom-project-p 'nocache) - #'projectile-find-file) + (let ((files (projectile-current-project-files))) + (if (<= (length files) ivy-sort-max-size) + #'counsel-projectile-find-file + #'projectile-find-file))) + (#'counsel-file-jump)))) ;;;###autoload