Fork me on GitHub
#emacs
<
2020-10-22
>
frozenlock13:10:28

Is there a command to sort all the keys in maps? (In the source file, not with a sorted-map.) Similarly, I'd like to sort all functions arguments.

practicalli-johnny16:10:37

If there is no such command, wrap the hash-map with sorted-map and use cider-eval-last-sexp-and-replace

ag02:10:47

There's pretty cool, yet a tiny bit complicated way of doing this using babashka: So you're gonna need to run shell-command-on-region with a prefix C-u M-| shell-command-on-region sends marked region to an external command, when called with a prefix, it replaces the selected text in the buffer with the result of the command. So you do exactly this: C-u M-| bb '(into (sorted-map) *input*)' RET and it does it. Now, if you do this fairly often, next time you can call C-u M-|, you can press C-r and find your babashka call.

ag02:10:47

There's pretty cool, yet a tiny bit complicated way of doing this using babashka: So you're gonna need to run shell-command-on-region with a prefix C-u M-| shell-command-on-region sends marked region to an external command, when called with a prefix, it replaces the selected text in the buffer with the result of the command. So you do exactly this: C-u M-| bb '(into (sorted-map) *input*)' RET and it does it. Now, if you do this fairly often, next time you can call C-u M-|, you can press C-r and find your babashka call.