-
-
Notifications
You must be signed in to change notification settings - Fork 649
CIDER session is lost when navigating to definition #3250
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I cannot reproduce this although I think I've seen it happen. Also, definitely have heard of it happening to other people (e.g. today) @bbatsov , do you recall what the mechanism is for making sure a Sesman session is 'inherited' from one buffer to a new one (the new one being that I thought it had to do with |
Ok, this summarizes it https://docs.cider.mx/cider/usage/managing_connections.html#friendly-sessions A way to debug this is by
(mapcar (lambda (session)
(sesman-friendly-session-p 'CIDER session))
(sesman--all-system-sessions 'CIDER)) The resulting list should include at least one truthy item. If not, one has to debug why. Get started by inlining CIDER's (mapcar (lambda (session)
(setcdr session (seq-filter #'buffer-live-p (cdr session)))
(when-let* ((repl (cadr session))
(proc (get-buffer-process repl))
(file (file-truename (or (buffer-file-name) default-directory))))
;; With avfs paths look like /path/to/.avfs/path/to/some.jar#uzip/path/to/file.clj
(when (string-match-p "#uzip" file)
(let ((avfs-path (directory-file-name (expand-file-name (or (getenv "AVFSBASE") "~/.avfs/")))))
(setq file (replace-regexp-in-string avfs-path "" file t t))))
(when (process-live-p proc)
(let* ((classpath (or (process-get proc :cached-classpath)
(let ((cp (with-current-buffer repl
(cider-classpath-entries))))
(process-put proc :cached-classpath cp)
cp)))
(classpath-roots (or (process-get proc :cached-classpath-roots)
(let ((cp (thread-last
classpath
(seq-filter (lambda (path) (not (string-match-p "\\.jar$" path))))
(mapcar #'file-name-directory)
(seq-remove #'null)
(seq-uniq))))
(process-put proc :cached-classpath-roots cp)
cp))))
(or (seq-find (lambda (path) (string-prefix-p path file))
classpath)
(seq-find (lambda (path) (string-prefix-p path file))
classpath-roots))))))
(sesman--all-system-sessions 'CIDER)) ...it should return the same as before. Then, one has to figure out why it doesn't include at least one truthy element. Add some |
Thank you @mmontone for sharing that code! It works for me too. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
when navigating to a definition via
xref-find-definition
(M-.), if the target buffer is not part of the Clojure project I'm in, the buffer is 'unlinked', and so I cannot continue navigating or evaluate Clojure code in the new buffer, unless I manually link it with sesman-link-buffer.So, I've added this to my .emacs, that propagates the current CIDER session to the definition buffer:
Not sure if this is the best fix, but it does the job for me.
The text was updated successfully, but these errors were encountered: