On 30-Apr-2014 13:14 +0200, Bram Moolenaar wrote: > Christian Brabandt wrote: > >>>> Hi Andrew! >>>> >>>> On Di, 29 Apr 2014, Andrew wrote: >>>> >>>>> Hi, Christian, >>>>> >>>>>> Can you please come up with a mapping that shows the wrong behaviour? >>>>> >>>>> I made this example: https://gist.github.com/AndrewRadev/11408444 >>>>> >>>>> It's supposed to paste some text and comment it in the process. It's kind >>>>> of silly, but a realistic enough example. If you `"_dd` anything and then >>>>> immediately perform a `gp`, nothing happens, since the `v:register` >>>>> variable is set to `_`. If you've managed ot fix the issue, it should >>>>> paste normally, from the default register. >>>> >>>> Thanks. I think this one fixes it: >>>> >>>> diff --git a/src/normal.c b/src/normal.c >>>> --- a/src/normal.c >>>> +++ b/src/normal.c >>>> @@ -1263,6 +1263,10 @@ getcount: >>>> normal_end: >>>> >>>> msg_nowait = FALSE; >>>> +#ifdef FEAT_EVAL >>>> + /* reset v:register */ >>>> + set_reg_var(0); >>>> +#endif >>>> >>>> /* Reset finish_op, in case it was set */ >>>> #ifdef CURSOR_SHAPE >>>> >>>> (I hope, it doesn't have any side effect). >>> >>> Well, if one first does "add and then "_dd, it's a bit unexpected that >>> v:register is then '"' and not '_' or 'a'. >> >> I am not sure I follow. Why would one expect v:register to hold the >> register name from the previous >> normal mode command? > > Because that's where the deleted text is. I know that the docs say that > the v:register variable holds the register name for the *current* normal > mode command, but it appears users writing a mapping also use it after > the normal mode command is done, to find the text that was yanked or > deleted. It would then be logical to use the black hole register if any > other delete must happen, without messing with registers. But then > v:register must also not be changed by the operation that uses the black > hole register.
I find this undocumented behavior quirky and unexpected. If I do "xyy, then :echo v:register should return ", not x. Isn't : a normal-mode command that enters command-line mode? Also, after "x:echo v:register, I get x, but then the next :echo v:register gives ", not x as in the yank example. > I don't have a good example of where this is needed though. And perhaps > it's not too difficult to get the value of v:register before using the > black hole register, in which case the change to v:register is irrelevant. I haven't seen this in use, neither. A mapping should go to command-line mode as soon as possible, and there save / use the v:register value. If someone really needs this, a v:prevregister could still be contemplated. Christian, thanks for the patch! -- regards, ingo -- -- 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.
