all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Dir-Locals + Editorconfig Changes in Emacs 26
@ 2017-10-02 17:55 Jay Kamat
  2017-10-03 15:39 ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Jay Kamat @ 2017-10-02 17:55 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Everyone!

I use an emacs plugin called 'editorconfig' which provides an editor
independent way to set style configuration on a per-project basis, very
similar to the dir-locals feature in Emacs.

In emacs 25 and below, dir-locals and editorconfig interacted "as
expected", in that, the dir-locals file was applied after the
editorconfig, so dir-locals would take precedence over editorconfig
settings.

However, since emacs 26, this is reversed, where dir-locals is applied
first, rather than last, and so editorconfig overrides dir-locals. I
have filed a bug report to the project here to document it:
https://github.com/editorconfig/editorconfig-emacs/issues/141

The reason that this is significant is that editorconfig not only lets
you configure on a per-project basis, but recursively on a per machine
basis as well, so if you have a editorconfig file in your home directory
(as many people do) those settings will apply for every file on your
system, overwriting dir-locals settings. Since dir-locals is more
powerful and project-specific, I would much prefer dir-locals to
override editorconfig.

Editorconfig seems to apply on the 'after-change-major-mode' hook, as
shown below:
https://github.com/editorconfig/editorconfig-emacs/blob/master/editorconfig.el#L521-L531

I tried bisecting emacs to try to find a relevant change, but I wasn't
able to compile some of the older versions due to ASLR-related(?)
crashes I couldn't solve, so unfortunately that approach won't help me.

I am willing to help out with this, both on the editorconfig and the
emacs side of this to try and solve the issue, but I'm not sure where to
begin (since I'm very new to emacs development).

I'm essentially looking for one of:

1. A way to re-apply dir-locals settings manaully, so I can simply run 
that after editorconfig is done
2. A way to change dir-locals to apply after 'after-change-major-mode-hook'
3. A pointer to where dir-locals is applied in emacs source (since I
couldn't easily bisect it)
4. (undesirable) A way to check if dir-locals has been applied, so I can
turn of editorconfig in said situation.

I'll admit I could probably figure this out by going through the emacs
source code myself, but I thought it would be faster to try to find
someone who has seen this before, and I also wanted to ask for opinions
on this situation.

Thanks in advance,
-Jay Kamat



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dir-Locals + Editorconfig Changes in Emacs 26
  2017-10-02 17:55 Dir-Locals + Editorconfig Changes in Emacs 26 Jay Kamat
@ 2017-10-03 15:39 ` Eli Zaretskii
  2017-10-04 15:45   ` Jay Kamat
  0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2017-10-03 15:39 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Jay Kamat <jaygkamat@gmail.com>
> Date: Mon, 02 Oct 2017 13:55:33 -0400
> 
> However, since emacs 26, this is reversed, where dir-locals is applied
> first, rather than last, and so editorconfig overrides dir-locals. I
> have filed a bug report to the project here to document it:
> https://github.com/editorconfig/editorconfig-emacs/issues/141
> 
> The reason that this is significant is that editorconfig not only lets
> you configure on a per-project basis, but recursively on a per machine
> basis as well, so if you have a editorconfig file in your home directory
> (as many people do) those settings will apply for every file on your
> system, overwriting dir-locals settings. Since dir-locals is more
> powerful and project-specific, I would much prefer dir-locals to
> override editorconfig.
> 
> Editorconfig seems to apply on the 'after-change-major-mode' hook, as
> shown below:

Could it be that the major mode hook is now called twice, and
Editorconfig fails to notice that one of these calls is to turn the
mode off?



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dir-Locals + Editorconfig Changes in Emacs 26
  2017-10-03 15:39 ` Eli Zaretskii
@ 2017-10-04 15:45   ` Jay Kamat
  2017-10-04 17:00     ` Eli Zaretskii
  0 siblings, 1 reply; 4+ messages in thread
From: Jay Kamat @ 2017-10-04 15:45 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Jay Kamat <jaygkamat@gmail.com>
>> Date: Mon, 02 Oct 2017 13:55:33 -0400
>> 
>> However, since emacs 26, this is reversed, where dir-locals is applied
>> first, rather than last, and so editorconfig overrides dir-locals. I
>> have filed a bug report to the project here to document it:
>> https://github.com/editorconfig/editorconfig-emacs/issues/141
>> 
>> The reason that this is significant is that editorconfig not only lets
>> you configure on a per-project basis, but recursively on a per machine
>> basis as well, so if you have a editorconfig file in your home directory
>> (as many people do) those settings will apply for every file on your
>> system, overwriting dir-locals settings. Since dir-locals is more
>> powerful and project-specific, I would much prefer dir-locals to
>> override editorconfig.
>> 
>> Editorconfig seems to apply on the 'after-change-major-mode' hook, as
>> shown below:
>
> Could it be that the major mode hook is now called twice, and
> Editorconfig fails to notice that one of these calls is to turn the
> mode off?

Is `after-change-major-mode' getting called twice in emacs 26, but not
25? I can't seem to find a related news entry about the change, could
you point me to more information about that?

I took a look at the implementation of `after-change-major-mode', and I
found `change-major-mode-after-body-hook' nearby, which seems to do what
I want at a first glance (running hooks before dir-locals is set). Does
changing the hook seem like the proper way to solve this?

Thanks,
-Jay



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Dir-Locals + Editorconfig Changes in Emacs 26
  2017-10-04 15:45   ` Jay Kamat
@ 2017-10-04 17:00     ` Eli Zaretskii
  0 siblings, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2017-10-04 17:00 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Jay Kamat <jaygkamat@gmail.com>
> Cc: help-gnu-emacs@gnu.org
> Date: Wed, 04 Oct 2017 11:45:45 -0400
> 
> > Could it be that the major mode hook is now called twice, and
> > Editorconfig fails to notice that one of these calls is to turn the
> > mode off?
> 
> Is `after-change-major-mode' getting called twice in emacs 26, but not
> 25?

No, the mode is called twice, first time to turn it off, then to turn
it on.  The mode hook is also called twice, for the same reason.  I
don't know what that means for after-change-major-mode functions, but
maybe they are also called twice

> I can't seem to find a related news entry about the change, could
> you point me to more information about that?

I have no more information about that than what I told.  You should be
able to see whether after-change-major-mode is called twice by putting
some message there, or with Edebug.

> I took a look at the implementation of `after-change-major-mode', and I
> found `change-major-mode-after-body-hook' nearby, which seems to do what
> I want at a first glance (running hooks before dir-locals is set). Does
> changing the hook seem like the proper way to solve this?

Sorry, I don't know, since I have no idea what editorconfig wants to
do.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-10-04 17:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-02 17:55 Dir-Locals + Editorconfig Changes in Emacs 26 Jay Kamat
2017-10-03 15:39 ` Eli Zaretskii
2017-10-04 15:45   ` Jay Kamat
2017-10-04 17:00     ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.