tpope / vim-repeat

repeat.vim: enable repeating supported plugin maps with "."
http://www.vim.org/scripts/script.php?script_id=2136
2.59k stars 81 forks source link

Allow for some additional post-processing #10

Closed AndrewRadev closed 11 years ago

AndrewRadev commented 11 years ago

I'd like to be able to do this:

nnoremap . .`]

When I use repeat.vim, this doesn't quite work. The plugin uses feedkeys, which (I just learned) clears the typeahead buffer, effectively removing the "`]" at the end.

This pull request adds an after parameter that the plugin feeds after its own stuff. It also makes the main repeat function public (autoloaded) to make it remappable.

Bear in mind, this was just a result of a half-hour hacking session, so I currently have no idea of how big of a problem these changes could be and whether they break anything.

tpope commented 11 years ago

Could you change after into an optional parameter? Then you could just do if a:0.

AndrewRadev commented 11 years ago

Makes sense. Would you like me to squash it in one commit?

tpope commented 11 years ago

Please.

On Sat, Nov 3, 2012 at 3:21 PM, Andrew Radev notifications@github.comwrote:

Makes sense. Would you like me to squash it in one commit?

— Reply to this email directly or view it on GitHubhttps://github.com/tpope/vim-repeat/pull/10#issuecomment-10043092.

AndrewRadev commented 11 years ago

Done.

tpope commented 11 years ago

A thought occurs. What if we just dropped feedkeys() entirely in favor of norm? I just tried and everything still appears to work. Does that address your issue? (Presumably, you'll still need a mapping or function exposed.) Check the no-feedkeys branch.

AndrewRadev commented 11 years ago

Yes, with a norm, it seems to work just fine with my use case even without the parameter. I've updated my pull request to use that instead.

By the way, do let me know if you figure out a better name for repeat#run. It was the first thing I came up with.

tpope commented 11 years ago

Merged. I don't love the name but I can't top it.

tpope commented 11 years ago

@inkarkat, let me know if this breaks your register stuff.

AndrewRadev commented 11 years ago

Thanks.

AndrewRadev commented 11 years ago

Actually, it doesn't look like it's merged, neither into master, nor in the no-feedkeys mapping. Maybe you haven't pushed yet?

tpope commented 11 years ago

I'm really bad at pushing.

On Sun, Nov 4, 2012 at 5:56 AM, Andrew Radev notifications@github.comwrote:

Actually, it doesn't look like it's merged, neither into master, nor in the no-feedkeys mapping. Maybe you haven't pushed yet?

— Reply to this email directly or view it on GitHubhttps://github.com/tpope/vim-repeat/pull/10#issuecomment-10049280.

inkarkat commented 11 years ago

@inkarkat, let me know if this breaks your register stuff.

No, it doesn't, but without feedkeys(), there's now another problem: The count isn't properly passed to the repeated mappings. This is a bug in :normal which I had reported; Bram fixed this in Vim 7.3.100, so repeat.vim is now broken in all released 7.x versions of Vim.

AndrewRadev commented 11 years ago

I made a new pull request (#11), which restores the feedkeys() call, but also consumes the typeahead buffer beforehand and feeds it back afterwards. This works with my case and should work normally as well. The one thing I'm wondering about is feeding the keys with "n". It won't work correctly in the case of using nmap to remap the keys, but I'd say it's still a reasonable compromise.

As an added bonus, the s:typeahead() function helped me implement something in one of my own plugins that I've been trying to get working for the last few days. Not that it's very important to you guys, I just got so excited that I wanted to share :).