diff options
| author | Spencer Baugh | 2024-09-05 09:56:50 -0400 |
|---|---|---|
| committer | Dmitry Gutov | 2024-09-06 19:16:46 +0300 |
| commit | d879c40f68c078bdba15122e4e886a2052fbddf4 (patch) | |
| tree | be256266b8765af07524a39c16470112b7741fd8 | |
| parent | 658715c977c78c312685cd6c594a2cbc0d31fc7d (diff) | |
| download | emacs-d879c40f68c078bdba15122e4e886a2052fbddf4.tar.gz emacs-d879c40f68c078bdba15122e4e886a2052fbddf4.zip | |
* 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.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/progmodes/project.el | 13 |
2 files changed, 18 insertions, 0 deletions
| @@ -108,6 +108,11 @@ latter throws an error when the argument FRAME cannot be deleted. | |||
| 108 | *** New abnormal hook 'tab-bar-auto-width-functions'. | 108 | *** New abnormal hook 'tab-bar-auto-width-functions'. |
| 109 | This hook allows you to control which tab-bar tabs are auto-resized. | 109 | This hook allows you to control which tab-bar tabs are auto-resized. |
| 110 | 110 | ||
| 111 | ** Project | ||
| 112 | |||
| 113 | New command `project-find-file-in-root` which is equivalent to running | ||
| 114 | ‘project-any-command’ with ‘find-file’. | ||
| 115 | |||
| 111 | 116 | ||
| 112 | * Editing Changes in Emacs 31.1 | 117 | * Editing Changes in Emacs 31.1 |
| 113 | 118 | ||
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 | |||
| @@ -1070,6 +1070,19 @@ using a command like `project-find-file'." | |||
| 1070 | filename)) | 1070 | filename)) |
| 1071 | 1071 | ||
| 1072 | ;;;###autoload | 1072 | ;;;###autoload |
| 1073 | (defun project-find-file-in-root () | ||
| 1074 | "Call `find-file' in the current project root. | ||
| 1075 | |||
| 1076 | Unlike `project-find-file', this doesn't provide completion over the | ||
| 1077 | entire file tree. | ||
| 1078 | |||
| 1079 | This is equivalent to running `project-any-command' with `find-file'." | ||
| 1080 | (interactive) | ||
| 1081 | (let* ((pr (project-current t)) | ||
| 1082 | (default-directory (project-root pr))) | ||
| 1083 | (call-interactively #'find-file))) | ||
| 1084 | |||
| 1085 | ;;;###autoload | ||
| 1073 | (defun project-find-file (&optional include-all) | 1086 | (defun project-find-file (&optional include-all) |
| 1074 | "Visit a file (with completion) in the current project. | 1087 | "Visit a file (with completion) in the current project. |
| 1075 | 1088 | ||