Skip to content
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

Show Cider eval spinner in current evaluating file buffer instead of repl-buffer #3516

Open
hierophantos opened this issue Oct 13, 2023 · 0 comments

Comments

@hierophantos
Copy link

hierophantos commented Oct 13, 2023

Is your feature request related to a problem? Please describe.

I would like to control where the cider-spinner appears--specifically, in the file buffer where I'm eval'ing my code. Mentioned this in Slack: https://clojurians.slack.com/archives/C0617A8PQ/p1696125697359089. Others thought this would be a neat feature to have as well.

Describe the solution you'd like

Some sort of defcustom that I can set.

Describe alternatives you've considered

I have the above working for me, but it's probably too hacky to include as a PR. I modified two lines in cider-client.el and added one hook to my config to get the desired effect of having the spinner show in file buffer. The following are those changes; my code follows the commented out lines:

(defun cider-nrepl-request:eval (input callback &optional ns line column additional-params connection)
  "Send the request INPUT and register the CALLBACK as the response handler.
If NS is non-nil, include it in the request.  LINE and COLUMN, if non-nil,
define the position of INPUT in its buffer.  ADDITIONAL-PARAMS is a plist
to be appended to the request message.  CONNECTION is the connection
buffer, defaults to (cider-current-repl)."
  (let ((connection (or connection (cider-current-repl nil 'ensure)))
        (eval-buffer (current-buffer)))
    (run-hooks 'cider-before-eval-hook)
    (nrepl-request:eval input
                        (lambda (response)
                          (when cider-show-eval-spinner
                            ;; (cider-eval-spinner connection response)
                            (cider-eval-spinner eval-buffer response))
                          (when (and (buffer-live-p eval-buffer)
                                     (member "done" (nrepl-dict-get response "status")))
                            (with-current-buffer eval-buffer
                              (run-hooks 'cider-after-eval-done-hook)))
                          (funcall callback response))
                        connection
                        ns line column additional-params)
    ;; (cider-spinner-start connection)
    (cider-spinner-start eval-buffer)))

(add-hook 'cider-after-eval-done-hook 'spinner-stop)

Additional context

I needed to add the 'spinner-stop to the 'cider-after-eval-done-hook, because the cider-eval-spinner function wasn't seeming to receive the eval response, as far as I can tell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants