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

Cannot use aggressive-indent-mode with html-mode #74

Closed angrybacon closed 8 years ago

angrybacon commented 8 years ago

Is it supposed to work for html-mode as well? aggressive-indent-mode is not active and aggressive-indent-excluded-modes doesn't contain html-mode.

(use-package aggressive-indent
  :functions (global-aggressive-indent-mode)
  :config
  (setq-default aggressive-indent-comments-too t)
  (global-aggressive-indent-mode 1)
  (add-to-list 'aggressive-indent-excluded-modes 'scss-mode))
Malabarba commented 8 years ago

No, it's excluded from html-mode because html-mode derives from text-mode (which is excluded). You can still turn it on like this:

(add-hook 'html-mode-hook
          (lambda ()
            (let ((global-aggressive-indent-mode nil))
              (aggressive-indent-mode 1))))

However, I suspect you'll find the performance to be suboptimal.

angrybacon commented 8 years ago

Oh that makes sense.

I have also noticed issues performance-wise with scss-mode. Am I right to assume that contrary to emacs-lisp-mode and js-mode (for instance), scss-mode and html-mode have their whole buffer reindented rather than the current "scope" only? If so, how hard would it be for aggressive-indent to act upon current "scope" only (definition of scope being different for many languages)?

Malabarba commented 8 years ago

Am I right to assume that contrary to emacs-lisp-mode and js-mode (for instance), scss-mode and html-mode have their whole buffer reindented rather than the current "scope" only?

I've never checked scss-mode. But yes, that's why html-mode is slow.

how hard would it be for aggressive-indent to act upon current "scope" only (definition of scope being different for many languages)?

Moderately hard. PRs welcome. :-)