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#63829: 29.0.90; project-find-file's future history breaks with common-parent-directory Date: Sat, 03 Jun 2023 07:00:56 -0400 Message-ID: References: <16b64d95-35e9-ef94-2c54-17b670111f0f@gutov.dev> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4949"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 63829@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 03 13:02:26 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 1q5P1e-00015X-N4 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Jun 2023 13:02:26 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q5P1H-0005tP-6Y; Sat, 03 Jun 2023 07:02:03 -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 1q5P1G-0005tE-FL for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 07:02: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 1q5P1G-0006v8-5u for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 07:02:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q5P1G-0001eX-19 for bug-gnu-emacs@gnu.org; Sat, 03 Jun 2023 07:02: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:02: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.16857900676283 (code B ref 63829); Sat, 03 Jun 2023 11:02:01 +0000 Original-Received: (at 63829) by debbugs.gnu.org; 3 Jun 2023 11:01:07 +0000 Original-Received: from localhost ([127.0.0.1]:41612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5P0M-0001dH-Lk for submit@debbugs.gnu.org; Sat, 03 Jun 2023 07:01:06 -0400 Original-Received: from mxout5.mail.janestreet.com ([64.215.233.18]:43835) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q5P0J-0001cc-5F for 63829@debbugs.gnu.org; Sat, 03 Jun 2023 07:01:05 -0400 In-Reply-To: <16b64d95-35e9-ef94-2c54-17b670111f0f@gutov.dev> (Dmitry Gutov's message of "Sat, 3 Jun 2023 05:30:10 +0300") 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:262819 Archived-At: Dmitry Gutov writes: > 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? Yes, your patch works great and solves the cases I care about! On top of your patch, I can implement the feature I mentioned with the patch at the end. This causes the following nice behavior: 1. Open ~/src/emacs/emacs-29/lisp/progmodes/project.el 2. C-x p p ~/src/emacs/trunk 3. f 4. M-n and the minibuffer contains "lisp/progmodes/project.el" 5. RET and we have now easily switched to the same file in another project Does the implementation seem OK? diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index ac7be8dcbb2..b1e01df5314 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1008,7 +1008,12 @@ project-find-file (dirs (list root))) (project-find-file-in (or (thing-at-point 'filename) - buffer-file-name) + (and buffer-file-name + (if-let (buffer-proj (and project-current-directory-override + (project-current nil default-directory))) + (let ((buffer-root (project-root buffer-proj))) + (file-name-concat root (file-relative-name buffer-file-name buffer-root))) + buffer-file-name))) dirs pr include-all))) ;;;###autoload