Skip to content

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

Merged
merged 8 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master (unreleased)

### New features

* [#187](https://github.com/clojure-emacs/inf-clojure/pull/197): Defcustom `inf-clojure-enable-eldoc` to disable eldoc interaction.

## 3.1.0 (2021-07-23)

### New features
Expand Down
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,20 @@ startup when using the `inf-clojure` command or is specified manually when using

#### ElDoc

**Note:** You can skip this section if you're using Emacs 26.1+, as `eldoc-mode`
is enabled by default there.

`eldoc-mode` is supported in Clojure source buffers and `*inferior-clojure*`
buffers which are running a Clojure REPL.

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


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

```emacs-lisp
(add-hook 'clojure-mode-hook #'eldoc-mode)
Expand Down
14 changes: 12 additions & 2 deletions inf-clojure.el
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,13 @@ mode line entirely."
:type 'sexp
:risky t)

(defcustom inf-clojure-enable-eldoc t
"Var that allows disabling `eldoc-mode` in `inf-clojure`.

Set to `nil` to disable eldoc. Eldoc can be quite useful by
displaying function signatures in the modeline, but can also
cause multiple prompts to appear and mess with `*1`, `*2`, etc.")

;;;###autoload
(define-minor-mode inf-clojure-minor-mode
"Minor mode for interacting with the inferior Clojure process buffer.
Expand All @@ -394,7 +401,8 @@ The following commands are available:
:lighter inf-clojure-mode-line
:keymap inf-clojure-minor-mode-map
(setq-local comint-input-sender 'inf-clojure--send-string)
(inf-clojure-eldoc-setup)
(when inf-clojure-enable-eldoc
(inf-clojure-eldoc-setup))
(make-local-variable 'completion-at-point-functions)
(add-to-list 'completion-at-point-functions
#'inf-clojure-completion-at-point))
Expand Down Expand Up @@ -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-enable-eldoc
(inf-clojure-eldoc-setup))
(setq comint-get-old-input #'inf-clojure-get-old-input)
(setq comint-input-filter #'inf-clojure-input-filter)
(setq-local comint-prompt-read-only inf-clojure-prompt-read-only)
Expand Down Expand Up @@ -1407,6 +1416,7 @@ Return the number of nested sexp the point was over or after."
"Backend function for eldoc to show argument list in the echo area."
;; todo: this never gets unset once connected and is a lie
(when (and (inf-clojure-connected-p)
inf-clojure-enable-eldoc
;; don't clobber an error message in the minibuffer
(not (member last-command '(next-error previous-error))))
(let* ((info (inf-clojure-eldoc-info-in-current-sexp))
Expand Down