On Monday, June 8, 2015 at 10:18:23 PM UTC+2, Bram Moolenaar wrote: > Ben Fritz wrote: > > > On Sunday, June 7, 2015 at 8:57:38 AM UTC-5, Bram Moolenaar wrote: > > > Carlo Baldassi wrote: > > > > > > > Ok, here is my attempt at a recursive version of the keepjumps command. > > > > It's called lockjumps, and works in the same way as keepjumps except > > > > that: > > > > 1) it's recursive > > > > 2) it only locks the jumplist, it does not affect the marks list > > > > > > > > Again, it seems to work as intended, "make test" passes and valgrind > > > > too. > > > > > > > > The reason for not touching the marks is that: > > > > 1) I think it is actually fairly common for functions/plugins/etc to > > > > use marks in jumping around, e.g. calling "normal ``" to get back > > > > after a jump, or having a mapping which does things like "ggdd``". It > > > > is much more uncommon to use CTRL-O in a script I think. > > > > 2) The marks can be set explicitly by the user and are much easier to > > > > control from user code (e.g. it is trivial to write a > > > > save_marks()/restore_marks() pair if needed). > > > > > > > > All things considered, I prefer this version to the previous one with > > > > the option. (I just hope it's correct!) > > > > > > Makes sense. I didn't like the solution with an option. > > > > > > I don't like using ":keepjumps!", adding an exclamation mark to a > > > command modifier is weird, I don't think this exists yet. We only have > > > the exclamation mark on commands. > > > > > > Any comments from plugin writers? > > > > > > > Justin mentioned that he needed a solution that also keeps marks. > > > > I guess it may be possible to use getpos/setpos to save/restore > > specific mark positions, but I'm not 100% sure this patch plus that > > method would meet his needs. > > It might be better to "lock" marks separately. In case someone wants to > lock the jumplist but set a mark. If we always keep marks that would > not be possible. I'm not sure if we should re-use :keepmarks. Perhaps > it's better to have :lockmarks to be paired with lockjumps. > > :lockmarks lockjumps call MyJumpingFunction() >
Yes, I had that thought as well. However, as also clearly stated in the documentation of lockmarks, the major drawbacks of this model are 1) not adjusting for line insertions / deletions 2) the possibility of making the command you're calling non-functional, it that command uses marks to jump around internally (and even if it uses the jumplist, although I think that's much less common.) The third patch I submitted after Justin's comments (the one which introduces "keepjumps!" - but the name can be easily changed! - file name "lkjbang_patch.txt") actually solves all this, quite nicely in my opinion. All operations inside keepjumps! work normally, and the state at the end is restored as best as possible keeping track of insertions/deletions. Of course, it comes at a slight cost in complexity/memory/speed. I could not observe any noticeable difference in practice though. To me, its worst issue is some code duplication, but it's not terrible. So that's actually my favourite choice at the moment (as I mentioned, I'd even use that in place of the current "keepjumps"), and if the costs are considered acceptable, I'd gladly polish that/rename/apply all required changes. (Otherwise, I'm still reasonably happy with the simpler "lockjumps" version - please let me know if there's anything I should do about that as well.) -- -- 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.
