ocaml / merlin

Context sensitive completion for OCaml in Vim and Emacs
https://ocaml.github.io/merlin/
MIT License
1.58k stars 233 forks source link

Different behavior from various completion modes #57

Closed roshanjames closed 11 years ago

roshanjames commented 11 years ago

Often auto-complete provided by the auto-complete-mode and completion-at-point (which I think ships with emacs) behave differently. i.e. one refuses to show completion results while the other does.

It is unclear why this and is hard to reproduce. One possibility is that this maybe do the fact that different modes are sending different queries to merlin. It would be good to have debug information displayed such that one can understand why completion-at-point and auto-complete behave differently.

This sort of information might also help towards building a better auto-complete mode one day that is more customized for merlin.

trefis commented 11 years ago

My (naïve) guess here is that auto-complete might have a fallback completion list (like, "all the words present in the buffer with the given prefix") when its principal completion function (i.e. merlin) fails to return any suggestion. completion-at-point having no such mechanism, it would explain why sometimes it doesn't offers anything while auto-complete-mode does.

One good way to check that is : if auto-complete-mode doesn't display any type along its completion propositions, then he is probably using such a fallback.

I'll let @asmanur confirm whether my guess is correct or not (or I will try to check that behavior tomorrow).

asmanur commented 11 years ago

Yes you are right. By default ac-complete-mode also uses "words-in-the-same-buffer" or so source, which completion-at-point does not. Moreover there is an history. For instance if you have already completed "Module.function", and you type "Mod" it can suggest you "Module.function" where merlin can only suggest you "Module".

Anyway, the queries sent by emacs with the two modes are exactly the same. However the code is not so modular at the moment in master.

On jeu. 15/août 2013 (18:05), Thomas Refis wrote:

My (naïve) guess here is that auto-complete might have a fallback completion list (like, "all the words present in the buffer with the given prefix") when its principal completion function (i.e. merlin) fails to return any suggestion. completion-at-point having no such mechanism, it would explain why sometimes it doesn't offers anything while auto-complete-mode does.

One good way to check that is : if auto-complete-mode doesn't display any type along its completion propositions, then he is probably using such a fallback.

I'll let @asmanur confirm whether my guess is correct or not (or I will try to check that behavior tomorrow).


Reply to this email directly or view it on GitHub: https://github.com/def-lkb/merlin/issues/57#issuecomment-22741870

roshanjames commented 11 years ago

The issue I had in mind here is where auto-complete-mode displayed merlin output (with types in a dropdown) while completion-at-point did not show merlin data.

We suspected that this might be because both modes were sending different queries to merlin. We enabled MERLIN_LOG to look at the difference between the queries. I am not sure I can interpret the log output very well, but it seemed like both modes differed in what column number they were sending to merlin. The line number seemed right. That said, I am not sure.

This goes back to the point I was making elsewhere that merlin should probably have somewhat richer output in the debug log. Maybe the output can be terse by default, but when we send it a command it can subsequently turn on verbose debug information. That way I will be able to include these log snippets when filing issues and you guys will have a better sense of what happens in the case of errors like this that are hard to reproduce.

trefis commented 11 years ago

There has been several changes on the emacs mode since the last message on this thread, and I believe you won't be able to reproduce now. So I'll close but feel free to reopen if the problem persisted for you.