How to enable ocp-indent on saving a buffer in Emacs?

I was just wondering how to apply ocp-indent on saving a buffer like how refmt (for reasonml) supports that.

    (add-hook 'reason-mode-hook (lambda ()
                                  (add-hook 'before-save-hook 'refmt-before-save)
                                  (merlin-mode)))

I figured it out (I am an idiot) that it was just this:

   (add-hook 'tuareg-mode-hook
        (lambda () (add-hook 'before-save-hook 'ocp-indent-buffer (merlin-mode))))
1 Like