Function: project-forget-projects-under

project-forget-projects-under is an interactive and byte-compiled function defined in project.el.gz.

Signature

(project-forget-projects-under DIR &optional RECURSIVE)

Documentation

Forget all known projects below a directory DIR.

If RECURSIVE is non-nil, recurse into all subdirectories to remove all known projects. After finishing, a message is printed summarizing the progress. The function returns the number of forgotten 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-forget-projects-under (dir &optional recursive)
  "Forget all known projects below a directory DIR.
If RECURSIVE is non-nil, recurse into all subdirectories to
remove all known projects.  After finishing, a message is printed
summarizing the progress.  The function returns the number of
forgotten projects."
  (interactive "DDirectory: \nP")
  (let ((count 0))
    (if recursive
        (dolist (proj (project-known-project-roots))
          (when (file-in-directory-p proj dir)
            (project-forget-project proj)
            (setq count (1+ count))))
      (dolist (proj (project-known-project-roots))
        (when (file-equal-p (file-name-directory proj) dir)
          (project-forget-project proj)
          (setq count (1+ count)))))
    (if (zerop count)
        (message "No projects were forgotten")
      (project--write-project-list)
      (message "%d project%s were forgotten"
               count (if (= count 1) "" "s")))
    count))