From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: spwhitton@spwhitton.name, sbaugh@janestreet.com, bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Jul 2025 02:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 79126@debbugs.gnu.org Cc: spwhitton@spwhitton.name, sbaugh@janestreet.com X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: spwhitton@spwhitton.name, sbaugh@janestreet.com Received: via spool by submit@debbugs.gnu.org id=B.17538430507877 (code B ref -1); Wed, 30 Jul 2025 02:38:01 +0000 Received: (at submit) by debbugs.gnu.org; 30 Jul 2025 02:37:30 +0000 Received: from localhost ([127.0.0.1]:37750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugwh7-00022y-Ji for submit@debbugs.gnu.org; Tue, 29 Jul 2025 22:37:29 -0400 Received: from lists.gnu.org ([2001:470:142::17]:55874) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ugwh4-00021t-Bo for submit@debbugs.gnu.org; Tue, 29 Jul 2025 22:37:27 -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 ) id 1ugwgg-00063v-UL for bug-gnu-emacs@gnu.org; Tue, 29 Jul 2025 22:37:02 -0400 Received: from fhigh-b3-smtp.messagingengine.com ([202.12.124.154]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ugwgc-0003Pw-6s for bug-gnu-emacs@gnu.org; Tue, 29 Jul 2025 22:37:02 -0400 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id B28D07A2395 for ; Tue, 29 Jul 2025 22:36:56 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Tue, 29 Jul 2025 22:36:56 -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:message-id:mime-version:reply-to:subject :subject:to:to; s=fm1; t=1753843016; x=1753929416; bh=e1u1vAn3uj Zm0PqCBvw2R9yfd4PGjkzxIXKA8IDhxdQ=; b=CyufdjbrlFlGEIYw3HOFnrk1Wj tZsBlVLzEDxTbvqYLLyEeV/gxdo/YhHEuzt0kRR6yws99fEJRTJXC5iAlzk8Afei E3kYhKFI0svku5aSmghJxKso7tGWwoXEv9X44QW9FNO3E5l1O+PvlE9LgJ71Rcd/ 5B6YGsWF/1FvbPz0xSVBuc3EKtpQTv+HaOYnIfMpIH63y+YERoGwFp1W4nwcAQme HoS/uY+1jwWz3AoNqi0y4T7ticorkoPJp/vpdLZgGbO05R34o9QdoG/9Mj7ixIrZ W6i9WZtfmbgy0b3GVwbhVIqwRNDcW2OwBAf8ldMHiSGhUCzY4tP7aS+AMwEA== 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:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1753843016; x=1753929416; bh=e1u1vAn3ujZm0PqCBvw2R9yfd4PGjkzxIXK A8IDhxdQ=; b=cjvCuaGUPtMm56u1DSb4+y38DmX9JARFljsUUDDblkq0X9dco3P kRvJCoukoiYHb3c/wcLmQk9MuQnwFAtgNqBpkiQhYn0tR0nlnpcW4v5f9xfT4UrD Y2ZSvUcYqLplvWfKM4ebbdXKVCYTFCVaM5ZS7B67V8U7NedWpvlb7PM8z5jREiyv 5ldgus6gtafZTPZ6G6S4tFno58SmZUp2GKdsAGv2BP0N7h3YRqAGsqyya2WNhpTY Y9fdHNRPsnINMHLGhtfgypdgv+KR9O1yyt8lmsw4Fu1z1vVD4BAUWpocYdA062UR shFu+m1DwAEEb0C1QPekqVr7ee8OaJFnVAA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdelieejhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepkfffgggfvffhufgtgfesthekredttddvje enucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdgu vghvqeenucggtffrrghtthgvrhhnpeeutdehffdtudejffeigfdtfffgtddvheekuedvhf ekhfdutedvleeiffefuefgueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtoh epuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsghughdqghhnuhdqvghmrggt shesghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 29 Jul 2025 22:36:55 -0400 (EDT) Message-ID: Date: Wed, 30 Jul 2025 05:36:54 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: Dmitry Gutov Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=202.12.124.154; envelope-from=dmitry@gutov.dev; helo=fhigh-b3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) X-Debbugs-CC: spwhitton@spwhitton.name, sbaugh@janestreet.com Hi! If the current buffer does not visit a file (such as Dired, mentioned in a FIXME comment), or if the current file has no corresponding on the other worktree, we end up with an error. Like file-relative-name: Wrong type argument: stringp, nil or File ‘lisp/progmodes/abc.el’ not found in ‘~/vc/emacs-28/’ I guess some of these could be improved in project-find-matching-file (support for more major modes?) but semantically it seems like vc-switch-working-tree should try harder. Falling back to visiting the worktree root in Dired, if it doesn't find a better choice. From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Jul 2025 04:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: sbaugh@janestreet.com, 79126@debbugs.gnu.org, spwhitton@spwhitton.name Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.17538498454302 (code B ref 79126); Wed, 30 Jul 2025 04:31:02 +0000 Received: (at 79126) by debbugs.gnu.org; 30 Jul 2025 04:30:45 +0000 Received: from localhost ([127.0.0.1]:38139 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugySj-00017K-6f for submit@debbugs.gnu.org; Wed, 30 Jul 2025 00:30:45 -0400 Received: from mail.eshelyaron.com ([107.175.124.16]:42368 helo=eshelyaron.com) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ugySf-000177-TW for 79126@debbugs.gnu.org; Wed, 30 Jul 2025 00:30:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1753849841; bh=c6eLlFB/mALAtoU6FTFzwUT/RdfR1+wPDiX8qnDpC2s=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=xDRSFJbYlTC4ABXOGttBEa0l/9GSNvV72rJSVjs0f9dI4FSj+O+bvIuWuUamTuxkJ Zi4UpfTN4BF6hETgt6MlkO/YTi7vx2jb/mTfwFBW8hs+dytWJJ4xNdm8Uy5OoqVhRn hY5PSkZorj4nw5sW8HDQ28yyNw9a9I1nwNdu/eFWyqJk1MTT3/xibmIfiNShPJW9ey 10HZOo2Qk8Ae5c689cANIREz0rZ4I8noxmmMENZh2JZzpaBNk+vEpxUquoUv9XdaIy Th7X44JtMDoVPmT3usp/8DsHG8BQa1yZAipSWpRXSJtTDGaEpbcm3JaVtqBKq6FL2B iLp34vI/Sr+/g== From: Eshel Yaron In-Reply-To: References: Date: Wed, 30 Jul 2025 06:30:31 +0200 Message-ID: <87ldo6b8rc.fsf@mail.eshelyaron.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Dmitry, Sean, Spencer, First of all, thank you for adding these new worktree commands, I use Git worktrees a lot and it's great to see VC supporting them. Dmitry Gutov writes: > If the current buffer does not visit a file (such as Dired, mentioned > in a FIXME comment), or if the current file has no corresponding on > the other worktree, we end up with an error. > > Like > > file-relative-name: Wrong type argument: stringp, nil > > or > > File =E2=80=98lisp/progmodes/abc.el=E2=80=99 not found in =E2=80=98~/vc= /emacs-28/=E2=80=99 FWIW, while incorporating this new feature in my Emacs branch, I've made a few experimental tweaks that eliminate these errors. Namely, I added a variable vc-switch-working-tree-function which vc-switch-working-tree consults to do the actual switching. By default this variable is set to a function that works for file-visiting buffers (similarly to the current implementation in master), but major modes can readily set this variable buffer-locally to provide worktree-switching support also for non-file buffers. I used this indirection to support Dired buffers. ( The more fundamental change I made was to avoid the dependency of VC on project.el, which I find... suboptimal. Instead I introduced hooks vc-delete/create-tree-hook which one can use, among other things, to keep project--list in sync with deleted/created worktrees. This does come at the expense of effectively disabling the Mercurial support. ) If you want to take a look, you can find my tweaks here: http://git.eshelyaron.com/gitweb/?p=3Demacs.git;a=3Dcommitdiff;h=3D2b1383= d647402df2b539f69cf73a12c0717b00f3 > I guess some of these could be improved in project-find-matching-file > (support for more major modes?) but semantically it seems like > vc-switch-working-tree should try harder. Falling back to visiting the > worktree root in Dired, if it doesn't find a better choice. That sounds like a good fallback, indeed. Best regards, Eshel From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Jul 2025 11:05:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: sbaugh@janestreet.com, 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175387345622109 (code B ref 79126); Wed, 30 Jul 2025 11:05:01 +0000 Received: (at 79126) by debbugs.gnu.org; 30 Jul 2025 11:04:16 +0000 Received: from localhost ([127.0.0.1]:39791 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh4bY-0005kU-31 for submit@debbugs.gnu.org; Wed, 30 Jul 2025 07:04:16 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:47742) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uh4bV-0005k1-Kc for 79126@debbugs.gnu.org; Wed, 30 Jul 2025 07:04:14 -0400 DKIM-Signature: a=rsa-sha256; b=WsPEAfOxo7P/jad6qoYHNOwbJOxsta0ZwTfdfJtM530u7E7HsKHXLNdPqD9gG/4l+I/g6psgHya2Y7otSDcoQp6ysMOadRGCEJiM9s4i3+CaJMP/fl91n+M8o9hnnQRP9WL5dMLx5rKF033fIh7YqlUZgWMMuRWDmkZFLHs6x9F4j0nIy8PYTKTcB1bCL34zdzY3YA+OyREZPy+Cj4DGOEORODE1YeWVAoz1fwzoPPBb5lIbT2nA36TMCZn56JuShA8C31RE/2aj1odJQpcHAn/N3b1hLasuCfEht0DGx5M0hUJ80VP5NQKzbfOEo75b69tCjgC1GaEe5XJ3d9pfwQ==; s=purelymail3; d=spwhitton.name; v=1; bh=3FW1B7pdKU/qggKNrGmbIbE/G2cgB9NVWBX3KPMRFpQ=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=dAa/D6f7Tdc+UiKYldwRrN0qF4MvQfu7umLINFOkgmJ33gkJYeAdSR2XAXrrtOlOddkcW2V8mfiT1H51GFO3YF0A3beDCNC0mzg3iMjtK7MimY6idS+XuQANgFWAq2lgxu//CHn4S3xq9yUBiTXbqf/SiIB1IUsU3o4EmjNIPziOfJL3H5BsIRWzDdCRrVcZ4xWyjGRxXcHx2jwmv8mK8Nh1iwCqRfmXLlFYrS+1n/omAvu/fxvMU3u00WPWp/OmRK34vAt01XDO83n48J0D54lS0RWmWmb7sJZX90pKJflwei2je2wgO8ADpZCU+AdZMiv4ARYvv3MDlH43J+xc9Q==; s=purelymail3; d=purelymail.com; v=1; bh=3FW1B7pdKU/qggKNrGmbIbE/G2cgB9NVWBX3KPMRFpQ=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79126@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -669229133; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 30 Jul 2025 11:04:07 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id A5F42940078; Wed, 30 Jul 2025 12:04:06 +0100 (BST) From: Sean Whitton In-Reply-To: References: Date: Wed, 30 Jul 2025 12:04:06 +0100 Message-ID: <877bzq3pp5.fsf@zephyr.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, On Wed 30 Jul 2025 at 05:36am +03, Dmitry Gutov wrote: > X-Debbugs-CC: spwhitton@spwhitton.name, sbaugh@janestreet.com > > Hi! > > If the current buffer does not visit a file (such as Dired, mentioned in a > FIXME comment), or if the current file has no corresponding on the other > worktree, we end up with an error. > > Like > > file-relative-name: Wrong type argument: stringp, nil > > or > > File =E2=80=98lisp/progmodes/abc.el=E2=80=99 not found in =E2=80=98~/vc= /emacs-28/=E2=80=99 > > I guess some of these could be improved in project-find-matching-file (su= pport > for more major modes?) but semantically it seems like vc-switch-working-t= ree > should try harder. Falling back to visiting the worktree root in Dired, i= f it > doesn't find a better choice. I was thinking I would implement switching between Dired directories and VC-Dir buffers in project-find-matching-file, yeah. Maybe when the file doesn't exist we could fall back to going only as high up the tree as we need to. So for example if foo/bar.el doesn't exist in the other worktree but foo/ does, invoking vc-switch-working-tree would go to a dired buffer visiting foo/. The last resort fallback could possibly be to call project-switch-project? --=20 Sean Whitton From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Jul 2025 12:31:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: sbaugh@janestreet.com, 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175387863322325 (code B ref 79126); Wed, 30 Jul 2025 12:31:03 +0000 Received: (at 79126) by debbugs.gnu.org; 30 Jul 2025 12:30:33 +0000 Received: from localhost ([127.0.0.1]:40192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh5x3-0005ny-6B for submit@debbugs.gnu.org; Wed, 30 Jul 2025 08:30:33 -0400 Received: from fout-b4-smtp.messagingengine.com ([202.12.124.147]:46229) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uh5wz-0005nc-RE for 79126@debbugs.gnu.org; Wed, 30 Jul 2025 08:30:31 -0400 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id 347501D00DDA; Wed, 30 Jul 2025 08:30:23 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Wed, 30 Jul 2025 08:30:23 -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:subject:subject:to:to; s=fm1; t=1753878623; x=1753965023; bh=NssqsMHPQPixXG8X5IUvyh7anARIPV+9gB/hTndtZv0=; b= OwWiMHsfr3uX1TpSvfykWRkdklqqr5OkT2lE4IbdtSR8wMrhMIH1jtYjeTFnRSji 4zu39Rt1Zfot4Q4qV9IhfuKo0dTBYnrdwPU2Mr/M+RKw5gkxJTsKRKFbpPvanRPB H/j6s3ys0jAiA6uga+ggzzCkg4Muq/Xf6she0A/GayIAyIz0YAKBbC8clQUKPNan 07MebboSIwhWNqCnYwcSI1sFJpMTg3V3XvstgE/uGe6z6SPWjTyFGy9b+5raw0pG SIPOFXIq6x7rFICUATJ1V7gcch8t0Uu51QH3LSHnsRMEPT4qaCUVnh5e1ocskrPw 1xjY+b/Bz1hbDA/Wrg8vJA== 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:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1753878623; x= 1753965023; bh=NssqsMHPQPixXG8X5IUvyh7anARIPV+9gB/hTndtZv0=; b=i VhIcRGjb9DbDJQiML4CTXvcheNN/sHwuuOrQw29JHEe53z6OsLTEaW7tqVMOH9dt 8nfnkuxZk49iD42Gc5CAkY4pnyXSkZsx7hnwNmXzyoNDNkzvLyw6aIE9VXwBStJO jlFcn81qBFEtGjJjgN31KS2n+Z0SKuYX2ujjW6y1CIM0VYtyyJjZePRxs7r182xw 71GZScw1pRh+Wy68/SylqA4/xPvbKkSXq3soEk0UDrX4ILiuidWc1zMj8XwbFvPD J1h1vLS+igKVs0Co1ajDfybn6A4UCMi+Y2Lu9vxK4hFrsqtZHROQ8zv//K6/ukjc CQBouevCm8G7zops2c6ug== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdeljeelfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomhepffhmihhtrhih ucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrghtthgvrh hnpeetudeljeegheetgfehgeejkeeuhedvveeikeeufedtvddtveefhfdvveegudejheen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegumhhith hrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtohepfedpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgvpd hrtghpthhtohepjeeluddvieesuggvsggsuhhgshdrghhnuhdrohhrghdprhgtphhtthho pehssggruhhghhesjhgrnhgvshhtrhgvvghtrdgtohhm X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 30 Jul 2025 08:30:21 -0400 (EDT) Message-ID: <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> Date: Wed, 30 Jul 2025 15:30:18 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird References: <877bzq3pp5.fsf@zephyr.silentflame.com> Content-Language: en-US From: Dmitry Gutov In-Reply-To: <877bzq3pp5.fsf@zephyr.silentflame.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 30/07/2025 14:04, Sean Whitton wrote: >> I guess some of these could be improved in project-find-matching-file (support >> for more major modes?) but semantically it seems like vc-switch-working-tree >> should try harder. Falling back to visiting the worktree root in Dired, if it >> doesn't find a better choice. > > I was thinking I would implement switching between Dired directories and > VC-Dir buffers in project-find-matching-file, yeah. Cool, either place sounds good to me. > Maybe when the file doesn't exist we could fall back to going only as > high up the tree as we need to. So for example if foo/bar.el doesn't > exist in the other worktree but foo/ does, invoking > vc-switch-working-tree would go to a dired buffer visiting foo/. Sounds reasonable. > The last resort fallback could possibly be to call project-switch-project? Probably not - it would show the prompt a second time, right? And the last step in the algorithm from the previous paragraph would visit the worktree root, I think, so there shouldn't be a scenario of a complete failure. From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Jul 2025 13:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: sbaugh@janestreet.com, Eshel Yaron , 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.1753881072506 (code B ref 79126); Wed, 30 Jul 2025 13:12:01 +0000 Received: (at 79126) by debbugs.gnu.org; 30 Jul 2025 13:11:12 +0000 Received: from localhost ([127.0.0.1]:40431 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh6aL-000081-An for submit@debbugs.gnu.org; Wed, 30 Jul 2025 09:11:11 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:39110) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uh6aF-00007G-4f for 79126@debbugs.gnu.org; Wed, 30 Jul 2025 09:11:07 -0400 DKIM-Signature: a=rsa-sha256; b=ThtrXYE7sfbrGEmYEWlq2UXMrdezocFOCGF829VrrHaqTiwCO0vwS7LPobuUB8+0y7uQ8g2m9s7UoaGIu2Niy1FqZk/Sch4gCTIJa5e34bzrEaHmBPsHgOe0D188vpeovFpQMV8XoRzgLbViVK3wbUzkAw3kqEmY3obLWhnzM1J90k3Gj2tLkiZIzK/W6sfOE3Bu86j+qwudtq7j6yXVA6Ok1bNfuQL7AWR6asYiXh8gDl7NjYaoKmXHbhPhUpOMPJDWLPmCyozUll5wyF3Rq/6yGh8JU3c4vWc1QuouLV6r1lvXWaYYXZ849cK5u6uFVOeyGRnj3YSV5SEDj4G4eg==; s=purelymail3; d=spwhitton.name; v=1; bh=r9bp73Xv+RA6C5R4FNG4t0fendWUOXS+LMDypdUielM=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=TNwEyEoC2/wk9nX7VERAi4Ne1qCbYNLTXh4sV/6/Kevfus+2Z58K11D3qAIE0XPozEPJ+MCx7nXm2KWRXtSSW1qWe0SNGs9VssqCHkt4lyUT+/2hiFomSbM/WKK2s0ePitp97zcqVPYozyRw18KKPxcu2C07i5Ewtm+ZcK1rJ4C/KuWmF5Dy5iKnzR7q5SqoBbs3g29Zdr5lzvhzHHZmUCj4fDA4JRoplvDimMiuAcYtrV+WPqAg8pR946iHKvWy27Fqz+tdrMUWS/4QQggS7iGt/f3HyHm68YIxbz5X+ayLwPZKxcJTUT4CNmV8hDLXNY+aI4fBYKL8ek+kIN2Vfw==; s=purelymail3; d=purelymail.com; v=1; bh=r9bp73Xv+RA6C5R4FNG4t0fendWUOXS+LMDypdUielM=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79126@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -1925911381; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 30 Jul 2025 13:10:55 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id 25F20940078; Wed, 30 Jul 2025 14:10:55 +0100 (BST) From: Sean Whitton In-Reply-To: <87ldo6b8rc.fsf@mail.eshelyaron.com> References: <87ldo6b8rc.fsf@mail.eshelyaron.com> Date: Wed, 30 Jul 2025 14:10:55 +0100 Message-ID: <87zfcl3jts.fsf@zephyr.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, On Wed 30 Jul 2025 at 06:30am +02, Eshel Yaron wrote: > FWIW, while incorporating this new feature in my Emacs branch, I've made > a few experimental tweaks that eliminate these errors. Namely, I added > a variable vc-switch-working-tree-function which vc-switch-working-tree > consults to do the actual switching. By default this variable is set to > a function that works for file-visiting buffers (similarly to the > current implementation in master), but major modes can readily set this > variable buffer-locally to provide worktree-switching support also for > non-file buffers. I used this indirection to support Dired buffers. Interesting, though it seems to me that instead of adding a whole new variable vc-switch-working-tree-function, someone could just write a custom command and bind that to 'C-x v w w'? Wouldn't that pretty much cover it? -- Sean Whitton From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 30 Jul 2025 13:42:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: Dmitry Gutov , Eshel Yaron , 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.17538828898331 (code B ref 79126); Wed, 30 Jul 2025 13:42:01 +0000 Received: (at 79126) by debbugs.gnu.org; 30 Jul 2025 13:41:29 +0000 Received: from localhost ([127.0.0.1]:40542 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uh73h-0002AI-4s for submit@debbugs.gnu.org; Wed, 30 Jul 2025 09:41:29 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:38187) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uh73c-00029o-00 for 79126@debbugs.gnu.org; Wed, 30 Jul 2025 09:41:25 -0400 From: Spencer Baugh In-Reply-To: <87zfcl3jts.fsf@zephyr.silentflame.com> (Sean Whitton's message of "Wed, 30 Jul 2025 14:10:55 +0100") References: <87ldo6b8rc.fsf@mail.eshelyaron.com> <87zfcl3jts.fsf@zephyr.silentflame.com> Date: Wed, 30 Jul 2025 09:41:18 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1753882878; bh=E2c4Jas0/KVPGM3TvyJPCp9rq5gzrB7uk9AlVjU1tCw=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=p92LL854lHra5zcGwD9fn/GT04+ipSz17aVof/lAjcywFOYDImkYLP8sqhp9geuo7 hSG4SwUZnzSM7GpQlSx71raBORK5W5ZHROiARSPaTgyF+E9iY77xVcB9Whfx6cwRpY 3l/AMN6t0P3l/DDM7uRqY9dcj62KfD5Uv2YR6WoD6yvt6F2uPGaR0DGevarodoBmF8 QRpQ+o7biY9i++NbDL2PJeJwLXOF57DuLXgwoFqwBgVtlRHXd+fZUymj0FStTUtEE2 QdpYgaXC5iclv7HLVdJk4Kfrjh7PcC69+MeeaGudhGy46cMtOCe9O+IAMGMHugBgua P/GUNLONNiz9g== X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Sean Whitton writes: > Hello, > > On Wed 30 Jul 2025 at 06:30am +02, Eshel Yaron wrote: > >> FWIW, while incorporating this new feature in my Emacs branch, I've made >> a few experimental tweaks that eliminate these errors. Namely, I added >> a variable vc-switch-working-tree-function which vc-switch-working-tree >> consults to do the actual switching. By default this variable is set to >> a function that works for file-visiting buffers (similarly to the >> current implementation in master), but major modes can readily set this >> variable buffer-locally to provide worktree-switching support also for >> non-file buffers. I used this indirection to support Dired buffers. > > Interesting, though it seems to me that instead of adding a whole new > variable vc-switch-working-tree-function, someone could just write a > custom command and bind that to 'C-x v w w'? Wouldn't that pretty much > cover it? No, because multiple other packages providing special buffers might want to integrate with the existing C-x v w w command. This sounds like a great idea to me, seems like it would be pretty nice. For example, we might want: - C-x v w w while in vc-dir brings you to vc-dir in the other worktree - C-x v w w while in project-eshell brings you to project-eshell in the other worktree - C-x v w w while in magit-status brings you to magit-status in the other worktree Also, at my site there is a custom "worktree/branch overview" buffer and it would be great if it was possible to make C-x v w w switch to the overview buffer for the other worktree. From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Aug 2025 10:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: sbaugh@janestreet.com, 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175439076713475 (code B ref 79126); Tue, 05 Aug 2025 10:47:02 +0000 Received: (at 79126) by debbugs.gnu.org; 5 Aug 2025 10:46:07 +0000 Received: from localhost ([127.0.0.1]:53813 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujFBH-0003VG-EW for submit@debbugs.gnu.org; Tue, 05 Aug 2025 06:46:07 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:52458) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujFBF-0003UO-Jv for 79126@debbugs.gnu.org; Tue, 05 Aug 2025 06:46:06 -0400 DKIM-Signature: a=rsa-sha256; b=UdKUTVcHXNWtcNrKreiQ9NGXHsfb0EzxtWFFV/4uV5v8CFcFCR2YIGTyhss4o1U/9SYMrmzuOerM7YwAzUfqouhiCHYU7E42OxEKS0gCGonnww/3RBgaklH33/meQ1cuOqUUFfhA2gTogYljVoN4A1gtOf1BRAflQM5I/o/4KBCTLrBdFxI6yI6wzuH+lCRLGg+AeFmvGYNVw9wgxwX+415X1D73f+nofXfLQ750GCA8Haoa6xv1eIwS31soNjGbmF3anqQc6AqXjknV/3/wwRldnRihMqt1SSjlDgTSe39a4iLV9xHeyWr2ppTlgyeyXdX9jJPBp2N41CCGlH6h9A==; s=purelymail3; d=spwhitton.name; v=1; bh=v36bqGNyUSsCOmsXMQVFjwMB+2gp2LCtVYL1RPopJ5w=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=JXeEMOhqIt/vr4CLL96qnysGxtQC3f1uQJip+DEl4A092tWe9ckvdRfxqZQCYtbkzL86n7WIH8Fd+OjPYUCkOJbhYMxII6aWBZ8TlqydYMmLSg93/ZfR7dtSdhvkJlXZtm60pOsXpyYgaWouaT6tcVS+9kISj1jao4V6MaolYN/6wAcdt0E6PMdR664feediKeyT+G9r1+ekArK7/+TaWvptgA3FLN4zBGKn9kwIZYMdsCJ87PY5O0+zIKUSDaMTdi5BRT7ONSFVVDds0ElENiOidP7JyXGWKHA5r6DSjKQuJeHhQ3kcvuvHn+7QFF7vgB6c9E0RGIYqy9zkT0g/mw==; s=purelymail3; d=purelymail.com; v=1; bh=v36bqGNyUSsCOmsXMQVFjwMB+2gp2LCtVYL1RPopJ5w=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79126@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id 1708809958; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 05 Aug 2025 10:45:57 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id 1AAE8940308; Tue, 05 Aug 2025 11:45:57 +0100 (BST) From: Sean Whitton In-Reply-To: <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> Date: Tue, 05 Aug 2025 11:45:57 +0100 Message-ID: <871ppqcahm.fsf@zephyr.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, On Wed 30 Jul 2025 at 03:30pm +03, Dmitry Gutov wrote: > On 30/07/2025 14:04, Sean Whitton wrote: > >>> I guess some of these could be improved in project-find-matching-file (support >>> for more major modes?) but semantically it seems like vc-switch-working-tree >>> should try harder. Falling back to visiting the worktree root in Dired, if it >>> doesn't find a better choice. >> I was thinking I would implement switching between Dired directories and >> VC-Dir buffers in project-find-matching-file, yeah. > > Cool, either place sounds good to me. > >> Maybe when the file doesn't exist we could fall back to going only as >> high up the tree as we need to. So for example if foo/bar.el doesn't >> exist in the other worktree but foo/ does, invoking >> vc-switch-working-tree would go to a dired buffer visiting foo/. > > Sounds reasonable. > >> The last resort fallback could possibly be to call project-switch-project? > > Probably not - it would show the prompt a second time, right? No, I mean calling project-switch-project non-interactively and passing it the root directory. Then the user would get some options of exactly what to do. > And the last step in the algorithm from the previous paragraph would visit the > worktree root, I think, so there shouldn't be a scenario of a complete > failure. True, but maybe failing all the way up to the root should be a special case. -- Sean Whitton From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Aug 2025 10:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh Cc: Dmitry Gutov , Eshel Yaron , 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175439085213650 (code B ref 79126); Tue, 05 Aug 2025 10:48:02 +0000 Received: (at 79126) by debbugs.gnu.org; 5 Aug 2025 10:47:32 +0000 Received: from localhost ([127.0.0.1]:53819 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujFCe-0003Y5-2Z for submit@debbugs.gnu.org; Tue, 05 Aug 2025 06:47:32 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:48214) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujFCb-0003Xp-5D for 79126@debbugs.gnu.org; Tue, 05 Aug 2025 06:47:29 -0400 DKIM-Signature: a=rsa-sha256; b=HJhmA0vjGF2YZxYMcH2UCZJbDwO3PRB/Q1cnc+GubbGjyNFeKP8Nww+RSVzD1Mrj761Ppnq9JYv2+E1/BS48hq8++4km8IrBJ858j3tXXDCTIMR3ZNg1hjc1CRamcmW+g8X6RgXBOJyjZcXbIYa6ehc0VIFG2kQ3TpRUtBcZmiKwhUQrwEurFznm3Ko+SJJkMkrVSl3IazMTkISKs0jAbYcIVDHdGnFIvX3+tB9XAhLKYWSYNLrMjFot1uaQAhPMtVoZxJJdXZTBPnReolzd2V38GISWR7cog6yySr2TWikLMjpQwR3Z8VUIXSNHC9f1CvN6yWiVu5fyXX8u4DfyIA==; s=purelymail3; d=spwhitton.name; v=1; bh=A5A0tvjI38K/TMwdVswl3qlIFYuPHI/hNKcCDwuQaxY=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=YLcRzvBVhIcsFIKClSxVUwwC5Jfj+Gmo2vtp7cIj+GFm4yCXzFO06hLtNVVTGqotryl1KFWxvtc0x9rREnKWE2V3gwXr4tKfx5zWpgspib9+AQwmc7QZtiRb0dOZq3TKSjxC8VQ2r2yYyRMrSslkHvjautyNxzyRAcTWm/ZPlNygyGrepySFlj/6VKPkj10nMbXTtvFYL5BL535t6F8S2rwbBo/XDRCwwykKLV/UQFpk7+KHE1VJsegA3cctvZ40Z4wvZ6V/6mkN0RASWcan16/8VPrUQhgAuq+sUOMiBVCeZQuammYCeGydG5+frwVg4jj95zXght+TB8JMdR4mCQ==; s=purelymail3; d=purelymail.com; v=1; bh=A5A0tvjI38K/TMwdVswl3qlIFYuPHI/hNKcCDwuQaxY=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79126@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id 1517769505; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Tue, 05 Aug 2025 10:47:23 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id C6F7A940308; Tue, 05 Aug 2025 11:47:22 +0100 (BST) From: Sean Whitton In-Reply-To: References: <87ldo6b8rc.fsf@mail.eshelyaron.com> <87zfcl3jts.fsf@zephyr.silentflame.com> Date: Tue, 05 Aug 2025 11:47:22 +0100 Message-ID: <87wm7iavut.fsf@zephyr.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, On Wed 30 Jul 2025 at 09:41am -04, Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote: > Sean Whitton writes: >> Hello, >> >> On Wed 30 Jul 2025 at 06:30am +02, Eshel Yaron wrote: >> >>> FWIW, while incorporating this new feature in my Emacs branch, I've made >>> a few experimental tweaks that eliminate these errors. Namely, I added >>> a variable vc-switch-working-tree-function which vc-switch-working-tree >>> consults to do the actual switching. By default this variable is set to >>> a function that works for file-visiting buffers (similarly to the >>> current implementation in master), but major modes can readily set this >>> variable buffer-locally to provide worktree-switching support also for >>> non-file buffers. I used this indirection to support Dired buffers. >> >> Interesting, though it seems to me that instead of adding a whole new >> variable vc-switch-working-tree-function, someone could just write a >> custom command and bind that to 'C-x v w w'? Wouldn't that pretty much >> cover it? > > No, because multiple other packages providing special buffers might want > to integrate with the existing C-x v w w command. Ah, are you thinking they would do this by using add-function on vc-switch-working-tree-function? > This sounds like a great idea to me, seems like it would be pretty nice. > > For example, we might want: > - C-x v w w while in vc-dir brings you to vc-dir in the other worktree > - C-x v w w while in project-eshell brings you to project-eshell in the > other worktree > - C-x v w w while in magit-status brings you to magit-status in the other > worktree > > Also, at my site there is a custom "worktree/branch overview" buffer and > it would be great if it was possible to make C-x v w w switch to the > overview buffer for the other worktree. Let's make sure we can support all these, indeed. -- Sean Whitton From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Aug 2025 11:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: Dmitry Gutov , Eshel Yaron , 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.1754393710642 (code B ref 79126); Tue, 05 Aug 2025 11:36:01 +0000 Received: (at 79126) by debbugs.gnu.org; 5 Aug 2025 11:35:10 +0000 Received: from localhost ([127.0.0.1]:53911 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujFwj-0000AD-Ik for submit@debbugs.gnu.org; Tue, 05 Aug 2025 07:35:10 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:35449) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujFwg-00009U-Op for 79126@debbugs.gnu.org; Tue, 05 Aug 2025 07:35:07 -0400 Received: from mail-ej1-f71.google.com ([209.85.218.71]) by mxgoog2.mail.janestreet.com with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) (Exim 4.98.2) id 1ujFwZ-00000007aXa-3vyE for 79126@debbugs.gnu.org; Tue, 05 Aug 2025 07:35:00 -0400 Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-ae98864f488so522625766b.0 for <79126@debbugs.gnu.org>; Tue, 05 Aug 2025 04:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=google; t=1754393699; x=1754998499; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Kvn5xWIZLmOArsTBcOqdkyjYsrjRh8rfNKP+ClLugxQ=; b=ZTzFq972T1DMb9wY5/oTv1IupBOQvMPJ043AwhcwJYZvCQlbKr77mCchmLeI5v9WHv EHpjCql6yDTbyA61iQZ7KME7UmcnHb93UHDNMIFwf7Y4MHPTl0ZalATF4AfgJ19jT+0x 7588nyJOqnXVlSWvM2mm/KEbZ/HdsED43UZkg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1754393700; bh=Kvn5xWIZLmOArsTBcOqdkyjYsrjRh8rfNKP+ClLugxQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc; b=dtxNvHpJpPT04dqyHt/8MDSb3yWtA+x3d+Mu99Ndk0YcHxHMvqnl+r7Ia3M5DipwY g4HGgy+2n/qhMg+fjozMMEvNz2j8eQ8qvyiJpjtYzsKMY1ACXCfhSouPwPHWg7/xc9 1l+5S86HJtqNLs4Up4vboemCpdl6GBxj8dpgGRMuAdPIUEvd36y8YeMp6noVTDH9Cb lxG8L1wUylasqWz4ZF7Ws85sgKfAd0RjfIJWVQdrwlMAvkwAKdKU69mgrbS7VMY1lJ qcwF52eGdU0YnOeqOyMA4nvaTZ7nrgE3IQWTROWu21Zl0cGNNXS7lBIQ1PxfHrbb79 nsxd+zbD/BCTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754393699; x=1754998499; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Kvn5xWIZLmOArsTBcOqdkyjYsrjRh8rfNKP+ClLugxQ=; b=mn3DijvIdJxVjtoRwI8IqaSC3elEP662kjhbbKrDIz6s7dG1RM3LX+80Jyq5K8fEjS tNpvNm2anqY7StDTJBuuQGItBs5rDGJ7/ONtWtAAqKFd/pLpZV0M/2PcSLkNOys6Cl3f WYyX9+6BIZXYNUqsXOQrV75IuJNZZLfJe1vmjz5lZ4UOPLoXXZL2Iaf6ELpqDbja4Ur3 piY9GztVGyvFbVUkJQI97dJdWvcMxopP4qzKtxHvSq0QpAi7pSX338TGvvRq8dnToA36 g8jRAatXIaI/QqsxmZB8bran1bSBFUdMTD5jgRA98QgIE8/gwbqc9Ye8KPi9EMVi/SK6 UcLw== X-Forwarded-Encrypted: i=1; AJvYcCV7GHbtslegg5uML762W31blG+0yLPkAo2DR0RLgCJtNeSbd/YSqWr7XYawEVQoiYWIvRd8/w==@debbugs.gnu.org X-Gm-Message-State: AOJu0YzRKXnrBzVKuVl62SwjyDt5Audm5O55pzQ/tyC24G3l0W/1+tvV IxC9tvbtctWTQr3rVvPrfS+BjNHNwhs+C/86UDVasTwMxXRB2VKfytqaOmJxW3BvVQXpYMAXIlg B5YSTzbLhCIhBmHyYQ59NhtdOmkSVi1NJ8vedlQgxYzNlJPWYewydqmkrVFFPfmSx50QHuOXQya /aI9byslLH4DQeux2EvYe+l9wg0hrTCw== X-Gm-Gg: ASbGnctbNZGDKU21tpGZUawstBg/7h79FCfiiAb5iJzKLULt3QSg4jPbe+u9aWJpvJH 9ZZgVVKzuNraLeNKp5uJB/oP2kYwt95+PbCKwP99DLh78X4PMkMR5LYIX7C23rP8grYb1Q09IW5 8QOYSGOCZuAG+2LwoXXoSp X-Received: by 2002:a17:907:97c1:b0:af9:8064:21e3 with SMTP id a640c23a62f3a-af9806424c3mr268009966b.56.1754393699488; Tue, 05 Aug 2025 04:34:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE4ez1bKDMr/MkdcjrFdN3NgvKaWy+ntHa/DQgYIedqgF0nozCLlWhU3oj7Wufu+8Njx7t/L91iLDKgYdhsLZ8= X-Received: by 2002:a17:907:97c1:b0:af9:8064:21e3 with SMTP id a640c23a62f3a-af9806424c3mr268007066b.56.1754393699040; Tue, 05 Aug 2025 04:34:59 -0700 (PDT) MIME-Version: 1.0 References: <87ldo6b8rc.fsf@mail.eshelyaron.com> <87zfcl3jts.fsf@zephyr.silentflame.com> <87wm7iavut.fsf@zephyr.silentflame.com> In-Reply-To: <87wm7iavut.fsf@zephyr.silentflame.com> From: Spencer Baugh Date: Tue, 5 Aug 2025 07:34:49 -0400 X-Gm-Features: Ac12FXyPxqJglseY8PsFrlgavvVoLLoaEfXW-UagsMQVsIuCRbCbr1ICDboL9CI Message-ID: Content-Type: multipart/alternative; boundary="0000000000003a5982063b9c9ddd" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --0000000000003a5982063b9c9ddd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Aug 5, 2025, 6:47=E2=80=AFAM Sean Whitton wrote: > Hello, > > On Wed 30 Jul 2025 at 09:41am -04, Spencer Baugh via "Bug reports for GNU > Emacs, the Swiss army knife of text editors" wrote: > > > Sean Whitton writes: > >> Hello, > >> > >> On Wed 30 Jul 2025 at 06:30am +02, Eshel Yaron wrote: > >> > >>> FWIW, while incorporating this new feature in my Emacs branch, I've > made > >>> a few experimental tweaks that eliminate these errors. Namely, I add= ed > >>> a variable vc-switch-working-tree-function which vc-switch-working-tr= ee > >>> consults to do the actual switching. By default this variable is set > to > >>> a function that works for file-visiting buffers (similarly to the > >>> current implementation in master), but major modes can readily set th= is > >>> variable buffer-locally to provide worktree-switching support also fo= r > >>> non-file buffers. I used this indirection to support Dired buffers. > >> > >> Interesting, though it seems to me that instead of adding a whole new > >> variable vc-switch-working-tree-function, someone could just write a > >> custom command and bind that to 'C-x v w w'? Wouldn't that pretty muc= h > >> cover it? > > > > No, because multiple other packages providing special buffers might wan= t > > to integrate with the existing C-x v w w command. > > Ah, are you thinking they would do this by using add-function on > vc-switch-working-tree-function? > No, just by setting that variable buffer locally. > --0000000000003a5982063b9c9ddd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Aug 5, 2025, 6:47=E2=80= =AFAM Sean Whitton <spwhitto= n@spwhitton.name> wrote:
Hel= lo,

