Search code examples
ocamltuaregocaml-lwt

How to enable syntax color and indention for lwt in Emacs Tuareg mode?


I am using Tuareg mode for Emacs.

I am also using lwt. lwt has some syntax extension, but Tuareg cannot recognize them and it is ugly without indention and coloring.

I found this:

https://github.com/skydeck/lwt/blob/master/utils/tuareg-2.0.4.patch

It is a patch for tuareg-2.0.4 to enable lwt coloring.


However, I am using Tuareg-2.0.5 and I tried the patch directly, it failed.

I am not sure how to downgrade Tuareg, so I just downloaded the files of tuareg-2.0.4 and copy them to the elpa/tuareg-2.0.5 folder and then I did the patch again.

This was successfully patched as it said, but still my emacs cannot recognize lwt.


Can anyone tell me how?


Solution

  • IMHO, you don't have to replace your stock tuareg.el.

    1. Place your patched tuareg.el to ~/.emacs.d/ directory

    2. Add the following lines to your ~/.emacs config

    (add-to-list 'load-path "~/.emacs.d/")
    (load "tuareg")
    

    3. (Optional) byte-compile your custom tuareg.el

    M-x byte-compile-file
    

    Stock tuareg mode

    stock tuareg mode

    Tuareg mode with lwt patch

    tuareg mode with lwt patch