diff --git a/CHANGELOG.md b/CHANGELOG.md index dac67f4dd..70df09628 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ * [#1875](https://github.com/clojure-emacs/cider/issues/1875): Ensure cljc buffers can load buffer into both clj and cljs repls. * [#1897](https://github.com/clojure-emacs/cider/issues/1897): Bind TAB in stacktrace buffers in the terminal. * [#1895](https://github.com/clojure-emacs/cider/issues/1895): Connect to the same host:port after `cider-restart` if the connection was established with `cider-connect`. +* [#1913](https://github.com/clojure-emacs/cider/issues/1913): Fix bug in `cider-toggle-buffer-connection` to not delete connections. ## 0.14.0 (2016-10-13) diff --git a/cider-client.el b/cider-client.el index 3b1fbed82..2325f759b 100644 --- a/cider-client.el +++ b/cider-client.el @@ -210,10 +210,9 @@ such a link cannot be established automatically." "Toggles the current buffer's connection between Clojure and ClojureScript." (interactive) (cider-ensure-connected) - (let ((other-conn (cider-other-connection))) - (if other-conn - (setq-local cider-connections (list other-conn)) - (user-error "No other connection available")))) + (when-let ((conns (cider-connections))) + (setq-local cider-connections (append (cdr conns) (list (car conns)))) + (message "Repl type default set to: %s" (cider--connection-type (car (cider-connections)))))) (defun cider-clear-buffer-local-connection () "Remove association between the current buffer and a connection." @@ -224,6 +223,8 @@ such a link cannot be established automatically." (defun cider-connection-type-for-buffer () "Return the matching connection type (clj or cljs) for the current buffer." (cond + ;; cljc mode must be first as it derives from clj mode + ((derived-mode-p 'clojurec-mode) "cljc") ((derived-mode-p 'clojurescript-mode) "cljs") ((derived-mode-p 'clojure-mode) "clj") (cider-repl-type) @@ -272,7 +273,12 @@ at all." (guessed-type (or type (cider-connection-type-for-buffer)))) ;; So we have multiple connections. Look for the connection type we ;; want, prioritizing the current project. - (or (seq-find (lambda (conn) + + ;; when cljc buffer, use the first connection (you can rotate this + ;; to set priority + (or (when (string= "cljc" guessed-type) + (car connections)) + (seq-find (lambda (conn) (equal (cider--connection-type conn) guessed-type)) project-connections) (seq-find (lambda (conn) diff --git a/cider-scratch.el b/cider-scratch.el index e4e3150d9..b537441b9 100644 --- a/cider-scratch.el +++ b/cider-scratch.el @@ -66,7 +66,7 @@ (or (get-buffer cider-scratch-buffer-name) (cider-create-scratch-buffer))) -(define-derived-mode cider-clojure-interaction-mode clojure-mode "Clojure Interaction" +(define-derived-mode cider-clojure-interaction-mode clojurec-mode "Clojure Interaction" "Major mode for typing and evaluating Clojure forms. Like clojure-mode except that \\[cider-eval-print-last-sexp] evals the Lisp expression before point, and prints its value into the buffer, advancing point.