Fork me on GitHub
#cider
<
2023-01-18
>
tatut12:01:09

say I have a vector of maps, could cider inspector print them as a table? (possibly utilizing clojure.pprint/print-table)

tatut12:01:05

there are fancy external tools that hook into tap> but that means I have to leave emacs to look at it

tatut12:01:46

I like that inspector shows large vectors as paged, but sometimes a table would be good and it could even allow selection of columns

jumar15:01:10

So you want to see everything at once? That would be cool especially for smaller collections of homogeneous maps with not so many keys Having an option to change “viewers” ala Portal would be nice. My ultimate wish is to be able to draw some charts, like with vega lite, without leaving emacs

jumar15:01:32

When it comes to tabular data and filtering, aggregations, etc. we could draw some inspiration from tools like Visidata

tatut15:01:10

not necessarily everything at once, you can set the page size as it is

tatut15:01:24

but sometimes a tabular view is just easier to glance at

tatut15:01:35

instead of trying to read a list of edn maps

tatut15:01:12

my elisp fu might be a little rusty, but I could try to hack something if I know where to start

tatut15:01:50

as emacs can show images, charting would definitely be doable, but that requires dependencies on the clojure side

tatut16:01:29

ok, I took a stab at orchard.inspect/inspect multimethod and while you can quite easily patch that to use table printing for a collection of maps… that doesn’t keep track of the values, would need to split that by lines and then output that like the emacs side needs it

tatut17:01:46

I hacked together a variant of orchard.inspect/render-indexed-values that tracks the values so that you can drill down

tatut17:01:05

that’s showing a query result of some fake organization data

tatut17:01:43

but to be really useful, it would need to have support on the cider side to switch between table mode and regular mode, and ideally selecting the columns to show

tatut17:01:38

if the table fits width wise to the buffer, it looks pretty nice

Sam Ritchie16:01:13

@U07SQTAEM had a Clerk view working inside of emacs, maybe someone has the link handy

jackrusher17:01:34

If you want to be able to visualize clojure data as various kinds of graphs inside emacs without adding any deps, consider: https://github.com/applied-science/emacs-vega-view It's also possible to open Clerk's front-end with *xwidget*-*webkit*-browse-url (assuming you've built your emacs with support). Using Clerk in your project does involve a dev dep, but that might change in the next few months 😉

👍 2
Carsten Behring23:01:28

I played a lot with cider-inspectorvs Clerk. Given the multitude of potential non text formats, I can hardly see how cider-inspector could be improved to render "them all ". The table-format you ask for is just one example. vega-lite an other. Maybe cider-inspector could get a "send-to-external-tool" feature, where it would send on key press the current sub-data structure to a user defined EmacsLisp/Clojure function, which could then open the data with Clerk while asking for the viewer to use... Similar to the way we can customize which clojure function to use for "pretty-print".

jumar05:01:32

@U07SQTAEM thanks a ton for sharing the vega-view package! I've been looking for something like this for a very long time.

👍 2
tatut06:01:28

vega looks nice, and if we can view charts inside emacs that is cool… but I still would want to keep the inspector drill down stuff, so launching an external tool is not quite the same

jumar07:01:41

I agree with that - the inspector is already great but it could be become even better for quick ad-hoc data exploration.

Carsten Behring14:01:18

I "live" as well in the inspector. It is kind of my "standard way" to evaluate expression in Cider. But from time to time I would wish I could "branch" out of the inspector on a certain level and render the current data in a "rich interface". I think this should be "rendered outside of Emacs". (due to the requirement of "full html compatible") With Clerk we have now a tool which can render rich data structures into html. Even support viewer plugins and complex data viewers based on JavaScript. The combination of the 2 would be fantastic. The shortest way to this might then be to extend the cider inspector, so that it can call on keypress a user supplied function with the "current" detail of the data structure.

Carsten Behring14:01:02

An the original request of @U11SJ6Q0K would then be solved by using Clerk for render tables (= vector-of-maps) into html.

Carsten Behring17:01:13

@U11SJ6Q0K At the end of this https://clojurians.slack.com/archives/C0617A8PQ/p1674493870044519?thread_ts=1674486881.210099&amp;cid=C0617A8PQ is some EmacsLisp code which solves your original problem to a large extend as well. You would need to "leave" Emacs, as Clerk renders in Browser.. Unless you have *xwidget*-*webkit*-browse-url working.

👍 2
Carsten Behring17:01:18

Maybe we could start a "clerk" mode, just for having a place to collect this functions.