Hook(s) for capturing incremental changes to a buffer

Why? Because I am having a crack at recreating some git porcelain for kak. I know that I could “just shell out to tig” or some other tool, but if you’ve used fugitive or magit seriously there are massive gains to be made in being able to interactively edit patches with your favourite to layer up changes. I have written some dumb code that knows how to take a patch apply it and generate a side by side diff with highlighting. Nice. I can keep cursors in sync with hooks. I can obviously through blunt force trauma keep selecting buffers and rebuilding the diff view but that is offensive. It seems like perhaps there is a clever scheme to keep last and current selections in a register and on keypresses check those against saved state, but it feels pretty fragile. The editor knows what edits it’s applying and it would be cool if there was a way to hook that. I am sure there would be other applications beyond what I am thinking of. Basically I’d just like a set of ranges passed to me, before and after s.t. that I could efficiently update the other pane of the view.

Of course if there is a cool way to do this without editor support I am all ears.

Hi! My plugin parinfer-rust, currently tries to emulate this by responding on a few hooks, and storing the entire contents of the buffer each time the buffer is processed. Inside parinfer-rust, it diffs the previous and current buffers.

I’d like to move to responding to changes, and there’s been a discussion about how to do that. It looks like the mechanism is largely decided, but I haven’t gotten to implementing it.

A ticket: https://github.com/mawww/kakoune/issues/2649 (I just updated it with what I remember from IRC discussion.)

Ah that’s rad. I’ll just watch that ticket and come back to my project when that’s in place.