From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#66663: 30.0.50; Allow dir locals file selection in *-dir-local-variable functions Date: Sat, 21 Oct 2023 21:21:17 +0300 Organization: LINKOV.NET Message-ID: <86zg0bu99e.fsf@mail.linkov.net> References: <03e5c99d-f900-4c8f-88b3-e7b458c0c777@gmail.com> <83o7gsqh3i.fsf@gnu.org> <514ef416-843b-4b80-abcf-cb4621b4b58d@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30876"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: Eli Zaretskii , 66663@debbugs.gnu.org To: Mauro Aranda Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 21 20:25:03 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1quGek-0007rA-VR for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Oct 2023 20:25:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quGeK-00063N-63; Sat, 21 Oct 2023 14:24:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1quGeI-00063A-Kz for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 14:24:34 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quGeI-0004Az-Be for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 14:24:34 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1quGek-0007MA-7v for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 14:25:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Oct 2023 18:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66663 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66663-submit@debbugs.gnu.org id=B66663.169791267428234 (code B ref 66663); Sat, 21 Oct 2023 18:25:02 +0000 Original-Received: (at 66663) by debbugs.gnu.org; 21 Oct 2023 18:24:34 +0000 Original-Received: from localhost ([127.0.0.1]:45016 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quGeH-0007LJ-MT for submit@debbugs.gnu.org; Sat, 21 Oct 2023 14:24:33 -0400 Original-Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]:48009) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quGeF-0007L4-He for 66663@debbugs.gnu.org; Sat, 21 Oct 2023 14:24:32 -0400 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 143B2E0003; Sat, 21 Oct 2023 18:23:56 +0000 (UTC) In-Reply-To: (Mauro Aranda's message of "Sat, 21 Oct 2023 11:06:28 -0300") X-GND-Sasl: juri@linkov.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:272926 Archived-At: > 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.