Received: (at 63870) by debbugs.gnu.org; 28 Jun 2023 11:24:31 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 28 07:24:31 2023 Received: from localhost ([127.0.0.1]:50120 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qETHi-0001Ex-SK for submit <at> debbugs.gnu.org; Wed, 28 Jun 2023 07:24:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45950) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1qETHf-0001Ee-2j for 63870 <at> debbugs.gnu.org; Wed, 28 Jun 2023 07:24:30 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1qETHZ-0001qJ-KN; Wed, 28 Jun 2023 07:24:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=EXNf5VCMr6JhSIN4ETYi2vWwzYX91VuHPxlChNFsVXc=; b=YQaDwqnGM0b3 ijpAPiyNL9DUBdf7hI4b91hdS3OxnJ/IiynelevMg7jz7NcmRxLuUCNRkiWMqjnHoNROksobjWxnX SELca+nvleO1LsCh0OZ470yIRGMnOVyQPGHr2kS745QdsfOJ0jvRo46U4w5HOzRVP34nhjKNLablI Qom4v0iYYPVKAb6J/hW2ghbHYS6/YpSycMbGfi6nyPgBneBeftuA29Ybt8R4XS31hzV216BUx0oSu VOBT2FrlL1LjgfAccJWz/eBPNim+5Mdf6tUp+73cvtsSFw+YrmeIDh973Bzus4oQi2yUDpVrUrN/9 2thcVmLy5ge9g0j8QftTGw==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1qETHZ-00026E-4M; Wed, 28 Jun 2023 07:24:21 -0400 Date: Wed, 28 Jun 2023 14:24:46 +0300 Message-Id: <83sfabvngh.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <ierbkh01za5.fsf@HIDDEN> (message from Spencer Baugh on Tue, 27 Jun 2023 15:27:30 -0400) Subject: Re: bug#63870: 29.0.90; project.el can't dynamically populate the project list References: <ierjzwkahgh.fsf@HIDDEN> <ierbkh01za5.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63870 Cc: 63870 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Spencer Baugh <sbaugh@HIDDEN> > Date: Tue, 27 Jun 2023 15:27:30 -0400 > > +(defun project-check-project (dir) > + "If there's a project at DIR, remember it; otherwise, forget it. > + > +Return the found project, if any." > + (let ((pr (project--find-in-directory dir))) > + (if pr (project-remember-project pr) > + (project-forget-project (file-name-as-directory dir))) > + pr)) > + > +(defun project--watch-cb-children (recursive predicate event) > + (unless (eq (cl-second event) 'stopped) > + (dolist (file (cddr event)) > + (condition-case _ (project-watch file recursive predicate) > + ((file-error file-notify-error)))))) > + > +(defun project--watch-cb-this (dir event) > + (unless (eq (cl-second event) 'stopped) > + (when (project-check-project dir) > + (file-notify-rm-watch (cl-first event))))) > + > +(defun project--file-notify-watch (dir callback &optional init) > + "Like `file-notify-add-watch' but also calls CALLBACK immediately." > + (let ((watch (file-notify-add-watch dir '(change) callback))) > + (funcall callback (append (list watch 'started) init)))) Beware of watching a tree recursively: file notifications are not very scalable, for more than one reason. For example, the inotify backend consumes a file descriptor and a slot in the descriptor set monitored by pselect per each file/directory you watch. And watching many directories can overwhelm Emacs if some program (even unrelated to Emacs) performs many file operations in that directory; VCS programs are notorious in this regard, e.g., when you update from upstream. > +(defun project-watch (dir &optional recursive predicate) > + "Watch DIR until it becomes a project. > + > +We stop watching DIR once it becomes a project. This never explains what it means for a directory to "become a project". It should, because this doc string begs that question. > +If RECURSIVE is an integer greater than 0, we'll also run > +`project-watch' on directories which appear inside DIR, > +passing (1- RECURSIVE) as RECURSIVE. To achieve this, we'll > +continue watching DIR even if it becomes a project. This can be > +expensive, so it's better to pass small values of RECURSIVE, like > +1 or 2. Are you sure this feature justifies the risks? When would someone want to use it, while simultaneously limiting the value of RECURSIVE to some small integer? (And what is considered "small" for these purposes?) Thanks.
bug-gnu-emacs@HIDDEN
:bug#63870
; Package emacs
.
Full text available.Received: (at 63870) by debbugs.gnu.org; 27 Jun 2023 19:29:56 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 27 15:29:56 2023 Received: from localhost ([127.0.0.1]:49561 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qEENv-0001DN-Vt for submit <at> debbugs.gnu.org; Tue, 27 Jun 2023 15:29:56 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:34791) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1qEENt-0001DA-V1 for 63870 <at> debbugs.gnu.org; Tue, 27 Jun 2023 15:29:54 -0400 From: Spencer Baugh <sbaugh@HIDDEN> To: Dmitry Gutov <dmitry@HIDDEN> Subject: Re: bug#63870: 29.0.90; project.el can't dynamically populate the project list In-Reply-To: <aa0618d7-e868-07ae-9cc4-ebe76f9803e1@HIDDEN> (Dmitry Gutov's message of "Sat, 17 Jun 2023 05:55:59 +0300") References: <ierjzwkahgh.fsf@HIDDEN> <aa0618d7-e868-07ae-9cc4-ebe76f9803e1@HIDDEN> Date: Tue, 27 Jun 2023 15:29:48 -0400 Message-ID: <ier7cro1z6b.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63870 Cc: 63870 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Dmitry Gutov <dmitry@HIDDEN> writes: > Hi! > > On 03/06/2023 14:55, Spencer Baugh wrote: >> 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. > > Are you sure the existing functions won't cut it? Such as > project-remember-project and project-forget-project. > > The names might seem a little wrong, but keeping in mind that > project--list is about having a list of projects "remembered" > somewhere, they're probably fine. And you could let-bind project--list > somewhere at the top level in your function/command/etc, so the list > is not altered in the end. Oh, certainly project-{remember,forget}-project work, indeed I've used them in the patch I just posted. I think I was unclear about what I wanted, perhaps that patch clarifies what exactly I was looking for. >> 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. > > We could add some var like project-list-no-write, so that dynamic > changes don't get written to disk. > > Unless you want to keep the "dynamic" list to be used by regular > commands, that is. > > In that case, the above will probably not suffice. We could go with > your approach, or even add some project-list-sources hook. > > But how would the entries from different sources (e.g. the list file > and your dynamic list) combined? How will they be sorted? > > In case we can't come up with a generic way, we could simply add a > generic storage abstraction (similar to xref-history-storage), which > you would override/advise to combine the lists as needed for your > usage. I don't think these changes are necessary after all. (Which is good, because they would add a fair bit of complexity.) This file-notify approach I think should work perfectly for a wide variety of uses.
bug-gnu-emacs@HIDDEN
:bug#63870
; Package emacs
.
Full text available.Received: (at 63870) by debbugs.gnu.org; 27 Jun 2023 19:27:39 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jun 27 15:27:39 2023 Received: from localhost ([127.0.0.1]:49551 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qEELi-00019i-Sh for submit <at> debbugs.gnu.org; Tue, 27 Jun 2023 15:27:39 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:38145) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1qEELg-00019S-Eo for 63870 <at> debbugs.gnu.org; Tue, 27 Jun 2023 15:27:37 -0400 From: Spencer Baugh <sbaugh@HIDDEN> To: 63870 <at> debbugs.gnu.org Subject: Re: bug#63870: 29.0.90; project.el can't dynamically populate the project list In-Reply-To: <ierjzwkahgh.fsf@HIDDEN> (Spencer Baugh's message of "Sat, 03 Jun 2023 07:55:10 -0400") References: <ierjzwkahgh.fsf@HIDDEN> Date: Tue, 27 Jun 2023 15:27:30 -0400 Message-ID: <ierbkh01za5.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63870 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Add project-watch to discover projects with file-notify Projects can be created outside of Emacs, but users might want to be able to switch to them with project-switch-project immediately. This function supports that. If a user calls (project-watch "~/src" 1) then any projects under ~/src will be discovered automatically immediately after their creation. I have strived to make this function usable for a wide set of use-cases, I think it will be a useful addition to project.el. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Add-project-watch-to-discover-projects-with-file-not.patch From b283eb7eec428b8b0027a28f8c5f547360386b80 Mon Sep 17 00:00:00 2001 From: Spencer Baugh <sbaugh@HIDDEN> Date: Tue, 27 Jun 2023 15:25:02 -0400 Subject: [PATCH] Add project-watch to discover projects with file-notify Projects can be created outside of Emacs, but users might want to be able to switch to them with project-switch-project immediately. This API supports that. If a user calls (project-watch "~/src" 1) then any projects under ~/src will be discovered automatically immediately after their creation. * lisp/progmodes/project.el (project-check-project) (project--watch-cb-children, project--watch-cb-this) (project--file-notify-watch, project-watch): Add. (bug#63870) --- lisp/progmodes/project.el | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 56c524bcab5..ddb033d50f9 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1884,5 +1884,56 @@ project-switch-project (let ((project-current-directory-override dir)) (call-interactively command)))) +(defun project-check-project (dir) + "If there's a project at DIR, remember it; otherwise, forget it. + +Return the found project, if any." + (let ((pr (project--find-in-directory dir))) + (if pr (project-remember-project pr) + (project-forget-project (file-name-as-directory dir))) + pr)) + +(defun project--watch-cb-children (recursive predicate event) + (unless (eq (cl-second event) 'stopped) + (dolist (file (cddr event)) + (condition-case _ (project-watch file recursive predicate) + ((file-error file-notify-error)))))) + +(defun project--watch-cb-this (dir event) + (unless (eq (cl-second event) 'stopped) + (when (project-check-project dir) + (file-notify-rm-watch (cl-first event))))) + +(defun project--file-notify-watch (dir callback &optional init) + "Like `file-notify-add-watch' but also calls CALLBACK immediately." + (let ((watch (file-notify-add-watch dir '(change) callback))) + (funcall callback (append (list watch 'started) init)))) + +;;;###autoload +(defun project-watch (dir &optional recursive predicate) + "Watch DIR until it becomes a project. + +We stop watching DIR once it becomes a project. + +If RECURSIVE is an integer greater than 0, we'll also run +`project-watch' on directories which appear inside DIR, +passing (1- RECURSIVE) as RECURSIVE. To achieve this, we'll +continue watching DIR even if it becomes a project. This can be +expensive, so it's better to pass small values of RECURSIVE, like +1 or 2. + +If PREDICATE is non-nil, it should be a function which will be +called with two arguments, the value of RECURSIVE and a +directory. Only directories for which PREDICATE returns non-nil +will be watched for being a project." + (setq predicate (or predicate (lambda (_recursive dir) t))) + (setq recursive (or recursive 0)) + (when (and (funcall predicate recursive dir) (file-directory-p dir)) + (project--file-notify-watch dir (apply-partially #'project--watch-cb-this dir))) + (when (> recursive 0) + (project--file-notify-watch + dir (apply-partially #'project--watch-cb-children (1- recursive) predicate) + (directory-files dir 'full directory-files-no-dot-files-regexp)))) + (provide 'project) ;;; project.el ends here -- 2.39.3 --=-=-=--
bug-gnu-emacs@HIDDEN
:bug#63870
; Package emacs
.
Full text available.Received: (at 63870) by debbugs.gnu.org; 17 Jun 2023 02:56:11 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 16 22:56:10 2023 Received: from localhost ([127.0.0.1]:50661 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qAM6k-00053j-Kd for submit <at> debbugs.gnu.org; Fri, 16 Jun 2023 22:56:10 -0400 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:49291) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <dmitry@HIDDEN>) id 1qAM6i-00053V-0e for 63870 <at> debbugs.gnu.org; Fri, 16 Jun 2023 22:56:08 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 5212F320076F; Fri, 16 Jun 2023 22:56:02 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 16 Jun 2023 22:56:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1686970561; x=1687056961; bh=8UowMyp/s7QQW2MzyitU/E2/CLOYZkMsWVd JR0/8KyY=; b=G8ia4Qncz/vfBhdhYXdAnEjCLSOU8QV7Sx3FTolTZljUAHXx/uN 2ryrySyEd1qlO06RrnuUac8PtphdVv7tqKLZR7ci22ogTlyKxAaoNvbh7YE2qRez /IU8h1qcvvDq/agBb4Ksl3sJ0RVN3msBeCGAewSqScyi1S9HwLMeYmBurp7VsXlN pFxcFzId9DQxMlwspxNORcdG8NPtt1PuMc2ShnYozG82E2JTHeOgHu9bLYSicT61 OjwW9vMsUaV/FBEZgy73vyndT8yc/GHZTu8FXFi8I4KZcedMMSvze/LhwQhaLz28 X3jk5wUtByZais9DQAcg+TVnEJw5lzuTJoQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1686970561; x= 1687056961; bh=8UowMyp/s7QQW2MzyitU/E2/CLOYZkMsWVdJR0/8KyY=; b=V 2bZXBIWMJQmH1WwRZXBcgniPRZlLNKLnmmfwnpqHDy7GifSapdB/FnrJHdREYSYU hFokmWTWlCDSFtWJlTQh4IY6SMWwVYRXUEezK01eYBqm8mKXOqIc0WUFS1HOARFf wDtV7q1Oz54liYTGE11KMaZ8HrjRpGFhPtqlGhEOdpOxKckIwdF9kzYLtG9Dq5wL Y4+nZD8sTAOOtrwr7C7DugPKDd2+RE08RJ759CIy1rblNMgX6xckWGDD/uIpG1kf j0Q/DpdLlAhpWB/9C2uS4BTMvl8D3cbG4rsYOeUD5/Xa2wAEwfPYUmT3m7a09c/W gSXY/wtXCSnyPA91eNgxg== X-ME-Sender: <xms:wSCNZPGLhuwnUd1jXy4Jt6x1tO6eIGdYip2qSY-Ea93qVAiHWNtkEQ> <xme:wSCNZMU3Jt-eAgLt-brc-H0Em_6z-pVmyKT5xjMGNyXcBYG5KceS8ya7PJvHo2lz6 ZL4lEVG4R4ZneJsqh4> X-ME-Received: <xmr:wSCNZBIVXZCV6C0eesOsmq7CLLVzzVIVYNGMzICOAOQ3jzv6pSxQy7QsL8av92U> X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgedviedgvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthejredttdefjeenucfhrhhomhepffhmihht rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth gvrhhnpeeghedthedujeeiteeutddtjeekheejteeukeehffdutdejuedvfeevueeviedu udenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumh hithhrhiesghhuthhovhdruggvvh X-ME-Proxy: <xmx:wSCNZNGQC2bIDi0LFkHDi6zl-2ZS85jMyySHxVCRb-z19_8G1F9FZA> <xmx:wSCNZFUz-NGKNswAn7MR0Jy3SnSCXpG50oZa30zdfedvIqy_pIKyPQ> <xmx:wSCNZIPVDu711DO57_UXd3ncLhRxjye0m5wcd5CS2E0B6_UWyj9Quw> <xmx:wSCNZGcC_c1u9LRNY0fBbLXv3WNFdXjp_-c50foVfoDLRSyib3VTYg> Feedback-ID: i0e71465a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 16 Jun 2023 22:56:00 -0400 (EDT) Message-ID: <aa0618d7-e868-07ae-9cc4-ebe76f9803e1@HIDDEN> Date: Sat, 17 Jun 2023 05:55:59 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: bug#63870: 29.0.90; project.el can't dynamically populate the project list Content-Language: en-US To: Spencer Baugh <sbaugh@HIDDEN>, 63870 <at> debbugs.gnu.org References: <ierjzwkahgh.fsf@HIDDEN> From: Dmitry Gutov <dmitry@HIDDEN> In-Reply-To: <ierjzwkahgh.fsf@HIDDEN> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.9 (-) X-Debbugs-Envelope-To: 63870 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.9 (--) Hi! On 03/06/2023 14:55, Spencer Baugh wrote: > 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. Are you sure the existing functions won't cut it? Such as project-remember-project and project-forget-project. The names might seem a little wrong, but keeping in mind that project--list is about having a list of projects "remembered" somewhere, they're probably fine. And you could let-bind project--list somewhere at the top level in your function/command/etc, so the list is not altered in the end. > 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. We could add some var like project-list-no-write, so that dynamic changes don't get written to disk. Unless you want to keep the "dynamic" list to be used by regular commands, that is. In that case, the above will probably not suffice. We could go with your approach, or even add some project-list-sources hook. But how would the entries from different sources (e.g. the list file and your dynamic list) combined? How will they be sorted? In case we can't come up with a generic way, we could simply add a generic storage abstraction (similar to xref-history-storage), which you would override/advise to combine the lists as needed for your usage.
bug-gnu-emacs@HIDDEN
:bug#63870
; Package emacs
.
Full text available.Received: (at 63870) by debbugs.gnu.org; 16 Jun 2023 05:45:38 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 16 01:45:38 2023 Received: from localhost ([127.0.0.1]:48463 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qA2HC-0005eJ-05 for submit <at> debbugs.gnu.org; Fri, 16 Jun 2023 01:45:38 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59382) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1qA2HA-0005Ms-DE for 63870 <at> debbugs.gnu.org; Fri, 16 Jun 2023 01:45:36 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1qA2H4-0005F0-1G; Fri, 16 Jun 2023 01:45:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=NvcORpYdTL50ALzZ0gCR4rKc5JcgagI1azO0lkfdSRQ=; b=GiJKK2zM9hWw w+BMuFdf8eKkzp01ocB990ZGcHYjMaqWy1Q+VOY86vm0oXupPsmSQJzQoTuR8WBzNmUP5r02Eq1AJ zkIlyNNMOiTxS/o4mQD4BlSm3ufGyCsvSXINwLK4EDCh00hKb3CV2FknXPPyTt5GagV8rPBwnBHlE Qv+sl/oVjj/hZdCKtYo5MzkMUPdQYJZpZDT+bWSxpZfeq3KMHXgB2Z8+cu1NLs2h+EQbJ2MIsrm5s +BTPySQIZpGm5tmM1UYQ7EUGo3Yhg/OdqgpynZUNaZ/1gOXTKeXAD5tJWo+D1WNX92xsIBVcOcwd8 N1EMSe/gztx0U61/rOHeFQ==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1qA2H1-0003pt-Aw; Fri, 16 Jun 2023 01:45:29 -0400 Date: Fri, 16 Jun 2023 08:45:52 +0300 Message-Id: <83a5x0t0xb.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> To: Spencer Baugh <sbaugh@HIDDEN> In-Reply-To: <ierwn04frpx.fsf@HIDDEN> (message from Spencer Baugh on Thu, 15 Jun 2023 15:30:50 -0400) Subject: Re: bug#63870: 29.0.90; project.el can't dynamically populate the project list References: <ierjzwkahgh.fsf@HIDDEN> <ierwn04frpx.fsf@HIDDEN> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63870 Cc: 63870 <at> debbugs.gnu.org X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Spencer Baugh <sbaugh@HIDDEN> > Date: Thu, 15 Jun 2023 15:30:50 -0400 > > Actually I think a file-notify solution works great. I have one working > for my use case and I'll post a patch for a generic one soon. Please keep in mind that in our experience watching a repository tree is problematic (if that is what you had in mind).
bug-gnu-emacs@HIDDEN
:bug#63870
; Package emacs
.
Full text available.Received: (at 63870) by debbugs.gnu.org; 15 Jun 2023 19:30:58 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jun 15 15:30:58 2023 Received: from localhost ([127.0.0.1]:47982 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1q9sgM-0000CW-4c for submit <at> debbugs.gnu.org; Thu, 15 Jun 2023 15:30:58 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:39389) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1q9sgK-0000CI-0X for 63870 <at> debbugs.gnu.org; Thu, 15 Jun 2023 15:30:57 -0400 From: Spencer Baugh <sbaugh@HIDDEN> To: 63870 <at> debbugs.gnu.org Subject: Re: bug#63870: 29.0.90; project.el can't dynamically populate the project list In-Reply-To: <ierjzwkahgh.fsf@HIDDEN> (Spencer Baugh's message of "Sat, 03 Jun 2023 07:55:10 -0400") References: <ierjzwkahgh.fsf@HIDDEN> Date: Thu, 15 Jun 2023 15:30:50 -0400 Message-ID: <ierwn04frpx.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 63870 X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Actually I think a file-notify solution works great. I have one working for my use case and I'll post a patch for a generic one soon.
bug-gnu-emacs@HIDDEN
:bug#63870
; Package emacs
.
Full text available.Received: (at submit) by debbugs.gnu.org; 3 Jun 2023 11:55:19 +0000 From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 03 07:55:19 2023 Received: from localhost ([127.0.0.1]:41725 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1q5Pqo-0005iq-LE for submit <at> debbugs.gnu.org; Sat, 03 Jun 2023 07:55:19 -0400 Received: from lists.gnu.org ([209.51.188.17]:52728) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <sbaugh@HIDDEN>) id 1q5Pqk-0005ib-4e for submit <at> debbugs.gnu.org; Sat, 03 Jun 2023 07:55:17 -0400 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 <sbaugh@HIDDEN>) id 1q5Pqj-0006Nt-EX for bug-gnu-emacs@HIDDEN; Sat, 03 Jun 2023 07:55:13 -0400 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 <sbaugh@HIDDEN>) id 1q5Pqh-0003xs-Nt for bug-gnu-emacs@HIDDEN; Sat, 03 Jun 2023 07:55:13 -0400 From: Spencer Baugh <sbaugh@HIDDEN> To: bug-gnu-emacs@HIDDEN Subject: 29.0.90; project.el can't dynamically populate the project list Date: Sat, 03 Jun 2023 07:55:10 -0400 Message-ID: <ierjzwkahgh.fsf@HIDDEN> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=64.215.233.18; envelope-from=sbaugh@HIDDEN; 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-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.4 (--) 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 ()
Spencer Baugh <sbaugh@HIDDEN>
:bug-gnu-emacs@HIDDEN
.
Full text available.bug-gnu-emacs@HIDDEN
:bug#63870
; Package emacs
.
Full text available.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.