Fork me on GitHub

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


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


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


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


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


Like a macroexpand? 😄


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


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. 😃


How are you currently reading code and parsing forms?


Many different ways, unfortunately.


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


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?


Yes, the thought has crossed my mind.


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


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


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.


Allowing for custom transformations via settings, even.


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


Yes, it calls for threading both first and last.


Hey Peter, I noticed this behavior in Calva:


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


Is this expected behavior?


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.


Thank you thanks3