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.
187 stars 31 forks source link

Split into local and global minor modes #39

Closed tummychow closed 6 years ago

tummychow commented 6 years ago

And now for my last trick. This change is definitely breaking. It splits dtrt-indent into two modes. The existing dtrt-indent-mode is local to the current buffer, and a new dtrt-indent-global-mode enables the mode for all prog-mode/text-mode buffers. People who currently invoke dtrt-indent-mode in their config will have to switch to dtrt-indent-global-mode. Let me know what you think and whether this change is acceptable to you.

rrthomas commented 6 years ago

Just to say I'm looking at this stuff Sundays only at present, and the window just closed for this week, so I'll try to get around to it next. But I'm not ignoring it!

rrthomas commented 6 years ago

Thanks, I like this pattern, merging.

Please could you write a release note (and perhaps paste it into this report) that I can add to a new release to help users transition?

tummychow commented 6 years ago

Sure. I imagine most people are using (dtrt-indent-mode 1) in their current config. They can simply replace that with (dtrt-indent-global-mode 1). If you want to preserve the exact behavior that currently exists (ie the mode runs when you find any file), you can instead use (add-hook 'find-file-hook 'dtrt-indent-mode).

Other configurations are also possible, of course. For example, maybe you want the mode in prog-mode buffers but not in text-mode buffers. In that case you can (add-hook 'prog-mode-hook 'dtrt-indent-mode) instead of enabling the global mode. Etc.

rrthomas commented 6 years ago

That's the sort of thing; could you just possibly reword it as instructions to users, I mean literally a couple of paras I can add to a release note? Many thanks!

tummychow commented 6 years ago

like this?

This release separates dtrt-indent into two minor modes, a buffer-local mode (dtrt-indent-mode) and a global mode (dtrt-indent-global-mode). If you are currently using (dtrt-indent-mode 1) in your emacs configuration, replace it with (dtrt-indent-global-mode 1) to maintain the current behavior of activating dtrt-indent-mode in all buffers. Alternatively, dtrt-indent-mode can be activated with a hook, eg (add-hook 'find-file-hook 'dtrt-indent-mode), for more granular control over which buffers will be affected.

rrthomas commented 6 years ago

Thanks, that's perfect.

rrthomas commented 6 years ago

I've just made the release and used the above as the notes. Thanks again!