summaryrefslogtreecommitdiff
path: root/cider-repl.el
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-01-10 08:50:33 -0700
committerSean Whitton <spwhitton@spwhitton.name>2019-01-10 08:50:33 -0700
commit9fa91217c2582736e929bab41cb58f506d4d0b7f (patch)
tree6932cef398345f25acba2737d8f9b696ee040b88 /cider-repl.el
parentb17a12b301a82f1e1ab9b19674aeb7fff3c25b40 (diff)
parentcd71f5cc12c93355cdf5698ac0aee9606480176a (diff)
Merge tag 'v0.19.0+dfsg'
DFSG-clean upstream version 0.19.0
Diffstat (limited to 'cider-repl.el')
-rw-r--r--cider-repl.el39
1 files changed, 26 insertions, 13 deletions
diff --git a/cider-repl.el b/cider-repl.el
index 14eaeb84..3adfb1d4 100644
--- a/cider-repl.el
+++ b/cider-repl.el
@@ -1,7 +1,7 @@
;;; cider-repl.el --- CIDER REPL mode interactions -*- lexical-binding: t -*-
;; Copyright © 2012-2013 Tim King, Phil Hagelberg, Bozhidar Batsov
-;; Copyright © 2013-2018 Bozhidar Batsov, Artur Malabarba and CIDER contributors
+;; Copyright © 2013-2019 Bozhidar Batsov, Artur Malabarba and CIDER contributors
;;
;; Author: Tim King <kingtim@gmail.com>
;; Phil Hagelberg <technomancy@gmail.com>
@@ -315,22 +315,31 @@ client process connection. Unless NO-BANNER is non-nil, insert a banner."
(when cider-repl-display-in-current-window
(add-to-list 'same-window-buffer-names (buffer-name buffer)))
(pcase cider-repl-pop-to-buffer-on-connect
- (`display-only (display-buffer buffer))
+ (`display-only
+ (let ((orig-buffer (current-buffer)))
+ (display-buffer buffer)
+ ;; User popup-rules (specifically `:select nil') can cause the call to
+ ;; `display-buffer' to reset the current Emacs buffer to the clj/cljs
+ ;; buffer that the user ran `jack-in' from - we need the current-buffer
+ ;; to be the repl to initialize, so reset it back here to be resilient
+ ;; against user config
+ (set-buffer orig-buffer)))
((pred identity) (pop-to-buffer buffer)))
(cider-repl-set-initial-ns buffer)
(cider-repl-require-repl-utils)
(cider-repl-set-config)
(unless no-banner
(cider-repl--insert-banner-and-prompt buffer))
+ (with-current-buffer buffer
+ (set-window-point (get-buffer-window) (point-max)))
buffer)
(defun cider-repl--insert-banner-and-prompt (buffer)
"Insert REPL banner and REPL prompt in BUFFER."
(with-current-buffer buffer
- (when (zerop (buffer-size))
- (insert (propertize (cider-repl--banner) 'font-lock-face 'font-lock-comment-face))
- (when cider-repl-display-help-banner
- (insert (propertize (cider-repl--help-banner) 'font-lock-face 'font-lock-comment-face))))
+ (insert (propertize (cider-repl--banner) 'font-lock-face 'font-lock-comment-face))
+ (when cider-repl-display-help-banner
+ (insert (propertize (cider-repl--help-banner) 'font-lock-face 'font-lock-comment-face)))
(goto-char (point-max))
(cider-repl--mark-output-start)
(cider-repl--mark-input-start)
@@ -678,8 +687,7 @@ If BOL is non-nil insert at the beginning of line. Run
(defun cider-repl--emit-interactive-output (string face)
"Emit STRING as interactive output using FACE."
(with-current-buffer (cider-current-repl)
- (let ((pos (cider-repl--end-of-line-before-input-start))
- (string (replace-regexp-in-string "\n\\'" "" string)))
+ (let ((pos (cider-repl--end-of-output)))
(cider-repl--emit-output-at-pos (current-buffer) string face pos t))))
(defun cider-repl-emit-interactive-stdout (string)
@@ -1056,10 +1064,15 @@ See also the related commands `cider-repl-clear-output' and
(recenter t))
(run-hooks 'cider-repl-clear-buffer-hook))
-(defun cider-repl--end-of-line-before-input-start ()
- "Return the position of the end of the line preceding the beginning of input."
- (1- (previous-single-property-change cider-repl-input-start-mark 'field nil
- (1+ (point-min)))))
+(defun cider-repl--end-of-output ()
+ "Return the position at the end of the previous REPL output."
+ (if (eq (get-text-property (1- cider-repl-input-start-mark) 'field)
+ 'cider-repl-prompt)
+ ;; if after prompt, return eol before prompt
+ (previous-single-property-change cider-repl-input-start-mark
+ 'field nil (point-min))
+ ;; else, input mark because there is no prompt (yet)
+ cider-repl-input-start-mark))
(defun cider-repl-clear-output (&optional clear-repl)
"Delete the output inserted since the last input.
@@ -1072,7 +1085,7 @@ With a prefix argument CLEAR-REPL it will clear the entire REPL buffer instead."
(ignore-errors (forward-sexp))
(forward-line)
(point)))
- (end (cider-repl--end-of-line-before-input-start)))
+ (end (cider-repl--end-of-output)))
(when (< start end)
(let ((inhibit-read-only t))
(cider-repl--clear-region start end)