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: Sat, 3 Jun 2023 05:30:10 +0300 Message-ID: <16b64d95-35e9-ef94-2c54-17b670111f0f@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="19491"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 To: Spencer Baugh , 63829@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 03 04:31:27 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 1q5H38-0004u0-MJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Jun 2023 04:31:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5H2r-00088x-D8; Fri, 02 Jun 2023 22:31:09 -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 1q5H2l-00088a-DC for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 22:31:03 -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 1q5H2k-00036k-L1 for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 22:31:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q5H2k-00080k-6M for bug-gnu-emacs@gnu.org; Fri, 02 Jun 2023 22:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Jun 2023 02:31:02 +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.168575942330746 (code B ref 63829); Sat, 03 Jun 2023 02:31:02 +0000 Original-Received: (at 63829) by debbugs.gnu.org; 3 Jun 2023 02:30:23 +0000 Original-Received: from localhost ([127.0.0.1]:41126 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5H26-0007zp-P4 for submit@debbugs.gnu.org; Fri, 02 Jun 2023 22:30:23 -0400 Original-Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:56201) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5H25-0007zW-14 for 63829@debbugs.gnu.org; Fri, 02 Jun 2023 22:30:22 -0400 Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 43954320092C; Fri, 2 Jun 2023 22:30:13 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Fri, 02 Jun 2023 22:30:13 -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= 1685759412; x=1685845812; bh=1UI8QODFq6yx8JZww0XPvRNRm2P7XNIoz8y C9sE7NCs=; b=c3Dm61L4jDWtnYIVS6vbIPC3Zl3+5UzkpAJNHSJmh5I/rJ4R+q+ kKaYlp/kpAbLRfnyN6dqsv2b06N2zjfygjyFHi5M8UKQ3Rs6umcNShhWDfoKcKln PkLldsYi7lhgt0cj+lkY73Nf8nNDt7mfTjJw2ryO01sDUzUYa+OWQKHZd/4TTAhy C+2AxyXjihdT4nEjzCyAxtvj0KI6gk+qZcbdaypd3Uo9Cl+JKQrWDJc3e4trNwNb oTUgq7whX0lqMlc4IluN/Y6MbLGlL+kKj3+k13CScrkslBhyH/119+UayexiDvhc kImEqOuFabhFNiA6PduJhFKWRHgRQiv4B7Q== 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=fm1; t=1685759412; x= 1685845812; bh=1UI8QODFq6yx8JZww0XPvRNRm2P7XNIoz8yC9sE7NCs=; b=Q d/RJX2q5N4aw5SWmqtJtvcmEoRbJVmDrdRZzI5Um2JQR40GVsLHCbt9PUAiS0im+ gvjuITiMqJz2f3wPUlhLFNm6Rk6lVXseOFJIJrPfk4ykzzwoivYDoM6FITLuJpI7 Epb+RMnywsEnGVYwAYvvJb4lZKIRP1uALIutAj7qiLh1K2FR/nlpG9vSIwXnoDpC Wr8PXRDGZ9ZekIGRkh15F9YlRSsLfHcUF7CU0cja17a9ISIJc/6yBZhlI+38Hic8 UgCOhv5y4Pa3PfYAn97zlu6ll9Ccxf5dl6CoLPkS5X4AGn8iR2g44TL+s8jOhcQM NbOHOr8A68KYqg6yfzUvg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeelgedgiedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthejredttdefjeenucfhrhhomhepffhmihht rhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtth gvrhhnpeeghedthedujeeiteeutddtjeekheejteeukeehffdutdejuedvfeevueeviedu udenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumh hithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 2 Jun 2023 22:30:11 -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:262795 Archived-At: Hi! On 02/06/2023 01:32, Spencer Baugh wrote: > > 1. emacs -Q > 2. Open a project where project-files only returns files in a certain > subdirectory. For example, a git repo /repo where the only file is > "dir/file.txt". > 3. Open dir/file.txt > 4. C-x p f ;; project-find file > 5. Observe that the prompt is "Find file in /repo/dir: " which correctly > contains the common parent directory between all the paths returned by > project-files. > 6. M-n ;; next-history-element > 7. The minibuffer now contains "dir/file.txt". RET will fail to > open the file. Note that if you continue pressing 'M-n', you will see the corresponding proper relative file names. The first one comes from the value constructed in project-find-file. Which indeed looks problematic, since we remove context in there by creating a relative name. > Instead, the common parent directory should be stripped from the "future > history" element. Try the patch at the end, please. It seems to fix the scenario you presented. Does it help with the feature you mention below, too? It doesn't handle the case when (thing-at-point 'filename) returns a relative file name that includes a directory name, relative to the project root (where common-parent-directory differs), but that one seems even more ambiguous. > (As a separate point: I ran into this while adding a feature for > switching between projects with similar directory structures. I want to > include the relative path in the starting project in the "future > history", so that when you have a file in projectA open, you can switch > to the same file in projectB with C-x p p f M-n RET. For example, > switching between the same file in multiple clones of Emacs. But sadly > the future history doesn't work properly right now even in a single > project) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 7c51778d5d4..184f2316074 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1008,7 +1008,7 @@ project-find-file (dirs (list root))) (project-find-file-in (or (thing-at-point 'filename) - (and buffer-file-name (file-relative-name buffer-file-name root))) + buffer-file-name) dirs pr include-all))) ;;;###autoload @@ -1062,6 +1062,10 @@ project--read-file-cpd-relative (delete common-parent-directory all-files)) t)) (substrings (mapcar (lambda (s) (substring s cpd-length)) all-files)) + (mb-default (if (and common-parent-directory + (file-name-absolute-p mb-default)) + (file-relative-name mb-default common-parent-directory) + mb-default)) (_ (when included-cpd (setq substrings (cons "./" substrings)))) (new-collection (project--file-completion-table substrings))