Function: project-remember-projects-under
project-remember-projects-under is an interactive and byte-compiled
function defined in project.el.gz.
Signature
(project-remember-projects-under DIR &optional RECURSIVE)
Documentation
Index all projects below a directory DIR.
If RECURSIVE is non-nil, recurse into all subdirectories to find more projects. After finishing, a message is printed summarizing the progress. The function returns the number of detected projects.
Probably introduced at or before Emacs version 28.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/project.el.gz
(defun project-remember-projects-under (dir &optional recursive)
"Index all projects below a directory DIR.
If RECURSIVE is non-nil, recurse into all subdirectories to find
more projects. After finishing, a message is printed summarizing
the progress. The function returns the number of detected
projects."
(interactive "DDirectory: \nP")
(project--ensure-read-project-list)
(let ((queue (directory-files dir t nil t)) (count 0)
(known (make-hash-table
:size (* 2 (length project--list))
:test #'equal )))
(dolist (project (mapcar #'car project--list))
(puthash project t known))
(while queue
(when-let ((subdir (pop queue))
((file-directory-p subdir))
((not (gethash subdir known))))
(when-let (pr (project--find-in-directory subdir))
(project-remember-project pr t)
(message "Found %s..." (project-root pr))
(setq count (1+ count)))
(when (and recursive (file-symlink-p subdir))
(setq queue (nconc (directory-files subdir t nil t) queue))
(puthash subdir t known))))
(unless (eq recursive 'in-progress)
(if (zerop count)
(message "No projects were found")
(project--write-project-list)
(message "%d project%s were found"
count (if (= count 1) "" "s"))))
count))