Subject: bug#65120: 29.1; directory-abbrev-alist breaks various things when inside an abbreviated directory

From: Sean Allred <[email-masked]>
Date: Wed, 09 Aug 2023 06:28:55 -0500

Eli Zaretskii <[email-masked]> writes:
> This is not how directory-abbrev-alist should be used, according to
> documentation.  The cdr of each alist element ("tmp" in your case) is
> supposed to be an absolute file name, and "tmp" isn't.  Also, the car
> of each element is supposed to be an anchored regexp.
>
> What did you want to accomplish with directory-abbrev-alist such as
> the above, and why did you want that?

Ah, I missed this key part of the docstring of `directory-abbrev-alist';
my apologies for that:

    Use this feature when you have directories that you normally refer to
    via absolute symbolic links.  Make TO the name of the link, and FROM
    a regexp matching the name it is linked to.

I jumped the gun on that one a bit. These are definitely not actual
symlinks. In fact, symlinks are categorically a no-go in the target
environment -- Windows on a corporate network. Other solutions like
junctions are probably not something my target audience is going to be
comfortable maintaining.

What I'm trying to do:

I work on the internal tools team at a large-ish software company (~2500
devs). I'm creating a Magit 'distribution' of sorts for Windows to try
to promote its adoption -- since it's the only application in which I
can build first-class support for our workflows. Part of this support
(since I'm developing to lower the barrier to entry for non-Emacs users)
is the creation of a GUI menu that has all the different repositories
and worktrees I can find on their system.

The problem is that our standard folder structure for source code yields
very long paths that look pretty ugly in this menu system. I'm talking
things like 'C:/$MegaCorpSource/git/$host/project/path/here.git' and
'C:/$MegaCorpSource/$version/$SomeDevelopmentIdentifier'. For various
reasons (mostly a _huge_ corpus of other tooling that relies on this
structure), this path structure cannot change. I'm also not limited to
things in $MegaCorpSource; I'm trying to collect all repositories in
`magit-repository-directories'.

So, I'd like to shorten this $MegaCorpSource path using built-in
functionality where possible. My users aren't going to care about most
of the path components. I can roll my own, but is there something like
`abbreviate-file-name' that doesn't assume we're working with symlinks?
(Should/could there be? Thoughts on whether or not it is A Good
Idea(tm)?)

--
Sean Allred