Skip to content

Commit de59e5c

Browse files
authored
Adds an option to disable eldoc (#197)
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.
1 parent e47684d commit de59e5c

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## master (unreleased)
44

5+
### New features
6+
7+
* [#187](https://github.com/clojure-emacs/inf-clojure/pull/197): Defcustom `inf-clojure-enable-eldoc` to disable eldoc interaction.
8+
59
## 3.1.0 (2021-07-23)
610

711
### New features

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -356,18 +356,20 @@ startup when using the `inf-clojure` command or is specified manually when using
356356

357357
#### ElDoc
358358

359-
**Note:** You can skip this section if you're using Emacs 26.1+, as `eldoc-mode`
360-
is enabled by default there.
361-
362359
`eldoc-mode` is supported in Clojure source buffers and `*inferior-clojure*`
363360
buffers which are running a Clojure REPL.
364361

365-
When ElDoc is enabled and there is an active REPL, it will show the
366-
argument list of the function call you are currently editing in the
367-
echo area.
362+
When ElDoc is enabled and there is an active REPL, it will show the argument
363+
list of the function call you are currently editing in the echo area. It
364+
accomplishes this by evaluating forms to get the metadata for the vars under
365+
your cursor. One side effect of this is that it can mess with repl vars like
366+
`*1` and `*2`. You can disable inf-clojure's Eldoc functionality with `(setq
367+
inf-clojure-enable-eldoc nil)`.
368+
368369

369-
You can activate ElDoc with `M-x eldoc-mode` or by adding the
370-
following to you Emacs config:
370+
ElDoc should be enabled by default in Emacs 26.1+. If it is not active by
371+
default, you can activate ElDoc with `M-x eldoc-mode` or by adding the following
372+
to you Emacs config:
371373

372374
```emacs-lisp
373375
(add-hook 'clojure-mode-hook #'eldoc-mode)

inf-clojure.el

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,13 @@ mode line entirely."
420420
:type 'sexp
421421
:risky t)
422422

423+
(defcustom inf-clojure-enable-eldoc t
424+
"Var that allows disabling `eldoc-mode` in `inf-clojure`.
425+
426+
Set to `nil` to disable eldoc. Eldoc can be quite useful by
427+
displaying function signatures in the modeline, but can also
428+
cause multiple prompts to appear and mess with `*1`, `*2`, etc.")
429+
423430
;;;###autoload
424431
(define-minor-mode inf-clojure-minor-mode
425432
"Minor mode for interacting with the inferior Clojure process buffer.
@@ -430,7 +437,8 @@ The following commands are available:
430437
:lighter inf-clojure-mode-line
431438
:keymap inf-clojure-minor-mode-map
432439
(setq-local comint-input-sender 'inf-clojure--send-string)
433-
(inf-clojure-eldoc-setup)
440+
(when inf-clojure-enable-eldoc
441+
(inf-clojure-eldoc-setup))
434442
(make-local-variable 'completion-at-point-functions)
435443
(add-to-list 'completion-at-point-functions
436444
#'inf-clojure-completion-at-point))
@@ -632,7 +640,8 @@ to continue it."
632640
(setq mode-line-process '(":%s"))
633641
(clojure-mode-variables)
634642
(clojure-font-lock-setup)
635-
(inf-clojure-eldoc-setup)
643+
(when inf-clojure-enable-eldoc
644+
(inf-clojure-eldoc-setup))
636645
(setq comint-get-old-input #'inf-clojure-get-old-input)
637646
(setq comint-input-filter #'inf-clojure-input-filter)
638647
(setq-local comint-prompt-read-only inf-clojure-prompt-read-only)
@@ -1408,6 +1417,7 @@ Return the number of nested sexp the point was over or after."
14081417
"Backend function for eldoc to show argument list in the echo area."
14091418
;; todo: this never gets unset once connected and is a lie
14101419
(when (and (inf-clojure-connected-p)
1420+
inf-clojure-enable-eldoc
14111421
;; don't clobber an error message in the minibuffer
14121422
(not (member last-command '(next-error previous-error))))
14131423
(let* ((info (inf-clojure-eldoc-info-in-current-sexp))

0 commit comments

Comments
 (0)