emacs-diffs
[Top][All Lists]
Advanced

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

master 466db358772: ; Revise new command 'project-find-file-in-root'


From: Eshel Yaron
Subject: master 466db358772: ; Revise new command 'project-find-file-in-root'
Date: Mon, 9 Sep 2024 13:51:07 -0400 (EDT)

branch: master
commit 466db35877281ce2d5c2a5804e16d9401017d766
Author: Eshel Yaron <me@eshelyaron.com>
Commit: Eshel Yaron <me@eshelyaron.com>

    ; Revise new command 'project-find-file-in-root'
    
    * lisp/progmodes/project.el (project-find-file-in-root):
    Call 'find-file' directly, not via 'call-interactively'.
    Move interactive behavior to 'interactive' spec.
---
 lisp/progmodes/project.el | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ce2960c248b..ab884935a77 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1070,17 +1070,16 @@ using a command like `project-find-file'."
     filename))
 
 ;;;###autoload
-(defun project-find-file-in-root ()
-  "Call `find-file' with the current project root as `default-directory'.
-
-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)))
+(defun project-find-file-in-root (filename)
+  "Edit file FILENAME.
+
+Interactively, prompt for FILENAME, defaulting to the root directory of
+the current project."
+  (declare (interactive-only find-file))
+  (interactive (list (read-file-name "Find file in root: "
+                                     (project-root (project-current t)) nil
+                                     (confirm-nonexistent-file-or-buffer))))
+  (find-file filename t))
 
 ;;;###autoload
 (defun project-find-file (&optional include-all)



reply via email to

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