aboutsummaryrefslogtreecommitdiff
path: root/projectile.el
diff options
context:
space:
mode:
authorMohsin Kaleem <mohkale@kisara.moe>2021-07-12 19:36:10 +0100
committerBozhidar Batsov <bozhidar@batsov.dev>2021-08-10 11:55:45 +0300
commit1c9d1191362842b53c26bfce199293c00584759b (patch)
tree678b03997a4b078ec9c68f8572f799093864ac61 /projectile.el
parent931c9d0c18fde1bcf5ec8fe9633a736e07533850 (diff)
Allow recursive project searches to add a directory explicitly
See #1500. Now you can add a directory DIR to `projectile-project-search-path` with depth 0 to mean that if DIR is a project then add it to projectiles project list.
Diffstat (limited to 'projectile.el')
-rw-r--r--projectile.el22
1 files changed, 11 insertions, 11 deletions
diff --git a/projectile.el b/projectile.el
index 38afe26..125c17c 100644
--- a/projectile.el
+++ b/projectile.el
@@ -637,7 +637,8 @@ Examples of such paths might be ~/projects, ~/work, (~/github . 1) etc.
For elements of form (DIRECTORY . DEPTH), DIRECTORY has to be a
directory and DEPTH an integer that specifies the depth at which to
-look for projects."
+look for projects. A DEPTH of 0 means check DIRECTORY. A depth of 1
+means check all the subdirectories of DIRECTORY. Etc."
:group 'projectile
:type '(repeat (choice directory (cons directory (integer :tag "Depth"))))
:package-version '(projectile . "1.0.0"))
@@ -1031,15 +1032,14 @@ The cache is created both in memory and on the hard drive."
If DEPTH is non-nil recursively descend exactly DEPTH levels below DIRECTORY and
discover projects there."
- (if (file-exists-p directory)
- (let ((subdirs (directory-files directory t)))
- (dolist (dir subdirs)
- (when (and (file-directory-p dir)
- (not (member (file-name-nondirectory dir) '(".." "."))))
- (if (and (numberp depth) (> depth 0))
- (projectile-discover-projects-in-directory dir (1- depth))
- (when (projectile-project-p dir)
- (projectile-add-known-project dir))))))
+ (if (file-directory-p directory)
+ (if (and (numberp depth) (> depth 0))
+ (dolist (dir (directory-files directory t))
+ (when (and (file-directory-p dir)
+ (not (member (file-name-nondirectory dir) '(".." "."))))
+ (projectile-discover-projects-in-directory dir (1- depth))))
+ (when (projectile-project-p directory)
+ (projectile-add-known-project directory)))
(message "Project search path directory %s doesn't exist" directory)))
;;;###autoload
@@ -1050,7 +1050,7 @@ Invoked automatically when `projectile-mode' is enabled."
(dolist (path projectile-project-search-path)
(if (consp path)
(projectile-discover-projects-in-directory (car path) (cdr path))
- (projectile-discover-projects-in-directory path 0))))
+ (projectile-discover-projects-in-directory path 1))))
(defun delete-file-projectile-remove-from-cache (filename &optional _trash)