Malabarba / aggressive-indent-mode

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

Conflict with nameless-mode #106

Closed cpitclaudel closed 7 years ago

cpitclaudel commented 7 years ago

Hi there,

I commonly run into cases in which aggressive-indent does its thing in an invisible part of the buffer, before that part has been fontified. The issue with that is that I use nameless, and thus fontification is relevant to indentation.

The solution could be as simple as running font-lock-ensure on the appropriate region before indenting, but if that's too costly in general there could be a function set to #'ignore by default that nameless would hook into.

Cheers, and thanks for the cool packages!

Malabarba commented 7 years ago

That's interesting. I'd never seen Emacs font-lock the buffer that lazily. Aggressive-indent has changed a bit since you posted this issue. If it's still a problem I can look into it.

cpitclaudel commented 7 years ago

It's still an issue :)

I sometimes have mismatched parentheses, and these tend to cause reindentation of large bits of the file. Often these bits aren't syntax-highlighted.

Malabarba commented 7 years ago

I'll try adding a variable you can configure to font-lock the buffer, is that ok?

Malabarba commented 7 years ago

You should be able to fix your problem by doing:

(add-function :before
              aggressive-indent-region-function
              #'font-lock-ensure)