projectile-discover-projects-in-search-path recursively

Created on 13 Feb 2020  ยท  3Comments  ยท  Source: bbatsov/projectile

I organize my ~/Code folder by language. So it's directory structure might look like...

โ”œโ”€โ”€ browser-extensions
โ”‚ย ย  โ”œโ”€โ”€ My Cool Extension
โ”‚ย ย  โ””โ”€โ”€ My Other Cool Extension
โ”œโ”€โ”€ Jekyll
โ”‚ย ย  โ””โ”€โ”€  Some Website
โ”œโ”€โ”€ python
โ”‚ย ย  โ””โ”€โ”€ Some Python Project

I use this to set my project search path.

(setq projectile-project-search-path '("~/Code"))

Instead of adding each sub-folder to my projectile search path (I have quite a few languages/categories in there), I would love to be able to run projectile-discover-projects-in-search-path and have it go recursively.

Any thoughts?

EDIT

For my unique situation, I came up with a pretty simple solution.

  (setq projectile-project-search-path (cddr (directory-files "~/Code" t)))

(The cddr bit removes the first two items from the returned list which are . and .. directories.)

Could also use the function directory-files-recursively which will catch any projects nested even deeper. :)

Good First Issue Improvement

Most helpful comment

thank you for the workaround.

All 3 comments

thank you for the workaround.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding!

I do this FWIW:

;;;###autoload
(defun mb-cmd-projectile-index-projects ()
  "Index my project directories."
  (interactive)

  (mapc #'projectile-add-known-project
        (mb-f-find-git-projects "~/" 5))

  (projectile-cleanup-known-projects))

(defun mb-f-find-git-projects (dir &optional depth)
  "Find all git projects under DIR.
Optionally only search as deep as DEPTH."
  (let* ((depth-flag (if depth (format "-maxdepth %d" depth) ""))
         (cmd (format "find %s %s -name '.git' -type d" dir depth-flag))
         (result (split-string (shell-command-to-string cmd))))
    (mapcar (lambda (s) (substring s 0 -4)) result)))

;; This is from memory, I have another construct for simplifying keybindings.
(define-key 'projectile-command-map (kbd "i") #'mb-cmd-projectile-index-projects)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

breadncup picture breadncup  ยท  3Comments

nishantvarma picture nishantvarma  ยท  6Comments

bomgar picture bomgar  ยท  4Comments

ghost picture ghost  ยท  4Comments

rrudakov picture rrudakov  ยท  4Comments