This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-07-31
Channels
- # architecture (1)
- # babashka (17)
- # calva (18)
- # cider (5)
- # clj-kondo (5)
- # cljdoc (44)
- # cljs-dev (2)
- # clojure (49)
- # clojure-europe (11)
- # clojure-norway (16)
- # clojure-uk (3)
- # clojurescript (89)
- # clr (8)
- # conjure (7)
- # cursive (26)
- # data-science (2)
- # datomic (15)
- # emacs (11)
- # events (1)
- # fulcro (8)
- # gratitude (3)
- # hyperfiddle (68)
- # introduce-yourself (1)
- # london-clojurians (1)
- # lsp (3)
- # nbb (8)
- # pathom (44)
- # pedestal (14)
- # polylith (2)
- # random (1)
- # shadow-cljs (8)
- # spacemacs (13)
- # squint (36)
- # tools-deps (9)
- # xtdb (17)
Is it possible to link a Sesman REPL to a buffer rather than a session with multiple REPLs? Sesman browser:
CIDER Sessions:
1: Project/example:localhost:62628
linked-to: proj(~/Development/project/)
objects: *cider-repl %s(clj)* *cider-repl %s(cljs:shadow)*
I'd like to link a buffer directly to the cljs
REPL only so evaluations aren't sent to both REPLs.
(Context: Trying out hyperfiddle/electric, where both REPLs have to be in the same JVM process, however it'd be convenient to evaluate CLJS code inline without it erroring out on the JVM REPL)Perhaps you'd have luck by redefining this function to introduce an if
:
(defun cider-repl-type-for-buffer (&optional buffer)
"Return the matching connection type (clj or cljs) for BUFFER.
BUFFER defaults to the `current-buffer'. In cljc buffers return
multi. This function infers connection type based on the major mode.
For the REPL type use the function `cider-repl-type'."
(with-current-buffer (or buffer (current-buffer))
(cond
((derived-mode-p 'clojurescript-mode) 'cljs)
((derived-mode-p 'clojurec-mode) (if "<current directory is named my_project>" ;; <---------------
'cljs
'multi))
((derived-mode-p 'clojure-mode) 'clj)
(cider-repl-type))))
Maybe we could introduce a defcustom, at some point
Edit: a more idiomatic way of hacking this defun is to add-advice :filter-return
, inspect the return value, modify it if it is 'multi
Perfect, thank you! 🙂
Here's what I ended up with:
(defcustom cider-clojurec-repl-type-override nil
"Override the REPL type for the current buffer."
:type '(choice (const :tag "None" nil)
(const :tag "Clojure" clj)
(const :tag "ClojureScript" cljs)
(const :tag "Multi" multi))
:group 'cider)
(defun cider-set-clojurec-repl-type-override ()
"Set REPL type override for the current clojurec buffer."
(interactive)
(let ((type (intern (completing-read "Set REPL type to: " '("nil" "clj" "cljs" "multi")))))
(setq-local cider-clojurec-repl-type-override type)
(message "Set REPL type override to %s" type)))
(defun cider-repl-type-for-buffer (&optional buffer)
"Return the matching connection type (clj or cljs) for BUFFER.
BUFFER defaults to the `current-buffer'. In cljc buffers return
multi. This function infers connection type based on the major mode.
For the REPL type use the function `cider-repl-type'."
(with-current-buffer (or buffer (current-buffer))
(cond
((derived-mode-p 'clojurescript-mode) 'cljs)
((derived-mode-p 'clojurec-mode) (or cider-clojurec-repl-type-override 'multi))
((derived-mode-p 'clojure-mode) 'clj)
(cider-repl-type))))