Skip to content

Commit

Permalink
Merge pull request #471 from cemerick/master
Browse files Browse the repository at this point in the history
Let *1 be set properly when pretty-printing, fixes gh-468
  • Loading branch information
bbatsov committed Feb 5, 2014
2 parents 53458df + ee0b0e0 commit 675ef05
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ cider-nrepl's complete middleware for CLJ/CLJS autocomplete.
`cider-prompt-save-file-on-load`.
* New interactive command `cider-insert-defun-in-repl`.
* New interactive command `cider-insert-ns-form-in-repl`.
* [#468](https://github.com/clojure-emacs/cider/issues/468) Fix
pretty-printing of evaluation results so that `*1` is set properly.

## 0.5.0 / 2014-01-24

Expand Down
4 changes: 2 additions & 2 deletions cider-interaction.el
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ Print its value into the current buffer."
(interactive)
(let ((form (cider-last-sexp))
(result-buffer (cider-popup-buffer cider-result-buffer nil)))
(cider-tooling-eval (format "(clojure.pprint/pprint %s)" form)
(cider-tooling-eval (cider-format-pprint-eval form)
(cider-popup-eval-out-handler result-buffer)
(cider-current-ns))))

Expand All @@ -1002,7 +1002,7 @@ Print its value into the current buffer."
(interactive)
(let ((form (cider-defun-at-point))
(result-buffer (cider-popup-buffer cider-result-buffer nil)))
(cider-tooling-eval (format "(clojure.pprint/pprint %s)" form)
(cider-tooling-eval (cider-format-pprint-eval form)
(cider-popup-eval-out-handler result-buffer)
(cider-current-ns))))

Expand Down
5 changes: 3 additions & 2 deletions cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ the symbol."
"Make a nREPL evaluation handler for the REPL BUFFER."
(nrepl-make-response-handler buffer
(lambda (buffer value)
(cider-repl-emit-result buffer value t))
(when (not cider-repl-use-pretty-printing)
(cider-repl-emit-result buffer value t)))
(lambda (buffer out)
(cider-repl-emit-output buffer out))
(lambda (buffer err)
Expand Down Expand Up @@ -551,7 +552,7 @@ If NEWLINE is true then add a newline at the end of the input."
(let* ((input (cider-repl--current-input))
(form (if (and (not (string-match "\\`[ \t\r\n]*\\'" input))
cider-repl-use-pretty-printing)
(format "(clojure.pprint/pprint %s)" input)
(cider-format-pprint-eval input)
input)))
(goto-char (point-max))
(cider-repl--mark-input-start)
Expand Down
4 changes: 4 additions & 0 deletions cider-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ buffer-local wherever it is set."
(font-lock-fontify-buffer)
(buffer-string)))

(defun cider-format-pprint-eval (form)
"Return a string of Clojure code that will eval and pretty-print FORM."
(format "(let [x %s] (clojure.pprint/pprint x) x)" form))

(provide 'cider-util)

;;; cider-util.el ends here

0 comments on commit 675ef05

Please sign in to comment.