|
From: | JD Smith |
Subject: | Mitigating the long-lines penalty in vundo |
Date: | Sat, 16 Dec 2023 11:19:51 -0500 |
Yuan’s excellent ELPA package vundo[1] uses `buffer-undo-list’ and `undo-equiv-table’ to visualize and flexibly navigate the entire tree of edits/undos/redos (see the beautiful explanation how[2]). We’ve been improving it lately with saved state visibility and diff functionality. It displays the tree of edits sideways in just a few lines of text or unicode chars in a small buffer at the bottom of the frame. This works nicely, until you accumulate undo branches >~300 levels deep, which is easy to achieve in long editing sessions, or if you save undo state (e.g. with undo-fu-session). This leads to displayed lines which are >1000 columns wide. And then Emacs' dreaded long-line display/edit slowness starts creeping in, imposing a quadratic time penalty [3]: I verified that this is due to long lines and not some vundo issue per se by simply breaking the tree-drawing algorithm so it wraps to a new line after some max number of columns: But obviously such “broken” trees aren’t terribly useful as-is. What creative solutions can people suggest? The tree draw algorithm [4] is relatively simple, and depth-first. Only a total of 6 distinct characters are displayed. It has to do things like “bend” a branch down if it runs into a preexisting branch deeper in the tree. I didn’t see any improvement by enabling so-long-minor-mode. Since we don’t need access to more than a window-width worth of tree at a time, is there a simple way to display only some range of columns of a very wide buffer, and have the full structure live in a non-displayed “backing data store”? Would that even help with the long-line penalty, or does that penalty come in with any sort of character insertion, looking-at, etc. within long lines? Do we have to resort to our own “backing store” like a ragged array of long vectors, redrawing when the left/right column boundaries change (sounds complicated!)? Thanks for your insights. [2] https://archive.casouri.cat/note/2021/visual-undo-tree [4] https://github.com/casouri/vundo/blob/824be351527f7a606b25637f6ba2a00cceade338/vundo.el#L591 |
[Prev in Thread] | Current Thread | [Next in Thread] |