Subject: bug#77122: [PATCH] project--find-in-directory resolves symlinks

From: Ship Mints <[email-masked]>
Date: Mon, 24 Mar 2025 06:40:29 -0400

On Sat, Mar 22, 2025 at 9:47 PM Daniel Colascione <[email-masked]> wrote:

> Dmitry Gutov <[email-masked]> writes:
>
> > Hi!
> >
> > On 19/03/2025 18:55, Ship Mints wrote:
> >> This avoids duplicate projects accessed via symlinks that share
> >> resolved directory locations.  This has bothered me for a while, so
> >> here we go.
> >
> > Could you describe the reasons why your setup is the way it is?
> >
> > Personally, I've never used symlinks at this level, and if I did, I'm
> > not sure I would see the problem with project-root returning different
> > strings for those.
> >
> > What exactly is the problem? Having the "same" project multiple times
> > in project history?
> >
> > I can name a couple of (probably minor) downsides:
> >
> > * The project detection would be slower (more disk I/O).
> > * project-root would more often return a string that is not a parent
> >   directory of default-directory. Some code out there probably
> >   soft-depends on that.
>
> FWIW, I sometimes symlink convenient names to inconvenient ones, and it
> would be a shame to use the inconvenient names due to excessive
> symlink chasing. (Other packages aren't great about this.) Can't people
> who want symlink chasing add something to project-find-functions?
>

Yeah, good question.  "Can't people" applies pretty much to every feature
and option added to Emacs that people can do themselves including
overriding functions wholesale.  The bigger picture, to me, is that if we
add options to do things like this for our users, then we can help more of
them, we can refine implementations at deeper levels should we need to, we
can prompt people to think more considerately about their working
environments.  Perhaps some never considered using symlinks as vanity paths
and they'll have the choice to treat project objects among those
paths canonically.

Since I suggested it be optional, it would be off by default, right?  If
you think you'd want to canonicalize paths to project roots in some places
and not others, perhaps we could contrive a project sentinel file ala
.project-notruename.el/d or .project-config.el/d, and for people that want
to do things in code, a list project can consult.