I want to be able to connect emacs keybindings to specific evals in my running clojure process, and I don’t want these evals to result in text output in my cider-repl buffer.
Currently I am at
(ns user)
(defn keydown []
... some logic ...)
and in .dir-locals.el
I’m at
(defun keydown-thing ()
(interactive)
(cider-nrepl-send-request
'("op" "eval"
"ns" "user"
"code" "(keydown)")
(cider-repl-handler (current-buffer))))
(global-set-key (kbd "<f2>") 'keydown-thing)
When I press F2 in the some cider-buffer, it works, but there is also a nil
output in the *cider-repl ...*
-buffer.
What is a better way to send data “silently” to the clojure process from emacs? It really doesn’t have to be through cider-nrepl if there is some more efficient way.
PEZ
December 16, 2022, 10:10am
2
Not an expert on CIDER (obviously ), but got curious. Maybe you can go a bit lower level? With nrepl-request:eval
you pass your own callback:
`("op" "eval"
"code" ,(substring-no-properties input))
(when cider-enlighten-mode
'("enlighten" "true"))
(let ((file (or (buffer-file-name) (buffer-name))))
(when (and line column file)
`("file" ,file
"line" ,line
"column" ,column)))))
(defun nrepl-request:eval (input callback connection &optional ns line column additional-params tooling)
"Send the request INPUT and register the CALLBACK as the response handler.
The request is dispatched via CONNECTION. If NS is non-nil,
include it in the request. LINE and COLUMN, if non-nil, define the position
of INPUT in its buffer. A CONNECTION uniquely determines two connections
available: the standard interaction one and the tooling session. If the
tooling is desired, set TOOLING to true.
ADDITIONAL-PARAMS is a plist to be appended to the request message."
(nrepl-send-request (append (nrepl--eval-request input ns line column) additional-params)
callback
connection
system
Closed
June 16, 2023, 10:10pm
3
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.