-
-
Notifications
You must be signed in to change notification settings - Fork 45
Adds an option to disable eldoc #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds an option to disable eldoc #197
Conversation
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. ```clojure 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 ```clojure 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.
Can't people just turn-off |
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. |
|
By the way, as an inspiration,
I wonder if |
inf-clojure.el
Outdated
"Var that allows disabling `eldoc-mode` in `inf-clojure`. | ||
|
||
Set to `nil` to disable eldoc. Eldoc can be quite useful by | ||
displaying funciton signatures in the modeline, but can also |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, this disclaimer is true for every command that does some code evaluation on the side. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, but all others are user driver. If you refresh a namespace or call doc, you understand that *1
and others will have been moved because you caused an evaluation. Eldoc is special because unbeknownst to the user those vars will change value. It makes using them very frustrating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also - there's a typo in function
.
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. |
inf-clojure.el
Outdated
@@ -384,6 +384,13 @@ mode line entirely." | |||
:type 'sexp | |||
:risky t) | |||
|
|||
(defvar inf-clojure-eldoc-enabledp t |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this a defcustom and name it inf-clojure-enable-eldoc
.
inf-clojure.el
Outdated
@@ -631,7 +639,8 @@ to continue it." | |||
(setq mode-line-process '(":%s")) | |||
(clojure-mode-variables) | |||
(clojure-font-lock-setup) | |||
(inf-clojure-eldoc-setup) | |||
(when inf-clojure-eldoc-enabledp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with this, but it might be better to make the eldoc integration a no-op instead, so that people won't have to disable/enable inf-clojure-mode for the new config to be taken into account.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was originally my solution, but that still leads to some problems. Eldoc is initialized as follows:
(defun inf-clojure-eldoc-setup ()
"Turn on eldoc mode in the current buffer."
(setq-local eldoc-documentation-function #'inf-clojure-eldoc)
(apply #'eldoc-add-command inf-clojure-extra-eldoc-commands))
Since it clobbers any existing eldoc-documentation-function
, once eldoc is initialized in a buffer there's no good way to go back to a clean slate since any previous eldoc function is gone. I'll add the enabledp
function to the eldoc function so it would prevent more eldocs, but it cannot restore the previous eldoc unfortunately.
I've added a couple of small feedback remarks. This also needs to be documented somewhere in the README. |
If someone changes this value after using `inf-clojure`, we cannot restore other eldoc functions (lsp, etc) but we can at least not send more eldoc requests and mess with the repl. Restarting emacs or perhaps even just disabling and then enabling the mode would put them in a clean state
All addressed I believe. Thanks for the thoughtful review @bbatsov ! |
You're welcome! Thanks for tackling this. |
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 promptsappearing in the repl buffer.
user
appears multiple times, and then*1
has been bound to theresult of getting arglists
The multiple prompts is quite annoying when inserting forms into the
repl.
Note that
*1
is oftentimesnil
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 byC-c C-v
(inf-clojure-show-var-documentation
)