GNU bug report logs - #66702
Add easy customization for .dir-locals.el files

Previous Next

Package: emacs;

Reported by: Mauro Aranda <maurooaranda <at> gmail.com>

Date: Mon, 23 Oct 2023 14:23:01 UTC

Severity: wishlist

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 66702 in the body.
You can then email your comments to 66702 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#66702; Package emacs. (Mon, 23 Oct 2023 14:23:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mauro Aranda <maurooaranda <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 23 Oct 2023 14:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Add easy customization for .dir-locals.el files
Date: Mon, 23 Oct 2023 11:21:44 -0300
Severity: wishlist

This is a feature request.  The idea is to provide an Easy Customization
interface to editing .dir-locals.el files:
https://lists.gnu.org/archive/html/emacs-devel/2023-09/msg01306.html

Currently, there are two ways of handling .dir-locals.el: either by
hand or by using the *-dir-locals commands.  Using the Customize
interface has, IMO, the following non-exhaustive advantages:
- It's useful for beginners or for people that are used to using the
interface for customizing the init file.
- Validation for defcustom :type, unlike the commands in files-x.el
- Ability to edit multiple settings and then save just once.
- Ability to quickly select the .dir-locals file to edit.

I'll attach a patch once I get assigned a Bug#.  The patch adds a new
command, customize-dirlocals to pop up a buffer with the dirlocals
settings in a .dir-locals.el file.  The file can be changed later on in
the buffer.  Saving, reverting and validating customizations is
supported.  There is also support for the menubar and the toolbar.

There are some differences with the usual Customize buffer.  One is
that, since these customizations don't go to the custom-file, I didn't
reuse all of the functions for creating the Custom buffer, neither I
reuse Custom-mode.  Other one is that there's no "magic" widget, no
information about the STATE of the variable, or the widget.

The most important difference, I think, is that the buffer needs to
update upon each option the user wants to edit.  This is similar to the
situation for the customize-create-theme buffer, but my code follows a
different approach.  It lets the user enter any symbol, and upon hitting
RET or TAB it updates the widget that will hold the value.  The *Custom
Theme* buffer prompts for the variable to edit, so it can add the right
editing widget.






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66702; Package emacs. (Mon, 23 Oct 2023 14:25:01 GMT) Full text and rfc822 format available.

Message #8 received at 66702 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: 66702 <at> debbugs.gnu.org
Subject: Re: bug#66702: Add easy customization for .dir-locals.el files
Date: Mon, 23 Oct 2023 11:24:16 -0300
[Message part 1 (text/plain, inline)]
tags 66702 patch
quit


