jscheid / dtrt-indent

A minor mode that guesses the indentation offset originally used for creating source code files and transparently adjusts the corresponding settings in Emacs, making it more convenient to edit foreign files.
184 stars 31 forks source link

do nothing when editor-config is activated #53

Open sten0 opened 4 years ago

sten0 commented 4 years ago

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

rrthomas commented 4 years ago

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 commented 4 years ago

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.)

jscheid commented 3 years ago

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.

rrthomas commented 3 years ago

@jscheid That seems reasonable.