kakoune-state-save doesn’t save or restore any registers by default, for privacy and security reasons.
For cursor positions, the only privacy concern is recording the names of files on your hard-drive to people who have access to your local hard-drive; the only security concern is that somebody could overwrite a cursor-position file and make you lose your place. Either way, this doesn’t seem like a big deal so cursor-positions are saved and restored by default.
For registers, they may contain document fragments (alphabetic registers) or commands or searches (history registers) for things you tried then reverted. Making a permanent record of such things on disk could be a privacy concern. Meanwhile, the only way to restore such things is with Kakoune’s :evaluate-commands
command, which can be pretty easily tricked into executing arbitrary commands. While an attacker would already need write access for such an exploit, I imagine there’s people who would be uncomfortable with that happening automatically. For people who do want to save and restore registers by default, it’s really easy to set up and there’s a config snippet in the README you can copy and paste, so it’s off by default.
The other potential issue with saving and restoring registers is that in Kakoune registers are also marks, but unlike Vim, Kakoune won’t automatically open the file a mark points to when you try to jump to the mark. I could update the register loading/saving code to say something like “if this register contents looks like a mark, make sure the filename is an absolute path before saving it” and “if this saved register looks like a mark, open the named file in addition to restoring the register value”, but until somebody makes that change, saving and restoring registers is not as useful as people might expect.
In the config snippet, the bits that clobber the "b
register proceed to immediately use the value and don’t care about it after that. If many plugins used "b
as scratch space at startup, it would be fine - they’d each take turns and not step on each other’s toes.
The only concern would be if somebody used kakoune-state-save to persist user-provided information in the "b
register. If the “restore the user’s "b
value” hook executed last, everything would be fine, but if some other plugin’s hook happened to execute last, the user’s "b
value would be lost.
That’d be easy to fix, though - just wrap the contents of the KakBegin
hook in the snippet in evaluate-commands -save-regs b %{ }
like the :mru
command does.