On Wed 30 Jul 2025 at 09:41am -04, Spencer Baugh via "Bug reports for = GNU Emacs, the Swiss army knife of text editors" wrote:

> Sean Whitton <spwhitton@spwhitton.name> writes:
>> Hello,
>>
>> On Wed 30 Jul 2025 at 06:30am +02, Eshel Yaron wrote:
>>
>>> FWIW, while incorporating this new feature in my Emacs branch,= I've made
>>> a few experimental tweaks that eliminate these errors.=C2=A0 N= amely, I added
>>> a variable vc-switch-working-tree-function which vc-switch-wor= king-tree
>>> consults to do the actual switching.=C2=A0 By default this var= iable is set to
>>> a function that works for file-visiting buffers (similarly to = the
>>> current implementation in master), but major modes can readily= set this
>>> variable buffer-locally to provide worktree-switching support = also for
>>> non-file buffers.=C2=A0 I used this indirection to support Dir= ed buffers.
>>
>> Interesting, though it seems to me that instead of adding a whole = new
>> variable vc-switch-working-tree-function, someone could just write= a
>> custom command and bind that to 'C-x v w w'?=C2=A0 Wouldn&= #39;t that pretty much
>> cover it?
>
> No, because multiple other packages providing special buffers might wa= nt
> to integrate with the existing C-x v w w command.

