Skip to content

Commit 04972c8

Browse files
committed
[Fix #670] Save point between two inserts to popup buffer.
Solution is inspired by "Process Filter Example" from Emacs Lisp manual (including moving point if it was at the insert position).
1 parent f728678 commit 04972c8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cider-interaction.el

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,7 @@ If prefix argument KILL-BUFFER-P is non-nil, kill the buffer instead of burying
10601060
(erase-buffer)
10611061
(when major-mode
10621062
(funcall major-mode))
1063+
(setq-local cider-popup-output-marker (point-marker))
10631064
(cider-popup-buffer-mode 1)
10641065
(setq buffer-read-only t)
10651066
(current-buffer)))
@@ -1068,9 +1069,14 @@ If prefix argument KILL-BUFFER-P is non-nil, kill the buffer instead of burying
10681069
"Emit into BUFFER the provided VALUE."
10691070
(with-current-buffer buffer
10701071
(let ((inhibit-read-only t)
1071-
(buffer-undo-list t))
1072-
(insert (format "%s" value))
1073-
(indent-sexp))))
1072+
(buffer-undo-list t)
1073+
(moving (= (point) cider-popup-output-marker)))
1074+
(save-excursion
1075+
(goto-char cider-popup-output-marker)
1076+
(insert (format "%s" value))
1077+
(indent-sexp)
1078+
(set-marker cider-popup-output-marker (point)))
1079+
(when moving (goto-char cider-popup-output-marker)))))
10741080

10751081
(defun cider-emit-into-color-buffer (buffer value)
10761082
"Emit into color BUFFER the provided VALUE."

0 commit comments

Comments
 (0)