Emacs hangs when opening a file with a multiline comment
StephenWakely opened this issue · 4 comments
So Emacs suddenly started hanging every time I opened a file that had a multiline comment it the first line such as
{-# LANGUAGE GADTs #-}
I tracked it down to the code in haskell-lexeme.el :
(and (looking-at "{-")
(save-excursion
(forward-comment 1)
(set-match-data (list point (point-marker)))
'nested-comment))
It seems (forward-comment 1) was setting point-marker back to the point 0. This just caused the haskell-syntax-propertize
function to get stuck in a loop.
I'm not sure why the problem suddenly popped up. I tried rolling back any changes I made to my config file, deleting my elpa folder. I've tried it on Emacs 25.3 and 26.2, Ubuntu and MacOs. All suddenly have the same issue.
I am able to fix the issue by checking that the point-marker has actually moved the point along and it seems to work, although it does now highlight any syntax in my comments...
(and (looking-at "{-")
(save-excursion
(forward-comment 1)
(when (> (marker-position (point-marker)) (match-end 0))
(set-match-data (list point (point-marker))))
'nested-comment))
Any ideas what could be going on?
I'm not sure if this is relevant, because I'm not a Haskeller.
Anyway, while trying to get prism
working with Haskell code, I noticed that --
was not matching a regexp like this:
(rx (or (syntax comment-start)
(syntax comment-delimiter)))
I made the following change to haskell-mode-syntax-table
and restarted haskell-mode
in a buffer, and now it seems to work properly. I'm very much not an expert on Emacs's syntax tables, but according to modify-syntax-entry
, the .
character sets the given character to punctuation
, while <
sets it to comment starter
, so I'm guessing that is a mistake.
diff -u --label /tmp/trycgzDcj/haskell-mode-20190801.50/haskell-mode.el --label \#\<buffer\ haskell-mode.el\> /tmp/trycgzDcj/haskell-mode-20190801.50/haskell-mode.el /tmp/buffer-content-WAL8ib
--- /tmp/trycgzDcj/haskell-mode-20190801.50/haskell-mode.el
+++ #<buffer haskell-mode.el>
@@ -466,7 +466,7 @@
(modify-syntax-entry ?\{ "(}1nb" table)
(modify-syntax-entry ?\} "){4nb" table)
- (modify-syntax-entry ?- ". 123" table)
+ (modify-syntax-entry ?- "<123" table)
(modify-syntax-entry ?\n ">" table)
(modify-syntax-entry ?\` "$`" table)
Diff finished. Mon Aug 26 02:20:43 2019
I can't reproduce this issue, but the fix from @alphapapa is valid and I've applied it: in (2 - 1)
, the -
is correctly assigned punctuation
syntax, while in -- foobar
the -
are assigned comment syntax.
Interesting. That hasn't resolved the issue, but it seems it is only me getting it. I wonder if its a conflict with some other package I have installed? When I get the time I'll try to narrow down the issue..