Patch attached.
[0001-Add-easy-customization-for-dir-locals-files-Bug-6670.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66702; Package emacs. (Mon, 23 Oct 2023 17:27:03 GMT) Full text and rfc822 format available.

Message #11 received at 66702 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Mauro Aranda <maurooaranda <at> gmail.com>
Cc: 66702 <at> debbugs.gnu.org
Subject: Re: bug#66702: Add easy customization for .dir-locals.el files
Date: Mon, 23 Oct 2023 20:16:27 +0300
> Patch attached.

I tried it out on emacs/.dir-locals.el, and one thing that I noticed is that
it changes the order of modes by sorting them alphabetically.  I'm sure
people won't like if their files will get so much changes especially
when they intend to commit a change in a single value.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66702; Package emacs. (Mon, 23 Oct 2023 20:45:02 GMT) Full text and rfc822 format available.

Message #14 received at 66702 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 66702 <at> debbugs.gnu.org
Subject: Re: bug#66702: Add easy customization for .dir-locals.el files
Date: Mon, 23 Oct 2023 17:43:35 -0300
On 23/10/23 14:16, Juri Linkov wrote:
>> Patch attached.
>
> I tried it out on emacs/.dir-locals.el, and one thing that I noticed 
is that
> it changes the order of modes by sorting them alphabetically.  I'm sure
> people won't like if their files will get so much changes especially
> when they intend to commit a change in a single value.

That's modify-dir-local-variable doing the sorting.

You get the same results by doing:
emacs -Q
M-x add-dir-local-variable RET nil RET foo RET t
M-x diff-buffer-with-file RET RET

Should we add a nosort option somewhere?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66702; Package emacs. (Tue, 24 Oct 2023 07:29:02 GMT) Full text and rfc822 format available.

Message #17 received at 66702 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Mauro Aranda <maurooaranda <at> gmail.com>
Cc: 66702 <at> debbugs.gnu.org
Subject: Re: bug#66702: Add easy customization for .dir-locals.el files
Date: Tue, 24 Oct 2023 09:58:50 +0300
>> I tried it out on emacs/.dir-locals.el, and one thing that I noticed is that
>> it changes the order of modes by sorting them alphabetically.  I'm sure
>> people won't like if their files will get so much changes especially
>> when they intend to commit a change in a single value.
>
> That's modify-dir-local-variable doing the sorting.
>
> You get the same results by doing:
> emacs -Q
> M-x add-dir-local-variable RET nil RET foo RET t
> M-x diff-buffer-with-file RET RET
>
> Should we add a nosort option somewhere?

The assumption was that .dir-locals.el will always be modified
by these commands.  But since it's often modified manually
with an arbitrary order, this means that the sorting order
is not important.  So we could simply remove the sorting code.

PS: This is not directly related to your current patch that I believe
is ready to be installed if no one will have more comments.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66702; Package emacs. (Tue, 24 Oct 2023 09:46:01 GMT) Full text and rfc822 format available.

Message #20 received at 66702 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 66702 <at> debbugs.gnu.org
Subject: Re: bug#66702: Add easy customization for .dir-locals.el files
Date: Tue, 24 Oct 2023 06:45:04 -0300
On 24/10/23 03:58, Juri Linkov wrote:
>>> I tried it out on emacs/.dir-locals.el, and one thing that I 
noticed is that
>>> it changes the order of modes by sorting them alphabetically.  I'm sure
>>> people won't like if their files will get so much changes especially
>>> when they intend to commit a change in a single value.
>>
>> That's modify-dir-local-variable doing the sorting.
>>
>> You get the same results by doing:
>> emacs -Q
>> M-x add-dir-local-variable RET nil RET foo RET t
>> M-x diff-buffer-with-file RET RET
>>
>> Should we add a nosort option somewhere?
>
> The assumption was that .dir-locals.el will always be modified
> by these commands.  But since it's often modified manually
> with an arbitrary order, this means that the sorting order
> is not important.  So we could simply remove the sorting code.

Hmm, but that would be backward incompatible.  Someone out there might
be relying in these commands to keep the settings sorted.

> PS: This is not directly related to your current patch that I believe
> is ready to be installed if no one will have more comments.

Great.  Thank you!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66702; Package emacs. (Wed, 25 Oct 2023 06:52:02 GMT) Full text and rfc822 format available.

Message #23 received at 66702 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Mauro Aranda <maurooaranda <at> gmail.com>
Cc: 66702 <at> debbugs.gnu.org
Subject: Re: bug#66702: Add easy customization for .dir-locals.el files
Date: Wed, 25 Oct 2023 09:48:27 +0300
>>> M-x add-dir-local-variable RET nil RET foo RET t
>>> M-x diff-buffer-with-file RET RET
>>>
>>> Should we add a nosort option somewhere?
>>
>> The assumption was that .dir-locals.el will always be modified
>> by these commands.  But since it's often modified manually
>> with an arbitrary order, this means that the sorting order
>> is not important.  So we could simply remove the sorting code.
>
> Hmm, but that would be backward incompatible.  Someone out there might
> be relying in these commands to keep the settings sorted.

Then we could add a simple variable, not a customizable option.
Then they could even set this variable in the customized .dir-locals.el!




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66702; Package emacs. (Fri, 27 Oct 2023 11:08:01 GMT) Full text and rfc822 format available.

Message #26 received at 66702 <at> debbugs.gnu.org (full text, mbox):

From: Mauro Aranda <maurooaranda <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 66702 <at> debbugs.gnu.org
Subject: Re: bug#66702: Add easy customization for .dir-locals.el files
Date: Fri, 27 Oct 2023 08:06:26 -0300
On 25/10/23 03:48, Juri Linkov wrote:
>>>> M-x add-dir-local-variable RET nil RET foo RET t
>>>> M-x diff-buffer-with-file RET RET
>>>>
>>>> Should we add a nosort option somewhere?
>>>
>>> The assumption was that .dir-locals.el will always be modified
>>> by these commands.  But since it's often modified manually
>>> with an arbitrary order, this means that the sorting order
>>> is not important.  So we could simply remove the sorting code.
>>
>> Hmm, but that would be backward incompatible.  Someone out there might
>> be relying in these commands to keep the settings sorted.
>
> Then we could add a simple variable, not a customizable option.
> Then they could even set this variable in the customized .dir-locals.el!

That should be good enough, I think.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#66702; Package emacs. (Sat, 28 Oct 2023 17:08:02 GMT) Full text and rfc822 format available.

Message #29 received at 66702 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Mauro Aranda <maurooaranda <at> gmail.com>
Cc: 66702 <at> debbugs.gnu.org
Subject: Re: bug#66702: Add easy customization for .dir-locals.el files
Date: Sat, 28 Oct 2023 20:02:44 +0300
close 66702 30.0.50
thanks

> Patch attached.

Thanks for the patch, now pushed to master.




bug marked as fixed in version 30.0.50, send any further explanations to 66702 <at> debbugs.gnu.org and Mauro Aranda <maurooaranda <at> gmail.com> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Sat, 28 Oct 2023 17:08:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 26 Nov 2023 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 196 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.