I have a problem with haskell-mode where Emacs will hang every time I open up a Haskell file. Mashing Ctrl-g a few times will get the file opened.

So I would imagine setting debug-on-quit would allow me to debug the issue. But it doesn't. No debugger shows up. Likewise if I run this elisp code (while 1). Emacs locks up, Ctrl-g will will break out of the hang, but no debugger.

I can sometimes bring up the debugger. Say if I run grep and then Ctrl-g whilst it is running, I will get a backtrace popping up.

So I'm not totally sure what is going on. Is there another way I should be debugging this hang with haskell-mode?

GNU Emacs 26.2 (build 1, x86_64-apple-darwin17.7.0, Carbon Version 158 AppKit 1561.6)

  • 1
    In your (while 1) example, C-g does bring me the debugger as expected. – xuchunyang Jun 20 '19 at 11:09
  • Ah interesting. It does bring up the debugger if I break in the scratch buffer, but not if I break in ielm. – Mongus Pong Jun 20 '19 at 11:24
  • Oh, I see, that's because ielm captures the quit signal via (condition-case err ... (quit ...)). – xuchunyang Jun 20 '19 at 12:50
  • Most likely this is a font-lock problem. Try to disable global-font-lock-mode before opening the file. – Lindydancer Jun 20 '19 at 18:56
  • @Lindydancer Ah, yes you are correct. That does stop the hanging! But I now have no syntax highlighting.. How did you find this out? – Mongus Pong Jun 20 '19 at 21:58

So it seems that I was able to bypass the problem from occuring whilst opening the file by disabling global-font-lock-mode (M-x global-font-lock-mode). (Thanks to @Lindydancers advice.)

For reasons currently unknown to me, if Emacs hangs whilst opening the file, pressing Ctrl-G doesn't bring up the debugger.

This did at least allow me to open the file. While editing the file Emacs would occasionally hang, and this time pressing Ctrl-G did bring up the debugger which did allow me to locate where the problem was. There is something going on in the Lexer of haskell mode.

So although I don't fully understand why the debugger didn't open during file load, if you have a similar hang whilst opening the file, it is probably well worth disabling font-lock-mode which should get you a few steps further to debugging the actual issue.

  • 2
    I think the debugger is suppressed during redisplay, and redisplay might the one calling font-lock. – npostavs Jun 22 '19 at 1:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.