unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Can project.el or projectile.el help? How about completion?
@ 2021-10-31 18:48 John Yates
  2021-11-01  0:39 ` Stephen Leake
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: John Yates @ 2021-10-31 18:48 UTC (permalink / raw)
  To: Emacs developers

I work on a large corporate mono-repo in which numerous
filenames occur repeatedly.  Further, various directories
above such duplicates also have duplicated names.

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?

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.

/john



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can project.el or projectile.el help? How about completion?
  2021-10-31 18:48 Can project.el or projectile.el help? How about completion? John Yates
@ 2021-11-01  0:39 ` Stephen Leake
  2021-11-01 12:20 ` Bozhidar Batsov
  2021-11-01 13:48 ` Dmitry Gutov
  2 siblings, 0 replies; 4+ messages in thread
From: Stephen Leake @ 2021-11-01  0:39 UTC (permalink / raw)
  To: John Yates; +Cc: Emacs developers

John Yates <john@yates-sheets.org> writes:

> I work on a large corporate mono-repo in which numerous
> filenames occur repeatedly.  Further, various directories
> above such duplicates also have duplicated names.

Not directly answering your question, but the ELPA package
uniquify-files might help.


-- 
-- Stephe



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can project.el or projectile.el help? How about completion?
  2021-10-31 18:48 Can project.el or projectile.el help? How about completion? John Yates
  2021-11-01  0:39 ` Stephen Leake
@ 2021-11-01 12:20 ` Bozhidar Batsov
  2021-11-01 13:48 ` Dmitry Gutov
  2 siblings, 0 replies; 4+ messages in thread
From: Bozhidar Batsov @ 2021-11-01 12:20 UTC (permalink / raw)
  To: Emacs Devel

[-- Attachment #1: Type: text/plain, Size: 2198 bytes --]

Projectile's author here. 

Some examples of the nature of the problem would be useful, as I don't quite understand if we're talking about exactly the same files appearing at different places of the repo or it's files with the name that are actually different.

Projectile returns the project files relative to the project root, so it's pretty easy to tell apart files in the second case, but I'm assuming your problem is probably the first case. I'm not aware of any existing sort order based on the distance from the current folder, although I can imagine this shouldn't very hard to implement. 

At any rate - projectile's quite flexible when it comes both to indexing strategies and to sorting orders, so it will definitely be possible to use something custom there, if the built-in options don't work well for you. 

On Sun, Oct 31, 2021, at 8:48 PM, 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.
> 
> 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?
> 
> 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.
> 
> /john
> 
> 

[-- Attachment #2: Type: text/html, Size: 2939 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Can project.el or projectile.el help? How about completion?
  2021-10-31 18:48 Can project.el or projectile.el help? How about completion? John Yates
  2021-11-01  0:39 ` Stephen Leake
  2021-11-01 12:20 ` Bozhidar Batsov
@ 2021-11-01 13:48 ` Dmitry Gutov
  2 siblings, 0 replies; 4+ messages in thread
From: Dmitry Gutov @ 2021-11-01 13:48 UTC (permalink / raw)
  To: John Yates, Emacs developers

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.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-01 13:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-31 18:48 Can project.el or projectile.el help? How about completion? John Yates
2021-11-01  0:39 ` Stephen Leake
2021-11-01 12:20 ` Bozhidar Batsov
2021-11-01 13:48 ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).