Fork me on GitHub
#emacs
<
2022-06-02
>
Drew Verlee17:06:20

If i wanted to be able to visually hide some clojure data what would be the best way to do that? E. G kind of like folding but only a specified set of clojure data.

practicalli-johnny20:06:07

i do move data to their own name spaces for this reason when they are more than a few lines. I also think it makes far more sense in the long run. I can very easily see the data by evaluating the name of the def binding around that data in the namespace with the functions that work on the data.

practicalli-johnny20:06:46

Spacemacs has very simple to use folding tools and a few different folding options.

;; Code folding method. Possible values are `evil', `origami' and `vimish'.
   ;; (default 'evil)
   dotspacemacs-folding-method 'vimish
The vimish method allows folding of visual selections

👀 1
Drew Verlee21:06:38

Thanks I'll take a look

practicalli-johnny07:06:29

I appreciate this isn't probably isn't the approach asked for, but hopefully it's of some use

Drew Verlee17:06:22

I'm thinking i could use clojure metadata to just mark them and then have something look for it. Maybe cider has something like clojure postwalk?

vemv17:06:18

> hide some clojure data where?

Drew Verlee17:06:43

Are you asking where i want to hide it?

vemv17:06:11

yeah like in the repl? editor buffer?

Drew Verlee17:06:55

Editor buffer. In cases where you're editing clojure files.

vemv17:06:26

what does the data look like? are you editing big maps? Those are relatively uncommon in .clj files

Drew Verlee17:06:58

Yep. Big distracting (at times) maps.

Drew Verlee17:06:00

I'm not having trouble inspecting them, i just don't always need them around for what I'm currently doing in the surrounding code changes. So it would be nice to toggle them in and out as they were useful.

Drew Verlee17:06:01

There are other solutions to this, references for one, but i would rather not move them out of context just because they're visually noisy.

vemv17:06:06

aha so as you say you could add metadata, e.g. (def ^:fold chunky-data {,,,}) And then you'd make (def ^:fold part of a Hideshow mode regex My personal example https://github.com/zenmacs/.emacs.d/blob/cbe6088f8e8cd892b81c10cf9e2400f02b1942f7/lib/non-submodules/vemv.clojure-interaction.el#L60-L66

👀 1
Drew Verlee17:06:11

Ty. Ill take a deeper look when I'm back at my computer

Felipe Oliveira23:08:22

@U0DJ4T5U1 sorry to necrobump this. What I do is to have the built-in hs-minor-mode on and bind hs-toggle-hiding to an easy keybinding (I use C-c h). This way I can not only hide pesky huge maps but also branches in if statements that I have already dealt with. Just move right before it and toggle it. Pretty useful.

👀 1
Drew Verlee23:08:29

Thanks @U6MEUHZBK I'll have to think about this on the weekend.

👍 1
Drew Verlee03:09:01

@U6MEUHZBK got around to looking at this again. Yeah hiding via hs-toggle-hiding is useful. i have been using "evil-toggle-hide" which seems to be the same thing. My idea was to add a more permanent kind of hiding, one that lasted between sessions. Not sure what form it would take it exactly.