Fork me on GitHub
#cider
<
2017-10-14
>
gonewest81801:10:45

@wpcarro is what you want equivalent to C-c C-k followed by C-x M-n?

qqq09:10:23

how do I get cider to indent "forv" the sameway it indents "for" ?

qqq12:10:59

I'm not familiar with that yet. I ended up using:

(define-clojure-indent
  (match 1)
  (tdefm 3)
  (forv 1))

gonewest81818:10:01

@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)))

gonewest81818:10:30

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)")))

madstap18:10:03

@qqq

(defmacro forv
  "Like for, but returns a vector. Not lazy."
  {:style/indent 1}
  [seq-exprs body-expr]
  `(vec (for ~seq-exprs ~body-expr)))

wpcarro18:10:14

@gonewest818 C-x M-n is undefined for me… which fn is it supposed to run?

wpcarro18:10:32

RE: C-c C-k followed by C-x M-n

gonewest81818:10:36

Should be cider-repl-set-ns ...

wpcarro18:10:44

@gonewest818 correct me if I’m mistaken, but -set-ns doesn’t (require ...) the ns, right?

wpcarro18:10:00

I’m looking to have access to the deps being required by the buffer’s namespace

gonewest81818:10:48

Yes, but loading the buffer and changing ns should do what you want .. if I’m understanding you properly

wpcarro18:10:45

@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?

gonewest81819:10:14

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.

gonewest81819:10:52

(I just realized I typoed C-x M-n before …. my bad. It’s C-c M-n)

gonewest81821:10:09

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.