unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#63870: 29.0.90; project.el can't dynamically populate the project list
@ 2023-06-03 11:55 Spencer Baugh
  2023-06-15 19:30 ` Spencer Baugh
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Spencer Baugh @ 2023-06-03 11:55 UTC (permalink / raw)
  To: 63870



project.el wants a list of known projects, for project-switch-project
and prompting in project-current.

Currently this list is maintained in two ways:
- automatically, by remembering any project the user runs project
  commands within
- manually by the user with project-remember-project and other functions

In both cases, this list is persisted so that it stays around through
Emacs restarts.  All this is good.

But, I often clone new repositories outside of Emacs, and I also have
scripts outside Emacs which make new clones automatically.  It would be
nice for project.el to know about those clones, so I can switch to them
with project-switch-project right away.  Instead, today I usually
manually navigate to those projects the first time, and I'm only able to
use project-switch-project on subsequent times.

These new repos are created in relatively predictable places, so I can
write code which discovers them all.  But I don't have a way to tell
project.el about them.

I could run code on a timer to project-remember-project these projects,
since I create them in predictable locations.  But that would mean
there's a delay between cloning the repo and being able to use it with
project-switch-project, which is annoying especially when I manually
cloned the repo and want to use it immediately.

The new projects are created while Emacs is running, so just remembering
them all at startup doesn't work either.

I'd like a customization point where I can supply a function (or list of
functions) which project-known-project-roots should run to produce an
additional list of project root directories, which should then be
appended to project--list.

I don't need project.el to specifically remember these projects; they'll
be remembered automatically as users use them, and completing-read will
nicely deduplicate the project roots anyway.

Does that seem reasonable?  It would be something like this:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 04c67710d71..cc05cf460ef 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1679,11 +1679,21 @@ project-prompt-project-name
       (let ((proj (assoc pr-name choices)))
         (if (stringp proj) proj (project-root (cdr proj)))))))
 
+(defcustom project-dynamic-roots '()
+  "List of functions to call to dynamically find projects.
+
+Each is called with no arguments and should return a list of
+project root dirs."
+  :type '(repeat function)
+  :group 'project
+  :version "30.1")
+
 ;;;###autoload
 (defun project-known-project-roots ()
   "Return the list of root directories of all known projects."
   (project--ensure-read-project-list)
-  (mapcar #'car project--list))
+  (flatten-tree (cons (mapcar #'car project--list)
+                      (mapcar #'funcall project-dynamic-roots))))
 
 ;;;###autoload
 (defun project-execute-extended-command ()





^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-07-27  1:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-03 11:55 bug#63870: 29.0.90; project.el can't dynamically populate the project list Spencer Baugh
2023-06-15 19:30 ` Spencer Baugh
2023-06-16  5:45   ` Eli Zaretskii
2023-06-17  2:55 ` Dmitry Gutov
2023-06-27 19:29   ` Spencer Baugh
2023-06-27 19:27 ` Spencer Baugh
2023-06-28 11:24   ` Eli Zaretskii
2023-06-28 12:05     ` Spencer Baugh
2023-06-28 12:18       ` Eli Zaretskii
2023-06-28 12:37         ` Spencer Baugh
2023-06-28 12:56           ` Eli Zaretskii
2023-07-18  2:21             ` Dmitry Gutov
2023-07-18 16:28               ` Spencer Baugh
2023-07-18 17:41                 ` Juri Linkov
2023-07-27  1:59                   ` Dmitry Gutov
2023-07-27  1:57                 ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).