Search code examples
emacsclojureautocompletecider

Emacs + cider: Autocomplete defprotocol methods. Possible or not?


Is it possible to have autocompletion of defprotocol methods in Emacs?

An example:

(defprotocol Foo
  (bar [this])
  (baz [this])

(deftype Qux [a b c]
  Foo
  (bar [this] a)
  (baz [this] b))

(bar (Qux. 1 2 3))
(baz (Qux. 1 2 3))

I was looking for something like this(in pseudocode):

;; (1)
(`M-Tab` (Qux. 1 2 3)) 
;;
;; or (2):
(-> (Qux. 1 2 3) `M-Tab`)

to trigger a dropdown with bar & baz options. As a workaround I'm currently using (2) but it needs to have at least 1st character to be present(autocomplete all options doesn't work).

Is there a better way to do it? Thanks


Solution

  • For me auto-completion also works in case (1) when one character is present. It does not seem to specifically be aware of the functions belonging to the protocol, CIDER is just aware of the functions in scope. The completion-at-point does not seem to toggle without a first character. Maybe you can try asking on #cider of clojurians.slack.org?

    😄