clojure-emacs/cider — pull request #700 by vitoshka (2014-08-05 08:46:59+00:00)
Title: Fix and enhance switching between connections

I am commonly working with several projects and it very often happens that my file is associated with the wrong process. This happens even with C-c C-z. Cider always thinks the current connection is the top of `nrepl-connection-list`. Such handling is cumbersome and pretty fragile and should be better changed. Cider also bogs itself down into it's own complexity with all its buffers and buffer indirections.

Why do you need `*cider-connection XXX:dddd*` buffer? If I understand correctly this buffer is used to store process specific variables. Well, firstly, why not use nrepl process buffer directly? Secondly, if you need to store process specific variables why not use process properties for that? Then use processes directly instead of connection-buffer indirection. What I mean is to directly use nrepl-process-list of processes instead of nrepl-connection-list of buffers for low level handling.

----------

Anyways, this patch fixes the switching to the repl buffer. It was broken for two main reasons. First it was switching to the most recent process and was pretty much always doing the wrong thing. It went especially nuts when you have at least one "projectless" repl. Second, on C-u C-u the connection was asking for project directory in order to choose the connection. Besides having had a broken implementation of that idea, it's an additional layer of indirection; if you want to chose a connection, choose by connection not by XXX property of that connection.

New switching never makes connection mistakes and asks users whenever unsure. It also handles starting of a new process when user selects the `*new*` option.

++++

* cider-switch-to-relevant-repl-buffer: Never select wrong connection. When not
sure ask the user. Register new connection locally. On C-u C-u interactively
ask for connection.

* cider-switch-connection: New command to interactively switch between
connection. Allows *new* option which is currently delegated to
cider-jack-in.