Subject: bug#77566: [PATCH] Add option for automatically delete non-existent projects.

From: Elijah Gabe Pérez <[email-masked]>
Date: Mon, 7 Apr 2025 19:34:12 -0600

Dmitry Gutov <[email-masked]> writes:

> On 07/04/2025 03:39, Elijah Gabe Pérez wrote:
> > +(defcustom project-prune-zombie-projects nil
> > +  "Automatically remove from project list projects that were deleted.
> > +If set to `all', remove projects when project list file
> > +is being read or written.
> > +If set to `list-read', only remove projects when project list file
> > +is being read.
> > +If set to `list-write', only remove projects when project list file is
> > +being written.
>
> That's a lot of alternatives. Do we have a picture of the users who
> would use each of the values?
>

AFAIK, no, I would honestly prefer just a booelan, this can be confused.

And speaking of remote projects, maybe we should add a prefix argument
> to project-forget-zombie-projects instead of an option.
>

The patch already provides this, should the option be removed?:

@@ -2117,12 +2148,17 @@ project-remember-projects-under
                          count) count))
     count))

-(defun project-forget-zombie-projects ()
-  "Forget all known projects that don't exist any more."
-  (interactive)
+(defun project-forget-zombie-projects (&optional no-remote no-message)
+  "Forget all known projects that don't exist any more.
+If NO-REMOTE is non-nil, don't forget remote projects.
+If NO-MESSAGE is non-nil, don't display a message about projects removed."
+  (interactive "P")
   (dolist (proj (project-known-project-roots))
-    (unless (file-exists-p proj)
-      (project-forget-project proj))))
+    (unless (or (and no-remote (file-exists-p proj) (not (file-remote-p
proj)))
+                (and project-dont-prune-remote-zombie-projects
+                     (file-exists-p proj) (not (file-remote-p proj)))
+                (file-exists-p proj))
+      (project-forget-project proj no-message))))