I've been an emacs user for about a year now and I use it for Haskell programming. I chose to go the vanilla emacs route and customized a plain init file as I went along.

Over time, however, I realise that emacs started getting quite sluggish on my computer. The computer is not the bottleneck: its a powerful machine with 32GB of RAM.

My suspicion is that I have too many modes enabled, and hence my question: how do I debug where the modes are being enabled from?

For example; the current list of emacs modes I have enabled in a Haskell buffer are:

Enabled minor modes: Async-Bytecomp-Package Auto-Composition
Auto-Compression Auto-Encryption Autopair Autopair-Global Blink-Cursor
Cl-Old-Struct-Compat Company Desktop-Save Diff-Auto-Refine Dimmer
Display-Line-Numbers Eldoc Erc-Button Erc-Fill Erc-Irccontrols
Erc-List Erc-Match Erc-Menu Erc-Move-To-Prompt Erc-Netsplit
Erc-Networks Erc-Noncommands Erc-Pcomplete Erc-Readonly Erc-Ring
Erc-Sound Erc-Stamp Erc-Track Evil Evil-Commentary Evil-Local
Evil-Surround Evil-Visual-Mark File-Name-Shadow Flx-Ido Flycheck
Font-Lock Frames-Only Global-Display-Line-Numbers Global-Eldoc
Global-Evil-Surround Global-Font-Lock Global-Git-Commit
Global-Magit-File Global-Undo-Tree Haskell-Indentation
Highlight-Indentation Hindent Ido-Everywhere Intero Intero-Global
Line-Number Magit-Auto-Revert Magit-File Mouse-Wheel Override-Global
Popwin Projectile Rainbow-Delimiters Recentf Shell-Dirtrack Subword
Tooltip Transient-Mark Undo-Tree Which-Key Winner Yas

I can spot multiple ERC related modes which seem to be enabled, and they make no sense since:

  • ERC is not running at this time
  • I'm in a Haskell buffer

Moreover, I'm not too keen on starting over with a vanilla emacs configuration for 2 reasons:

  • If this has happened now, it will likely happen again in future
  • I'd like to dig into what enables these ERC modes

My init file as a gist

Can anyone help?

EDIT 2: I experienced a crash recently. The stacktrace doesn't really say much.

  • 3
    Let the profiler run for some time (profiler-start, profiler-report, profiler-stop) and identify the largest culprits before optimizing.
    – Tobias
    Mar 29, 2019 at 10:36
  • The ERC modes are probably global modes, they seem to get enabled as soon as you do M-x erc (I just tried it in an emacs -Q session).
    – npostavs
    Mar 29, 2019 at 13:17
  • You need to compile with debug symbols to get useful stacktraces.
    – npostavs
    Mar 29, 2019 at 13:19
  • 1
    Turn off ~half of the modes, especially ones you suspect aren't currently relevant, and see how that affects performance. Then turn off 1/4, 1/8, 1/16,... to try to see which modes are costing you (and don't seem to be helping you). This is generally pretty quick. (Otherwise: yes, use profiler or other benchmarking code.)
    – Drew
    Mar 29, 2019 at 14:58


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.