5

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.

Necto
  • 2,454
  • 1
  • 17
  • 40

1 Answers1

3

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.

tkf
  • 2,880
  • 15
  • 32
  • As I learned, it is for Python. And I need some general mechanism, for universal auto-completion from read characters; from TAGS etc. – Necto Feb 10 '13 at 08:44
  • Right, probably my answer was misleading. But you can use the technique (use init to send request, etc.) anyway. You need to use some kind of RPC to communicate with the background process. Using [EPC](https://github.com/kiwanami/emacs-epc) as emacs-jedi does is one possibility. It is a general purpose RPC and has Perl, Python and elisp implementation. – tkf Feb 10 '13 at 10:10