Permalink
Browse files

refactor into nrepl-emit-output-at-pos

  • Loading branch information...
kingtim committed Aug 26, 2012
1 parent 0dc81c7 commit 465576af0b19889920c8da1739b6d33f3fc2181b
Showing with 10 additions and 19 deletions.
  1. +10 −19 nrepl.el
View
@@ -970,30 +970,13 @@ 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)
+(defun nrepl-emit-output-at-pos (buffer string position &optional bol)
;; insert STRING and mark it as output
(with-current-buffer buffer
(save-excursion
(nrepl-save-marker nrepl-output-start
(nrepl-save-marker nrepl-output-end
- (goto-char nrepl-input-start-mark)
+ (goto-char position)
(when (and bol (not (bolp))) (insert-before-markers "\n"))
(nrepl-propertize-region `(face nrepl-output-face
rear-nonsticky (face))
@@ -1004,6 +987,14 @@ Return the position of the prompt beginning."
(set-marker nrepl-output-end (1- (point))))))))
(nrepl-show-maximum-output)))
+(defun nrepl-emit-interactive-output (string)
+ (with-current-buffer "*nrepl*"
+ (nrepl-emit-output-at-pos (current-buffer) string (1- (nrepl-input-line-beginning-position)))))
+
+(defun nrepl-emit-output (buffer string &optional bol)
+ (with-current-buffer buffer
+ (nrepl-emit-output-at-pos buffer string nrepl-input-start-mark bol)))
+
(defun nrepl-emit-prompt (buffer)
(with-current-buffer buffer
(save-excursion

0 comments on commit 465576a

Please sign in to comment.