This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-14
Channels
- # beginners (4)
- # boot (2)
- # cider (17)
- # clara (8)
- # cljs-dev (5)
- # clojure (16)
- # clojure-italy (14)
- # clojure-nl (1)
- # clojure-norway (1)
- # clojure-russia (1)
- # clojure-uk (4)
- # clojurescript (8)
- # data-science (19)
- # datomic (4)
- # ethereum (1)
- # events (1)
- # fulcro (15)
- # graphql (4)
- # hoplon (10)
- # jobs (1)
- # mount (1)
- # off-topic (15)
- # parinfer (4)
- # perun (1)
- # portkey (6)
- # re-frame (15)
- # reagent (10)
- # schema (1)
- # shadow-cljs (80)
- # specter (4)
- # test-check (35)
@wpcarro is what you want equivalent to C-c C-k followed by C-x M-n?
@qqq maybe via :style/indent
metadata? https://cider.readthedocs.io/en/latest/indent_spec/
I'm not familiar with that yet. I ended up using:
(define-clojure-indent
(match 1)
(tdefm 3)
(forv 1))
@wpcarro something like this?
(defun cider-load-buffer-and-set-ns (&optional buffer)
"Load buffer's file and set ns in nREPL"
(interactive)
(let ((buf (or buffer (current-buffer)))
(ns (cider-current-ns)))
(cider-load-buffer buf)
(cider-repl-set-ns ns)))
while we’re at it, can also use clojure.repl:
(defun cider-load-buffer-and-set-ns (&optional buffer)
"Load buffer's file and set ns in nREPL"
(interactive)
(let ((buf (or buffer (current-buffer)))
(ns (cider-current-ns)))
(cider-load-buffer buf)
(cider-repl-set-ns ns)
(cider-nrepl-sync-request:eval "(use 'clojure.repl)")))
(defmacro forv
"Like for, but returns a vector. Not lazy."
{:style/indent 1}
[seq-exprs body-expr]
`(vec (for ~seq-exprs ~body-expr)))
@gonewest818 C-x M-n
is undefined for me… which fn is it supposed to run?
Should be cider-repl-set-ns
...
@gonewest818 correct me if I’m mistaken, but -set-ns
doesn’t (require ...)
the ns, right?
Yes, but loading the buffer and changing ns should do what you want .. if I’m understanding you properly
@gonewest818 I’m new to Clojure, but if my buffer requires deps like ... :as reagent
, the REPL should be able to resolve a symbol like reagent
, yea?
yes, but only if the (ns ...)
or (require ...)
or (use ...)
form is evaluated in the repl. Opening a file in emacs doesn’t automatically load it into the repl. Instead you have to ask for it explicitly, using C-c C-k
(which runs the elisp function cider-load-buffer
) to load the current buffer. And C-c M-n
(which runs cider-repl-set-ns
) switches the repl to the namespace of the current buffer.
(I just realized I typoed C-x M-n
before …. my bad. It’s C-c M-n
)
So in other words, the emacs workflow would be: C-c C-k
to load the buffer, C-c M-n
to set the namespace in the repl, C-c C-z
to switch focus to the repl. At that point the repl should resolve reagent
.