diff --git a/CHANGELOG.md b/CHANGELOG.md index ec5e0c1..5718b6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index dc314a8..edf3b74 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/inf-clojure.el b/inf-clojure.el index bbcb0c1..3996c4b 100644 --- a/inf-clojure.el +++ b/inf-clojure.el @@ -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. @@ -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)) @@ -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) @@ -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))