dtrt-indent icon indicating copy to clipboard operation
dtrt-indent copied to clipboard

do nothing when editor-config is activated

Open sten0 opened this issue 4 years ago • 4 comments

I'm about half-way through the work of packaging dtrt-indent for Debian (we provide and support elpa-foo.deb packages as an alternative to MELPA), and I noticed that it seems to be missing the following logic: if editor-config is active, then do nothing. I'm not sure what the best method would be, but I think that if an upstream project provides an EditorConfig config file, then Do The Right Thing means silently doing nothing is editorconfig.el is installed (and allowing it to activate using its own mechanism), and otherwise not activating dtrt-indent but instead emitting a message to install https://github.com/editorconfig/editorconfig-emacs

sten0 avatar Jul 01 '20 16:07 sten0

I agree that if editorconfig is active then dtrt-indent should defer to it, but otherwise, it should work as normal: if the user doesn't want to use editorconfig, then dtrt-indent should do its job, and also it's not really dtrt-indent's place to notify the user about editorconfig (they may neither know nor care about it).

rrthomas avatar Jul 03 '20 10:07 rrthomas

It's easy enough to detect whether editorconfig is installed and active, but how to detect whether there is a configuration for the current project? It seems to me that by dtrt-indent's philosophy, which is that it tries to guess the right thing to do, it should remain active if editorconfig is not run. It seems that editorconfig runs before the major mode hooks (it hooks into change-major-mode-after-body-hook, which runs before the major mode hooks (where dtrt-indent-mode is run), but editorconfig-apply doesn't seem to set anything to say that it has run. (I'm also not sure whether dtrt-indent should run when editorconfig-apply has run but unsuccessfully—probably not.)

rrthomas avatar Jul 03 '20 10:07 rrthomas

but editorconfig-apply doesn't seem to set anything to say that it has run

How about if dtrt-indent-mode simply ignore any settings that already have a buffer-local override? That should make it leave alone any relevant settings applied by editorconfig and also other packages, such as prettier. I suppose it would be a fairly major change at this point but I can't see how it would hurt.

jscheid avatar May 28 '21 23:05 jscheid

@jscheid That seems reasonable.

rrthomas avatar May 31 '21 11:05 rrthomas