Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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): Defvar `inf-clojure-eldoc-enabledp` to disable eldoc interaction.

## 3.1.0 (2021-07-23)

### New features
Expand Down
13 changes: 11 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)

(defvar inf-clojure-eldoc-enabledp t
Copy link
Member

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.

"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
Copy link
Member

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. :-)

Copy link
Contributor Author

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.

Copy link
Member

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.

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-eldoc-enabledp
(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-eldoc-enabledp
Copy link
Member

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.

Copy link
Contributor Author

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.

(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