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, 2019 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. Jun 20, 2019 at 11:24
  • Oh, I see, that's because ielm captures the quit signal via (condition-case err ... (quit ...)).
    – xuchunyang
    Jun 20, 2019 at 12:50
  • Most likely this is a font-lock problem. Try to disable global-font-lock-mode before opening the file. Jun 20, 2019 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? Jun 20, 2019 at 21:58

2 Answers 2


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.

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

Try sending Emacs the SIGUSR2 signal, or whatever signal is specified by the Emacs variable debug-on-event. The easiest way to do this is probably to run killall -SIGUSR2 emacs.

  • If you can put Emacs into a responsive state, then M-: (emacs-pid) will tell you the process ID number to use: kill -SIGUSR2 <pid>
    – phils
    Jul 14, 2021 at 6:04
  • Failing that, I would personally always use ps to figure out which PID to use, as I invariably have more than one instance of Emacs running.
    – phils
    Jul 14, 2021 at 6:05
  • Also note that debug-on-quit is set when this signal is processed. You can use M-x toggle-debug-on-quit to switch that off again.
    – phils
    Jul 14, 2021 at 6:09

Your Answer

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

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