GNU bug report logs - #78099
[PATCH] Make 'project-remember-project' interactive

Previous Next

Package: emacs;

Reported by: Elijah Gabe Pérez <eg642616 <at> gmail.com>

Date: Sun, 27 Apr 2025 20:19:02 UTC

Severity: normal

Tags: patch

Fixed in version 31.1

Done: Dmitry Gutov <dmitry <at> gutov.dev>

Full log


Message #35 received at 78099 <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: Dmitry Gutov <dmitry <at> gutov.dev>
Cc: 78099 <at> debbugs.gnu.org
Subject: Re: bug#78099: [PATCH] Make 'project-remember-project' interactive
Date: Wed, 14 May 2025 18:30:48 -0600
Dmitry Gutov <dmitry <at> gutov.dev> 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.




This bug report was last modified 20 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.