Language Pragma causes hanging in haskell-lexeme-looking-at-token
Adding a language pragma, for example:
{-# LANGUAGE ExistentialQuantification #-}
to my .hs files results in frequent pausing whenever emacs re-draws the buffer (after using a formatting package, for instance). Without the language pragma there is no delay for this action. I can C-g out of these delays usually, but sometimes it causes Emacs to crash. There are previous issues with the same context but different causes like #820.
This is the profiler report for the problematic action, :
15521 86% - redisplay_internal (C function)
15514 86% - jit-lock-function
15511 86% - jit-lock-fontify-now
15511 86% - jit-lock--run-functions
15511 86% - run-hook-wrapped
15511 86% - #<compiled 0x19a2965dcd3c8bfd>
15511 86% - font-lock-fontify-region
15511 86% - font-lock-default-fontify-region
15425 85% - font-lock-fontify-syntactically-region
15421 85% - syntax-propertize
14843 82% - haskell-syntax-propertize
9339 51% - haskell-lexeme-looking-at-token
4 0% haskell-lexeme-looking-at-qidsym
2 0% + haskell-lexeme-looking-at-quasi-quote-literal
82 0% + font-lock-fontify-keywords-region
2 0% + eval
2 0% file-remote-p
2102 11% + ...
309 1% + command-execute
26 0% + timer-event-handler
4 0% + jit-lock-function
This is happening to me on emacs 27.2 and 28.1 (native-compiled), with haskell-mode pulled with straight.el at commit 4ec2aa3 (current HEAD). On NixOS, if it matters. My haskell-mode config is the following, but the additional options make no difference in this scenario.
(straight-use-package 'haskell-mode)
(add-hook 'haskell-mode-hook 'interactive-haskell-mode)
(add-hook 'haskell-mode-hook 'haskell-doc-mode)
(add-hook 'haskell-mode-hook
#'(lambda () (setq-local format-all-formatters
'(("Haskell" stylish-haskell)))))
I am curious about this since it's such a fundamental feature of Haskell/haskell-mode and I haven't found any other issues.
Thank you!
Thanks for digging into this and providing the helpful specific information! Currently I think I'm the only "maintainer" (semi-)actively responding to issues but I am generally quite inactive atm and I will likely struggle to find time to tackle this.
I just played around with a minimal version of my config and quickly found the offending customization: (add-hook 'prog-mode-hook #'(lambda () (modify-syntax-entry ?- "w"))). It probably breaks the assumptions made by this haskell-mode looking-at function for the syntax table and causes the looping.
Doesn't look like a problem with haskell-mode, and also doesn't seem to merit any documentation changes since I doubt this is a common configuration. I'll probably just add a workaround in my own config to remove this syntax change in haskell-mode.
Thanks!
Ah cool, thanks for following up with this info. It rings a bell w.r.t. past reported issues, I believe...
Hello @michzappa I'm running into what looks like the same issue, and I'm not sure if you finally found a way to work around it?
Ok, got it I guess you had
(add-hook 'after-change-major-mode-hook (lambda () (modify-syntax-entry ?- "w")))
somewhere in your config (like I have). I confirm removing this line fix the behavior