Subject: bug#44297: [Feature request] project.el: Additional utility functions

From: Dmitry Gutov <[email-masked]>
Date: Fri, 30 Oct 2020 01:20:21 +0200

On 29.10.2020 11:03, Juri Linkov wrote:
>> It would be nice if project.el had the following interactive functions:
>>
>> project-find-other-file: Find a file with the same basename as the current file but a different extension
> 
> Maybe then it should be named project-find-other-extension?
> Otherwise, project-find-other-file might imply a similarity
> with find-alternate-file (C-x C-v).

I think the term is pretty much established: 
https://www.emacswiki.org/emacs/FindOtherFile

Projectile also has a command with a similar name.

The feature will be pretty C/C++-centric, but I suppose it's useful enough.

What I don't understand, is why should it be in the project- namespace? 
Looking for a file with the same name in the current dir doesn't execute 
the notion of the current project, even a little bit.

Projectile does a project-wide search for a file with the same basename 
(but a different extension). Is that actually useful?

> Another question: how it should work?  Maybe running this command
> should completing-read on all files with the same basename
> ignoring the extension?

Projectile has projectile-other-file-alist. A similar defcustom should 
narrow the search somewhat.

>> project-find-file-in-directory: completing-read for a directory within
>> the project, and then within the selected directory, completing-read
>> for a file within that directory
>> project-find-directory: completing-read for a directory within the project
> 
> Another useful command would be:
> project-find-file-only using completing-read to match on file names only,
> not on directory parts.

And then... disambiguate files with the same base name with another prompt?

IME, having multiple files with the same name in the project is very 
common. Your experience can vary, though.

A fuzzy search across full names works best for me, personally. We could 
also try some differently weighted, fuzzy matching styles.

>> project-recentf: completing-read recently-accessed files in the project
> 
> All project file-reading commands could provide a list of recent files
> as the default values available via M-n key presses.

Perhaps a flat, immediately visible list will have its own value, though?