Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ELisp Syntax Table Comments for Haskell style comments

I am attempting to set up Haskell style comments using ELisp Syntax-Table-Comments but I can't quite get it.

In Haskell, there are 2 basic types of comments

-- denotes a single line comment ending with \n

{- denotes a multi line comment ending with -} It should be noted that these can be nested

Multiline comments can be done this way:

(defvar my-syntax-table
  (let ((st (make-syntax-table)))
    (modify-syntax-entry ?{ ". 1n" st)
    (modify-syntax-entry ?- ". 23n" st)
    (modify-syntax-entry ?} ". 4n" st)
   st))

Single line comments can be done this way:

(defvar my-syntax-table
  (let ((st (make-syntax-table)))
    (modify-syntax-entry ?- ". 12" st)
    (modify-syntax-entry ?\n ">" st)
   st))

Based on the documentation, I can set up an alternative using b. However, b applies to the second character of the sequence which in both cases is -. So, when I try to combine these using alternatives, it becomes impossible to do multiline and single line comments.

I have seen this done so I know it is possible. However, I'm not sure how to do it. Any help is appreciated.

like image 856
Joe Avatar asked Oct 22 '25 06:10

Joe


1 Answers

Haskell-mode uses

       (modify-syntax-entry ?\{  "(}1nb" table)
       (modify-syntax-entry ?\}  "){4nb" table)
       (modify-syntax-entry ?-  "_ 123" table)))
       (modify-syntax-entry ?\n ">" table)
like image 78
Stefan Avatar answered Oct 23 '25 21:10

Stefan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!