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

Better error feedback in emacs mode #190

Open roshanjames opened 10 years ago

roshanjames commented 10 years ago

Very often I have a situation where I have typed something that I think is pretty reasonable like [Int.] and I ask merlin for auto-completion and nothing happens. In such cases I get really no feedback as to what might be wrong.

Can you build something into the emacs mode such that I get some feedback about why I am not getting any auto-complete? The same idea extends to locate as well.

I imagine it would work as follows -- the first time one hits the key you display a very brief message. If the key press is repeated, like with type alias expansion, you display a more verbose message. You error messages could include things like the string that you are using in your expansion lookup, which libraries you are scanning based on the .merlin file etc. Anything that would then help me figure out what might be wrong.

trefis commented 10 years ago

Hi!

I agree with you that having more feedback when things go wrong would be really helpful. However it is not so easy to do, that is why there isn't much feedback at the moment when merlin fails to answer the user' requests. With time, things should hopefully get better, but you should be prepared to wait.

I started tackling the issue on the locate front (which is the part of the code I know the best among the ones you listed) as it seemed to be the easiest to improve. Indeed there are only three error cases (if I'm not mistaken) :

These cases should now be identified and you should have proper error messages for them.

On top of that there is of course another error cases which is : merlin is buggy. If that is the case you'll see the usual "Not found" message and you should tell us that/how it happened so we can try to fix it.

Cheers

PS: I notice that in all your messages you speak of "the emacs mode", but be assured that vim users don't have wonderful features that are not accessible to the poor emacs users. Both editors have the same features, indeed there is nearly no logic in them, everything is done on the ml side ;)

roshanjames commented 10 years ago

I understand that this is hard to get right, but this is also an important thing.

Too often I have someone call me to tell me that merlin is not working. At which point I check to see if their tree is built and if they have a .merlin in the expected place. I ask them to restart their merlin to flush any bad state state.

Sometimes they may have just pull in a lot of changes and probably some files got rebuilt and some didn't and merlin got into a bad state because if read some cmi files with incompatible interfaces. To hedge against these sorts of things I have people distclean, rebuild everything from scratch and then restart their merlin.

Usually one one of these steps will get their merlin working again, but there are still a bunch of cases when merlin still doesn't show all the auto-complete information that one would expect. By this point the user in question is pretty fed up with the whole process. And the frustrating thing is that merlin tells me nearly nothing that will help me diagnose what the underlying issue is. I have seen it not pick up information about local modules more often in these sort of situations, than modules that come in from libraries.

ps. I meant "emacs mode" only in the sense that this sort of debug information should be displayed in the editor as opposed to being written out into the log file. I didn't mean to imply any vim vs emacs bias :)

rgrinberg commented 10 years ago

@roshanjames

I find that there's some friction when using merlin with big libraries such as core, at least from what I noticed. If you use merlin without many libs I find the experience much smoother.

roshanjames commented 10 years ago

That's possibly true. But for me not using Core is not really an option :)