Skip to content

Commit

Permalink
Merge pull request #786 from vitoshka/master
Browse files Browse the repository at this point in the history
[fix #772] and fix broken `cider-eval-and-get-value`
  • Loading branch information
bbatsov committed Sep 10, 2014
2 parents 123e1b5 + be86fcf commit 837635a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
6 changes: 4 additions & 2 deletions cider-browse-ns.el
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
(interactive (list (completing-read "Browse namespace: " (cider--all-ns))))
(with-current-buffer (cider-popup-buffer cider-browse-ns-buffer t)
(let* ((form "(sort (map name (keys (ns-publics (quote %s)))))")
(vars (cider-eval-and-get-value (format form namespace))))
(vars (cider-sync-eval-and-parse (format form namespace))))
(cider-browse-ns-list (current-buffer)
namespace
(mapcar (lambda (var)
Expand All @@ -110,7 +110,7 @@
"List all loaded namespaces in BUFFER."
(interactive)
(with-current-buffer (cider-popup-buffer cider-browse-ns-buffer t)
(let ((names (cider-eval-and-get-value
(let ((names (cider-sync-eval-and-parse
"(->> (all-ns)
(map ns-name)
(map name)
Expand Down Expand Up @@ -140,6 +140,8 @@
(cider-browse-ns-operate-on-point))


(define-obsolete-variable-alias 'cider-eval-and-get-value 'cider-sync-eval-and-parse "0.8.0")

(provide 'cider-browse-ns)

;;; cider-browse-ns.el ends here
17 changes: 5 additions & 12 deletions cider-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,18 @@ NS specifies the namespace in which to evaluate the request."
NS & SESSION specify the evaluation context."
(nrepl-sync-request:eval input ns session))

(defun cider-eval-and-get-value (input &optional ns session)
(defun cider-sync-eval-and-parse (input &optional ns session)
"Send the INPUT to the nREPL server synchronously and return the value.
NS & SESSION specify the evaluation context."
(cider-get-value (cider-eval-sync input ns session)))
NS & SESSION specify the evaluation context. The output must be a readable
Emacs list or a vector of other lists and vectors as `read' is used to
convert the output into an Emacs object."
(read (plist-get (cider-eval-sync input ns session) :value)))

(defun cider-tooling-eval-sync (input &optional ns)
"Send the INPUT to the nREPL server using a tooling session synchronously.
NS specifies the namespace in which to evaluate the request."
(cider-eval-sync input ns (nrepl-current-tooling-session)))

(defun cider-get-raw-value (eval-result)
"Get the raw value (as string) from EVAL-RESULT."
(plist-get eval-result :value))

(defun cider-get-value (eval-result)
"Get the value from EVAL-RESULT."
(with-output-to-string
(message "%s" (cider-get-raw-value eval-result))))

(defun cider-send-op (op attributes handler)
"Send the specified OP with ATTRIBUTES and response HANDLER."
(nrepl-send-request (append
Expand Down
4 changes: 2 additions & 2 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -1329,7 +1329,7 @@ If invoked with a PREFIX argument, print the result in the current buffer."
(interactive)
(let ((last-sexp (cider-last-sexp)))
;; we have to be sure the evaluation won't result in an error
(cider-eval-and-get-value last-sexp)
(cider-eval-sync last-sexp)
;; seems like the sexp is valid, so we can safely kill it
(backward-kill-sexp)
(cider-interactive-eval-print last-sexp)))
Expand Down Expand Up @@ -1400,7 +1400,7 @@ If invoked with a prefix ARG eval the expression after inserting it."
(defun cider-ping ()
"Check that communication with the server works."
(interactive)
(message "%s" (cider-eval-and-get-value "\"PONG\"")))
(message "%s" (cider-sync-eval-and-parse "\"PONG\"")))

(defun clojure-enable-cider ()
"Turn on CIDER mode (see command `cider-mode').
Expand Down
2 changes: 1 addition & 1 deletion cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ text property `cider-old-input'."

(defun cider--all-ns ()
"Get a list of the available namespaces."
(cider-eval-and-get-value
(cider-sync-eval-and-parse
"(clojure.core/map clojure.core/str (clojure.core/all-ns))"))

(defun cider-repl-set-ns (ns)
Expand Down
2 changes: 1 addition & 1 deletion test/cider-tests--no-auto.el
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ from the latter. Remaining content is compared for string equality."

(defun cider-test-all-docs ()
"Verify docs for all special forms and every public var in `clojure/core'."
(let ((syms (cider-eval-and-get-value
(let ((syms (cider-sync-eval-and-parse
"(->> (merge @#'clojure.repl/special-doc-map
(->> (ns-map 'clojure.core)
(filter (every-pred
Expand Down

0 comments on commit 837635a

Please sign in to comment.