From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#63870: 29.0.90; project.el can't dynamically populate the project list Date: Sat, 03 Jun 2023 07:55:10 -0400 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17858"; mail-complaints-to="usenet@ciao.gmane.io" To: 63870@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 03 13:56:29 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q5Prw-0004T3-M6 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Jun 2023 13:56:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5PrY-0006Uo-7W; Sat, 03 Jun 2023 07:56:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q5PrW-0006Ug-Uy for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 07:56:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q5PrW-00044r-Mb for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 07:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q5PrW-0005k1-Hs for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 07:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Jun 2023 11:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 63870 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.168579331922005 (code B ref -1); Sat, 03 Jun 2023 11:56:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Jun 2023 11:55:19 +0000 Original-Received: from localhost ([127.0.0.1]:41725 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5Pqo-0005iq-LE for submit@debbugs.gnu.org; Sat, 03 Jun 2023 07:55:19 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:52728) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5Pqk-0005ib-4e for submit@debbugs.gnu.org; Sat, 03 Jun 2023 07:55:17 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q5Pqj-0006Nt-EX for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 07:55:13 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q5Pqh-0003xs-Nt for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 07:55:13 -0400 Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@janestreet.com; helo=mxout5.mail.janestreet.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:262823 Archived-At: 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 ()