emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master d879c40f68c: * etc/NEWS: Mention it.


From: Dmitry Gutov
Subject: master d879c40f68c: * etc/NEWS: Mention it.
Date: Fri, 6 Sep 2024 12:17:54 -0400 (EDT)

branch: master
commit d879c40f68c078bdba15122e4e886a2052fbddf4
Author: Spencer Baugh <sbaugh@janestreet.com>
Commit: Dmitry Gutov <dmitry@gutov.dev>

    * etc/NEWS: Mention it.
    
    Add project-find-file-in-root (bug#73044)
    
    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.
    
    * etc/NEWS: Mention it.
---
 etc/NEWS                  |  5 +++++
 lisp/progmodes/project.el | 13 +++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 1e66f084117..e257721f5b4 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -108,6 +108,11 @@ latter throws an error when the argument FRAME cannot be 
deleted.
 *** New abnormal hook 'tab-bar-auto-width-functions'.
 This hook allows you to control which tab-bar tabs are auto-resized.
 
+** Project
+
+New command `project-find-file-in-root` which is equivalent to running
+‘project-any-command’ with ‘find-file’.
+
 
 * Editing Changes in Emacs 31.1
 
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 983242628f0..ddaa58fbcf1 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1069,6 +1069,19 @@ using a command like `project-find-file'."
               (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'."
+  (interactive)
+  (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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]