On May 27, 2015 2:28 AM, "Carlo Baldassi" <carlobalda...@gmail.com> wrote:
>
> On Tuesday, May 26, 2015 at 3:50:06 AM UTC+2, Justin M. Keyes wrote:
> > In your implementation, you could save the './'^/jumplist/changelist
> > and then restore it after the script ends. This would allow plugins to
> > use marks et. al. as needed but the user can use :keepjumps! to
> > prevent side effects from the plugin.
>
> Ok, I did this, see the attached patch.
> Everything seems to work great (and all tests pass etc), and I am quite
pleased with the result.
> However, this is now a considerably larger patch, and I really need some
feedback on both the implementation and the interface.
>
> Reagrding the implementation:
>
> The way it works is that there are duplicated entries for all items which
need to be restored at the end of the execution, and more precisely:
> 1) for buffers: last_cursor, last_insert, last_change, changelist,
changelistlen
> 2) for windows: pcmark, prev_pcmark, jumplist, jumplistsen, changelistidx
> There are also additional entries in the structs, to keep track if we're
actively keeping a backup of those.
>
> Then, within functions `mark_adjust`, `mark_col_adjust` and
`cleanup_jumplist`, the backup entries are updated (if the backup tag is
active).
> This ensures that, if the code called by keepjumps! is making changes,
those are reflected in the jumplist/changelist/etc when those are restored
at the end.
>
> I thought about alternative ways to achieve the same effect but I can't
see any simpler way to keep that guarantee (which is essential in my
opinion).
> This is the major point on which I'd like to have feedback. Is this ok?
Did I miss something? Will this get merged (possibly after some polishing,
of course)?

:/

> Regarding the interface:
>
> As discussed, I used :keepjumps! for the recursive version.
> This has forced me to make some changes to the parser, to account for the
possibility of the trailing bang in the command.

ea->forceit should already indicate presence of bang.

> I don't particularly like those changes.
> First, they are very slightly breaking, in that before, ":keepjumps!
command" was parsed as "keepjumps" followed by "!command". I don't think
this is important (note: all other commands still parse the same).
> Second, ":keepjumps" and ":keepjumps!" behave in a slightly different way
in some cases, besides the fact that :keepjumps! is recursive. Consider
this example:
>
>   :keepjumps normal ggdd``
>   :keepjumps! normal ggdd``
>
> In the first case, the ' mark is not set by the gg jump, and therefore
the cursor is brought back to the *previous* location of the ' mark, if any.
> In the second case, the ' mark is set by the gg jump, the cursor is
brought back to the location from where the command was invoked, and the
previous ' mark is restored afterwards (if it existed at all).
>
> I have a proposal: instead of introducing keepjumps!, just redefine
:keepjumps to act recursively.
> This is slightly breaking for 2 reasons: 1) examples such as the one
above, 2) cases in which :keepjumps would have been a no-op.
> I don't know what's the vim policy about these kind of slightly breaking
changes, but I think that the recursive version is what one would want most
of the time.
> I also doubt that anyone would be relying on such behaviours as the ones
which would be broken by the change.

Many plugins use keepjumps, would need to analyze those cases.

Justin M. Keyes

-- 
-- 
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 vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui