Configuring company to not complete keywords

My highschool labs have Emacs+Tuareg+Utop+Merlin+Company under Windows, and the completion has a annoying behaviour with keywords : it pops up a completion menu, but since it does not list keyword that is being typed, validation replaces the keyword with something else.

For instance, typing the end keyword gives a completion popup that starts with exn, so that typing Enter replaces end with exn (same with then versus tan).

Now, my Linux system does not exhibit this, and I do not think I did any custom configuration on either system.

Any clue ?

On Windows, I have Emacs 30.2, Tuareg 3.0.1, Merlin 5.6-503 and Company 1.0.2.
On Linux, Emacs 29.3, Tuareg 3.0.1, Merlin 5.6-503 and Company 1.0.2.

Not really, but I can confirm that if I try to complete on emacs 30.2, merlin v5.6.1-504, neocaml-mode 20260406.915 and company 20260331.245 I also see identifier completions on trying to complete end (without end being offered itself).

Hand waves. But I’d say it makes sense from a grammatical point of view, you are possibly in an expression so completing an identifier is a possibility. On the other hand always having end as a choice when you are trying to complete an identifier may be suboptimal.

That being said I always thought that automatically showing up completions was a terrible ergonomic choice anyways – if only because of the annoying flickering on typing. In my own init.el I have:

; Only complete on request
(setq company-idle-delay nil) 
(global-set-key (kbd "S-<tab>") 'company-complete)

Perhaps that could sooth the pain.

Yes, or having a key to validate the completion that is neither Space, Tab or Enter.

But what is also strange is that the popup should become empty when typing end fully, since there is no completion that starts with that.

Do you know if I should look into company per se or rather the merlin-company module ?

Weird : I did a fresh install of opam, tuareg, merlin and company (under a new Linux user account), and it does not exhibit the unwanted behaviour…

There used to be a similar problem on vscode + ocaml platform where in would get “completed” to in_channel. It seems they fixed it by adding keywords to the suggestions at some point, I do not know at which level.

It prompted me to turn off completion on enter which I am happy with, even with this particular issue fixed it’s too error-prone.

I spotted a (require ‘merlin-company) in my intialisation files that seems to be causing this (maybe in conjunction with (global-company-mode). Anyway, without it, company completes in a more convenient way.