Subject: Re: bug#66663: 30.0.50; Allow dir locals file selection in *-dir-local-variable functions

From: Juri Linkov <[email-masked]>
Date: Sat, 21 Oct 2023 21:21:17 +0300

> I reworked the patch to implement that UI instead.  Patch attached.

Thanks, some comments:

> +(defun read-dir-locals-file ()
> +  "Read a dir-locals filename using completion.
> +Intended to be used in the `interactive' spec of `add-dir-local-variable',
> +`delete-dir-local-variable' and `copy-file-locals-to-dir-locals'.
> +
> +Returns the filename, expanded."
> +  (expand-file-name
> +   (read-file-name "File" nil nil

The prompt needs a colon.

> +                   (lambda (fname)
> +                     (member (file-name-nondirectory fname)
> +                             (list dir-locals-file
> +                                   (replace-regexp-in-string
> +                                    ".el$" "-2.el" dir-locals-file))))
> +                   dir-locals-file)))

This needs to be run in the project's root directory
where the dir-locals file is saved.  Probably it's not easy
to find the root without using project.el.  But when one of the
files already exists (either .dir-locals.el or .dir-locals-2.el),
then better to use the directory of the existing file by default.