Fork me on GitHub
#calva
<
2019-09-02
>
craftybones02:09:16

@pez - is there any way you can write a simple feature where I am allowed to take an s-exp and turn it into a threading macro-based one?

craftybones02:09:18

If selected text could be sent to a function like that and upon success substitute the selection with the result

craftybones03:09:59

I could always surround the selected text with a fn call, but having that available as a shortcut would be really dandy

pez04:09:18

Yeah. That looks straightforward. File it as a feature request, please.

pez09:09:44

If you come up with a way to wind a threaded form to it's non-threaded counterpart. that would be nice as well. 😃

craftybones18:09:29

Like a macroexpand? 😄

pez18:09:17

macroexpand I think we can also do, but using nREPL. 😃 But, yeah, maybe it is like a macroexpand.

pez19:09:39

We will need a way to format the code as well, so this might take a while to implement. Not sure what would be the best way to do it. But a solid cljc library is a good start. 😃

craftybones19:09:31

How are you currently reading code and parsing forms?

pez19:09:36

Many different ways, unfortunately.

craftybones19:09:07

What if you don’t do this at all. What if you simply handoff to nREPL? Instead of thinking about it as a core Calva feature, you could simply create an infrastructure that lets people execute custom functions over the wire

craftybones19:09:12

So, selected code, along with context and a key of some sort like “wind thread” or “unwind thread” or something of that nature gets sent, and nREPL middleware handles it?

pez19:09:43

Yes, the thought has crossed my mind.

pez19:09:15

What I tried today was to do this locally, in the CLJS parts of Calva.

pez19:09:05

So, there is a Calva command today for replacing the evaluated code with its results. We could maybe do this by using that but wrapping the form in a (wrangle <form>)… Maybe even (do (defn wrangle ... ) (wrangle <form>))?

pez19:09:48

With that we could have a command that was Transform current form… which would pop open a menu with selections of transformations, of which wrangle would be one.

pez19:09:32

Allowing for custom transformations via settings, even.

pez19:09:48

Maybe this was your original suggestion, almost, I now realize. 😃

pez05:09:43

Yes, it calls for threading both first and last.

Sasho14:09:49

Hey Peter, I noticed this behavior in Calva:

Sasho14:09:40

The difference between 5 and 7 is that I’ve evaluated 5 while my cursor was next to +, while with 7 I had selected both ` and + (the whole form).

Sasho14:09:51

Is this expected behavior?

pez14:09:33

Hello. Iircc (can’t check right now) Calva’s selection of “current” form is pretty lame. So the difference between 5 and 7 would be that in the first case this lame current form is used and in the second case you dodge that by using a selection instead. There is a related issue about this, having to do with that Calva should disregard some whitespace when determining the current form. Add this to that issue, is my suggestion. We have much smarter tools for this current form thing now, than was the case before, so this should be entirely possible to fix.

Sasho14:09:29

Thank you thanks3