Skip to content

Commit

Permalink
Refactor repl<->connection names
Browse files Browse the repository at this point in the history
  • Loading branch information
vspinu committed Jun 15, 2018
1 parent 06616ba commit 528a899
Show file tree
Hide file tree
Showing 15 changed files with 386 additions and 376 deletions.
1 change: 0 additions & 1 deletion cider-apropos.el
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ optionally search doc strings (based on DOCS-P), include private vars
;;;###autoload
(defun cider-apropos-select (query &optional ns docs-p privates-p case-sensitive-p)
"Similar to `cider-apropos', but presents the results in a completing read.
Show all symbols whose names match QUERY, a regular expression.
QUERY can also be a list of space-separated words (e.g. take while) which
will be converted to a regular expression (like take.+while) automatically
Expand Down
30 changes: 15 additions & 15 deletions cider-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ REPL's ns, otherwise fall back to \"user\". When NO-DEFAULT is non-nil, it
will return nil instead of \"user\"."
(or cider-buffer-ns
(clojure-find-ns)
(when-let* ((repl (cider-current-connection)))
(when-let* ((repl (cider-current-repl)))
(buffer-local-value 'cider-buffer-ns repl))
(if no-default nil "user")))

Expand Down Expand Up @@ -138,7 +138,7 @@ to the file backing the current buffer. The command falls back to

(defun cider-nrepl-op-supported-p (op &optional connection)
"Check whether the CONNECTION supports the nREPL middleware OP."
(nrepl-op-supported-p op (or connection (cider-current-connection))))
(nrepl-op-supported-p op (or connection (cider-current-repl))))

(defvar cider-version)
(defun cider-ensure-op-supported (op)
Expand All @@ -153,7 +153,7 @@ REQUEST is a pair list of the form (\"op\" \"operation\" \"par1-name\"
\"par1\" ... ).
If CONNECTION is provided dispatch to that connection instead of
the current connection. Return the id of the sent message."
(nrepl-send-request request callback (or connection (cider-current-connection))))
(nrepl-send-request request callback (or connection (cider-current-repl))))

(defun cider-nrepl-send-sync-request (request &optional connection abort-on-input)
"Send REQUEST to the nREPL server synchronously using CONNECTION.
Expand All @@ -163,13 +163,13 @@ If ABORT-ON-INPUT is non-nil, the function will return nil
at the first sign of user input, so as not to hang the
interface."
(nrepl-send-sync-request request
(or connection (cider-current-connection))
(or connection (cider-current-repl))
abort-on-input))

(defun cider-nrepl-send-unhandled-request (request &optional connection)
"Send REQUEST to the nREPL CONNECTION and ignore any responses.
Immediately mark the REQUEST as done. Return the id of the sent message."
(let* ((conn (or connection (cider-current-connection)))
(let* ((conn (or connection (cider-current-repl)))
(id (nrepl-send-request request #'ignore conn)))
(with-current-buffer conn
(nrepl--mark-id-completed id))
Expand All @@ -180,8 +180,8 @@ Immediately mark the REQUEST as done. Return the id of the sent message."
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-connection)."
(let ((connection (or connection (cider-current-connection))))
buffer, defaults to (cider-current-repl)."
(let ((connection (or connection (cider-current-repl))))
(nrepl-request:eval input
(if cider-show-eval-spinner
(cider-eval-spinner-handler connection callback)
Expand All @@ -193,7 +193,7 @@ buffer, defaults to (cider-current-connection)."
(defun cider-nrepl-sync-request:eval (input &optional connection ns)
"Send the INPUT to the nREPL CONNECTION synchronously.
If NS is non-nil, include it in the eval request."
(nrepl-sync-request:eval input (or connection (cider-current-connection)) ns))
(nrepl-sync-request:eval input (or connection (cider-current-repl)) ns))

(defcustom cider-pprint-fn 'pprint
"Sets the function to use when pretty-printing evaluation results.
Expand Down Expand Up @@ -252,7 +252,7 @@ clobber *1/2/3)."
;; namespace forms are always evaluated in the "user" namespace
(nrepl-request:eval input
callback
(or connection (cider-current-connection))
(or connection (cider-current-repl))
ns nil nil nil 'tooling))

(defun cider-sync-tooling-eval (input &optional ns connection)
Expand All @@ -263,7 +263,7 @@ bindings of the primary eval nREPL session (e.g. this is not going to
clobber *1/2/3)."
;; namespace forms are always evaluated in the "user" namespace
(nrepl-sync-request:eval input
(or connection (cider-current-connection))
(or connection (cider-current-repl))
ns
'tooling))

Expand Down Expand Up @@ -296,22 +296,22 @@ The library is a string of the format \"group-id/artifact-id\"."
"Interrupt any pending evaluations."
(interactive)
;; FIXME: does this work correctly in cljc files?
(with-current-buffer (cider-current-connection)
(with-current-buffer (cider-current-repl)
(let ((pending-request-ids (cider-util--hash-keys nrepl-pending-requests)))
(dolist (request-id pending-request-ids)
(nrepl-request:interrupt
request-id
(cider-interrupt-handler (current-buffer))
(cider-current-connection))))))
(cider-current-repl))))))

(defun cider-nrepl-eval-session ()
"Return the eval nREPL session id of the current connection."
(with-current-buffer (cider-current-connection)
(with-current-buffer (cider-current-repl)
nrepl-session))

(defun cider-nrepl-tooling-session ()
"Return the tooling nREPL session id of the current connection."
(with-current-buffer (cider-current-connection)
(with-current-buffer (cider-current-repl)
nrepl-tooling-session))

(defun cider--var-choice (var-info)
Expand Down Expand Up @@ -382,7 +382,7 @@ thing at point."
(defun cider-request:load-file (file-contents file-path file-name &optional connection callback)
"Perform the nREPL \"load-file\" op.
FILE-CONTENTS, FILE-PATH and FILE-NAME are details of the file to be
loaded. If CONNECTION is nil, use `cider-current-connection'. If CALLBACK
loaded. If CONNECTION is nil, use `cider-current-repl'. If CALLBACK
is nil, use `cider-load-file-handler'."
(cider-nrepl-send-request `("op" "load-file"
"file" ,file-contents
Expand Down
Loading

0 comments on commit 528a899

Please sign in to comment.