3

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

BinaryButterfly
  • 18,137
  • 13
  • 50
  • 91
  • 1
    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`](https://docs.cider.mx/cider/usage/code_completion.html) does not seem to toggle without a first character. Maybe you can try asking on #cider of clojurians.slack.org? – user2609980 Jul 06 '20 at 21:03
  • @ErwinRooijakkers If you would like to post your comment as an answer I'll accept it because well.. it answers the question :) – BinaryButterfly Jul 07 '20 at 11:11
  • 1
    Yay! Thank you. POINTS! – user2609980 Jul 07 '20 at 15:24

1 Answers1

1

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?

user2609980
  • 10,264
  • 15
  • 74
  • 143