From f158054a1572210d10976d0f7ded9ee334b6d3d7 Mon Sep 17 00:00:00 2001 From: Jessie Hildebrandt Date: Mon, 27 Jun 2022 00:36:53 -0400 Subject: [PATCH] Add custom fn to find project.el project roots --- init.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/init.el b/init.el index f371ebb..881ef0d 100644 --- a/init.el +++ b/init.el @@ -375,6 +375,23 @@ (delete-directory package-user-dir t) (init-file/byte-compile-init-file))) +(defun init-file/project-find-projects () + "Prompt for a directory and then search for any project roots within." + (interactive) + (when-let* ((valid-root-p (lambda (path) + (and (file-accessible-directory-p path) + (not (string= (file-name-nondirectory path) ".git"))))) + (directory (read-directory-name "Look for projects in: ")) + (project-list (mapcar 'file-name-directory (directory-files-recursively directory "\\.git$" 'valid-root-p t ))) + (num-projects-found (length project-list)) + (temp-buffer-name (concat "*" (number-to-string num-projects-found) " Project Roots Found*")) + (temp-buffer (with-output-to-temp-buffer temp-buffer-name (progn (princ (mapconcat 'identity project-list "\n")) + standard-output)))) + (when (yes-or-no-p "Index all of these directories as projects? ") + (mapc 'project-remember-projects-under project-list) + (message "%d%s" num-projects-found " directories indexed as projects.")) + (kill-buffer temp-buffer))) + ;; Make sure that this init file is byte-compiled whenever it changes. (if (file-newer-than-file-p (concat user-emacs-directory "init.el")