emacs-jupyter / jupyter

An interface to communicate with Jupyter kernels.
GNU General Public License v3.0
934 stars 92 forks source link

Completion is buggy #249

Open robsmith11 opened 4 years ago

robsmith11 commented 4 years ago

When using the the REPL with a Julia kernel, the tab completion is very buggy. It's not documented in the README, but it seems completion is bound to C-M-i (why not TAB??). The first time I press C-M-i, I always get a message saying "No matches". The 2nd time I press it, I will sometimes get the completion, but sometimes it will still do nothing and I will need to type it 3-4 times to get the completion.

Completion works perfectly with this kernel in the browser btw.

nnicandro commented 2 years ago

Completion in emacs-jupyter is done through Emacs built-in completion-at-point mechanism. There is no specific keybinding for completion that is defined by emacs-jupyter. In my case, I use company which has completions bound to TAB and integrates well with completion-at-point.

I agree that completion acts in the way you say, sometimes it takes a couple of presses of TAB to get anything.

Maybe the issue lies in the use of sit-for when getting the completion results

https://github.com/nnicandro/emacs-jupyter/blob/b87ecf0cd3697bcdc5180fc5935786f2d282538d/jupyter-client.el#L1889-L1895

When jupyter-complete-at-point is called it makes a complete_request to the kernel and returns a function for completion-at-point to call to complete the current completion prefix. If the complete_reply message hasn't come in by the time that function is called, the sit-for is there to give a chance for it to come in. Maybe it would be more consistent if we wait for as long as needed for the complete_reply to come in.