editorconfig / editorconfig-emacs

EditorConfig plugin for Emacs
https://editorconfig.org
GNU General Public License v3.0
739 stars 105 forks source link

Can't override editorconfig locally #324

Open richcarl opened 7 months ago

richcarl commented 7 months ago

I'm on Emacs 29, and no matter what I do, it seems that editorconfig always overrides both dir-locals files and file local variables.

jcs090218 commented 7 months ago

See https://github.com/editorconfig/editorconfig-emacs/issues/148.

richcarl commented 7 months ago

See #148.

Note: that issue is only about dir-locals, but editorconfig seems to always override even my file local variables.

10sr commented 4 months ago

Hi!

I updated the code and added two new variables editorconfig-override-file-local-variables and editorconfig-override-dir-local-variables, which are set to t by default. When editorconfig-override-dir-local-variables is set to nil, this plugin will not override values when it is defined in dir-locals.el .

I'm not going to set these variables to nil by default, because it is not likely that other editors support dir-locals.el files...

richcarl commented 4 months ago

Thank you!

I still feel though that for Emacs, you expect that dir-locals and file-locals should be able to override any other configuration by default. The typical scenario is that a project has a .editorconfig file in its root (and perhaps additional ones per subdir), and then under one of the subdirs you may have some third party code or legacy code that follows its own rules, perhaps checked out as a dependency or git-subrepo, and that code may come with file-local annotations or a .dir-locals file. In that setting I expect Emacs to follow the most local rules for editing those files, not the project-wide rules. Maybe not everyone agrees.

10sr commented 4 months ago

We can add another .editorconfig file in the directory for that case.

Yeah, I know we can avoid creating new file explicitly if local variables override editorconfig values by default. But, what I worry about is the case where users forget to add entries to .editorconfig file because they are already configured in .dir-locals.el .

richcarl commented 3 months ago

If it's third party code, I'd have the choice of either asking them to add an .editorconfig file to their repo, which they may rightly think is irrelevant to them, or manually add a local .editorconfig file myself, which would then make git report a new untracked file (unless I also tell git to ignore it locally), and I'd have to remember to stop and do this just when I realize I want to edit a file in that subrepo. Philosophically, I don't think it's right for Emacs to ignore these. Maybe editorconfig could automatically offer to copy settings from .editorconfig to .dir-locals and/or vice versa, if both exist in the same dir and one of them is newer?