This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-09
Channels
- # announcements (4)
- # beginners (44)
- # boot (15)
- # calva (66)
- # cider (66)
- # clojure (75)
- # clojure-austin (4)
- # clojure-europe (2)
- # clojure-finland (1)
- # clojure-italy (3)
- # clojure-nl (10)
- # clojure-russia (3)
- # clojure-sg (1)
- # clojure-uk (109)
- # clojurescript (18)
- # datomic (8)
- # emacs (1)
- # figwheel-main (1)
- # fulcro (5)
- # jobs (1)
- # jobs-discuss (8)
- # kaocha (7)
- # leiningen (11)
- # luminus (2)
- # off-topic (69)
- # pathom (5)
- # re-frame (7)
- # reagent (4)
- # reitit (18)
- # ring-swagger (3)
- # shadow-cljs (123)
- # spacemacs (1)
- # sql (35)
- # tools-deps (89)
- # uncomplicate (3)
- # vim (6)
- # yada (3)
Dear channel, I have filed some issues regarding Jack-in: https://github.com/BetterThanTomorrow/calva/issues I will need help figuring some things out if I should be able to fix those issues. I’d appreciate it a lot if people read the issues tagged jack-in
and help me understand them better.
Good morning. If I have a blank clj file with the following forms:
(def a 1)
(def b 2)
(def c (+ a b))
c
in order for me to evaluate c and get 3 as a line comment: (`=> 3`) via ctr, I need to first evaluation each of the previous forms. Also, if I change the value of a to 2, I need to evaluate the first form (in order to assign 2 to a) and evaluate the third form (in order to reassign the new result to c). My question is - is there a way in Calva, so that whenever I evaluate a form, all previous forms also get reevaluated. That is - I want to change the value of a, then go straight to evaluating c and get the new value of 4.While typing this question I figured out, that if I select everything and evaluate, I get only the result for the last form, which is exactly what I want, but I post this anyway, so that I can make sure I understand how to use Calva 🙂
Actually, selecting all and evaluating “almost works”, because for example for this case:
; (def a 1)
(def b 2)
(def c (+ a b))
c
I’d expect to get an error: “Unable to resolve symbol: a in this context”, but instead I get 3. That is, the old definitions are not cleared. So basically my question is - is there a way to clear everything already define and define everything from scratch?Calva has no feature for clearing definitions. You’ll need to unmap them with something like
(ns-unmap *ns* 'a)
from my point of view, it can be useful to have a command for evaluating all previous forms (in order) in current level (I can explain what I mean if needed). Cause I have to wrap all current-level forms in one big do
for doing this now
@U0A6H3MFT or just selecting everything you want reevaulated
@U0ETXRFEW - so is there a way in Clojure to do something like (ns-unmap *ns* everything)
- if I put this statement at the start of the file, than combining this with selecting everything will have exactly the behavior I just described.
yes, but with separate command it will be more easy - do not need to find top form in current level manually
@U0A6H3MFT yes, for sure.
Yes, @U0ETXRFEW, this works perfectly!
I have an old branch lying around that allowed you to keep a list of custom commands and execute them at will. With that you would be able to register a custom command like
(remove-ns (symbol (str *ns*)))
And have convenient access to it.If you find the custom commands feature desirable I’d welcome a feature request on github about it. 😃
Also, I am not sure how good Calva is at identifying the top ns
form if you have stuff above it. It might work, but also, it might not. Also 2: I am sure the doc string for remove-ns
includes Use with caution. for a reason.
@U0A6H3MFT :
> from my point of view, it can be useful to have a command for evaluating all previous forms (in order) in current level (I can explain what I mean if needed). Cause I have to wrap all current-level forms in one big do
for doing this now.
Yes, please explain.
Often (especially in tests) I have a list of instructions such as
(do-1thing)
(def a 1)
(do-2thing)
......
and I wrap in one big do
form all instructions from first to choosen and eval this do block
and IDE sends all current level instructions in order from first to which cursor is to repl by one shortcut
It is much clearer now, at least. 😄 Can you paste an example of a real such list, with enough context around it so that I can try see what such a command would be selecting for evaluation?
Also, I wonder, if you place your cursor at the correct level and do Paredit: Expand selection, does the correct stuff get selected?
Fortunately I do not use any structure editors - neither paredit/parinfer/smartparens/etc
anyway only current level forms above the cursor should be selected, not oll current level
It is there in Calva anyway. So hitting ctrl+w
might select the right stuff for you. Try not to think about it as structural editing, It is just selecting stuff, anyway. 😃
(deftest claims-loaded
;; (do
(w/bronx)
(def refs
{:patient {:id "pt"} :organization {:name "A payor"} :encounter {:id "enc"} :procedure {:id "proc"}})
(w/a! [:patient :appointment :organization :coverage :encounter] refs)
(def refs-to-hold-on
{:patient {:id "pt-hold"} :organization {:name "B payor"} :encounter {:id "enc-hold"} :procedure {:id "proc-hold"}})
(w/a! [:patient :appointment :organization :coverage :encounter] refs-to-hold-on)
(rf/dispatch [:claims/verify :init {}])
(def m (rf/subscribe [*ns]))
(matcho/match
@m
{:locations not-empty
:practs not-empty
:items empty?})
.........................
I uncomment this do and move its closed paren from top to bottom and eval this do-block each time
Yes, I think I know which blocks to evaluate. But I don’t see a clear way to get Calva to do the right thing… How would it know to not inlcude claims-needed
?
If I'd wrote my own clojure plugin, I'd be filter raw symbols from all current-level forms for it 🙂 but I'm not sure if it clear behaviour for all 🙂
How about commands for growing and shrinking the selection, one form at a time, upwards? Or are these lists often too big for that?
One form at a time... Looks like manual do
is easier 🙂 This lists can be by several screens height... Anyway if there can not be more usable solution than adding do
I'l add do as before 🙂
If you do experiment with making an extension to help with this, then if you make it just select the right thing, people can use it together with Calva for evaluating it.
Of course, if you do get it to select the right thing I’d appreciate a PR to add such a command to Calva.
@sasho.popov, so having investigated this some more, it seems that remove-ns
can bite you pretty hard. The proper way to do it is using refresh
from tools.namespace
. Calva doesn’t help with that currently, so you’ll have to add that to your project or inject it at the command line. I will look into adding a refresh command to Calva.
@U0ETXRFEW thank you very much for your investigation. I also found something similar for sublime (although just a gist, no working plugin: https://gist.github.com/Qambar/3afe51be82a0c82828dcbf1c78888120#file-clojurehelpers-py (line2 12-15))
@bozhidar: does CIDER inject any tools.namespace
dependencies, or how does that cider-refresh
get powered? I have pointed @sasho.popov at remove-ns
and feel a bit bad about that. A proper refresh is what Calva needs.
I got help finding it, https://github.com/clojure-emacs/cider-nrepl/blob/master/src/cider/nrepl/middleware/refresh.clj , sorry for the holler!
This build contains a first stab at implementing the refresh
and refreshAll
commands. Currently they only seem to refresh CLJ stuff even if a CLJS repl is active. (I’m not sure if the nREPL ops used support CLJS, even). Also error reporting is a bit brief. But anyway. Maybe you can take it for a spin @sasho.popov?