Fork me on GitHub
#cider
<
2017-07-24
>
bozhidar11:07:07

@benedek CIDER already does this, so I guess you can reuse the existing code.

bozhidar11:07:11

I wonder how much code is duplicated in cider-nrepl and refactor-nrepl 🙂

benedek11:07:31

can u point me to the ns pls? btw run our own kinda makes sense even if duplicate...

benedek11:07:52

yeah I guess probably quite a few

benedek11:07:50

something to take care of when we merge the two ;)

bozhidar11:07:47

Indeed. I just opened your diff and saw 3 functions that exists in CIDER, therefore my remark.

benedek11:07:16

will have a look. had a chat about it with @dominicm

dominicm12:07:03

time for boot-tooling? 😄

qle-guen15:07:03

how to load all functions into cider in the current leiningen project in emacs?

dpsutton15:07:17

what do you mean?

qle-guen15:07:30

when I boot into a project I want all functions of the classpath to load into cider so I can test them

dpsutton15:07:55

so you would like to load a namespace?

qle-guen15:07:06

well I'd like to be able to load all of them at once

dpsutton15:07:41

i'm not sure i follow

dpsutton15:07:44

suppose you have 4 files

dpsutton15:07:54

you would like to have all of the functions in all of those 4 files loaded at once?

dpsutton15:07:09

why not go the traditional route and require those namespaces with a prefix?

qle-guen15:07:38

you mean with require?

dpsutton15:07:56

(ns tomahawk.db.utilities
  (:require [clojure.java.jdbc :as jdbc]
            [ :as io]
            [clojure.string :as s]
            [tomahawk.common :as c]
            [clojurewerkz.propertied.properties :as p])
  (:import java.lang.Exception javax.naming.ConfigurationException))

dpsutton15:07:09

yeah in a ns form.

qle-guen15:07:41

ok but that means each time I modify/add a function, I'll need to re-eval this ns form. right?

qle-guen15:07:52

isn't it kinda boring?

dpsutton15:07:57

i'm not sure i follow

dpsutton15:07:57

you are anticipating adding functions to a different file while working in another file?

dpsutton15:07:33

can you explain your ideal workflow and I can help you get there?

qle-guen15:07:42

yep. I'd like to have access to every function of my project when I boot into cider

qle-guen15:07:19

I'm confused because (use 'project.core) into cider doesn't even work actually

qle-guen15:07:21

I usually use cider-load-function-to-repl on each function, which is very annoying

dpsutton15:07:30

just load the whole buffer

dpsutton15:07:44

are you trying to put all of your functions into the user namespace?

dpsutton15:07:48

i'm just not following you at all

qle-guen15:07:58

yes, basically

dpsutton15:07:06

suppose you have 3 files. you want all of the functions defined in those three files available to you from the user namespace?

dpsutton15:07:23

what are you trying to get around by not just evaling one of the buffers and working in the namespace?

dpsutton15:07:52

you can do something along these lines with potemkin which can expose things into your current namespace

dpsutton15:07:21

what happens if you have two functions with the same name?

qle-guen15:07:36

well idk really, I'm just wondering how more experienced users in clojure do

dpsutton15:07:00

well, go look at a buffer you want to extend/edit/play-with, etc

dpsutton15:07:10

hit C-u C-c M-z

dpsutton15:07:17

this will evaluate the buffer and switch the repl to this namespace

dpsutton15:07:22

and now everything is loaded up

dpsutton15:07:36

you can eval any functions, all of the dependencies of the namespace will be there ready to use

dpsutton15:07:32

I've never run into wanting all my functions available at once. I only want the functions in the namespace I'm working in

qle-guen15:07:45

ok this is helping, but what does cider-refresh does then?

dpsutton15:07:52

i'm not sure how that follows. did the above change your understanding of that?

dpsutton15:07:21

cider-refresh will reload the namespaces Reload modified and unloaded namespaces on the classpath.

dpsutton15:07:39

on the repl, hit , (comma) and it will bring up a menu

dpsutton15:07:03

if you want to switch namespaces, you can use the ns entry and go into a namespace and then the functions will be available to you

qle-guen15:07:01

ok I think I was confusing "loading a namespace" and "loading the functions in a buffer"

dpsutton15:07:17

those are usually one and the same

dpsutton15:07:31

the namespace is just a collection of vars

dpsutton15:07:38

and a buffer usually aligns with a single namespace

qle-guen15:07:08

then cider-refresh should load functions of unloaded namespaces, then?

qle-guen15:07:48

and it doesn't

dpsutton15:07:05

how do you know it doesn't?

dpsutton15:07:14

trying to get a sense of what evidence you are seeing

dpsutton15:07:32

i think there's some miscommunication of terminology so I'm making sure I'm understanding what you are talking about

dpsutton15:07:14

Not trying to talk condescendingly or anything. just making sure I'm aware of what you're expecting from refresh and what makes you think it hasn't worked

qle-guen15:07:50

I use cider-refresh, then I try to use a function whose definition is in a file in the src/expert-system directory, and cider throws java.lang.RuntimeExpection

dpsutton15:07:04

ok yes that's correct

dpsutton15:07:16

that var's name is #'expert-system/function name

dpsutton15:07:21

it's not in the user namespace

dpsutton15:07:37

to see it you need to be in the expert-system namespace

dpsutton15:07:13

go the the file which contains the function you would like to use and C-u C-c M-z to load that namespace

dpsutton15:07:37

yeah to use functions, you need to be in that namespace

qle-guen15:07:45

thanks, this answers everything

dpsutton15:07:31

when i'm in those different namespaces I can see the functions and vars that they contain

dpsutton15:07:42

i can also require namespaces into a namespace that i'm working in to use it

dpsutton15:07:00

hit , (comma) on the repl and it will pull up a list of namespaces available to you

qle-guen15:07:18

is there a way to see what is available in the current namespace?

dpsutton15:07:51

your source code

dpsutton15:07:08

there's a namespace browser

dpsutton15:07:19

cider-browse-ns

qle-guen15:07:23

oh yes right

qle-guen15:07:32

that's perfect, thanks