From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#69584: 29.2.50; project-find-functions should have access to maybe-prompt Date: Fri, 15 Mar 2024 03:41:01 +0200 Message-ID: <65b29bab-3149-49e3-a6ae-6c0c1485e6f2@gutov.dev> References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10019"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla Thunderbird To: Spencer Baugh , 69584@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Mar 15 02:41:58 2024 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 1rkwa5-0002Qr-7r for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 15 Mar 2024 02:41:58 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rkwZd-0007Rs-9k; Thu, 14 Mar 2024 21:41:29 -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 1rkwZa-0007Rc-Nb for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2024 21:41:27 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rkwZa-0004jp-Be for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2024 21:41:26 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rkwa9-0003zV-OC for bug-gnu-emacs@gnu.org; Thu, 14 Mar 2024 21:42:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Mar 2024 01:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69584 X-GNU-PR-Package: emacs Original-Received: via spool by 69584-submit@debbugs.gnu.org id=B69584.171046691615328 (code B ref 69584); Fri, 15 Mar 2024 01:42:01 +0000 Original-Received: (at 69584) by debbugs.gnu.org; 15 Mar 2024 01:41:56 +0000 Original-Received: from localhost ([127.0.0.1]:50986 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkwa2-0003z8-H0 for submit@debbugs.gnu.org; Thu, 14 Mar 2024 21:41:56 -0400 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:36201) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rkwZw-0003yp-I8 for 69584@debbugs.gnu.org; Thu, 14 Mar 2024 21:41:52 -0400 Original-Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 2AB57320077A; Thu, 14 Mar 2024 21:41:06 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 14 Mar 2024 21:41:06 -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:subject:subject:to:to; s=fm3; t=1710466865; x=1710553265; bh=8cjSRRi7Soc3q5P8ejfvDjiEUm/qU4FurU49ezCyWwM=; b= IBAQlELpTW5QiSG09IGdlaDoqvbk+xwDZnhTmM5qOCd6VBTMpZW7pj/IsdmTj0cD bpbiXz45sSONZ11rH1zFTi4DESFzP4np3gWndIymcu2pqEGJigtTdbBsP+yf6LvY IXCZz0HX4RKtQrvOXWANKjmkFJakZwUnHwUJ77j8sBfK+xfaLKYf0Eq0rq2KUxbT h2yDwjcdcd0lkvt3ptCZO5Z8merwCaoWDyY/1zHYVRJ1L+UzsIt+4Zoo/xqwTf6j KvVOPf2jWHRrVwgClS4VayZSP60ij/OWEW2T/FUKXMMPs2bu6StQX6jWHzeRlQWD Cz2v2s7GO40rrbJcVImDgg== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1710466865; x= 1710553265; bh=8cjSRRi7Soc3q5P8ejfvDjiEUm/qU4FurU49ezCyWwM=; b=I CbFWFq0+/ki2z4rhm+UulwzjDMcAsA+aTskUr0xjf6e0SNl7A+dbD4Y+ycaTZnbI 074K3TkAH+ojygGGl/KOSBFPD+eCp3SmGBQK7eT5tU8AhIFj85Ob++XjANcLBr9y hvI75zhYZw6dcsgsF8/B7hwf+w0n5aYDBhU52BnBGHvtF8hnH1voaCR2crzAlXXw NOSIbbriBeBDyF2+dlehOEQhhjuBFGvlgDxBNFTLxqkCSgDc1lH9zrFh70Y9yqdt mXbFd9RfcNNrH0jAIl9c59RU3teiLg2AYi+CLpwbyC/lDVos7KjUpZKv+qLeuY9D XFP+LpnxtZzM16Ux/qWCg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjeekgdefiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfhfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeffmhhithhr hicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrthhtvg hrnhephfeftdfhudejleelfeekjedtheefjedvlefgieeuteekheeuffekgfdviefghfdt necuffhomhgrihhnpehgihhthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 14 Mar 2024 21:41:04 -0400 (EDT) Content-Language: en-US In-Reply-To: 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:281635 Archived-At: Hi Spencer, On 06/03/2024 16:23, Spencer Baugh wrote: > > I'd like to write a project-find-function which might prompt when > called, and so to suppress that prompting I'd like to be able to check > the maybe-prompt argument that project-current received. This is technically doable, but what looks worrying to me, is that this would make 'project-current' lose more of its idempotency. Originally, the DIRECTORY argument for it was intended to make sure that all calls from the same directory would return the same instance. But of course a hook can be local, so some can find it practical to define buffer-local projects. This side-steps the original design, making, for example, the relation "files A and B are in the same project" not necessarily symmetric or transitive. > Possible new functions for project-find-functions which would benefit > from this: > > - A local project-find-function in a version control buffer for viewing > a branch log; if the branch is not currently checked out, prompt to > check out that branch (or create a worktree for it) before returning the > project > > - A local project-find-function in a buffer from a package for Git > forges; if the buffer corresponds to a repository which is not currently > cloned locally, prompt to clone the repository. > > These behaviors should of course be suppressed if maybe-prompt is nil, > which is why it would be nice to be able to access maybe-prompt. What would such project functions return when maybe-prompt is nil? Also nil, right? That would kind of create a separate category of projects, interactive-only. With regards to caching, for example, if some caller wanted to do so (some related discussion: https://github.com/joaotavora/breadcrumb/issues/18#issuecomment-1984615275), then would also need to take this parameter into account. So the first thing I'd ask is whether you see a different way to implement the same features. I don't see the whole usage scenarios, so it's hard to judge. > Since adding a new argument to project-find-functions is hard, maybe we > could do this by introducing a new dynamic variable > project-find-functions-may-prompt which we let-bind? Like: > > diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el > index c7c07c3d34c..3975182b88d 100644 > --- a/lisp/progmodes/project.el > +++ b/lisp/progmodes/project.el > @@ -242,8 +242,9 @@ project-current > (setq pr (cons 'transient directory)))) > pr)) > > -(defun project--find-in-directory (dir) > - (run-hook-with-args-until-success 'project-find-functions dir)) > +(defun project--find-in-directory (dir &optional maybe-prompt) > + (let ((project-find-functions-may-prompt maybe-prompt)) > + (run-hook-with-args-until-success 'project-find-functions dir))) > > (defvar project--within-roots-fallback nil) As far as the implementation goes, a dynamic variable can work. We could also try reusing an existing one: non-essential, and we'd set it to nil when maybe-prompt is non-nil. I wonder how it would interact with Tramp (ask for password in disconnected buffers?), but that seems to fall into the same general category as your other cases.