clojure-emacs / inf-clojure

Basic interaction with a Clojure subprocess
249 stars 46 forks source link

Adds an option to disable eldoc #197

Closed dpsutton closed 2 years ago

dpsutton commented 2 years ago

Eldoc is quite nice and puts the function signatures in the minibuffer. But it does this at a cost. Since inf-clojure only uses a single connection (currently at least) the commands interrupt the values of *1, *2, etc. Further, this can lead to multiple prompts appearing in the repl buffer.

user=> user=> (map inc (range 4))
(1 2 3 4)
user=> user=> *1
nil
user=>

user appears multiple times, and then *1 has been bound to the result of getting arglists

user=> (+ 1 1)
2
user=> *1
([f] [f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls])

The multiple prompts is quite annoying when inserting forms into the repl.

Note that *1 is oftentimes nil because eldoc just runs (try (:arglists (meta _whatever-your-cursor-is-on)) (catch nil)) whenever your cursor stays on something for too long. This is also not throwing away too much functionality since you can easily get the docstring in the repl by C-c C-v (inf-clojure-show-var-documentation)

bbatsov commented 2 years ago

Can't people just turn-off eldoc-mode locally? (e.g. using a hook)

dpsutton commented 2 years ago

I think you are right that this is not the way to go forward. A hook to turn off eldoc mode helps for newly created buffers but is annoying for any that already exist. But perhaps that's not so bad. Let me think on it for a bit. I'm wondering if other modes in the buffer use eldoc so that turning eldoc mode completely off is heavy handed.

Andre0991 commented 2 years ago

I'm wondering if other modes in the buffer use eldoc so that turning eldoc mode completely off is heavy handed.

eglot (LSP client) uses eldoc.

Andre0991 commented 2 years ago

By the way, as an inspiration, eglot has an variable for not interfering with other modes:

`eglot-stay-out-of: List of Emacs features that Eglot shouldn't automatically try to manage on users' behalf. Useful when you need non-LSP Flymake or Company backends. See docstring for examples.

I wonder if inf-clojure could do the same for eldoc.

dpsutton commented 2 years ago

I've updated it to be a bit more sensible i think. Now I just prohibit the eldoc setup when it is not enabled. This allows other modes to use eldoc and seems quite nice in practice for me.

bbatsov commented 2 years ago

I've added a couple of small feedback remarks. This also needs to be documented somewhere in the README.

dpsutton commented 2 years ago

All addressed I believe. Thanks for the thoughtful review @bbatsov !

bbatsov commented 2 years ago

You're welcome! Thanks for tackling this.