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#63829: 29.0.90; project-find-file's future history breaks with common-parent-directory Date: Wed, 16 Aug 2023 04:49:58 +0300 Message-ID: <73a695f3-7c6a-0e50-41dd-61f8269f6ecf@gutov.dev> References: <16b64d95-35e9-ef94-2c54-17b670111f0f@gutov.dev> <86h6rnw7gm.fsf@mail.linkov.net> <3e404df1-b3a9-f9e3-4270-f42df8b704c7@gutov.dev> <87a5uti6mo.fsf@catern.com> 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="6103"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cc: 63829@debbugs.gnu.org, Juri Linkov To: sbaugh@catern.com, Spencer Baugh Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Aug 16 03:51:16 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 1qW5gp-0001OR-00 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 16 Aug 2023 03:51:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qW5ge-0002iv-AF; Tue, 15 Aug 2023 21:51: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 1qW5gc-0002iY-0v for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 21:51:02 -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 1qW5gb-0002av-P5 for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 21:51:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qW5gb-0002Hf-La for bug-gnu-emacs@gnu.org; Tue, 15 Aug 2023 21:51: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: Wed, 16 Aug 2023 01:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63829 X-GNU-PR-Package: emacs Original-Received: via spool by 63829-submit@debbugs.gnu.org id=B63829.16921506098717 (code B ref 63829); Wed, 16 Aug 2023 01:51:01 +0000 Original-Received: (at 63829) by debbugs.gnu.org; 16 Aug 2023 01:50:09 +0000 Original-Received: from localhost ([127.0.0.1]:38446 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qW5fk-0002GX-RQ for submit@debbugs.gnu.org; Tue, 15 Aug 2023 21:50:09 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:52965) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qW5fi-0002Fm-Fz for 63829@debbugs.gnu.org; Tue, 15 Aug 2023 21:50:07 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C62B65C0338; Tue, 15 Aug 2023 21:50:00 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 15 Aug 2023 21:50:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :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=fm2; t= 1692150600; x=1692237000; bh=5xTRvPalSi+SBJ15QIoYxSf+MXESh9NqPxn mddYKbL0=; b=CTBjcV8B7ccQ/kBfUZi6kxHQrjwxlWQGmtKczYRTxhKjTonqPZp N9HmVeB2MOhwCq4LxXD0XJFGAn3WxkA51XtoXTmXQR62Dx+tQoCGeZl0XY6Re78K vY89QZqI8nLBC6kGYFATWaP21M00xUA6mqMwtHoiE8vdgbtEpZhnqnjbdorvD+3J ddWQjtUrmzch8c4r4MHivg1BfeOEXyX+AdIoapcmar+F037ovEnyajjLUg580Uf0 CoYkjF8FPtphj9boelAqheDv5HwaWBcd0TltkfAJrYXxZIk/WDk2m9EhQpyVs0Xc M2380xaz6uInLUFj7iuQhraOiggpDKAMAfA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm1; t= 1692150600; x=1692237000; bh=5xTRvPalSi+SBJ15QIoYxSf+MXESh9NqPxn mddYKbL0=; b=iK+t20tkzsFpTVJyzcd4aZ9nsk65zsOc0m2XOVE0wOm8dhOQXiL jA0V24nqRUHvmY9Yva+Cb/y7xHIFMhoFe39zhA7bzhE3L9AocIQORIME/Fe3wmPG JwZMGOFR7yD6w57QN9nlSR679Md+RJEdq2+MzXzOFWQ0mplAui7jiyjvZu9HJ+TD oflB8mQvZsmr3Ef2J1H32TfJNUbaY+YUIRSP7UQSUw0tX6a1VktZGXV1rbQjJFss vYxslbPG6N7T46uLY7xNkM+i9OnoeTDpP8M/jXPfhZWH25AJlJ+fcjD8/usHaMtV a0H7sMZ8C0Z1I/BS+DZmNwCCH2fz4NhPHSA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedruddtkedgheduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth htvghrnhephfeutdekveeggeetteekfeejffegudduudfhueevleeftdffffeggeeivddv jeelnecuffhomhgrihhnpehgnhhurdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghv X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 15 Aug 2023 21:49:59 -0400 (EDT) Content-Language: en-US In-Reply-To: <87a5uti6mo.fsf@catern.com> 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:267537 Archived-At: On 15/08/2023 01:47, sbaugh@catern.com wrote: >>>> I'm not sure I understand the alternative - the idea would be to share >>>> project file name history between all projects? I guess that could be >>>> nice, although I don't personally use file name history that much, and >>>> AFAIK it wouldn't solve any concrete user problems, so I'm not really >>>> motivated to implement it. >>> >>> The alternative is a little more general, e.g. propertize every such >>> history entry with the value of the root, so that they can be >>> post-processed to adapt to any other root directory. >>> >>> This shouldn't take too much work, actually. But I don't know if that >>> is indeed a necessary feature. From the discussion >>> (https://debbugs.gnu.org/58447), I had been under impression that it >>> would be wanted, but it might be just "nice to have". >> >> I would be happy to do that. That sounds very cool actually. >> >> Can you elaborate on how exactly you imagine this happening? I guess, >> every time someone enters a filename with project-find-file or >> project-find-dir, we would include a propertized version of that >> filename in file-name-history? And then we would re-relativize them and >> adapt them to the current project when including them as history? > > Okay, I did that. Extremely rough patch follows. Thanks! It's very close to what I was thinking of (modulo some cosmetics and perf optimizations). > Btw, the reason I'm interested in this shared project history is because > our workflow involves creating many new projects (one per branch); so > mostly each project has no history at all, and sharing history between > projects is the only way to get any. Now that you can have this additional capability as an option, do you think you will be using it as well? > But, it seems to me that this doesn't really help with having the > current file be "future history". That's still useful when switching > between similar projects. And all the logic of my other patch which > does that, is still required with this patch. Indeed, that's a good point. So I think we'll install your first patch either way. Before we do that, small (or not so small) question: do you think we should test that the current buffer exists in the other project too? We could do that with file-exists-p (but that's an extra round-trip over Tramp), or by checking against the full list like in below. Relatedly, with the cross-project history, we should ask the same question: will we check that the "transplanted" history entries correspond to existing files in the other project (and filter out those that don't). WDYT? diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index d8b12c9c880..a32bc2dd8d3 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1116,7 +1116,10 @@ project-find-file-in (completion-ignore-case read-file-name-completion-ignore-case) (file (funcall project-read-file-name-function "Find file" all-files nil 'file-name-history - suggested-filename))) + (if (file-name-absolute-p suggested-filename) + (and (member suggested-filename all-files) + suggested-filename) + suggested-filename)))) (if (string= file "") (user-error "You didn't specify the file") (find-file file))))