Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cider-switch-to-repl-buffer should switch to relevant (not most recent) buffer #2084

Closed
mwfogleman opened this issue Sep 8, 2017 · 3 comments
Labels

Comments

@mwfogleman
Copy link

mwfogleman commented Sep 8, 2017

A few people (@magnars @dpsutton jumar?) were talking on Clojurians yesterday about an issue that I've noticed. I don't have all the details, but I borrowed from their descriptions, but will try to help report.

The documentation says "To switch to the relevant REPL buffer based on the Clojure namespace in the current Clojure buffer, use: C-c C-z." From cljs-mode, it should switch to the project's cljs-repl; from clojure-mode it should switch to the project's clj-repl.

Instead, it switches to the most recent REPL.

@dpsutton says it is related to: 746e4d6

To reproduce the problem:

  • Create a project with CLJ and CLJS.
  • Navigate to a file in that project, and run cider-jack-in-clojurescript.
  • Switch to the CLJ REPL buffer.
  • Navigate to a CLJS file buffer.
  • Hit C-c C-z (cider-switch-to-repl-buffer). It will switch to the CLJ REPL buffer, not the CLJS REPL buffer.

Leiningen 2.7.1

Emacs: 25.2.1

Arch/Antergos Linux

@mwfogleman mwfogleman changed the title cider-switch-to-repl-buffer should switch to relevant (not most recent cider-switch-to-repl-buffer should switch to relevant (not most recent) buffer Sep 8, 2017
@dpsutton
Copy link
Contributor

dpsutton commented Sep 8, 2017

My thinking is that it is the repl resolution that is the problem. In cider-current-connection, when there are more than one connection it just banks on the most recent connection, which seems wrong to me. This sounds like a resolution strategy that should be further down. I've had instances of cljs buffers loading in the clj repl, and clj files loading in other project repls.

  (cond
   ((not connections) nil)
   ;; if you're in a REPL buffer, it's the connection buffer
   ((and (derived-mode-p 'cider-repl-mode) (right-type-p (current-buffer) type)))
   ((eq cider-request-dispatch 'static) (car connections))
   ((= 1 (length connections)) (right-type-p (car connections) type))
   (t (let ((project-connections (cider-find-connection-buffer-for-project-directory
                                  nil :all-connections))
            (guessed-type (or type (cider-connection-type-for-buffer))))
        (or
         ;; cljc
         (and (equal guessed-type "multi")
              (most-recent-buf project-connections nil))
         ;; clj or cljs
         (and guessed-type
              (or (most-recent-buf project-connections guessed-type)
                  (most-recent-buf connections guessed-type)))
         ;; when type was not specified or guessed
         (most-recent-buf project-connections type)
         (most-recent-buf connections type)))))

@vspinu
Copy link
Contributor

vspinu commented Sep 10, 2017

The problem is directly with cider-switch-to-repl-buffer. BTW, same issue shows with cider-switch-to-last-clojure-buffer. Will have a look.

@wizmer
Copy link

wizmer commented Sep 18, 2017

Here is a PR #2085 that solve at least the CLJS case.
For me it is not clear where to switch when being in a CLJC file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants