Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform auto-completion queries in background?

I'm very excited of emacs auto-completion mode. But my codebase is big, and sometimes, when i type, and it tries to ssuggest a completion, it searchs through all possible words, and hangs. It is very annoying.

Is there a way to run the search in background in parallel process, so emacs would still response to user actions. And only if the point holds on the place when the query is finished, suggest auto completion?

Like, the keyboard input is a primary process, and can never be delayed, and autocompletion works as a residual on machine resources.

like image 746
Necto Avatar asked Oct 21 '22 17:10

Necto


1 Answers

emacs-jedi exactly does that for Python auto-completion. You can send a request to the background process using the init property and then store the result somewhere. In the candidate property, you can process the stored result to pass it to auto-complete. Here is the ac-source definition. Please look at the source for details.

(ac-define-source jedi-direct
  '((candidates . jedi:ac-direct-matches)
    (prefix . jedi:ac-direct-prefix)
    (init . jedi:complete-request)
    (requires . -1)))

emacs-ipython-notebook also uses similar technique but I guess emacs-jedi is easier to read.

like image 87
tkf Avatar answered Oct 25 '22 19:10

tkf