From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73044: [PATCH] Add project-find-file-in-root Date: Thu, 05 Sep 2024 10:01:46 -0400 Message-ID: Reply-To: Spencer Baugh Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16077"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmitry@gutov.dev To: 73044@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 05 16:02:20 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1smD3z-00042G-Jx for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Sep 2024 16:02:19 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smD3f-0006qr-PD; Thu, 05 Sep 2024 10:01:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smD3e-0006qb-9Y for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 10:01:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smD3d-0005au-VW for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 10:01:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=4L797ns/Z4kdlBMiLGmEcDSWJZTgjHgIqe69rFThBlA=; b=ILhqhXYoU70/Lw+pazxlvIs2J1zrYaX4b0wn7pXTXnV/na0ivQx5uQtDvpxOUfPVfIivSq9nWiGkdQB0oCVUO7wapJyJOAKMn3On2ljGTEu4mCHhCybl5EUj8b6zNL50YWqdWb+iqYD4/hWn/ZuW54Jl5u70AC36AK8bTu/zgsVQKXfbwkH7ZdOpbaee4NU2Zs3eQB0GjKq3JMyuaHG4kpda4HDuEwL+g7++P3J04N5MtOBlyuZvjwE1Z7LqoR/ik9zBDTl1TTOVIAgNgTKgAhUMKKLib0lYP+WOlNMkxQYYx46jFm8/n36Su7u6vn3iwbkttGLvn63aJfFws4ZzZA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1smD4g-00041c-07 for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 10:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Sep 2024 14:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 73044 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172554498015462 (code B ref -1); Thu, 05 Sep 2024 14:03:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Sep 2024 14:03:00 +0000 Original-Received: from localhost ([127.0.0.1]:37720 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smD4d-00041K-Qn for submit@debbugs.gnu.org; Thu, 05 Sep 2024 10:03:00 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:57720) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smD4c-00041C-03 for submit@debbugs.gnu.org; Thu, 05 Sep 2024 10:02:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smD3Y-0006qP-LD for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 10:01:52 -0400 Original-Received: from mxout6.mail.janestreet.com ([64.215.233.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smD3W-0005aC-Qn for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 10:01:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=janestreet.com; s=waixah; t=1725544907; bh=4L797ns/Z4kdlBMiLGmEcDSWJZTgjHgIqe69rFThBlA=; h=From:To:Cc:Subject:Date; b=iKaFTYLpy9UF+DvC0ceWIgu17gGmvsKX9QmzHNeAByoiKnPL7a89haPSajlmw5vuc CYU/mHJhuZzZQJbPFuQuZEspwkESFWprSFSVP0iyS3FTQGw59JalvGMPGpcIquvICc +QYg3aiB8AN9PdwnvxaCQ1nbnFTnU3/aGrO1Q7/xCN3v6yMYWCm6nV4J6OPmOHQ1XD 1zC+yyy8C0IPolVlK+oZ+zJPhy/rBK+WIiTIqdJu23mOnMYM/SZC4gFNAvfMbAGWD9 X5gsmhf/Ibzl3OEUNSG8ZPgJdmcq5G3sg/QbKR7SZowTxbt7Y83ahINUy0zTdGwxvo F0FcYibQbxR+g== Received-SPF: pass client-ip=64.215.233.21; envelope-from=sbaugh@janestreet.com; helo=mxout6.mail.janestreet.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291255 Archived-At: --=-=-= Content-Type: text/plain Tags: patch Several users have asked me for a command which is just find-file, but starting from the project root. In large projects, where project-files is expensive, this will have substantially better performance than project-find-file. Also, it allows opening files which aren't included in project-files without paying the further cost of running project--files-in-directory (which is what happens when passing INCLUDE-ALL=t to project-find-file). Also, it may help with user confusion about why project-find-file doesn't behave like find-file. (which I've encountered a few times) This command is equivalent to C-x p o C-x C-f, but it's nice to be able to bind it to a specific key. Overall, this is easy enough to provide, so let's just do that. In GNU Emacs 29.2.50 (build 16, x86_64-pc-linux-gnu, X toolkit, cairo version 1.15.12, Xaw scroll bars) of 2024-08-26 built on igm-qws-u22796a Repository revision: e6d04c06a7eb6ce932b52a346368d02b7a811a00 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Rocky Linux 8.10 (Green Obsidian) Configured using: 'configure --with-x-toolkit=lucid --without-gpm --without-gconf --without-selinux --without-imagemagick --with-modules --with-gif=no --with-cairo --with-rsvg --without-compress-install --with-native-compilation=aot --with-tree-sitter PKG_CONFIG_PATH=/usr/local/home/garnish/libtree-sitter/0.22.6-1/lib/pkgconfig/' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Add-project-find-file-in-root.patch >From 960e5fc3486aa56d42c8c90fae025fe51c4cd7ad Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Thu, 5 Sep 2024 09:56:50 -0400 Subject: [PATCH] Add project-find-file-in-root Several users have asked me for a command which is just find-file, but starting from the project root. In large projects, where project-files is expensive, this will have substantially better performance than project-find-file. Also, it allows opening files which aren't included in project-files without paying the further cost of running project--files-in-directory (which is what happens when passing INCLUDE-ALL=t to project-find-file). Also, it may help with user confusion about why project-find-file doesn't behave like find-file. (which I've encountered a few times) This command is equivalent to C-x p o C-x C-f, but it's nice to be able to bind it to a specific key. Overall, this is easy enough to provide, so let's just do that. * lisp/progmodes/project.el (project-find-file-in-root): Add. --- lisp/progmodes/project.el | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 983242628f0..cfb81e5425c 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1069,6 +1069,18 @@ project--find-default-from (file-relative-name filename (project-root filename-proj))) filename)) +;;;###autoload +(defun project-find-file-in-root () + "Call `find-file' in the current project root. + +Unlike `project-find-file', this doesn't provide completion over the +entire file tree. + +This is equivalent to running `project-any-command' with `find-file'." + (let* ((pr (project-current t)) + (default-directory (project-root pr))) + (call-interactively #'find-file))) + ;;;###autoload (defun project-find-file (&optional include-all) "Visit a file (with completion) in the current project. -- 2.39.3 --=-=-=--