Subject: 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:01:58 +0300

> From: [email-masked]
> Date: Fri, 14 Jul 2023 11:28:13 +0000 (UTC)
> Cc: [email-masked], [email-masked]
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > If there are a couple of simpler alternatives which could be offered
> > via simple symbolic values, we should not force everyone to write
> > functions, IMNSHO.  IOW, we should NOT immediately generalize to
> > functions only because such generalization could make sense in some
> > use cases.  Repeat after me: Use options whose values are functions
> > are hard on our users, because they require them to be Lisp
> > programmers.
> 
> 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?

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.

> >> +(defcustom uniquify-dirname-transform #'identity
> >> +  "A function to transform the dirname used to uniquify a buffer.
> >
> > "Function to transform buffer's `default-directory' for uniquifying its name."
> 
> 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.