Ben Fritz wrote:
> 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.
Adding these commands will make life more complicated. I think the
solution would be to have a different kind of map, which indicates that
undo is not to be split, and what the map results in should not be added
to the redo buffer. Instead, what triggered the map is to be added to
the redo buffer. So that redo-ing it will trigger the map again.
This won't be easy, it probably requires adding markers in the typeahead
buffer and redo buffer, but it's certainly better than adding a bunch of
strange commands to move around without splitting undo/redo.
> 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.
--
hundred-and-one symptoms of being an internet addict:
38. You wake up at 3 a.m. to go to the bathroom and stop and check your e-mail
on the way back to bed.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
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.