redguardtoo/evil-matchit

OCaml: keywords are matched even when they are part of a string

Khady opened this issue · 4 comments

Khady commented
let () = begin
  let _s = "string containing the words let and begin" in
  ()
end

In this example, if one have the cursor on end or in and call matchit, it will jump to the corresponding keyword in the string "string containing the words let and begin" rather than on the real keyword.

good point, I should skip text in comments and string.

I'm going holiday soon. So bugs fixes are suspended for 2 weeks. I can review and accept patches.

Khady commented

I read the evil-matchit-ocaml.el before to submit the issue. But I honestly have no idea where to start from. Maybe if you provide a few leads I can try to dig further. Otherwise there is no hurry. I'm already very pleased you answered my issue. Enjoy your holiday.

ocaml is not implemented by me. But should be easy. evilmi-ocaml-get-tag get current tag if it exist. evilmi-ocaml-jump find the matching tag. I guess you might want to focus on evilmi-ocaml-jump. Try ignore comments and strings when searching matching tag.

I updated the code of evil-matchit-sdk.el to add three new APIs you can use:

  • evilmi-current-font-among-fonts-p
  • evilmi-in-comment-p
  • evilmi-in-string-or-doc-p