(unless (file-exists-p proj)
(project-forget-project proj))))
+(defun project-read-ancestor-directory (prompt)
+ "Prompt with PROMPT for an ancestor directory of one or more project roots."
+ (project--ensure-read-project-list)
+ (read-directory-name
+ prompt nil nil nil nil
+ (let ((ps (mapcar (lambda (p) (expand-file-name (car p))) project--list)))
+ (lambda (dir)
+ (catch 'ball
+ (dolist (p ps)
+ (when (string-prefix-p (expand-file-name dir) p)
+ (throw 'ball t))))))))
+
(defun project-forget-projects-under (dir &optional recursive)
"Forget all known projects below a directory DIR.
Interactively, prompt for DIR.
to remove those projects from the index.
Display a message at the end summarizing what was forgotten.
Return the number of forgotten projects."
- (interactive "DDirectory: \nP")
+ (interactive
+ (list (project-read-ancestor-directory "Forget projects under directory: ")
+ current-prefix-arg))
(let ((count 0))
(if recursive
(dolist (proj (project-known-project-roots))
(project--write-project-list)
(message (ngettext "%d project was forgotten"
"%d projects were forgotten"
- count) count))
+ count)
+ count))
count))
+(put 'project-forget-projects-under 'minibuffer-action
+ ;; TODO: Respect prefix arg.
+ ;; TODO: Update completion predicate for live feedback.
+ "forget")
+
\f
;;; Project switching