Ah, are you thinking they would do this by using add-function on
vc-switch-working-tree-function?

No, just by setting that variable buffer lo= cally.
--0000000000003a5982063b9c9ddd-- From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Aug 2025 12:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh Cc: Dmitry Gutov , 79126@debbugs.gnu.org, Sean Whitton Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.17543955116750 (code B ref 79126); Tue, 05 Aug 2025 12:06:01 +0000 Received: (at 79126) by debbugs.gnu.org; 5 Aug 2025 12:05:11 +0000 Received: from localhost ([127.0.0.1]:53960 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujGPm-0001ke-Th for submit@debbugs.gnu.org; Tue, 05 Aug 2025 08:05:11 -0400 Received: from mail.eshelyaron.com ([107.175.124.16]:33294 helo=eshelyaron.com) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujGPk-0001hu-BT for 79126@debbugs.gnu.org; Tue, 05 Aug 2025 08:05:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1754395507; bh=AXzz1e2TYg8FnA2mWo2DugAA3g7SHo6UCU3Rs2TKnCU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=kWfyAND3u9o0KdYZVKuQWhiWUI+MvV/ADoTr8fuMCf6tnXpK9kswf7L2kqoMKBgE8 W+CNY7M6HMqJcbmXOVbJ2Kw7Fn6wXfi9eQ9IyBuTfjQ6PMYS/xdGBwKsuIFC8LpdFi urmRm8Xd4QfHQhG+TSCxp1UltixoRpQTjjn88C+oCE36DJlbX1OgQIE7w3rNanktnO +kpVtxzIrgDByvjlUfWDHeI9MblLvYiKDNJLpniRo/gRnXg5eb5jYLLLmHOCCGwRfA AvwTUosoJBGUjpHt4FtpcZ5w2phgLP2RCX2fL1+57I+3k+jRqG0ufthTmUevu/I6+I 5fiBvxe2zCRIg== From: Eshel Yaron In-Reply-To: References: <87ldo6b8rc.fsf@mail.eshelyaron.com> <87zfcl3jts.fsf@zephyr.silentflame.com> <87wm7iavut.fsf@zephyr.silentflame.com> Date: Tue, 05 Aug 2025 14:05:02 +0200 Message-ID: <87y0ry3rf5.fsf@mail.eshelyaron.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Spencer Baugh writes: > On Tue, Aug 5, 2025, 6:47=E2=80=AFAM Sean Whitton wrote: > > Hello, > > On Wed 30 Jul 2025 at 09:41am -04, Spencer Baugh via "Bug reports for GN= U Emacs, the Swiss army > knife of text editors" wrote: > > > Sean Whitton writes: > >> Hello, > >> > >> On Wed 30 Jul 2025 at 06:30am +02, Eshel Yaron wrote: > >> > >>> FWIW, while incorporating this new feature in my Emacs branch, I've = made > >>> a few experimental tweaks that eliminate these errors. Namely, I ad= ded > >>> a variable vc-switch-working-tree-function which vc-switch-working-t= ree > >>> consults to do the actual switching. By default this variable is se= t to > >>> a function that works for file-visiting buffers (similarly to the > >>> current implementation in master), but major modes can readily set t= his > >>> variable buffer-locally to provide worktree-switching support also f= or > >>> non-file buffers. I used this indirection to support Dired buffers. > >> > >> Interesting, though it seems to me that instead of adding a whole new > >> variable vc-switch-working-tree-function, someone could just write a > >> custom command and bind that to 'C-x v w w'? Wouldn't that pretty mu= ch > >> cover it? > > > > No, because multiple other packages providing special buffers might wa= nt > > to integrate with the existing C-x v w w command. > > Ah, are you thinking they would do this by using add-function on > vc-switch-working-tree-function? > > No, just by setting that variable buffer locally. Exactly, that'd be the usual way to use this variable. Eshel From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Aug 2025 12:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: sbaugh@janestreet.com, 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175439703417983 (code B ref 79126); Tue, 05 Aug 2025 12:31:02 +0000 Received: (at 79126) by debbugs.gnu.org; 5 Aug 2025 12:30:34 +0000 Received: from localhost ([127.0.0.1]:54007 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujGoL-0004ep-LP for submit@debbugs.gnu.org; Tue, 05 Aug 2025 08:30:34 -0400 Received: from fhigh-b8-smtp.messagingengine.com ([202.12.124.159]:33547) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujGoI-0004IJ-Dy for 79126@debbugs.gnu.org; Tue, 05 Aug 2025 08:30:31 -0400 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id 97F767A0257; Tue, 5 Aug 2025 08:30:24 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Tue, 05 Aug 2025 08:30:24 -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:subject:subject:to:to; s=fm2; t=1754397024; x=1754483424; bh=CJKlkgMfVYv6Uw3I2K5fRg3v01V0DMHXYoLIlAiY2hs=; b= K/qKtt/61FN6ss0HyIHPuxVARemXGzVI4Yi//wpyic99x49a2gB6fNqera58CXY/ 7xzsgw2RHSMmIA3bV7E7G5XXQPB6L8bu0S/LQ0PmfaBomzBa6y3SCTtPymruzimz Xoh3ipU2zbD60tVSEyWLKl7Gc24iGTc4ReMezKVwjFuWRCVZ8bZpM2kPnAhWC0nM xLmPej3O8VLkLqcJyG3QN3KHK0LpM3HsmHuep9jfQgSqEqs27AP2zztkMOK0Cwoi 62sw8rkt4VaF2zLdNYAUNcCUqO5jqUoA1KzRajQwqarIr3u8uzUJnDVjPq/Cm/9u 57aVuw+Cma2NFNYLqc1lmA== 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:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1754397024; x= 1754483424; bh=CJKlkgMfVYv6Uw3I2K5fRg3v01V0DMHXYoLIlAiY2hs=; b=P hlJIS034gKO420Xd8IU+W2f6f49rQaNdm0VNhftHEfQjTZzsIYvmMMVblTxZFGdx 0kvrjrh/PXp8p2WOz5zgrW0AZsqTkeATOTJEUy1gGkSJCwgXfcwHG2+IN/8k+gd3 pLJwatPPcLKddQD2JmDs2ip/mATCYN9vnochGQBKFiR5rIr/Xy1sHnqYCFPfy9u5 GRxLXH8mw1bgwniI+rxyL9Reyw/CWQIsXx/EDYf8ytknJ3YobXqdEtS6xd9cF378 +ze/9xIu+cBete1HclfxvwuAiGx6cgsKqdwfZtowyXtL0emPi/9iLGltee4mshxT uEoIOpW50E2Ub35Y3UgvQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduudehudekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeffmhhithhr hicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrthhtvg hrnhepteduleejgeehtefgheegjeekueehvdevieekueeftddvtdevfefhvdevgedujeeh necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepughmih htrhihsehguhhtohhvrdguvghvpdhnsggprhgtphhtthhopeefpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvg dprhgtphhtthhopehssggruhhghhesjhgrnhgvshhtrhgvvghtrdgtohhmpdhrtghpthht ohepjeeluddvieesuggvsggsuhhgshdrghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 5 Aug 2025 08:30:22 -0400 (EDT) Message-ID: <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> Date: Tue, 5 Aug 2025 15:30:21 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> Content-Language: en-US From: Dmitry Gutov In-Reply-To: <871ppqcahm.fsf@zephyr.silentflame.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 05/08/2025 13:45, Sean Whitton wrote: >>> The last resort fallback could possibly be to call project-switch-project? >> Probably not - it would show the prompt a second time, right? > No, I mean calling project-switch-project non-interactively and passing > it the root directory. Then the user would get some options of exactly > what to do. Adhering to project-switch-commands might be a fine idea, indeed. Although I'd probably prefer to just use Dired, myself. >> And the last step in the algorithm from the previous paragraph would visit the >> worktree root, I think, so there shouldn't be a scenario of a complete >> failure. > True, but maybe failing all the way up to the root should be a special > case. Semantically, just going by the command's name, it seems to me that switching to a different directory is the key part of its behavior, and finding a corresponding file - a secondary one. Perhaps we'll want to add a command called 'vc-worktree-find-matching-file'? From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Aug 2025 14:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov , Spencer Baugh , Eshel Yaron Cc: 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.17544893194386 (code B ref 79126); Wed, 06 Aug 2025 14:09:01 +0000 Received: (at 79126) by debbugs.gnu.org; 6 Aug 2025 14:08:39 +0000 Received: from localhost ([127.0.0.1]:59559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujeoo-00018e-4a for submit@debbugs.gnu.org; Wed, 06 Aug 2025 10:08:38 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:36258) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujeoa-000189-D7 for 79126@debbugs.gnu.org; Wed, 06 Aug 2025 10:08:33 -0400 DKIM-Signature: a=rsa-sha256; b=BUrRotMS/Fdw90jdApo9wu0IyBHH0kPoqusIpqkNxOe26aj7PQKfeVtrSYMOqDt8beM3cQNjT89Nhk9CSQE5ZXWzrQS50Rec30NFpqelWXzyYEUB7amaA6DP7AQoc9wBWvoy8Anl/L26g9jKXBawx8jXs14S6lrXZNXkqT3nrGurcuHMqNoPpt0Tde3OOdcd1BEGj8VDOfT03qjj3VSeQDwNMQbRFGIaQKrkkg6YZTPNeh1aDPY4paKOTk0fjjxfnWL4HIVRg97sT58qBmbJvyd7DIVuOeQXaB0BHKPyL4e62Pt/8J7pSUGlNrAKMv8YR7jzDkKAN7Vh3F4wXoQP6w==; s=purelymail1; d=spwhitton.name; v=1; bh=08ie43IPqcNU2eKA8PKqGg7s+fFVCOdX/KitMWdq2LI=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=hI2szrlMTdrVFKRpg484YJ/IBDPInFtW1YbLquePJFsNotv7Ho6nklq+gWpjUzg6nk5u7DRj909Gdd1MwywUaToKDSpqToAwY6WJlVsj/92WiWsmJfZiYWUKZ6zxTKtTL226aZs+PF/3n7TFpOoxXnPckwLhwgIWMDfscvFQQ6iM9MAi2EbiGpmBwzOtCAe68t9CP8Z9UvTSLvgT5AQlYc2AUL9Q/zZ2rBSQUOxaAq2Pc3ivnnI/9LHBWJ0aLLFjYPv1D05n0PTgGwrgGydkojOYcZQt3k+RDueq+u9FQ51+Qx+QCZr69I0usTvyjAirituUoGbivxaLxF8WdI7yWQ==; s=purelymail1; d=purelymail.com; v=1; bh=08ie43IPqcNU2eKA8PKqGg7s+fFVCOdX/KitMWdq2LI=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79126@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -2095678017; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 06 Aug 2025 14:08:17 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id 3BF11940925; Wed, 06 Aug 2025 15:08:17 +0100 (BST) From: Sean Whitton In-Reply-To: <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> Date: Wed, 06 Aug 2025 15:08:17 +0100 Message-ID: <87ldnw7dbi.fsf@zephyr.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hello, Thank you all for the comments. Please find attached an implementation. On Tue 05 Aug 2025 at 03:30pm +03, Dmitry Gutov wrote: > On 05/08/2025 13:45, Sean Whitton wrote: >>>> The last resort fallback could possibly be to call project-switch-project? >>> Probably not - it would show the prompt a second time, right? >> No, I mean calling project-switch-project non-interactively and passing >> it the root directory. Then the user would get some options of exactly >> what to do. > > Adhering to project-switch-commands might be a fine idea, indeed. Although I'd > probably prefer to just use Dired, myself. Skipped that idea for now. >>> And the last step in the algorithm from the previous paragraph would visit the >>> worktree root, I think, so there shouldn't be a scenario of a complete >>> failure. >> True, but maybe failing all the way up to the root should be a special >> case. > > Semantically, just going by the command's name, it seems to me that switching > to a different directory is the key part of its behavior, and finding a > corresponding file - a secondary one. > > Perhaps we'll want to add a command called 'vc-worktree-find-matching-file'? I've done it within project-find-matching-file for now but am certainly open to renaming that function or moving things around -- let me know what you think. -- Sean Whitton --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Generalize-project-find-matching-file-to-other-major.patch >From a458eb6a117408821c7ec304c7bef60cf4a544ab Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 6 Aug 2025 15:05:08 +0100 Subject: [PATCH] Generalize project-find-matching-file to other major modes * lisp/progmodes/project.el (dired-current-directory): Declare. (project-find-matching-file): Handle Dired buffers (bug#79126). When matching file/directory does not exist, try going up in the directory tree until finding something that does. (project-find-matching-buffer-function): New variable. * etc/NEWS: Announce it. * lisp/vc/vc.el (vc-switch-working-tree): Use it (bug#79126). (project-current-directory-override): Declare. --- etc/NEWS | 5 +++ lisp/progmodes/project.el | 85 ++++++++++++++++++++++++++++++--------- lisp/vc/vc.el | 5 ++- 3 files changed, 73 insertions(+), 22 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index a34a3d73292..b5555d8e042 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -472,6 +472,11 @@ It can be used when switching between projects with similar file trees (such as Git worktrees of the same repository). It supports being invoked standalone or from the 'project-switch-commands' dispatch menu. +--- +*** New variable 'project-find-matching-buffer-function'. +Major modes can set this to major mode-specific versions of +'project-find-matching-file', to find appropriate matching buffers. + +++ *** New user option 'project-list-exclude'. This user option describes projects that should always be skipped by diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index dafc01c7684..367e7cf86dc 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1307,33 +1307,78 @@ project-find-file-in (user-error "You didn't specify the file") (find-file file)))) +;; The default value works for file-visiting and Dired buffers. +;; Non-file-visiting major modes (other than `dired-mode'), where there +;; is a sensible notion of a matching buffer, can set this. +;; File-visiting major modes shouldn't set it, except possibly some +;; highly specialized ones. +(defvar project-find-matching-buffer-function #'project-find-matching-file + "Function to switch to a matching buffer in another project. +Usually set buffer-locally by non-file-visiting major modes. +The function will be called with no arguments. If the other project is +already determined, `project-current-directory-override' will be bound +to a directory under that other project. Otherwise the function should +prompt for the other project, usually with `project-read-project'.") + +(declare-function dired-current-directory "dired") + ;;;###autoload (defun project-find-matching-file () - "Visit the file that matches the current one, in another project. -It will skip to the same line number as well. -A matching file has the same file name relative to the project root. + "Visit file or directory in another project that matches the current one. +A matching file, or Dired buffer's matching directory, has the same file +name relative to the project root. +Also skip to the same line number. + +If the matching file does not exist in the other project, try going up +in the directory tree until encountering a file or directory that +exists. For example, from a buffer visiting a file \"lisp/vc/vc.el\", +if in the other project this file does not exist, try visiting +\"lisp/vc\" if that exists as a file or directory. + +If a Dired buffer's matching directory does not exist in the other +project, try going up in the directory tree until encountering a +directory that exists. For example, from a buffer visiting a +subdirectory named \"lisp/vc/\", if in the other project \"lisp/vc\" is +missing or not a directory, try visiting a directory named \"lisp/\" in +the other project. + When called during switching to another project, this command will detect it and use the override. Otherwise, it prompts for the project -to use from the known list." +to use from the list of known projects." (interactive) (let* ((pr (project-current)) (line (line-number-at-pos nil t)) - relative-name mirror-name) - (if project-current-directory-override - (let* (project-current-directory-override - (real-project (project-current t))) - (setq relative-name (file-relative-name buffer-file-name - (project-root real-project)))) - (setq relative-name (file-relative-name buffer-file-name (project-root pr))) - (setq pr (project-read-project))) - (setq mirror-name (expand-file-name relative-name (project-root pr))) - (if (not (file-exists-p mirror-name)) - (user-error "File `%s' not found in `%s'" relative-name (project-root pr)) - (find-file mirror-name) - (save-restriction - (widen) - (goto-char (point-min)) - (forward-line (1- line)))))) + (dirp (derived-mode-p 'dired-mode)) + (relative-name + (file-relative-name (cond + (dirp (dired-current-directory)) + ((buffer-file-name)) + (t (error "Don't know how to find matching buffer"))) + (if project-current-directory-override + (let (project-current-directory-override) + (project-root (project-current t))) + (prog1 (project-root pr) + (setq pr (project-read-project)))))) + (mirror-name (expand-file-name relative-name (project-root pr))) + (orig-mirror-name mirror-name) + (root (project-root pr))) + (while (not (if dirp (file-directory-p mirror-name) + (file-exists-p mirror-name))) + (setq mirror-name (directory-file-name + (file-name-parent-directory mirror-name))) + (unless (file-in-directory-p mirror-name root) + (user-error "`%s' not found in `%s'" relative-name root))) + (find-file mirror-name) + (save-restriction + (widen) + (goto-char (point-min)) + (forward-line (1- line))) + (unless (equal mirror-name orig-mirror-name) + (message "`%s' not found; visiting `%s' instead" + (abbreviate-file-name orig-mirror-name) + (abbreviate-file-name (if (file-directory-p mirror-name) + (file-name-as-directory mirror-name) + mirror-name)))))) (defun project--completing-read-strict (prompt collection &optional predicate diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 3ba01210667..9dab054da47 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -4425,6 +4425,7 @@ vc--prompt-other-working-tree t))) (defvar project-current-directory-override) +(defvar project-find-matching-buffer-function) ;;;###autoload (defun vc-switch-working-tree (directory) @@ -4434,13 +4435,13 @@ vc-switch-working-tree This command switches to the file which has the same file name relative to DIRECTORY that this buffer's file has relative to the root of this working tree." - ;; FIXME: Switch between directory analogues, too, in Dired buffers. (interactive (list (vc--prompt-other-working-tree (vc-responsible-backend default-directory) "Other working tree to visit"))) + (require 'project) (let ((project-current-directory-override directory)) - (project-find-matching-file))) + (funcall project-find-matching-buffer-function))) ;;;###autoload (defun vc-delete-working-tree (backend directory) -- 2.47.2 --=-=-=-- From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Aug 2025 14:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton , Spencer Baugh , Eshel Yaron Cc: 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175449108410260 (code B ref 79126); Wed, 06 Aug 2025 14:39:02 +0000 Received: (at 79126) by debbugs.gnu.org; 6 Aug 2025 14:38:04 +0000 Received: from localhost ([127.0.0.1]:59651 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujfHH-0002fP-BM for submit@debbugs.gnu.org; Wed, 06 Aug 2025 10:38:03 -0400 Received: from fout-a3-smtp.messagingengine.com ([103.168.172.146]:50977) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujfHD-0002er-Kk for 79126@debbugs.gnu.org; Wed, 06 Aug 2025 10:38:00 -0400 Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id E86D4EC006C; Wed, 6 Aug 2025 10:37:53 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Wed, 06 Aug 2025 10:37:53 -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:subject:subject:to:to; s=fm2; t=1754491073; x=1754577473; bh=q4hUTmxsgbXQ254KqmSCLgTO4OaXQqTJG7TnCcNlpDM=; b= VEHDYlx1hYMmJXycxx05BXvaoXB/NiJC/tDM8gK1LPcJ2DTLs2jHKxdJsCMezwqK RDeuIQWhsumeV2sbHq457ohZhLLhuFURRV6rBHikDU4jx8yByVr123XgKusriSTi oDkErS1xv24B0GjGp4ZDrMdMpDBuetoKJ6kM7HmQU3FYlIa4XEp4FzmpRxhc0n/8 3EyZ69X2Ywbt6iXLqErbngLxQTPzw4KYzggWTRjRPcRfCOZaOsgJO91Q1mo13uMU 0oVGHea3Wu4dAM5SGK4rjmSU0vno37/UmHrj5MoHX97fou6srGyEEuk4BABJycgn Tn0ekm0tG64vmcptqNRIIg== 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:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1754491073; x= 1754577473; bh=q4hUTmxsgbXQ254KqmSCLgTO4OaXQqTJG7TnCcNlpDM=; b=P b6oN5yps04Fo/h7MZCBAmWxVYxnZuBSHDNNw5yDT8no2tGK9u5rZ+MFPLTy3p7zm KR4D0XHHVbCQC/s7GvDB7C/YL0squs7zyoDWek4zw9kga3M7hAqQfssOxdo2/L/u Om45qWp71xxdo7de9fwI1/gRLbQBnoweb9OiqZ4jlLFP9XRr6AHxBOhJDZPooSjP 4vuZAgfR7cNwswBxul4jUTfEkZoHNABaj/f27+5+n7G/qiWldim2M1ygtXLPLEfB tQW+YRLyVBEBdWZKFmb+GSbCKmAFDLEoc6z9TcB92F0Qr1iW3aPKUAboSCStiZgB noFvPg+SqACV16u+W+F+Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduudekfeduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeffmhhithhr hicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrthhtvg hrnhepteduleejgeehtefgheegjeekueehvdevieekueeftddvtdevfefhvdevgedujeeh necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepughmih htrhihsehguhhtohhvrdguvghvpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvg dprhgtphhtthhopehssggruhhghhesjhgrnhgvshhtrhgvvghtrdgtohhmpdhrtghpthht ohepmhgvsegvshhhvghlhigrrhhonhdrtghomhdprhgtphhtthhopeejleduvdeiseguvg gssghughhsrdhgnhhurdhorhhg X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Aug 2025 10:37:51 -0400 (EDT) Message-ID: <8a128dc7-a3e7-44c4-ba7c-d132eef6948a@gutov.dev> Date: Wed, 6 Aug 2025 17:37:50 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> <87ldnw7dbi.fsf@zephyr.silentflame.com> Content-Language: en-US From: Dmitry Gutov In-Reply-To: <87ldnw7dbi.fsf@zephyr.silentflame.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 06/08/2025 17:08, Sean Whitton wrote: > +;; The default value works for file-visiting and Dired buffers. > +;; Non-file-visiting major modes (other than `dired-mode'), where there > +;; is a sensible notion of a matching buffer, can set this. > +;; File-visiting major modes shouldn't set it, except possibly some > +;; highly specialized ones. > +(defvar project-find-matching-buffer-function #'project-find-matching-file > + "Function to switch to a matching buffer in another project. > +Usually set buffer-locally by non-file-visiting major modes. > +The function will be called with no arguments. If the other project is > +already determined, `project-current-directory-override' will be bound > +to a directory under that other project. Otherwise the function should > +prompt for the other project, usually with `project-read-project'.") How about we try to simplify that hook? The command will check whether there is an overriding project and pass that value as an argument to project-find-matching-buffer-function. Or just the root directory, is that is simpler. Or two arguments: current-root and new-root. That should cut the default function's definition by about a third, and do even better for the specialized ones. From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Aug 2025 16:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov Cc: Eshel Yaron , 79126@debbugs.gnu.org, Sean Whitton Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175449641826578 (code B ref 79126); Wed, 06 Aug 2025 16:07:01 +0000 Received: (at 79126) by debbugs.gnu.org; 6 Aug 2025 16:06:58 +0000 Received: from localhost ([127.0.0.1]:59840 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujgfK-0006ub-AS for submit@debbugs.gnu.org; Wed, 06 Aug 2025 12:06:58 -0400 Received: from mxout5.mail.janestreet.com ([64.215.233.18]:58547) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujgfJ-0006uJ-03 for 79126@debbugs.gnu.org; Wed, 06 Aug 2025 12:06:57 -0400 From: Spencer Baugh In-Reply-To: <8a128dc7-a3e7-44c4-ba7c-d132eef6948a@gutov.dev> (Dmitry Gutov's message of "Wed, 6 Aug 2025 17:37:50 +0300") References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> <87ldnw7dbi.fsf@zephyr.silentflame.com> <8a128dc7-a3e7-44c4-ba7c-d132eef6948a@gutov.dev> Date: Wed, 06 Aug 2025 12:06:50 -0400 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1754496410; bh=y+PjEI+BVzA1au+tGWuJt/UtWNLKByxFECw6F/DiCwY=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=PEH/bmVQGMOumY9wQA/BJpLIWVHrZ1UTeqLyc2lRMXlJIn+Tdfcxgbn7Km4vMdkxG znWnJdZ0WwoeUos+hv/2/rHIZYk8m9qyGwAU6yHh7tVNG4qgwmAH3g0Vz7KOMjRgEN GGakIO+Zt02K3I4CTiHM8uU7o5dCfmblLM+P/nb6xTDKL2bfAahPGLH4ci77pqA/8X rFCRUPv5F7dq2pBl92hHPEpUuNwZz7ELLHPFXYiKoVndUkXVCmPctKPuy6lS1TiP2K 8FtNR6VeBiq50fk1gDiTR1YUUdN12QOtjKdfFEcHvGDNxwfCgnewkhlitHkGpbzmAU CMXuTcB9Nz1uw== X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Dmitry Gutov writes: > On 06/08/2025 17:08, Sean Whitton wrote: >> +;; The default value works for file-visiting and Dired buffers. >> +;; Non-file-visiting major modes (other than `dired-mode'), where there >> +;; is a sensible notion of a matching buffer, can set this. >> +;; File-visiting major modes shouldn't set it, except possibly some >> +;; highly specialized ones. >> +(defvar project-find-matching-buffer-function #'project-find-matching-file >> + "Function to switch to a matching buffer in another project. >> +Usually set buffer-locally by non-file-visiting major modes. >> +The function will be called with no arguments. If the other project is >> +already determined, `project-current-directory-override' will be bound >> +to a directory under that other project. Otherwise the function should >> +prompt for the other project, usually with `project-read-project'.") > > How about we try to simplify that hook? > > The command will check whether there is an overriding project and pass > that value as an argument to project-find-matching-buffer-function. Or > just the root directory, is that is simpler. > > Or two arguments: current-root and new-root. That should cut the > default function's definition by about a third, and do even better for > the specialized ones. Yes, I agree with that, we should at least pass the new project as an argument. Passing the current project too sounds even better. IMO, it's slightly nicer to pass project objects rather than the root file names, since that avoids duplicate filesystem accesses to find project information (e.g. the vc backend) when necessary, but either way is fine. (This is maybe overengineering, but: we could even make it take *either* a root file name or a project object, so that callers can pass whatever is most convenient for them. Then the code inside could use some new helper function which when passed a file name, returns (project-current nil file-name), and when passed anything else, returns that thing. That might be simple enough, and this function would be fairly useful I think) From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Aug 2025 16:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: Dmitry Gutov , 79126@debbugs.gnu.org, Spencer Baugh Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175449694128164 (code B ref 79126); Wed, 06 Aug 2025 16:16:01 +0000 Received: (at 79126) by debbugs.gnu.org; 6 Aug 2025 16:15:41 +0000 Received: from localhost ([127.0.0.1]:59857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujgnk-0007KA-Im for submit@debbugs.gnu.org; Wed, 06 Aug 2025 12:15:40 -0400 Received: from mail.eshelyaron.com ([107.175.124.16]:41258 helo=eshelyaron.com) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujgng-0007K2-Ur for 79126@debbugs.gnu.org; Wed, 06 Aug 2025 12:15:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1754496936; bh=mZX6MfX0ye9SXKWYr1CBh3jxLVHmuqwSrFkvwIw9CqM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=x8fKOc9ul5KDIxbDNAWXVnMOwexpnTMUiKhlxrc5p7Wuvl/wNCv3wYM3MZVFDlD24 pMfoHT4rTLFYg0yHgZk84DVS8tON/n1VkVxYARyhzKDXO5RdJUQ9bBCqVyvK/9IzSF W1v7wtK5WOZYtAUJQs4dFTMKBjQxqTtOzalno1DufFI6cKjQt3J2Cn/pZtuq++AqwA HnalU9+E7ABzkrGOQ5jwrusB0re6gBWPzpeSV3jMR54/JIZ4wjg6HN+iP0OZU8pnq1 WN7kcwF5mfevMaSclIN+MuQGcM3cQEHHbVvrapZz3SWRxVRJGM7HKQjkrFfV0jLSQG xor0akZf529vg== From: Eshel Yaron In-Reply-To: <87ldnw7dbi.fsf@zephyr.silentflame.com> References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> <87ldnw7dbi.fsf@zephyr.silentflame.com> Date: Wed, 06 Aug 2025 18:15:32 +0200 Message-ID: <87ldnwwhnf.fsf@mail.eshelyaron.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi, Sean Whitton writes: > Hello, > > Thank you all for the comments. Please find attached an implementation. [...] > From a458eb6a117408821c7ec304c7bef60cf4a544ab Mon Sep 17 00:00:00 2001 > From: Sean Whitton > Date: Wed, 6 Aug 2025 15:05:08 +0100 > Subject: [PATCH] Generalize project-find-matching-file to other major modes > > * lisp/progmodes/project.el (dired-current-directory): Declare. > (project-find-matching-file): Handle Dired buffers (bug#79126). Any good reason to special-case Dired? Wouldn't it be nicer to have Dired set project-find-matching-buffer-function appropriately, as I do in my implementation with vc-switch-working-tree-function? :) [...] > + (dirp (dired-current-directory)) I don't think dired-current-directory is the right choice here. It does the wrong thing when point is in a subdir added with 'i' (it gives you the subdir, not the dir of the current buffer). I use: (car (ensure-list dired-directory)) Perhaps there's an even cleaner way to do that, but I don't know of one. Best, Eshel From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Aug 2025 17:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh , Dmitry Gutov , Eshel Yaron , 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.17545017729637 (code B ref 79126); Wed, 06 Aug 2025 17:37:02 +0000 Received: (at 79126) by debbugs.gnu.org; 6 Aug 2025 17:36:12 +0000 Received: from localhost ([127.0.0.1]:59983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uji3g-0002VN-9b for submit@debbugs.gnu.org; Wed, 06 Aug 2025 13:36:12 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:44356) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uji3d-0002V8-W7 for 79126@debbugs.gnu.org; Wed, 06 Aug 2025 13:36:11 -0400 DKIM-Signature: a=rsa-sha256; b=YlZ+3HotVg4M6tNRh58sjidX+lv138AnT/J7P2cvp1B9Y7EB+ANxBP5FOU4SvASQj3udDmGr2RDGnC3oTBxpGYx6BmU7t4mk6BdO7AwHgfYTHEgHiH6QoGmRn0/Fp9VTHThf1cjBkHJW54u/u8ubVELicL3z4db7Ju4Z7oWaqydXhqS1Zf8QgkdrtDAqTUtBmzxG0FUpXR5nXSVVXb9ji5IqmA0wnrt4S0n8eTznHrTkJreChr346EETgW6L/BM0ya7RWltTNV851e167nBLe8OeKng+bDSW9/kuN2oJQ6DoOcKBmAYK7FgMHkgxDbkyZ6LI3LKfp44+KlFoi9/Big==; s=purelymail1; d=spwhitton.name; v=1; bh=t6uyQRofuE7vc8H6ROb5SAIIOt0X2DZiqXibODKcAKA=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=gnjZr8PWE/mgCAtJlXEDaDT76kf/c5d9jMAtgvM7FRO9F2FZmw2HpKdr2Sf35XnZ63YoCZzJ24l6Fwu6u72tXYFYqrlTsdcb6bGIg5jxCLdFrRwmPNLujHodmibEQIDJ+4Rt8V3DYoUq6XBHXPWx//eg/zBxvJZWaCPnxKqaM2qasBVvECqeqq99JFdKNYot9dNPu0e4lv+69f7aOAkoFadXoFW5CTFGvYjatU4qYGkAbzHJLo1mfAJBpW9Z0wo3WH0dC5qLvQbkL/BWJT2yYmovwTzOFj8yTGledpWs5B0lJeLUdp53g8tvHIL1jBkXzDhhoxjRW2jTbLeT1jRrRQ==; s=purelymail1; d=purelymail.com; v=1; bh=t6uyQRofuE7vc8H6ROb5SAIIOt0X2DZiqXibODKcAKA=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79126@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id 80542277; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 06 Aug 2025 17:36:02 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id BB4E0940174; Wed, 06 Aug 2025 18:36:01 +0100 (BST) From: Sean Whitton In-Reply-To: References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> <87ldnw7dbi.fsf@zephyr.silentflame.com> <8a128dc7-a3e7-44c4-ba7c-d132eef6948a@gutov.dev> Date: Wed, 06 Aug 2025 18:36:01 +0100 Message-ID: <877bzg73pa.fsf@zephyr.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, On Wed 06 Aug 2025 at 12:06pm -04, Spencer Baugh wrote: > Dmitry Gutov writes: > >> On 06/08/2025 17:08, Sean Whitton wrote: >>> +;; The default value works for file-visiting and Dired buffers. >>> +;; Non-file-visiting major modes (other than `dired-mode'), where there >>> +;; is a sensible notion of a matching buffer, can set this. >>> +;; File-visiting major modes shouldn't set it, except possibly some >>> +;; highly specialized ones. >>> +(defvar project-find-matching-buffer-function #'project-find-matching-file >>> + "Function to switch to a matching buffer in another project. >>> +Usually set buffer-locally by non-file-visiting major modes. >>> +The function will be called with no arguments. If the other project is >>> +already determined, `project-current-directory-override' will be bound >>> +to a directory under that other project. Otherwise the function should >>> +prompt for the other project, usually with `project-read-project'.") >> >> How about we try to simplify that hook? >> >> The command will check whether there is an overriding project and pass >> that value as an argument to project-find-matching-buffer-function. Or >> just the root directory, is that is simpler. >> >> Or two arguments: current-root and new-root. That should cut the >> default function's definition by about a third, and do even better for >> the specialized ones. > > Yes, I agree with that, we should at least pass the new project as an > argument. Passing the current project too sounds even better. > > IMO, it's slightly nicer to pass project objects rather than the root > file names, since that avoids duplicate filesystem accesses to find > project information (e.g. the vc backend) when necessary, but either way > is fine. > > (This is maybe overengineering, but: we could even make it take *either* > a root file name or a project object, so that callers can pass whatever > is most convenient for them. Then the code inside could use some new > helper function which when passed a file name, returns (project-current > nil file-name), and when passed anything else, returns that thing. That > might be simple enough, and this function would be fairly useful I > think) Sounds good, I agree with factoring things out along these lines. I think we might want a function which wraps the (funcall project-find-matching-buffer-function), and that could handle ensuring a project object. -- Sean Whitton From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Aug 2025 17:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eshel Yaron Cc: Dmitry Gutov , 79126@debbugs.gnu.org, Spencer Baugh Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.17545018749809 (code B ref 79126); Wed, 06 Aug 2025 17:38:02 +0000 Received: (at 79126) by debbugs.gnu.org; 6 Aug 2025 17:37:54 +0000 Received: from localhost ([127.0.0.1]:59992 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uji5K-0002Y9-HA for submit@debbugs.gnu.org; Wed, 06 Aug 2025 13:37:54 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:41544) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uji5H-0002Xj-QJ for 79126@debbugs.gnu.org; Wed, 06 Aug 2025 13:37:52 -0400 DKIM-Signature: a=rsa-sha256; b=O/f3eBFuvJpaxhO6rD9bYk4WBL7YoTBLdlMEVKyGQpgevhgBwSOTK1cIDWBUER+xaXqzOc/pWWihhr9aZom356wIoHfoZo6aHPI1F29OBCISb02PA4NWf0WMZtevtrtrkghcYsWakTiugFhtAu4E0oo4+VrA7FRn0N16YdTnNWOyGiFoiEc5LQL049wtP5ojrzRG9gfsK7TRpVNbJzZY/MyQGOef5Oar4g8RQ0Zs0MQwIN4y0Ti7LPsHueBS/1VSSGjlC9A2WcggZIpZNb3OsFo6XRbXm+zTj1Am4CRI+j+icODZvDIxZnkqZQLowRDVVgHlXgSbgPxgCjZVYnR4Lw==; s=purelymail1; d=spwhitton.name; v=1; bh=EfHayDeOVi87YFOAfQOSiKeRyZwDETMH0jcYn378hsc=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=qYEYZiAH0419cJlJ2/UKlIm7MN5adLNNyotf+OWfjaB+ijo0C99L0MOGe4So9+nbrgwIP0qEf6DPNqJGo8MyoQsRJGtO3wgzm8GdVxK+R4RJ3DvG0dgVE6G3HPWHGnLFHdI/T9vxvZ+RMtfkTh5Yu9WPvLio9Blgn5XIVmPqMMtY43KIaEyfxB+ZKulmTYlUtZN05vrZiK3JTP4HJU+JrD7C2TMx9DXEZdT8Yv/RwnOZmhAGqlisJe5swnhv9UVwyX9Cl39dk36Ej3GdaiT/8XJ3TsyhX3ZtbpAr7JdYp0SHW4hyuTAqq1GzcssNjqurQlASDru1iavcltB1diaDOw==; s=purelymail1; d=purelymail.com; v=1; bh=EfHayDeOVi87YFOAfQOSiKeRyZwDETMH0jcYn378hsc=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79126@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id 1070698056; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 06 Aug 2025 17:37:45 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id 2FC15940174; Wed, 06 Aug 2025 18:37:44 +0100 (BST) From: Sean Whitton In-Reply-To: <87ldnwwhnf.fsf@mail.eshelyaron.com> References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> <87ldnw7dbi.fsf@zephyr.silentflame.com> <87ldnwwhnf.fsf@mail.eshelyaron.com> Date: Wed, 06 Aug 2025 18:37:44 +0100 Message-ID: <8734a473mf.fsf@zephyr.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, On Wed 06 Aug 2025 at 06:15pm +02, Eshel Yaron wrote: > Hi, > > Sean Whitton writes: > >> Hello, >> >> Thank you all for the comments. Please find attached an implementation. > > [...] > >> From a458eb6a117408821c7ec304c7bef60cf4a544ab Mon Sep 17 00:00:00 2001 >> From: Sean Whitton >> Date: Wed, 6 Aug 2025 15:05:08 +0100 >> Subject: [PATCH] Generalize project-find-matching-file to other major modes >> >> * lisp/progmodes/project.el (dired-current-directory): Declare. >> (project-find-matching-file): Handle Dired buffers (bug#79126). > > Any good reason to special-case Dired? Wouldn't it be nicer to have > Dired set project-find-matching-buffer-function appropriately, as I do > in my implementation with vc-switch-working-tree-function? :) Heh. I tried that first, but found myself duplicating code, so decided that folding it into project-find-matching-file was neatest. > [...] > >> + (dirp (dired-current-directory)) > > I don't think dired-current-directory is the right choice here. It does > the wrong thing when point is in a subdir added with 'i' (it gives you > the subdir, not the dir of the current buffer). This was deliberate. To me it seems desirable to look for the matching subdirectory. Sounds like you disagree? -- Sean Whitton From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Aug 2025 01:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Spencer Baugh Cc: Eshel Yaron , 79126@debbugs.gnu.org, Sean Whitton Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175453052510842 (code B ref 79126); Thu, 07 Aug 2025 01:36:02 +0000 Received: (at 79126) by debbugs.gnu.org; 7 Aug 2025 01:35:25 +0000 Received: from localhost ([127.0.0.1]:60806 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujpXQ-0002oY-KV for submit@debbugs.gnu.org; Wed, 06 Aug 2025 21:35:24 -0400 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]:47039) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujpXN-0002io-Fu for 79126@debbugs.gnu.org; Wed, 06 Aug 2025 21:35:22 -0400 Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id 1B856EC016E; Wed, 6 Aug 2025 21:35:16 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-10.internal (MEProxy); Wed, 06 Aug 2025 21:35:16 -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:subject:subject:to:to; s=fm2; t=1754530516; x=1754616916; bh=ieiC+3ejieLYGWTUNozg/0CTKFTeACHstfS2WrmZp0s=; b= vTgtN29FiNutq/rXAbtIrI54ub8J1g93gWyn5MMMPdQ6ZGt1XYTmuqoSpG/w8zti uGb26u1ytPVMZcNtk02WywDPPkgXMPvDOKbpLM/43vTPZjD4JsDjeP1f8n0ZAfKF 9NYjEcZ9QXBbnTZcdmMw5tEvYKxAW2FX98m3nJOSIUeQ59gUFO7osoiDQdhQxkvg cm5FSF/A5Wr2hdiaZr5p+qCBUsZEr4A8NiNd6WyjbfANV4FCihsw1cds3WAUeMbt Gk0ZDnkDSuSsp5gWJa674hsoHaZdixP9TfKIufyPl33fVfzko5yjtKhtPSHQX/0V m2tWREyGiQO+5zRGiJRrxA== 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:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1754530516; x= 1754616916; bh=ieiC+3ejieLYGWTUNozg/0CTKFTeACHstfS2WrmZp0s=; b=W 2TSmLShThaT9NRghOmDvrCsuKaGE33J8HzHa9FnbbPVdbEmWkT1M9qMH7s476PTF NQ4vEbkepxcqJInQjMEr8+boWFNh4othmx6aQMlvDGhzR1OrFLOfkK6UVWc0d4NR GOAbgZr82PGJslsQn78HTBXjHNgC6IvKknQxvhHkhW+yyEj0kxuKMYDD2A27Nf+5 As1Mx3WuCrbPfECigQJdBtz3aD+GlwBjmEn+eUDia9oxhDjn+mj+E0M5AE/oirPs hyKj2oxsY1RYrdgwPiaKfXGuVDrRmUvBLzNqSvLfisUHtxqlQ+k4DwmGvCHyJPFH dwnxdIFFfHdZ3d4c7JO6Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduudeliedvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeffmhhithhr hicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrthhtvg hrnhepteduleejgeehtefgheegjeekueehvdevieekueeftddvtdevfefhvdevgedujeeh necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepughmih htrhihsehguhhtohhvrdguvghvpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehssggruhhghhesjhgrnhgvshhtrhgvvghtrdgtohhmpdhrtg hpthhtohepshhpfihhihhtthhonhesshhpfihhihhtthhonhdrnhgrmhgvpdhrtghpthht ohepmhgvsegvshhhvghlhigrrhhonhdrtghomhdprhgtphhtthhopeejleduvdeiseguvg gssghughhsrdhgnhhurdhorhhg X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 6 Aug 2025 21:35:14 -0400 (EDT) Message-ID: <20c02526-1feb-4805-84ae-e47265191bb8@gutov.dev> Date: Thu, 7 Aug 2025 04:35:12 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> <87ldnw7dbi.fsf@zephyr.silentflame.com> <8a128dc7-a3e7-44c4-ba7c-d132eef6948a@gutov.dev> Content-Language: en-US From: Dmitry Gutov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 06/08/2025 19:06, Spencer Baugh wrote: > (This is maybe overengineering, but: we could even make it take*either* > a root file name or a project object, so that callers can pass whatever > is most convenient for them. Not sure there will be other callers for it. Or not many anyway. > Then the code inside could use some new > helper function which when passed a file name, returns (project-current > nil file-name), and when passed anything else, returns that thing. That > might be simple enough, and this function would be fairly useful I > think) If the value needs to be passed through a helper, we could just pass it through 'project-root'. The project values must be available in the caller already, so let's just standardize on those. (We're probably coming from different schools of design: you're thinking in ADTs where it's normal to have something like "Thing | String" as a parameter type, and I'm thinking more in OOP where you pass a type, or a supertype - like a general protocol - but rarely a union of disjoint types, and if that happens, they are usually all primitive types). From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Eshel Yaron Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Aug 2025 05:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton Cc: Dmitry Gutov , 79126@debbugs.gnu.org, Spencer Baugh Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175454589528929 (code B ref 79126); Thu, 07 Aug 2025 05:52:02 +0000 Received: (at 79126) by debbugs.gnu.org; 7 Aug 2025 05:51:35 +0000 Received: from localhost ([127.0.0.1]:33084 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujtXK-0007WW-JV for submit@debbugs.gnu.org; Thu, 07 Aug 2025 01:51:34 -0400 Received: from mail.eshelyaron.com ([107.175.124.16]:53398 helo=eshelyaron.com) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujtXH-0007WN-Jd for 79126@debbugs.gnu.org; Thu, 07 Aug 2025 01:51:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=eshelyaron.com; s=mail; t=1754545890; bh=nG33KI72uzZYTGuOVxcgXZbNH+pzqTzz93dK/F3SaJI=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=PxdCgXtAW2CObGBw3LnzT8q1+Ylo8fgQiqk+eX6qO4Sr/5ooQ4OG3Otr/5q+2MbIy Yg2eIsidzfDbUox1dPkByC8xYX9AKr4GGnpBvH/fLjMtRPh7NdCFD/VahZvcGXo2Pj 3Cb0v6iZoltVvJwNazeLOkteX8DLr/Pr3fp6L9LyMxqOTZvuqDRHqZlhL5MIWwI2/2 FeFjRaA0Zsvy6qGZ5AC/Ludlit3jJH8bKzr7IyuxxIeNlx9Nu+ZDJOy4SVIiy6DXs+ 352NA+2IAYJTxUamfOeiy9V3Hwt93P13KCQPPvA4cPXkIYk98f59cPeYlkGbQTd7IL a+FzT1kSQB4jw== From: Eshel Yaron In-Reply-To: <8734a473mf.fsf@zephyr.silentflame.com> References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> <87ldnw7dbi.fsf@zephyr.silentflame.com> <87ldnwwhnf.fsf@mail.eshelyaron.com> <8734a473mf.fsf@zephyr.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) Date: Thu, 07 Aug 2025 07:51:26 +0200 Message-ID: <87jz3fvfvl.fsf@mail.eshelyaron.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Sean Whitton writes: > > On Wed 06 Aug 2025 at 06:15pm +02, Eshel Yaron wrote: >> >> Sean Whitton writes: >>> >>> * lisp/progmodes/project.el (dired-current-directory): Declare. >>> (project-find-matching-file): Handle Dired buffers (bug#79126). >> >> Any good reason to special-case Dired? Wouldn't it be nicer to have >> Dired set project-find-matching-buffer-function appropriately, as I do >> in my implementation with vc-switch-working-tree-function? :) > > Heh. I tried that first, but found myself duplicating code, so decided > that folding it into project-find-matching-file was neatest. I see. Note that if you stumbled upon such need to duplicate code, others trying to use this variable to support additional buffers (say, Shell buffers) will likely have similar difficulties. In other words, it's an indication that the extension mechanism could be more convenient or could benefit from some helper function(s) to avoid duplication. >>> + (dirp (dired-current-directory)) >> >> I don't think dired-current-directory is the right choice here. It does >> the wrong thing when point is in a subdir added with 'i' (it gives you >> the subdir, not the dir of the current buffer). > > This was deliberate. To me it seems desirable to look for the matching > subdirectory. Sounds like you disagree? It's nothing crucial, but IMO getting a different result depending on the position of point in the Dired buffer is slightly non-intuitive. Few will probably experience this difference in practice, so it doesn't matter to much either way. Best, Eshel From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Sean Whitton Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 07 Aug 2025 12:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dmitry Gutov , Spencer Baugh , Eshel Yaron Cc: 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175457033620572 (code B ref 79126); Thu, 07 Aug 2025 12:39:01 +0000 Received: (at 79126) by debbugs.gnu.org; 7 Aug 2025 12:38:56 +0000 Received: from localhost ([127.0.0.1]:33983 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ujztX-0005Lj-EI for submit@debbugs.gnu.org; Thu, 07 Aug 2025 08:38:56 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:39732) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ujztU-0005LV-OP for 79126@debbugs.gnu.org; Thu, 07 Aug 2025 08:38:53 -0400 DKIM-Signature: a=rsa-sha256; b=hUUzg3QGS6ng4Fy56z+ao7dDhuqF0C9l+5lC4L8MPYqtssjBzRdfHZTF2MH3lGb3p5vyFaMwjeol97NeFA+t1CZdPpwEOCIeVep97wQFhAgDiaXQLBt6xLPOjeSDAuYKWiwxlc8Gw/1dq+UxJL0I0xh7m3WRRFuY29PjmozSzalQJO15AU+hgpRBdwQJBexmnT6WHVQMUXiZ33iXgOyr5qf73W3siSzgOG2z6vypXYjQuy4HxVTi9PlP7e3BGx8X6BEKZPJQbLrzSlqy5MOAkwoG3y0tefmObJkCi9H589T+kObAOcR/cZ5qaa9ul537q8vF7n9FgOH0c03Dkt6J5g==; s=purelymail1; d=spwhitton.name; v=1; bh=U6bxjryN/o2vIBenJJHBSKjNHeKjDufEDnSjyFc3Fg8=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=q9oAM2ASwzI2E0cLs7b7ugrb2JPFC/VcGnf1b8/uvnAzRIhOEQkJFBsUJouStN2sQ88cPa6nsK9co3EbpjKK8Bg3Da+NWq1gmb1XR6L1xc3+ZeCA1hvbcdfYLLoDDDRGj7IpkfdkfFO2nrTAggPAXL4qBiur6aJNR78km0c8LjfmZdRbqnG6vSa6nPf5FV8G2E0ct5wkcf2S22zyx2qUTH4kkzUQO1yMXY0OW01gBMTnZVV7609OLgHgpGjVsKGqL/s/fdFJg+kmY9fEWOa388bZG9KahyQoskleumeUcO6Yj7BOipXetXC0YUSDLG0PTcCJPTClONNiTq9rYzmb+w==; s=purelymail1; d=purelymail.com; v=1; bh=U6bxjryN/o2vIBenJJHBSKjNHeKjDufEDnSjyFc3Fg8=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79126@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -831056362; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Thu, 07 Aug 2025 12:38:46 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id 051FA94012E; Thu, 07 Aug 2025 13:38:45 +0100 (BST) From: Sean Whitton In-Reply-To: <8a128dc7-a3e7-44c4-ba7c-d132eef6948a@gutov.dev> References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> <87ldnw7dbi.fsf@zephyr.silentflame.com> <8a128dc7-a3e7-44c4-ba7c-d132eef6948a@gutov.dev> Date: Thu, 07 Aug 2025 13:38:44 +0100 Message-ID: <87o6sr5msr.fsf@zephyr.silentflame.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Hello, Thanks again all. Here's the revised patch. -- Sean Whitton --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=v2-0001-Generalize-finding-project-matching-files-to-othe.patch >From 0b98398cfde844d0765688da18e427b79cef3849 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Wed, 6 Aug 2025 15:05:08 +0100 Subject: [PATCH v2] Generalize finding project matching files to other major modes * lisp/progmodes/project.el (project-find-matching-buffer-function): New variable. (project-find-matching-file): Delete. (dired-current-directory): Declare. (project-find-matching-file-or-directory): New function. Like the old 'project-find-matching-file', but also handle Dired buffers (bug#79126). When matching file/directory does not exist, try going up in the directory tree until we find something that does. (project-find-matching-buffer): New command. * lisp/vc/vc.el (vc-switch-working-tree): Use it (bug#79126). * etc/NEWS: Announce new command and new variable. --- etc/NEWS | 7 ++- lisp/progmodes/project.el | 108 +++++++++++++++++++++++++++++--------- lisp/vc/vc.el | 3 +- 3 files changed, 91 insertions(+), 27 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index a34a3d73292..5985348e101 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -467,11 +467,16 @@ Callers can use this to indicate the reason for which or context in which Emacs should ask the user to select a project. --- -*** New command 'project-find-matching-file'. +*** New command 'project-find-matching-buffer'. It can be used when switching between projects with similar file trees (such as Git worktrees of the same repository). It supports being invoked standalone or from the 'project-switch-commands' dispatch menu. +--- +*** New variable 'project-find-matching-buffer-function'. +Major modes can set this to major mode-specific functions to control how +'project-find-matching-buffer' finds matching buffers. + +++ *** New user option 'project-list-exclude'. This user option describes projects that should always be skipped by diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index dafc01c7684..e9e8c558843 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1307,33 +1307,93 @@ project-find-file-in (user-error "You didn't specify the file") (find-file file)))) +;; The default value works for file-visiting and Dired buffers. +;; Non-file-visiting major modes (other than `dired-mode'), where there +;; is a sensible notion of a matching buffer, can set this. +;; File-visiting major modes shouldn't set it, except possibly some +;; highly specialized ones. +(defvar project-find-matching-buffer-function + #'project-find-matching-file-or-directory + "Function to switch to a matching buffer in another project. +Usually set buffer-locally by non-file-visiting major modes. +The function will be called with two arguments, the project instance for +this buffer's project, and the project instance for the matching buffer.") + ;;;###autoload -(defun project-find-matching-file () - "Visit the file that matches the current one, in another project. -It will skip to the same line number as well. -A matching file has the same file name relative to the project root. +(defun project-find-matching-buffer () + "Switch to a matching buffer in another project. +For most file-visiting buffers, the matching buffer is one visiting a +file in the other project which has the same file name relative to the +project root. See `project-find-matching-file' for details. +Non-file-visiting major modes may configure a different notion of +matching buffer; see `project-find-matching-buffer-function'. + When called during switching to another project, this command will -detect it and use the override. Otherwise, it prompts for the project -to use from the known list." +detect that, and use the override. Otherwise, it prompts for the +project to use from the list of known projects. +When calling from Lisp, bind `project-current-directory-override' to a +directory under the target project to preempt this prompting." (interactive) - (let* ((pr (project-current)) - (line (line-number-at-pos nil t)) - relative-name mirror-name) - (if project-current-directory-override - (let* (project-current-directory-override - (real-project (project-current t))) - (setq relative-name (file-relative-name buffer-file-name - (project-root real-project)))) - (setq relative-name (file-relative-name buffer-file-name (project-root pr))) - (setq pr (project-read-project))) - (setq mirror-name (expand-file-name relative-name (project-root pr))) - (if (not (file-exists-p mirror-name)) - (user-error "File `%s' not found in `%s'" relative-name (project-root pr)) - (find-file mirror-name) - (save-restriction - (widen) - (goto-char (point-min)) - (forward-line (1- line)))))) + (let ((pr (project-current))) + (apply project-find-matching-buffer-function + (if project-current-directory-override + (let (project-current-directory-override) + (list (project-current t) pr)) + (list pr (project-read-project)))))) + +(declare-function dired-current-directory "dired") + +(defun project-find-matching-file-or-directory (current-project mirror-project) + "Visit file or directory in another project that matches the current one. +A matching file, or Dired buffer's matching directory, has the same file +name relative to the project root. +CURRENT-PROJECT is the project instance for the current project. +MIRROR-PROJECT is the project instance for the project to visit. +Also skip to the same line number. + +If the matching file does not exist in the other project, try going up +in the directory tree until encountering a file or directory that +exists. For example, from a buffer visiting a file \"lisp/vc/vc.el\", +if in the other project this file does not exist, try visiting +\"lisp/vc\" if that exists as a file or directory. + +If a Dired buffer's matching directory does not exist in the other +project, try going up in the directory tree until encountering a +directory that exists. For example, from a buffer visiting a +subdirectory named \"lisp/vc/\", if in the other project \"lisp/vc\" is +missing or not a directory, try visiting a directory named \"lisp/\" in +the other project. + +This function is intended to be used as the value of +`project-find-matching-buffer-function'." + (let* ((line (line-number-at-pos nil t)) + (dirp (derived-mode-p 'dired-mode)) + (mirror-root (project-root mirror-project)) + (relative-name + (file-relative-name (cond + (dirp (dired-current-directory)) + ((buffer-file-name)) + (t (error "Don't know how to find matching buffer"))) + (project-root current-project))) + (mirror-name (expand-file-name relative-name mirror-root)) + (orig-mirror-name mirror-name)) + (while (not (if dirp (file-directory-p mirror-name) + (file-exists-p mirror-name))) + (setq mirror-name (directory-file-name + (file-name-parent-directory mirror-name))) + (unless (file-in-directory-p mirror-name mirror-root) + (user-error "`%s' not found in `%s'" relative-name mirror-root))) + (find-file mirror-name) + (save-restriction + (widen) + (goto-char (point-min)) + (forward-line (1- line))) + (unless (equal mirror-name orig-mirror-name) + (message "`%s' not found; visiting `%s' instead" + (abbreviate-file-name orig-mirror-name) + (abbreviate-file-name (if (file-directory-p mirror-name) + (file-name-as-directory mirror-name) + mirror-name)))))) (defun project--completing-read-strict (prompt collection &optional predicate diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 67eed872fd7..5dc6461af1f 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -4435,13 +4435,12 @@ vc-switch-working-tree This command switches to the file which has the same file name relative to DIRECTORY that this buffer's file has relative to the root of this working tree." - ;; FIXME: Switch between directory analogues, too, in Dired buffers. (interactive (list (vc--prompt-other-working-tree (vc-responsible-backend default-directory) "Other working tree to visit"))) (let ((project-current-directory-override directory)) - (project-find-matching-file))) + (project-find-matching-buffer))) ;;;###autoload (defun vc-delete-working-tree (backend directory) -- 2.47.2 --=-=-=-- From unknown Fri Aug 15 20:55:55 2025 X-Loop: help-debbugs@gnu.org Subject: bug#79126: vc-switch-working-tree does not work if there is no matching file Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 08 Aug 2025 00:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 79126 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sean Whitton , Spencer Baugh , Eshel Yaron Cc: 79126@debbugs.gnu.org Received: via spool by 79126-submit@debbugs.gnu.org id=B79126.175461332322172 (code B ref 79126); Fri, 08 Aug 2025 00:36:02 +0000 Received: (at 79126) by debbugs.gnu.org; 8 Aug 2025 00:35:23 +0000 Received: from localhost ([127.0.0.1]:36330 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ukB4s-0005lY-D4 for submit@debbugs.gnu.org; Thu, 07 Aug 2025 20:35:22 -0400 Received: from fhigh-b5-smtp.messagingengine.com ([202.12.124.156]:55701) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ukB4m-0005ki-80 for 79126@debbugs.gnu.org; Thu, 07 Aug 2025 20:35:19 -0400 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id 1F2D27A00DC; Thu, 7 Aug 2025 20:35:10 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Thu, 07 Aug 2025 20:35:10 -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:subject:subject:to:to; s=fm2; t=1754613309; x=1754699709; bh=a659eA4TEo5Q58TgQfyBKBbZW7FfPEhkJRyusF0A0jw=; b= A477Nd5b6XBiolVLcuSYFZneWjRB4l/z7Zp7z9tHCwykGLmoMfFQ4bLkX4EPdfdw SUM6mSrVz5dlENuZh2VhsUGFa49Gx9IMhbvGw7TrfzFfgkGDV3byQEWoEw0Tcq3H CvvsMCAhakQkxVEh6qIOkkmQ1uuhFxUm4tY8e+H1P/ceN0PYbY0KN95IL1v+EASt z6aAM0dbltgDMSE+IWPcHtTtJ3tXJmNi18UL/UIlr4pcBt3yVGtR2hOdI9TfR0+P DNM53rHmfCQvHKGmPYF7XkqI+eGxyEAwE7U/bzQ8U0DDT/ts+2gX6lZ0MWIL+xDv kDV0iVa/K/IywlIRCIkCMw== 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:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1754613309; x= 1754699709; bh=a659eA4TEo5Q58TgQfyBKBbZW7FfPEhkJRyusF0A0jw=; b=Z bCjbLQ7zbTNPctXI6JHbuon8qaM+HdjNCuzIV356VHZhm5943BigrIjwW80EQW0j yRYaCxwyP6NLJZub7Q6cf3utSOqzKmbuCSQqPFK769uVydATfbzT2nHLXqjw0q1h 0DFflXZ5F+g8Rk3xdcrXd4aCaGK4uiSU3i48R7YQiWre4XmrtUK3penInA1BtEsd zPQuuItyWBUrAbE1rwHe6cuVgiFUVX9iPGOH9BPO2u7il7Ge3YQ7cp5qGRJQBbrY JHk8ULy82NoPgaod89n5N2vEpTdzuZEyWAtuWBs4xtaTl5IYdxrRME+ADqokVDqe i1AdZdtVCqdx9WUEskAAw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdduvddvfeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeffmhhithhr hicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrthhtvg hrnhepteduleejgeehtefgheegjeekueehvdevieekueeftddvtdevfefhvdevgedujeeh necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepughmih htrhihsehguhhtohhvrdguvghvpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhp ohhuthdprhgtphhtthhopehsphifhhhithhtohhnsehsphifhhhithhtohhnrdhnrghmvg dprhgtphhtthhopehssggruhhghhesjhgrnhgvshhtrhgvvghtrdgtohhmpdhrtghpthht ohepmhgvsegvshhhvghlhigrrhhonhdrtghomhdprhgtphhtthhopeejleduvdeiseguvg gssghughhsrdhgnhhurdhorhhg X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Aug 2025 20:35:07 -0400 (EDT) Message-ID: <98502142-a2af-4ba7-984c-71c127980c07@gutov.dev> Date: Fri, 8 Aug 2025 03:35:05 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> <87ldnw7dbi.fsf@zephyr.silentflame.com> <8a128dc7-a3e7-44c4-ba7c-d132eef6948a@gutov.dev> <87o6sr5msr.fsf@zephyr.silentflame.com> Content-Language: en-US From: Dmitry Gutov In-Reply-To: <87o6sr5msr.fsf@zephyr.silentflame.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) On 07/08/2025 15:38, Sean Whitton wrote: > Thanks again all. Here's the revised patch. Nice! Looking good. > +;; The default value works for file-visiting and Dired buffers. > +;; Non-file-visiting major modes (other than `dired-mode'), where there > +;; is a sensible notion of a matching buffer, can set this. > +;; File-visiting major modes shouldn't set it, except possibly some > +;; highly specialized ones. > +(defvar project-find-matching-buffer-function > + #'project-find-matching-file-or-directory > + "Function to switch to a matching buffer in another project. > +Usually set buffer-locally by non-file-visiting major modes. > +The function will be called with two arguments, the project instance for > +this buffer's project, and the project instance for the matching buffer.") I suggest to try to get more of the info from the comment into the docstring. > + (dirp (derived-mode-p 'dired-mode)) One more thing to try is not to specialize on Dired mode: and default to assuming that any buffer without buffer-file-name is "dirp". The default implementation would either find/create a Dired buffer in the same dir, or even search through the buffer list for a buffer with matching values of major-mode and default-directory. This is optional, just something that came to mind. From unknown Fri Aug 15 20:55:55 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Dmitry Gutov Subject: bug#79126: closed (Re: bug#79126: vc-switch-working-tree does not work if there is no matching file) Message-ID: References: <87cy963ym2.fsf@zephyr.silentflame.com> X-Gnu-PR-Message: they-closed 79126 X-Gnu-PR-Package: emacs Reply-To: 79126@debbugs.gnu.org Date: Fri, 08 Aug 2025 10:19:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1754648342-9156-1" This is a multi-part message in MIME format... ------------=_1754648342-9156-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #79126: vc-switch-working-tree does not work if there is no matching file which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 79126@debbugs.gnu.org. --=20 79126: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D79126 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1754648342-9156-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 79126-done) by debbugs.gnu.org; 8 Aug 2025 10:18:58 +0000 Received: from localhost ([127.0.0.1]:37271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ukKBe-0002NR-9j for submit@debbugs.gnu.org; Fri, 08 Aug 2025 06:18:58 -0400 Received: from sendmail.purelymail.com ([34.202.193.197]:60322) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ukKBZ-0002N4-0T for 79126-done@debbugs.gnu.org; Fri, 08 Aug 2025 06:18:56 -0400 DKIM-Signature: a=rsa-sha256; b=nAr37MyyErpl/LWrDXxAExXiBQk+NP8gRloLCzvDXswp4Vcr7HzUiG7XvlRH8T5zf54oXWRfdpC6z0Jh+boZgFrmw6e7D+IUgKmmdGLxQFhydZRU5r/HTfkS3uDY/nUdHS7r7eTizFZCHNA+gwH7UuvAfpscu+qbBvZPHwWxboVelLjDYMxy+7xltFQl2pQuC+rPqZ7dURO/S1yS72BZ7vw+5KxU7JaQoI+qVB8JQI+kJxw3+VkGXXEzgxu4yKYSR10psZvEhP0xCaX2/EMN2kHLo10+0pXEwizrlZprb3IpruSG313cQv0bhBSPtANL1nUb6TH8YrVfF6aY2WJvHw==; s=purelymail1; d=spwhitton.name; v=1; bh=RZI0JCKroZw60A+YSKg2jVyu/qLmin0HF01syTymAco=; h=Received:Received:From:To:Subject:Date; DKIM-Signature: a=rsa-sha256; b=tJMaybhO4gfqIgMihG8pMAzRTr0Wz0d4RfuytEVBqVW9foU5sMJYymG9SkwzFeNbUWO9UdJRt0yUZ8AxUP5hYrNygGwwfGLTrc0gDLSIoGcNWf+BjCSNs1U4kvSgmJfteNrXbPQOMcj/CLm2MDT2pLLmtMOIcjtB9MWtcdLeohp4klvd0I4a4BPox+ogYYbEXi2hYqQUSlcaPbwE8MnMk727Olz88PupplFEpUs2AbVo4ADjkBJpKXQBe1BU4JhoL51j+QszUDsgNohJ8MqqslQrUN5Hk3LXKINe4rEh4lkMm2nqmnXvpBXATjABnPRro+biUKtjVVlK4G3AQnfRRA==; s=purelymail1; d=purelymail.com; v=1; bh=RZI0JCKroZw60A+YSKg2jVyu/qLmin0HF01syTymAco=; h=Feedback-ID:Received:Received:From:To:Subject:Date; Feedback-ID: 20115:3760:null:purelymail X-Pm-Original-To: 79126-done@debbugs.gnu.org Received: by smtp.purelymail.com (Purelymail SMTP) with ESMTPSA id -1660074985; (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Fri, 08 Aug 2025 10:18:46 +0000 (UTC) Received: by zephyr.silentflame.com (Postfix, from userid 1000) id 6178694012E; Fri, 08 Aug 2025 11:18:45 +0100 (BST) From: Sean Whitton To: Dmitry Gutov Subject: Re: bug#79126: vc-switch-working-tree does not work if there is no matching file In-Reply-To: <98502142-a2af-4ba7-984c-71c127980c07@gutov.dev> References: <877bzq3pp5.fsf@zephyr.silentflame.com> <71e95ecf-5f65-4b05-9d5d-bd5fcff27f02@gutov.dev> <871ppqcahm.fsf@zephyr.silentflame.com> <361dc553-f17c-43a9-ad24-626116734edd@gutov.dev> <87ldnw7dbi.fsf@zephyr.silentflame.com> <8a128dc7-a3e7-44c4-ba7c-d132eef6948a@gutov.dev> <87o6sr5msr.fsf@zephyr.silentflame.com> <98502142-a2af-4ba7-984c-71c127980c07@gutov.dev> Date: Fri, 08 Aug 2025 11:18:45 +0100 Message-ID: <87cy963ym2.fsf@zephyr.silentflame.com> 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: 79126-done Cc: Spencer Baugh , Eshel Yaron , 79126-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, On Fri 08 Aug 2025 at 03:35am +03, Dmitry Gutov wrote: > On 07/08/2025 15:38, Sean Whitton wrote: >> Thanks again all. Here's the revised patch. > > Nice! Looking good. > >> +;; The default value works for file-visiting and Dired buffers. >> +;; Non-file-visiting major modes (other than `dired-mode'), where there >> +;; is a sensible notion of a matching buffer, can set this. >> +;; File-visiting major modes shouldn't set it, except possibly some >> +;; highly specialized ones. >> +(defvar project-find-matching-buffer-function >> + #'project-find-matching-file-or-directory >> + "Function to switch to a matching buffer in another project. >> +Usually set buffer-locally by non-file-visiting major modes. >> +The function will be called with two arguments, the project instance for >> +this buffer's project, and the project instance for the matching buffer.") > > I suggest to try to get more of the info from the comment into the docstring. Thanks yeah, I think it's fine to just move it all in, as a second paragraph. >> + (dirp (derived-mode-p 'dired-mode)) > > One more thing to try is not to specialize on Dired mode: and default to > assuming that any buffer without buffer-file-name is "dirp". This seems like a useful fallback -- it gets you into a buffer with the default-directory you wanted, so you could conveniently run some other command in the right place, even if the dired buffer isn't much use. > The default implementation would either find/create a Dired buffer in > the same dir, or even search through the buffer list for a buffer with > matching values of major-mode and default-directory. I believe that find-file/dired already handle reusing buffers if they already exist, so we don't need to search. Installed and closing the bug. -- Sean Whitton ------------=_1754648342-9156-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 30 Jul 2025 02:37:30 +0000 Received: from localhost ([127.0.0.1]:37750 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ugwh7-00022y-Ji for submit@debbugs.gnu.org; Tue, 29 Jul 2025 22:37:29 -0400 Received: from lists.gnu.org ([2001:470:142::17]:55874) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ugwh4-00021t-Bo for submit@debbugs.gnu.org; Tue, 29 Jul 2025 22:37:27 -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 ) id 1ugwgg-00063v-UL for bug-gnu-emacs@gnu.org; Tue, 29 Jul 2025 22:37:02 -0400 Received: from fhigh-b3-smtp.messagingengine.com ([202.12.124.154]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ugwgc-0003Pw-6s for bug-gnu-emacs@gnu.org; Tue, 29 Jul 2025 22:37:02 -0400 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfhigh.stl.internal (Postfix) with ESMTP id B28D07A2395 for ; Tue, 29 Jul 2025 22:36:56 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Tue, 29 Jul 2025 22:36:56 -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:message-id:mime-version:reply-to:subject :subject:to:to; s=fm1; t=1753843016; x=1753929416; bh=e1u1vAn3uj Zm0PqCBvw2R9yfd4PGjkzxIXKA8IDhxdQ=; b=CyufdjbrlFlGEIYw3HOFnrk1Wj tZsBlVLzEDxTbvqYLLyEeV/gxdo/YhHEuzt0kRR6yws99fEJRTJXC5iAlzk8Afei E3kYhKFI0svku5aSmghJxKso7tGWwoXEv9X44QW9FNO3E5l1O+PvlE9LgJ71Rcd/ 5B6YGsWF/1FvbPz0xSVBuc3EKtpQTv+HaOYnIfMpIH63y+YERoGwFp1W4nwcAQme HoS/uY+1jwWz3AoNqi0y4T7ticorkoPJp/vpdLZgGbO05R34o9QdoG/9Mj7ixIrZ W6i9WZtfmbgy0b3GVwbhVIqwRNDcW2OwBAf8ldMHiSGhUCzY4tP7aS+AMwEA== 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:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1753843016; x=1753929416; bh=e1u1vAn3ujZm0PqCBvw2R9yfd4PGjkzxIXK A8IDhxdQ=; b=cjvCuaGUPtMm56u1DSb4+y38DmX9JARFljsUUDDblkq0X9dco3P kRvJCoukoiYHb3c/wcLmQk9MuQnwFAtgNqBpkiQhYn0tR0nlnpcW4v5f9xfT4UrD Y2ZSvUcYqLplvWfKM4ebbdXKVCYTFCVaM5ZS7B67V8U7NedWpvlb7PM8z5jREiyv 5ldgus6gtafZTPZ6G6S4tFno58SmZUp2GKdsAGv2BP0N7h3YRqAGsqyya2WNhpTY Y9fdHNRPsnINMHLGhtfgypdgv+KR9O1yyt8lmsw4Fu1z1vVD4BAUWpocYdA062UR shFu+m1DwAEEb0C1QPekqVr7ee8OaJFnVAA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdelieejhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecunecujfgurhepkfffgggfvffhufgtgfesthekredttddvje enucfhrhhomhepffhmihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdgu vghvqeenucggtffrrghtthgvrhhnpeeutdehffdtudejffeigfdtfffgtddvheekuedvhf ekhfdutedvleeiffefuefgueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhep mhgrihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvhdpnhgspghrtghpthhtoh epuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepsghughdqghhnuhdqvghmrggt shesghhnuhdrohhrgh X-ME-Proxy: Feedback-ID: i07de48aa:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 29 Jul 2025 22:36:55 -0400 (EDT) Message-ID: Date: Wed, 30 Jul 2025 05:36:54 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: bug-gnu-emacs@gnu.org From: Dmitry Gutov Subject: vc-switch-working-tree does not work if there is no matching file Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=202.12.124.154; envelope-from=dmitry@gutov.dev; helo=fhigh-b3-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) X-Debbugs-CC: spwhitton@spwhitton.name, sbaugh@janestreet.com Hi! If the current buffer does not visit a file (such as Dired, mentioned in a FIXME comment), or if the current file has no corresponding on the other worktree, we end up with an error. Like file-relative-name: Wrong type argument: stringp, nil or File ‘lisp/progmodes/abc.el’ not found in ‘~/vc/emacs-28/’ I guess some of these could be improved in project-find-matching-file (support for more major modes?) but semantically it seems like vc-switch-working-tree should try harder. Falling back to visiting the worktree root in Dired, if it doesn't find a better choice. ------------=_1754648342-9156-1--