Closed sahlte closed 6 months ago
Hi @sahlte thanks for the issue. As a rule of thumb, we'll only add features to evil which exist in vim or neovim, or which address an issue related to the interplay between emacs and evil. There are probably some exceptions to this, and if, for example, this issue got a deluge of upvotes in a short period of time, I'm sure we could make an exception.
However, to address each of your points:
gv
will restore the selection. For most users, being put back in normal mode is more often what you'd want than what you don't, and for the times when that's not the case, you're just two keypresses away from getting the selection back.`]
or
`>
(assuming the cursor was at the end of the region) So again, I don't think it's enough of an inconvenience to add an option to change the default.
``
I admit that evil doesn't seem to emulate this very well, so I would be happy to consider this for improvement. But again, actually adding a setting to not move the cursor does seem unnecessary.
My hunch is that your requests are rare enough, and emacs is extensible enough, that your above solution is sufficient. It's always difficult to balance the addition of settings against a focus on keeping the codebase simple, but in this case I think I'd err in the latter direction.
Issue type
Environment
Emacs version: 29.3 Operating System: Ubuntu 22.04.3 Evil version: 1.15 Evil installation type: MELPA Graphical/Terminal: Graphical Tested in a
make emacs
session: YesReproduction steps
Expected behavior
Have the option to make evil-mode not mess with the highlighted region or cursor position when acting on a region.
Actual behavior
When you copy (y) or format (=) some text, evil will remove your highlighted region (if you are in a visual mode) and move your cursor. The cursor position will always be set to the original point or mark preferring the one which comes first. If you are in visual mode it will always unhighlight your region, which feels like it should be opt in/out.
Cursor example:
If you highlight from left to right and yank, your cursor will jump to where you started highlighting. If you highlight from right to left and yank, the cursor will stay where you stopped highlighting. If you highlight top to bottom and yank, your cursor will jump to where you started highlighting. If you highlight bottom to top and yank, the cursor will stay where you stopped highlighting. This also applies to something like "y%" or "ya(". If you start on the "(" your cursor will be left there. If you started on the ")" your cursor will be moved to the "(".
As you can see, the point always ends up on whichever, mark or point, comes earlier in the buffer. The cursor also moves sometimes when you "undo" some change, which is somewhat unexpected and the user should be able to turn it off.
TLDR
Further notes
Here is the hacky solution I have in my config:
I add advice around
evil-indent
because I find that it is hard to simply wrap this function like withevil-yank
. I avoid wrappingevil-yank
because it makesevil-visual-paste
act wrong. I have not tried messing with undo.