rewrite-clj

lread 2025-04-07T15:55:27.276169Z

@ericdallo I am working out how paredit should deal with certain nodes

ericdallo 2025-04-07T15:57:42.086819Z

oh, looks quite promissing! I bet @andreribeirocamargo and @arthurfucher would be interested, andre may have suggestion to contribute too

lread 2025-04-07T15:57:46.528159Z

It's a bit rambly and wip at this point, but maybe we can go over specific cases.

πŸ‘ 1
lread 2025-04-07T15:59:00.802409Z

That would be great. Happy to hear feedback from other users of paredit too.

lread 2025-04-07T16:02:38.822119Z

Error handling is of interest. To no-op or throw. (I'm thinking of no-op, but looking for feedback).

lread 2025-04-07T16:03:27.153169Z

And am happy to no-op (or throw, tbd) for more complex cases if that makes more sense.

ericdallo 2025-04-07T16:04:46.941859Z

having a error handling sounds good, although not very useful for clojure-lsp especifically as we still need to code each on of the features manually to accept those ops on lsp side.

lread 2025-04-07T16:13:46.429449Z

We could start with a simple-ish case. What should splice on '|[1 2 3] do? Since paredit is a higher level API, we should think from the perspective of paredit rather than rewrite-clj nodes. I see options: 1. no-op (or throw, throw is current behaviour) '|[1 2 3] 2. raise but preserve quote on first form '|1 2 3 3. raise and lose quote |1 2 3

lread 2025-04-07T16:15:45.895139Z

I'm trying to think from the perspective of a user in an editor.

☝️ 1
ericdallo 2025-04-07T16:16:17.410849Z

at least on emacs (what I think is usually the most close to what paredit should look like): β€’ '|[1 2 3] => does nothing β€’ '[|1 2 3] => '1 2 3

lread 2025-04-07T16:23:31.747159Z

Hmmm... it is tricky. We do not want to break compatibility with the existing splice (which is the same as rewrite-clj.zip/splice). The current splice only splices when at the start of a seq, not when in a seq. We could always create a new splice in paredit, I suppose.

ericdallo 2025-04-07T16:25:24.935499Z

why we do not want to break compatibility with rewrite splice? for me itΕ› more important to be consistent with paredit than rewrite-clj custom splice feature

ericdallo 2025-04-07T16:25:40.372079Z

you said yourself we should think as the user/paredit and not rewrite-clj πŸ˜…

lread 2025-04-07T16:27:45.974069Z

Oh because rewrite-clj.zip/splice exists in the wild, and so does rewrite-clj.paredit/splice (which just calls rewrite-clj.zip/splice). So I don't want to break existing users of either.

lread 2025-04-07T16:32:28.546949Z

If we want a different basic behaviour, we'll need options on the existing rewrite-clj.paredit/splice or a new fn rewrite-clj/paredit . Which are both ok with me if that makes sense (I did this to address some design problems in slurp).

lread 2025-04-07T16:36:36.126819Z

A perhaps more straightforward example is a slurp on '[1 '|2 3] 4, to me it is pretty clear that this should result in '[1 '|2 3 4] , and I've fixed this in my branch already.

ericdallo 2025-04-07T16:37:07.847259Z

> a new fn rewrite-clj/paredit that makes a lot of sense to me, TBH I even think this could be a separated paredit.clj lib using rewrite-clj or even not, but being as closest as possible of a ideal user paredit feature

lread 2025-04-07T16:43:34.925349Z

Yeah, I think that makes sense... but... I'm focused on rewrite-clj/paredit and fixing it up the best I can for rewrite-clj users. It might not be entirely practical to use it for an editor (but like you have suggested, it might be good enough!). I see the mismatch between the granularity of the rewrite-clj node vs the granularity of the character in an editor as an awkwardness. I expect you have struggled with this awkwardness already?

ericdallo 2025-04-07T16:45:01.432269Z

yes hehe me and @andreribeirocamargo discussed a lot about the behaviors of forward/backward slurp/barf comparing how all main editors do

lread 2025-04-07T16:47:43.728049Z

Yeah, I've played with emacs to see what it does. I think for questions in my design doc, I could ask: what does emacs do? And use it as a sensible baseline.

πŸ’― 1
lread 2025-04-07T16:48:22.787099Z

That might help.

ericdallo 2025-04-07T16:49:17.056819Z

yes, that sounds good, but I'd suggest checking at least Calva as well, usually they are similar, but some feature or other may differ a little bit (same for Cursive)

lread 2025-04-07T16:50:06.996139Z

And I should also refer to the original ref that the original paredit author used: http://pub.gajendra.net/src/paredit-refcard.pdf

πŸ‘ 1
lread 2025-04-07T16:53:11.423019Z

When testing with emacs, there a lotsa choices:

lread 2025-04-07T16:53:47.033539Z

Which do you folks verify behaviour against?

ericdallo 2025-04-07T16:54:01.407789Z

ah, I use paredit-*

lread 2025-04-07T16:54:41.053709Z

Tx, I'll do the same when testing.