2
votes

I am using emacs autocomplete plugin, actually i am using Emacs Live(https://github.com/overtone/emacs-live) which in turn uses autocomplete. Autocomplete does work, but it only know the keywords list in the /dict/xxx files. When i add libs to current project using lein (for example ring, compojure), it doesn't work at all. Do i have to list all keywords in the libs to /dict directory to make autocomplete know them? Or is there a way to let autocomplete know the keywords each time i add a new lib using lein(Just like what happens in Java IDE)?

2

2 Answers

1
votes

Chris Barrett's answer gets you almost there.

Install nrepl and ac-nrepl from melpa, then put this in your init:

(require 'nrepl)
(require 'ac-nrepl)

(add-hook 'nrepl-mode-hook 'ac-nrepl-setup)
(add-hook 'nrepl-interaction-mode-hook 'ac-nrepl-setup)
(eval-after-load "auto-complete"
  '(add-to-list 'ac-modes 'nrepl-mode))

And use M-x nrepl-jack-in to hook your emacs session to your clojure project with auto complete and doc hints.

1
votes

Emacs live still uses Swank to talk to Clojure, right? You could try using nrepl as an alternative to Swank, which provides autocompletion of java libraries.

You're right that adding additional sources to Autocomplete is a bit involved. There's a variable called ac-sources which is what you customise to add completion sources. There's info on the built-in ones here.

Here's what I have in my init.el:

(set-default 'ac-sources
             '(ac-source-abbrev
               ac-source-dictionary
               ac-source-yasnippet
               ac-source-words-in-buffer
               ac-source-words-in-same-mode-buffers
               ac-source-semantic))

This should make autocomplete a bit more useful for you.