duplicate-thing
duplicate-thing copied to clipboard
Make duplicate things behave more predictably compared to other editors
Reason for change
If you duplicate smth you often want to move it. Currently, the point is moved beyond duplicated snipped which makes immediate use of commands to move the snipped also touches adjacent text from the line where the point is.
What was updated
The logic was improved to limit the selection after duplication to only duplicated text.
push-mark
is used instead of set-mark
for better compatibility as recommended by the Emacs manual.
set-mark is a compiled Lisp function in ‘simple.el’.
(set-mark POS)
Set this buffer’s mark to POS. Don’t use this function!
That is to say, don’t use this function unless you want
the user to see that the mark has moved, and you want the previous
mark position to be lost.
Normally, when a new mark is set, the old one should go on the stack.
This is why most applications should use ‘push-mark’, not ‘set-mark’.
Novice Emacs Lisp programmers often try to use the mark for the wrong
purposes. The mark saves a location for the user’s convenience.
Most editing commands should not alter the mark.
To remember a location for internal use in the Lisp program,
store it in a Lisp variable. Example:
(let ((beg (point))) (forward-line 1) (delete-region beg (point))).
Screenshots
Region
Line
Tests
I've manually tested for a couple of days. You can install it from my fork if you'd like to test yourself.
Cheers!