summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2018-11-19 11:22:03 -0500
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2018-12-23 09:11:54 +0200
commitb3b9c67abe2e5ce9eadf2a3cb4358203431c1ebf (patch)
tree0596c3a5d9b31545917a18ee8c86b44a7fa11e6a
parentcd98bc0f7b770f381dcbb3b25ba6008f9e88a8ac (diff)
[Fix #2515] Reset the current buffer after display-buffer
If the user has `:select nil` in their popup rules for the Cider REPL buffer, the call to `display-buffer` to display the repl buffer while initializing it will reset the `current-buffer` to the buffer the user ran `jack-in` from, which breaks any successive calls to `cider-current-repl`. Resetting the current buffer back to the original buffer after `display-buffer` is resilient against this config change, without breaking anything else in the case the config is absent.
-rw-r--r--cider-repl.el10
1 files changed, 9 insertions, 1 deletions
diff --git a/cider-repl.el b/cider-repl.el
index 8cb444f2..ab65e413 100644
--- a/cider-repl.el
+++ b/cider-repl.el
@@ -315,7 +315,15 @@ 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)