Permalink
Browse files

emit stdout from interactive-eval into repl buffer

  • Loading branch information...
1 parent 0e9b8b0 commit 0dc81c7fc4678f19f1df5e150b6d42143514bcec @kingtim kingtim committed Aug 25, 2012
Showing with 19 additions and 1 deletion.
  1. +19 −1 nrepl.el
View
@@ -448,7 +448,8 @@ joined together.")
(nrepl-make-response-handler buffer
(lambda (buffer value)
(message (format "%s" value)))
- '()
+ (lambda (buffer value)
+ (nrepl-emit-interactive-output value))
(lambda (buffer err)
(message (format "%s" err)))
'()))
@@ -969,6 +970,23 @@ Return the position of the prompt beginning."
(set-marker nrepl-prompt-start-mark prompt-start)
prompt-start))))
+(defun nrepl-emit-interactive-output (string)
+ ;; insert string into repl buffer and mark it as output
+ (with-current-buffer "*nrepl*"
+ (save-excursion
+ (nrepl-save-marker nrepl-output-start
+ (nrepl-save-marker nrepl-output-end
+ (goto-char (1- (nrepl-input-line-beginning-position)))
+ (when (not (bolp)) (insert-before-markers "\n"))
+ (nrepl-propertize-region `(face nrepl-output-face
+ rear-nonsticky (face))
+ (insert-before-markers string)
+ (when (and (= (point) nrepl-prompt-start-mark)
+ (not (bolp)))
+ (insert-before-markers "\n")
+ (set-marker nrepl-output-end (1- (point))))))))
+ (nrepl-show-maximum-output)))
+
(defun nrepl-emit-output (buffer string &optional bol)
;; insert STRING and mark it as output
(with-current-buffer buffer

0 comments on commit 0dc81c7

Please sign in to comment.