Subject: Re: bug#62621: 29.0.60; uniquify can't make buffers unique based on things other than filename

From: Eli Zaretskii <[email-masked]>
Date: Fri, 14 Jul 2023 15:29:02 +0300

> From: Spencer Baugh <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Fri, 14 Jul 2023 08:20:02 -0400
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> >> I agree, and I'm happy to change it to use a simple symbolic value
> >> 'project instead for the transform I wrote, but I'm not sure how best to
> >> handle the dependencies: uniquify.el is in loadup.el, is it OK for it to
> >> rely on project-uniquify-dirname-transform being autoloaded?
> >
> > I don't understand the difficulty.  If the function value could be
> > defined in uniquify.el, why cannot a symbolic value be defined there?
> 
> I don't understand your question :)
> 
> Here's concretely the diff I would apply.  This makes uniquify.el mention a
> function from project.el.  Is that OK?

No.

> > If the symbolic values are specific to project, simply let-bind
> > uniquify-dirname-transform to the value of the appropriate project.el
> > defcustom when project.el calls uniquify.
> 
> These customizations are in effect all the time, not just when the user
> is calling a project.el command.  e.g. rename-buffer triggers uniquify.

Then you can set the buffer-local value of uniquify-dirname-transform
in the project.el buffers.  Would that solve the problem?

> >> Unfortunately, this isn't quite right.  uniquify never uses
> >> default-directory, counterintuitively - by default, it uses the
> >> directory of buffer-file-name, which can differ from default-directory.
> >
> > That's a minor issue, just use "buffer's directory" instead.
> >
> > But I wonder why uniquify does something counterintuitive like that.
> 
> I assume it's something like "default-directory changes (such as by M-x
> cd) shouldn't change the buffer name too".

default-directory of a file-visiting buffer doesn't change.

> The fact that uniquify doesn't use default-directory also means it's
> unable to uniquify buffers which aren't visiting files

Exactly.