unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#73044: [PATCH] Add project-find-file-in-root
@ 2024-09-05 14:01 Spencer Baugh via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-09-06 16:20 ` Dmitry Gutov
  0 siblings, 1 reply; 8+ messages in thread
From: Spencer Baugh via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-09-05 14:01 UTC (permalink / raw)
  To: 73044; +Cc: dmitry

[-- Attachment #1: Type: text/plain, Size: 1465 bytes --]

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/'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-project-find-file-in-root.patch --]
[-- Type: text/patch, Size: 1937 bytes --]

From 960e5fc3486aa56d42c8c90fae025fe51c4cd7ad Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@janestreet.com>
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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#73044: [PATCH] Add project-find-file-in-root
  2024-09-05 14:01 bug#73044: [PATCH] Add project-find-file-in-root Spencer Baugh via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2024-09-06 16:20 ` Dmitry Gutov
  2024-09-06 17:44   ` Eli Zaretskii
  2024-09-15 18:14   ` Sean Whitton
  0 siblings, 2 replies; 8+ messages in thread
From: Dmitry Gutov @ 2024-09-06 16:20 UTC (permalink / raw)
  To: Spencer Baugh, 73044-done

Version: 31.1

Hi Spencer,

On 05/09/2024 17:01, Spencer Baugh via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:
> 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.

Makes sense, thanks, pushed to master (adding the 'interactive' form and 
a NEWS entry).

The name is a little verbose - if anybody has a better idea later, 
they're welcome to suggest it, there is some time to do a change.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#73044: [PATCH] Add project-find-file-in-root
  2024-09-06 16:20 ` Dmitry Gutov
@ 2024-09-06 17:44   ` Eli Zaretskii
  2024-09-06 20:05     ` Dmitry Gutov
  2024-09-15 18:14   ` Sean Whitton
  1 sibling, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2024-09-06 17:44 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: sbaugh, 73044

> Resent-To: bug-gnu-emacs@gnu.org
> Date: Fri, 6 Sep 2024 19:20:16 +0300
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> > 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.
> 
> Makes sense, thanks, pushed to master (adding the 'interactive' form and 
> a NEWS entry).

Thanks, but why only NEWS?  I think this should be in the user manual
as well.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#73044: [PATCH] Add project-find-file-in-root
  2024-09-06 17:44   ` Eli Zaretskii
@ 2024-09-06 20:05     ` Dmitry Gutov
  2024-09-07  6:10       ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Gutov @ 2024-09-06 20:05 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: sbaugh, 73044

On 06/09/2024 20:44, Eli Zaretskii wrote:
>> Resent-To:bug-gnu-emacs@gnu.org
>> Date: Fri, 6 Sep 2024 19:20:16 +0300
>> From: Dmitry Gutov<dmitry@gutov.dev>
>>
>>> 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.
>> Makes sense, thanks, pushed to master (adding the 'interactive' form and
>> a NEWS entry).
> Thanks, but why only NEWS?  I think this should be in the user manual
> as well.

I don't know, to me it seems like a niche enough feature, having lived 
without this addition for a number of major releases.

Spencer seems to agree, having submitted the patch without a default 
binding.

But if someone wants to describe it in the manual, I of course wouldn't 
mind. They can mention the situations described in this report.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#73044: [PATCH] Add project-find-file-in-root
  2024-09-06 20:05     ` Dmitry Gutov
@ 2024-09-07  6:10       ` Eli Zaretskii
  2024-09-08  2:14         ` Dmitry Gutov
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2024-09-07  6:10 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: sbaugh, 73044

> Date: Fri, 6 Sep 2024 23:05:06 +0300
> Cc: 73044@debbugs.gnu.org, sbaugh@janestreet.com
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> On 06/09/2024 20:44, Eli Zaretskii wrote:
> >> Resent-To:bug-gnu-emacs@gnu.org
> >> Date: Fri, 6 Sep 2024 19:20:16 +0300
> >> From: Dmitry Gutov<dmitry@gutov.dev>
> >>
> >>> 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.
> >> Makes sense, thanks, pushed to master (adding the 'interactive' form and
> >> a NEWS entry).
> > Thanks, but why only NEWS?  I think this should be in the user manual
> > as well.
> 
> I don't know, to me it seems like a niche enough feature, having lived 
> without this addition for a number of major releases.
> 
> Spencer seems to agree, having submitted the patch without a default 
> binding.
> 
> But if someone wants to describe it in the manual, I of course wouldn't 
> mind. They can mention the situations described in this report.

If you consider this not important enough to be in the manual, please
mark the NEWS entry with "---", to convey your opinion.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#73044: [PATCH] Add project-find-file-in-root
  2024-09-07  6:10       ` Eli Zaretskii
@ 2024-09-08  2:14         ` Dmitry Gutov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Gutov @ 2024-09-08  2:14 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: sbaugh, 73044

On 07/09/2024 09:10, Eli Zaretskii wrote:
> If you consider this not important enough to be in the manual, please
> mark the NEWS entry with "---", to convey your opinion.

Added, thanks.

Also split the entry into two lines.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#73044: [PATCH] Add project-find-file-in-root
  2024-09-06 16:20 ` Dmitry Gutov
  2024-09-06 17:44   ` Eli Zaretskii
@ 2024-09-15 18:14   ` Sean Whitton
  2024-09-16 23:12     ` Dmitry Gutov
  1 sibling, 1 reply; 8+ messages in thread
From: Sean Whitton @ 2024-09-15 18:14 UTC (permalink / raw)
  To: 73044, dmitry, sbaugh

Hello,

On Fri 06 Sep 2024 at 07:20pm +03, Dmitry Gutov wrote:

> The name is a little verbose - if anybody has a better idea later, they're
> welcome to suggest it, there is some time to do a change.

How about project-root-find-file ?

-- 
Sean Whitton





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#73044: [PATCH] Add project-find-file-in-root
  2024-09-15 18:14   ` Sean Whitton
@ 2024-09-16 23:12     ` Dmitry Gutov
  0 siblings, 0 replies; 8+ messages in thread
From: Dmitry Gutov @ 2024-09-16 23:12 UTC (permalink / raw)
  To: Sean Whitton, 73044, sbaugh

On 15/09/2024 21:14, Sean Whitton wrote:
> Hello,
> 
> On Fri 06 Sep 2024 at 07:20pm +03, Dmitry Gutov wrote:
> 
>> The name is a little verbose - if anybody has a better idea later, they're
>> welcome to suggest it, there is some time to do a change.
> 
> How about project-root-find-file ?

Nice! Renamed, thanks.

It does seem to create the necessary distinction.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-09-16 23:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-05 14:01 bug#73044: [PATCH] Add project-find-file-in-root Spencer Baugh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-06 16:20 ` Dmitry Gutov
2024-09-06 17:44   ` Eli Zaretskii
2024-09-06 20:05     ` Dmitry Gutov
2024-09-07  6:10       ` Eli Zaretskii
2024-09-08  2:14         ` Dmitry Gutov
2024-09-15 18:14   ` Sean Whitton
2024-09-16 23:12     ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).