1

Add custom fn to find project.el project roots

This commit is contained in:
Jessie Hildebrandt 2022-06-27 00:36:53 -04:00
parent 221343d166
commit f158054a15

17
init.el
View File

@ -375,6 +375,23 @@
(delete-directory package-user-dir t) (delete-directory package-user-dir t)
(init-file/byte-compile-init-file))) (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. ;; Make sure that this init file is byte-compiled whenever it changes.
(if (file-newer-than-file-p (if (file-newer-than-file-p
(concat user-emacs-directory "init.el") (concat user-emacs-directory "init.el")