Malabarba / aggressive-indent-mode

Emacs minor mode that keeps your code always indented. More reliable than electric-indent-mode.
850 stars 36 forks source link

Optionally disable/enable save hook #114

Closed nilsdeppe closed 6 years ago

nilsdeppe commented 6 years ago

Hi,

Thanks for the neat package! I just started playing around with it and find the before-save-hook very frustrating. I use clang-format on my code and then this goes and messes up all the indentation to something I don't actually want. I like the ability to indent comment blocks, etc. at once, would love to have that and have my clang-formatted code left alone :) Could there be a variable added to allow turning off some of the hooks that are added?

Thanks!

Malabarba commented 6 years ago

Well, the thing is that aggressive-indent-mode's entire functionality revolves around these hooks. You can turn them off by turning off the mode, but then you won't get much functionality (except for a couple of commands I guess).

nilsdeppe commented 6 years ago

Ah okay. So the specific functionality that I'm looking for is the really awesome block indentation of the comments, I think that's really cool! Does that rely on the hooks too or could that be extracted as a separate functionality? I'm not suggesting that should be done with this project, I'd be perfectly happy just extracting the code and using it in my configuration, just wondering if that's possible :) Thanks!

Malabarba commented 6 years ago

Maybe what you want is the aggressive-indent-defun command? If so, you can just bind it to a key of your liking.

nilsdeppe commented 6 years ago

I tried running aggressive-indent-defun and it didn't do anything for me. I'm clearly confused on how that works :) I did modify aggressive-indent-mode.el to not have the add-hook 'before-save-hook .... and that so far seems to be doing what I want. I'm going to try working with that on for a couple days and then provide an update. Thanks for the help :)

nilsdeppe commented 6 years ago

Alright, I experimented with this and unfortunately it conflicts too much with clang-format. I'll use it in other modes, just not C/C++. Really awesome package, great job! :)