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

Call asynchronously #96

Open ghost opened 8 years ago

ghost commented 8 years ago

This is freezing up my emacs.. can we use emacs-async to run the indenter?

https://github.com/jwiegley/emacs-async

Malabarba commented 8 years ago

It can't be made async because it has the side-effect of editing the buffer. Emacs-async runs on an entirely separate process, so that's not viable.

OTOH, it really shouldn't freeze up your Emacs. aggressive-indent takes a series of measures to avoid blocking input. Maybe it's a conflict with somw other package?

ghost commented 8 years ago

I know how to trigger input blocking and managed to get a stack trace of it before I filed this bug. It's aggressive-indent-mode and garbage collection:

command-execute                                               43389  39%
+ aggressive-indent--indent-if-changed                          35783  32%
+ ...                                                           18723  16%
+ indent-guide-post-command-hook                                 5236   4%
+ company-post-command                                           4075   3%
+ redisplay_internal (C function)                                2298   2%
+ timer-event-handler                                             952   0%
+ xterm-mouse-translate-extended                                   56   0%
+ global-hl-line-highlight                                         33   0%
+ winner-save-old-configurations                                   21   0%
+ nrepl-client-filter                                              18   0%
+ yas--post-command-handler                                        15   0%
+ compilation-filter                                               10   0%
  tooltip-hide                                                      6   0%
+ indent-guide-pre-command-hook                                     5   0%
+ delete-selection-pre-hook                                         5   0%
+ cua--post-command-handler                                         4   0%
+ isearch-pre-command-hook                                          1   0%
Malabarba commented 8 years ago

That's a performance report, not a stacktrace. Indeed, aggressive-indent does a lot of work , but it does so inside a while-no-input block, which should prevent input blocking.

Try the following:

  1. Do M-x toggle-debug-on-quit.
  2. Reproduce the situation that blocks input.
  3. While input is blocked, hit C-g a couple of times.

You'll get a backtrace you can paste here.

Malabarba commented 8 years ago

Hi Brian, did you have time to produce a stack trace?

Malabarba commented 8 years ago

Also, see my comment here, it might fix your problem: https://github.com/Malabarba/aggressive-indent-mode/issues/73#issuecomment-253313534