Subject: Re: bug#78099: [PATCH] Make 'project-remember-project' interactive

From: Elijah Gabe Pérez <[email-masked]>
Date: Wed, 14 May 2025 18:30:48 -0600

Dmitry Gutov <[email-masked]> writes:

> On 30/04/2025 03:38, Elijah Gabe Pérez wrote:
>>> On 27/04/2025 23:18, Elijah Gabe Pérez wrote:
>>>> +  (interactive)
>>> Something like
>>>
>>>    (interactive (list (project-current t)))
>>>
>>> should allow to keep PR a required argument.
>> Thanks, done:
>
> How about this? Modulo reindentation.
>
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index 27b69277e81..e7ae7d282ab 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1933,12 +1933,18 @@ project-remember-project
>   If project PR satisfies `project-list-exclude', then nothing is done.
>   Save the result in `project-list-file' if the list of projects
>   has changed, and NO-WRITE is nil."
> -  (let ((root (project-root pr)))
> -    (unless (seq-some (lambda (r)
> +  (interactive (list (project-current t)))
> +  (let ((root (project-root pr))
> +        (interact (called-interactively-p 'any)))
> +    (if     (seq-some (lambda (r)
>                           (if (functionp r)
>                               (funcall r pr)
>                             (string-match-p r root)))
>                         project-list-exclude)
> +        (when interact
> +          (message "Current project is blacklisted!"))
> +      (when interact
> +        (message "Current project remembered"))
>         (project--remember-dir root no-write))))
>
>   (defun project--remove-from-project-list (project-root report-message)
>

LGTM, Maybe it is better to also add a message to indicate that the
project is already remembered, this would avoid having to re-remember
the project.

#+begin_src diff
@@ -1992,13 +1992,22 @@ project-remember-project
 If project PR satisfies `project-list-exclude', then nothing is done.
 Save the result in `project-list-file' if the list of projects
 has changed, and NO-WRITE is nil."
-  (let ((root (project-root pr)))
-    (unless (seq-some (lambda (r)
-                        (if (functionp r)
-                            (funcall r pr)
-                          (string-match-p r root)))
-                      project-list-exclude)
-      (project--remember-dir root no-write))))
+  (interactive (list (project-current t)))
+  (let ((root (project-root pr))
+        (interact (called-interactively-p 'any)))
+    (if (and (listp project--list) (assoc root project--list))
+        (when interact
+          (message "This project is already remembered"))
+      (if (seq-some (lambda (r)
+                      (if (functionp r)
+                          (funcall r pr)
+                        (string-match-p r root)))
+                    project-list-exclude)
+          (when interact
+            (message "Current project is blacklisted!"))
+        (when interact
+          (message "Current project remembered"))
+        (project--remember-dir root no-write)))))
 
 (defun project--remove-from-project-list (project-root report-message)
   "Remove directory PROJECT-ROOT of a missing project from the project list.
#+end_src

-- 
                                          - E.G via GNU Emacs and Org.