Fork me on GitHub
#emacs
<
2018-09-12
>
mhcat17:09:03

👋 hey, anyone know how to take a very long map literal which is on a single line and have emacs split it into 1 key/value per line?

vemv17:09:20

I'd evaluate it at the repl and then (pprint *1) There may be a fancier way though 🙂

mhcat17:09:33

hmm, I guess that's ok 🙂 I often wish it was either part of or adjacent to C-c SPC

mhcat18:09:22

also that solution isn't great with data that can't be trivially read back in like jodatime objects

bozhidar18:09:38

So, you want to reformat the literals in clojure-mode, right?

bozhidar18:09:43

Or do something in the REPL?

vemv18:09:53

@U06MD7077 - precede the expr by '?

mhcat18:09:19

clojure-mode

mhcat18:09:54

@U051BLM8F my use case is that I often come to tests written by others which contain huge blobs of test data in the form of maps that have been captured during dev and pasted into the test files.

bozhidar07:09:47

I see. Well, when you’re connected to CIDER you can certainly you the pretty-printing logic in a source buffer as well, but something to transform hash literals can easily be added to clojure-mode as well.

borkdude12:09:26

cider-pprint-eval-last-sexp is usually what I use