`sesman-use-friendly-sessions` not respected
FelipeCortez opened this issue · 6 comments
Expected behavior
When setting up sesman-use-friendly-sessions
to nil
, use only explicitly linked sessions. Switching projects should make the modeline say cider[not connected]
and evals shouldn't eval.
Actual behavior
Cider always picks up friendly sessions regardless of the value of sesman-use-friendly-sessions
Steps to reproduce the problem
- jack into a project
- switch projects
- cider modeline shows the friendly session, evals work
Environment & Version information
;; CIDER 1.14.0-snapshot (package: 20240201.2038), nREPL 1.0.0
;; Clojure 1.11.1, Java 17.0.3
Emacs version
29.1
Operating system
macOS Sonoma 14.2.1
More details
the Cider docs say
When you evaluate some code from a dependency project and there are no explicit links in that project, the most recent friendly session is used to evaluate the code. Explicitly linked sessions have precedence over the friendly sessions.
You can disable friendly session inference by customizing sesman-use-friendly-sessions.
but can you really? I set this to nil after realizing that projects I didn't jack-into were picking up a REPL. then I noticed cider-current-repl
calls cider-repls
, and then sesman-current-session
singular, which is
(defun sesman-current-session (system &optional cxt-types)
,,,
(or (car (sesman--linked-sessions system 'sort cxt-types))
(car (sesman--friendly-sessions system 'sort))))
sesman-current-sessions
plural seems to respect use-friendly-sessions
:
(defun sesman-current-sessions (system &optional cxt-types)
,,,
(if sesman-use-friendly-sessions
(delete-dups
(append (sesman--linked-sessions system 'sort cxt-types)
(sesman--friendly-sessions system 'sort)))
(sesman--linked-sessions system 'sort cxt-types)))
originally posted in the Clojurians slack: https://clojurians.slack.com/archives/C0617A8PQ/p1713215082795399
Thanks!
Looks like you've found what seems quite clearly a bug in sesman-current-session
(https://github.com/vspinu/sesman) - with an easy fix (observe the defcustom)
@vspinu do you agree?
(@FelipeCortez you should be able to redefine sesman-current-session
in the meantime)
@vemv just did!
(defun my-sesman-current-session (system &optional cxt-types)
(if sesman-use-friendly-sessions
(or (car (sesman--linked-sessions system 'sort cxt-types))
(car (sesman--friendly-sessions system 'sort)))
(car (sesman--linked-sessions system 'sort cxt-types))))
(advice-add 'sesman-current-session :override #'my-sesman-current-session)
makes it work as expected.
I've commit access for Sesman, so if you file a PR there I can merge it.
@bbatsov thanks! here's the PR: vspinu/sesman#28
updated sesman to the latest version with the fix and this seems to be working now. thanks for the assistance!