Subject: bug#77229: [PATCH] Add 'project-customize-dirlocals'

From: Elijah Gabe Pérez <[email-masked]>
Date: Mon, 31 Mar 2025 14:21:26 -0600

Dmitry Gutov <[email-masked]> writes:

> On 24/03/2025 20:24, Elijah Gabe Pérez wrote:
>>     Yes, but file-name-concat is also not right here. Please use
>>     expand-file-name.
>> Done.
>
> FWIW, looks good to me.
>
> Waiting for the updated version with the NEWS entry, to install.

Done, sorry for the delay:

>From 73e2e627b0f9c1d92cddd39172ebb89ccc083801 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= <[email-masked]>
Date: Sun, 23 Mar 2025 21:35:32 -0600
Subject: [PATCH] Add 'project-customize-dirlocals'

* etc/NEWS: Add command entry.
* lisp/menu-bar.el (menu-bar-project-menu): Add command entry to
project menu.
* lisp/progmodes/project.el (project-customize-dirlocals):
New command.  (Bug#77229)
---
 etc/NEWS                  | 5 +++++
 lisp/menu-bar.el          | 1 +
 lisp/progmodes/project.el | 8 ++++++++
 3 files changed, 14 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 2745d467722..607e6da6301 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -341,6 +341,11 @@ docstring for arguments passed to a help-text function.
 *** New command 'project-root-find-file'.
 It is equivalent to running ‘project-any-command’ with ‘find-file’.
 
+---
+*** New command 'project-customize-dirlocals'.
+It is equivalent to running ‘project-any-command’ with
+‘customize-dirlocals’.
+
 ---
 *** Improved prompt for 'project-switch-project'.
 The prompt now displays the chosen project on which to invoke a command.
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 1685357fab6..6a68ad63a5b 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1830,6 +1830,7 @@ menu-bar-project-menu
     (define-key menu [project-compile] '(menu-item "Compile..." project-compile :help "Invoke compiler or Make for current project, view errors"))
     (define-key menu [separator-project-programs] menu-bar-separator)
     (define-key menu [project-switch-project] '(menu-item "Switch Project..." project-switch-project :help "Switch to another project and then run a command"))
+    (define-key menu [project-customize-dirlocals] '(menu-item "Customize Directory Local Variables" project-customize-dirlocals :help "Customize current project Directory Local Variables."))
     (define-key menu [project-vc-dir] '(menu-item "VC Dir" project-vc-dir :help "Show the VC status of the project repository"))
     (define-key menu [project-dired] '(menu-item "Open Project Root" project-dired :help "Read the root directory of the current project, to operate on its files"))
     (define-key menu [project-find-dir] '(menu-item "Open Directory..." project-find-dir :help "Open existing directory that belongs to current project"))
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index e2cd5bfa231..cb0cc038585 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1391,6 +1391,14 @@ project-vc-dir
   (interactive)
   (vc-dir (project-root (project-current t))))
 
+;;;###autoload
+(defun project-customize-dirlocals ()
+  "Run `customize-dirlocals' in current project's root."
+  (interactive)
+  (customize-dirlocals
+   (expand-file-name ".dir-locals.el"
+                     (project-root (project-current t)))))
+
 (declare-function comint-check-proc "comint")
 
 ;;;###autoload
-- 
2.49.0

-- 
                                          - E.G via GNU Emacs and Org.