calva

JR 2025-07-31T15:26:35.657129Z

When I looked into the issue that I filed: https://github.com/BetterThanTomorrow/calva/issues/2901#top I noticed that discard/ignore tokens weren't quite treated well. I use #_ quite a bit, so I figured I'd look into what it would feel like to have them work. All I did was hack up the code, but I kinda like it. But I'm wondering if I'm on the right track. Do others have feelings about if it's worth treating them as part of an sexp? Video in the thread, but the idea is that :b and :a [:a #_ :b] --paredit drag sexp forward--> [#_ :b a] for all/most of paredit keybindings (slurp forward sexp, etc...)

JR 2025-08-07T17:51:27.208969Z

I looked into clojure paredit in emacs. It handles # similarly to Calva. Maybe worse in some ways. And ##_ it handles pretty much the same.

JR 2025-08-06T02:05:34.636019Z

Any comments on this ignore tokens experiment? When there are stacked ignore tokens (`##`) that cause an affected s-expression to be ignored, then during an operation, one of those ignore tokens is grabbed and teleported in front of the moved s-expression. In the video :c dragged backward and :b becomes #_:b while #_#_:a becomes just #_:a.

JR 2025-08-01T15:03:19.262889Z

@phill Hopefully this is clearer... this one is me with the code that associates # with a sexp. For example, when dragged, slurped or deleted the whole thing (eg #4) comes as a unit.

JR 2025-08-01T15:05:21.291729Z

And here's the production (well, actually dev) code. The #_ part is treated separately from the sexp that it modifies.

JR 2025-08-01T15:07:13.414499Z

I did do this in screencast mode, but apparently the popup window doesn't get recorded. The comments indicate that I'm trying to do though.

2025-08-06T09:11:31.171959Z

I cannot tell what is going on in the videos. The written notation used by Calva's paredit unit tests (using | for cursor location, etc.) could make it clearer.

JR 2025-08-06T13:02:42.689539Z

@phill Yeah, this is hard to communicate [#_#_:a :b |:c :d] => [#_:a |:c #_:b :d] • There are stacked ignore tokens causing :a and :b to be ignored • User is on :c, drags it backward • Due to this :b must be moved forward, but it is currently ignored by a #_ in the stack • during the move, a #_ is moved from the stack to before :b A minor issue is that once pulled apart, the ignore token stack isn't rebuilt automatically. This feels OK to me, at least for now, but I'm not an expert Clojure developer. Another option would be to use keep the ignore stack. Hmm... maybe I should check what emacs or cursive does?

2025-08-06T22:12:00.830539Z

When I stack #_ (such as for a map key and its value), I do not want them pulled apart. And if I had not stacked ignores, I would not want them to get auto-stacked.

JR 2025-08-06T22:14:29.955289Z

Yeah, I get that, especially for a map

2025-08-06T22:14:38.792699Z

Or a let binding pair

2025-08-06T22:16:21.492609Z

Could a stacked ignore be treated as a single form, so [#_#_:a :b |:c :d] => [|:c #_#_:a :b :d]

2025-08-06T22:18:19.784019Z

But I am less certain I would want move-cursor-sexp-forward/backward to treat stacked ignores as a single form. It would become difficult to get into them.

2025-08-06T22:18:32.064889Z

Calva's status quo might be the happy medium. But I do not know what other editors do!

JR 2025-08-06T22:20:11.730559Z

My annoyance with how #_ is treated was less about dragging forward/backward and more about barf and slurp. It's just that dragging is easier to experiment with

2025-08-06T22:20:55.309919Z

Maybe for cursor motion, forward could advance over the whole stack (since the stack is sitting right there) and backward could ignore ignores and back up only one literal sexp.

2025-08-06T22:22:11.603999Z

Well you raised a very good question about splitting up the stacked ignores.

JR 2025-08-06T22:33:32.097039Z

Yeah, and maybe for now, I could look into the little bugs that are happening (like the cursor going to strange places) and spaces appearing. I just poked at my issues with #_ and it was bigger than I thought. (It also involves a decent amount of code changes)

2025-08-06T23:16:59.381319Z

Are there Jira issues for those?

JR 2025-08-07T00:56:34.377839Z

There's https://github.com/BetterThanTomorrow/calva/issues/2901. I'll file more when I re-encounter those small issues

JR 2025-07-31T15:27:18.726639Z

Some examples:

JR 2025-07-31T15:27:59.475989Z

I did verify that alt+enter evaluation on #_ (+ 1 1) can work with this too

JR 2025-07-31T15:30:56.392659Z

One downside is that, at least for now, multiple ignore tokens aren't handled (due to complexity). So [#_ #_ :a :b :c] still doesn't work correctly.

2025-07-31T22:56:28.813519Z

Consistent operation with 2 stacked ignores (as for a typical map entry) would be nice. And if it can do 2, it can do hundreds.

2025-07-31T22:58:32.455639Z

I don't know what's happening in the movie. Calva's unit tests have a very nice notation for this sort of thing - micro-document, cursor or selection is here, do the command, and here's the resulting micro-document with cursor, which might work well in Slack too, with the added benefit, of course, that if you contribute your suggestion then you've already got the tests ready

JR 2025-07-31T23:03:44.289459Z

Yup, I've been writing some unit tests. The movie is mostly moving dragging sexp around (alt+right and alt+left). I should redo it with presentation mode on so it's more obvious, and maybe add a comparison with the production code.

JR 2025-07-31T23:25:09.227229Z

I agree that two stacked ignores would be nice. But ugh, I didn't want to get into walking backward up the parse tree. And that backward walk would need to happen each time the code manipulates an s-expression. (ETA: would have to go all the way to the root of the parse tree.) It's already messy looking for one! :) I'm actually starting to wonder if it might be better to change the parser to somehow mark s-expressions as ignored, and perhaps include the associated ignore token (maybe along with associated metadata?).