emacs-devel
[Top][All Lists]
Advanced

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

Re: Can project.el or projectile.el help? How about completion?


From: Dmitry Gutov
Subject: Re: Can project.el or projectile.el help? How about completion?
Date: Mon, 1 Nov 2021 16:48:20 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

Hi!

On 31.10.2021 21:48, John Yates wrote:
I work on a large corporate mono-repo in which numerous
filenames occur repeatedly.  Further, various directories
above such duplicates also have duplicated names.

First of all, project-find-files by default uses 'substring' completion.

Which can allow you to type unique parts of the relative file name, separated by slashes, press TAB, and then see the name completed.

Completion frameworks like Ivy/Helm/Consult can also affect/augment the completion experience.

Currently I use a self-built emacs tool to index this space:
* Build a map from a unique filename to a set of
   repo-relative directory paths to files with that name
* Compute a disambiguation string for completing reads
   for unique filenames this string is empty; otherwise:
   * Repeatedly strip identical leading directories
   * Repeatedly strip identical trailing directories

I would like to replace this tool with something like
project.el or projectile.el.  So the first question is does
either package do anything intelligent when filenames
are duplicated?  If so, what?

project.el also comes with defcustom called project-read-file-name-function. It allows you to write your own wrapper which could convert all files names into "disambiguating strings", for ease of completion, before the completion prompt is displayed.

Then, is there any completion package that can present
the candidates in an order reflecting their distance from
the current buffer's working directory?  My thought is to
sort identically named candidates by their repo-relative
paths.  A focused, incrementally widening presentation
of candidates would show initially those in or below the
current working directory.  Each time instructed to widen
the presentation it would advance up the parent directory
chain, showing candidates in or below that directory.

Since project-read-file-name-function creates the completion table object, you could sort the strings inside it as well, using the algorithm of your choice. As long as the table defines `display-sort-function', the completion UIs should not re-sort the list alphabetically.



reply via email to

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