Evil numbered register behavior vis-a-vis vim

Frank Fischer frank-fischer at shadow-soft.de
Mon Feb 3 20:27:49 CET 2014


Am 03.02.2014 18:27, schrieb Kari Oikarinen:
> 
> Currell Berry <currellberry at gmail.com> writes:

>> One feature I use a lot in vim is, use 'yy' to yank a line, perform some
>> arbitrary editing, possibly including deletions, trusting that vim will
>> hold onto the yanked text in the 0 register until I yank another text, and
>> then, finally, pasting the text back with '"0p'.  Evil doesn't implement
>> the same behavior here.
> 
> There's a bug report about this at
> https://bitbucket.org/lyro/evil/issue/339/zero-register-0-has-odd-behavior
> 
> I'm not sure if it was done on purpose, but I think it was just an
> oversight. Perhaps an evil developer will confirm that. I also don't
> think it would be hard to implement but I don't really know elisp and
> haven't actually gotten around to trying to do it.

I can't really remember who implemented number registers and when, but I
think the current implementation is how it is because it was ... easy.
No special case concerning yank/delete ;).

I'm not sure how difficult it is to implement the desired behaviour. The
evil function that is responsible for yanking is `evil-yank`, so it
could be modified to put text in the 0 register (which would not be
mapped to the kill-ring anymore). However, it is also called by
`evil-delete` as a subroutine (because deleting is, well, yanking the
text followed by wiping it out of the buffer). There are also a few
other yank functions, but they all should call `evil-yank`. Furthermore,
there are also some non-Evil functions (e.g. `kill-ring-save` typically
bound to M-w), which also put text onto the kill-ring but do not delete
it from the buffer. Handling all of them appropriately might not be so easy.

So, implementing the 0-register correctly is certainly possible but not
completely trivial (unless there is some support by pre-existing Emacs
functions that I'm not aware of).

If somebody wants to try implementing it, I'll be glad to provide any
help I can ;)

Best regards,
Frank






More information about the implementations-list mailing list