Subject: [PATCH] Make 'project-remember-project' interactive

From: Elijah Gabe Pérez <[email-masked]>
Date: Sun, 27 Apr 2025 14:18:12 -0600

Tags: patch

Sometimes when creating a new project it is not added to project list.
AFAIK the only way to do it is using `project-remember-projects-under'
or `project-switch-project' but they are uncomfortable to use when you
just want to remember the current project you're in.

So I decided to make `project-remember-project' interactive in this
patch for archive this; this let to users use it in hooks (e.g
find-file-hook)

>From 717982c87ea0e65d8ab7c1df1ec6fa38558d08de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= <[email-masked]>
Date: Sun, 27 Apr 2025 13:44:39 -0600
Subject: [PATCH] Make 'project-remember-project' interactive

* lisp/progmodes/project.el (project-remember-project): Tweak.
---
 lisp/progmodes/project.el | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 1a8bba67124..dd0797da1e0 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1987,18 +1987,26 @@ project--remember-dir
         (project--write-project-list)))))
 
 ;;;###autoload
-(defun project-remember-project (pr &optional no-write)
-  "Add project PR to the front of the project list.
+(defun project-remember-project (&optional pr no-write)
+  "Add project PR or current project to the front of the project list.
 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)
+  (if-let* ((pr (or pr (project-current)))
+            (interac (called-interactively-p 'any))
+            (root (project-root pr)))
+      (if (not (seq-some (lambda (r)
+                           (if (functionp r)
+                               (funcall r pr)
+                             (string-match-p r root)))
+                         project-list-exclude))
+          (progn
+            (project--remember-dir root no-write)
+            (when interac (message "Current project remember")))
+        (when interac (message "Current project is blacklisted")))
+    (when (called-interactively-p 'any)
+      (user-error "No project at point"))))
 
 (defun project--remove-from-project-list (project-root report-message)
   "Remove directory PROJECT-ROOT of a missing project from the project list.
-- 
2.49.0

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