This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-02
Channels
- # announcements (3)
- # asami (29)
- # babashka (62)
- # beginners (131)
- # biff (7)
- # calva (31)
- # cider (5)
- # clerk (14)
- # clj-kondo (3)
- # cljsrn (12)
- # clojars (18)
- # clojure (72)
- # clojure-austin (17)
- # clojure-dev (6)
- # clojure-europe (31)
- # clojure-indonesia (1)
- # clojure-nl (1)
- # clojure-norway (18)
- # clojure-sweden (11)
- # clojure-uk (6)
- # clr (47)
- # conjure (42)
- # cursive (88)
- # datalevin (2)
- # datomic (25)
- # emacs (42)
- # exercism (1)
- # fulcro (10)
- # funcool (8)
- # gratitude (2)
- # honeysql (16)
- # introduce-yourself (5)
- # jobs-discuss (26)
- # leiningen (5)
- # lsp (31)
- # malli (21)
- # matcher-combinators (14)
- # missionary (2)
- # nbb (1)
- # off-topic (40)
- # pathom (38)
- # portal (2)
- # re-frame (7)
- # reagent (18)
- # reitit (1)
- # releases (5)
- # shadow-cljs (62)
- # sql (12)
- # testing (4)
- # xtdb (37)
Does anyone have a clever way to re-evaluate the lastly evealuated form, even if the cursor has moved? Use-case: I evaluate a function and see that its results is not what i want. I move the cursor to make and change, and want to re-evaluate the same function again. I know it is possible to set marks, but this requires planning ahead 🙃
I usually extract stuff I want to fiddle with like that into a comment-block.
Then I can move freely around in the comment block and use "Send top-form to repl". Cursive is smart enough to discard the outer (comment
expression, so
(comment
(* 4 (+ 2 2)))
evaluates to 16
no matter where inside the comment
block my cursor is located.Another hack I saw from the Conjure author is this:
(do
(defn my-fn [...])
(my-fn 'some-value))
Evaluating the whole block re-evaluates the function, and tests is in the same breathYeah, if you know ahead what you want to work with, there are lots of alternatives. Conjure also lets you set a mark and evaluate the form at that line, which is great. But often i only know afterwards that i want to evaluate the form again. Then i have to spend time to navigate back to it. This is not a huge issue, but just a micro optimisation i am looking for 🙂
One thing that is in Cursive, which might also exist in Conjure is the "re-run last test-action".
So I have some deftest
that I run once, and then I can go to whatever part of the implementation and change it, and just re-run last test action.
Sorry for referring to Cursive all the time, but I'm switching back and forth between it and Conjure all the time 😄
No worries. It is interesting to see how different editors work. Conjure does not have anything like this as i know of. My impression is that most people using conjure run tests outside the editor via kaocha and the like (although i like running them via conjure)
https://github.com/Olical/conjure/blob/d2e69a13b32e8574decfe81ea275292234eba6ea/doc/conjure.txt#L148
@U11EL3P9U Are you familar with a functionality similar to Cursive's "Re-run last test-action"?
The workflow is to re-evaluate eg "all tests in a namespace" or a specific test, when I'm somewhere else in the code base
Would it work if you put a mark on the test form then go to another namespace, does eval at last mark not work?
Yeah, it might do 👍 But in some cases I might want to evaluate multiple tests, eg all tests in a ns
suggest in github to add run all tests in a different namespace (not simply the alternative one, which is leader tN)
Just to throw some ideas out there that I haven’t actually tried myself, you could possibly make a command/key binding that calls EvalForm and always puts a mark (eg mark “r”) in the current cursor position and then create a second command/key binding that calls “EvalMark r”. Perhaps there’s an auto command you could use to set the mark on eval instead
You’d probably want to use a global mark e.g “R” if you’re likely to be in a different file when you make a change.
Great idea Carl, exactly what i was looking for. I just wrapped ConjureEval
to also set a global mark, but i noticed now that Conjure has an autocommand trigger by the same name
Any tips on how to automate calling a specific mark? It seems that ConjureEvalMarkedForm
and its keybinding prompts for a mark, rather than take it as an argument.
Ohhh yeah I guess that makes sense. Maybe nvim_feedkeys() could be used to send the key for the register.
It seems to just pass the keys to the editor itself, so for example nvim_feedkeys('x', ...)
deletes a character rather than passing it to the prompt :thinking_face:
Hmm what if you feed the keys “,emr” assuming your eval mark keybinding is “,em” and the register you’re using is “r”
Unfortunately this seems to trigger the form keybinding and do the normal-mode action for the last letter, not pass it to the prompt
Oh 🥲 what if you try feed keys “,em” and then use vim.schedule with a callback that does feed keys “r”? Perhaps feeding the whole sequence all at once prevents conjure taking “r” as an input. if I get time today I’ll take a look at the conjure code to see if that inspires any new ideas.
I cant get that working either, but i think i am doing something wrong with vim.schedule as i am not really familiar with it
Seems like it's easier to just look at conjure's code and do this:
(local eval (require "conjure.eval"))
(vim.schedule (fn [] (eval.marked-form "a")))
(vim.schedule (fn [] (eval.marked-form "A")))