On Sunday, April 6, 2014 6:42:35 AM UTC-5, Bram Moolenaar wrote: > > The problem is that there will not be a standard way how to apply those > > two changes. If it's just two inserts after another it would be > > possible, but in general the cursor would have moved somewhere else and > > perhaps indent depends on the indent of another line. > > > > Most likely the solution lies in repeating what the plugin does by > > invoking the plugin again. Instead of trying to record and replay what > > the plugin ended up doing. So the redo buffer would contain whatever > > triggered the plugin, and redo would trigger the plugin again. > > > > How do these kind of plugins get triggered anyway? Insert mode mapping? > > Would be good to start with a relevant example. > >
At its heart, this kind of plugin is an insert-mode mapping, where when you press ( you get () instead, with the cursor in between. To get it to work with the '.' operator, it also needs mappings for <Esc> and some other commands so it can invoke repeat.vim. But for undo/redo, there was not any known solution last I knew. I guess Justin may have found something as he posted earlier. I haven't seen it working in practice yet, I will probably try it out later this week. The difficulty is that EVERY cursor movement in insert-mode will break the undo sequence and there is no way around it. It would be nice to have some sort of movement command within a line that would not break the undo sequence, or an explicit command to join two arbitrary edits, or a command from normal mode that would start insert mode and join the resulting insert to the last undo in the chain. Before one of the 7.3 patches, I think it was 1200 or 1253, it was possible to use setline() to add text without affecting the undo sequence. It was very hacky, and apparently exploiting a bug, but it worked. That is no longer possible. The new potential solution looks a little bit nicer but still looks hackish enough that potentially it will break in a future patch as well, since there is nothing in the documentation guaranteeing it will work. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
