Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify startput functions by removing defer. #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

DerWeh
Copy link

@DerWeh DerWeh commented Jul 6, 2017

Instead of checking for defer argument, check if a register was used.

Instead of checking for `defer` argument, check if a register was used.
@DerWeh
Copy link
Author

DerWeh commented Jul 6, 2017

As far as I understand the only reason for <Plug>(miniyank-autoput) is to keep compatibility to with registers, e.g. to use "ap.

To just have a universal mapping I changed miniyank#startput to check, weather another register than the default one was used. If that is the case use that register, else use miniyank.

I think this is desirable, as I usually realize that I want a previous yank after pasting and seeing that it is a wrong one.

Please check if what I did is meaningful. I have no idea of vimscript, in particular I don't know how autocommands work. I just changed your code without any understanding. But I tried it and it seems to work like I want.

@bfredl
Copy link
Owner

bfredl commented Jul 6, 2017

Unfortunately it can't work completely, due to limitation in nvim: we cannot distiguish ""p which should paste the " register literally, and p which by should paste the latest item in the yankring. (same with * if one uses clipboard=unnamed). But nvim can add v:regname to make this work. In the meanwhile you can always use

noremap <silent> <expr> p miniyank#startput("p",v:register != '"')

As far as I understand the only reason for (miniyank-autoput) is to keep compatibility to with registers, e.g. to use "ap.

Another reason is if you want p to paste from the current instance by default. I think this should be supported.

In case the default register was used, e.g. `""p` Vim's unmapped past
will be used.
@DerWeh
Copy link
Author

DerWeh commented Jul 7, 2017

Thanks for clearing up. I think the case ""p can simply be handle by a noremap:
noremap ""p p

I don't understand what you mean by your other reason

Another reason is if you want p to paste from the current instance by default. I think this should be supported.

I don't have any idea of vimscript and thus don't really know what your plug-in, or miniyank-toblock and the like does.

@bfredl
Copy link
Owner

bfredl commented Jul 7, 2017

No. The plugin should be invoked (if the user wants it) even with explicit register, so one can cycle if the register contents were unexpected and change the register type if one wants. So instead:

noremap <silent> <expr> p miniyank#startput("p",v:register != '"')
noremap <silent> <expr> ""p miniyank#startput("p",1)

But nvim should add v:regname, then this plugin can add <Plug>(miniyank-flexiput) with this behavior.

I don't understand what you mean by your other reason

It's a matter of nonintrusiveness, the user can make sure the default behavior of p doesn't change at all, while still enable cycle and toRegtype. This is how I use it myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants