Weird behaviour when yanking
Closed this issue · 3 comments
Same issue with emacs -q
with GNU Emacs 29.3 (build 2, x86_64-w64-mingw32) of 2024-03-24
.
I was expecting the line should be (after yanking):
name VARCHAR(1010) NOT NULL
And not (in the image):
10
name VARCHAR(10) NOT NULL
Step to reproduce
emacs -q
eval
the following (in scratch buffer):
(require 'package)
(package-initialize) ; assumed you have this package installed
- Open a sql file with these lines:
CREATE TABLE account (
name VARCHAR(10) NOT NULL
);
M-x whole-line-or-region-local-mode
- Navigate to line 2 and
M-x whole-line-or-region-kill-region
M-x undo
- Select text
10
thenM-x kill-ring-save
M-x yank
I'm facing very same issue. After taking a quick look at the source code, I found that the issue is caused by the uncleared yank-handler
text property. It seems to be easy to fix, but I wonder why `yank-handler' is needed actually.
I'll work on that anyways when I have time.
IIRC, the yank-handler
was so that the yank behaviour is overridden when whole-line-or-region-mode
is enabled to handle the following case: if you copy the final line of a file, and there's no newline after it, then when it's yanked a newline should be added. Hopefully a test should fail if you disable the yank-handler
, but a couple of tests are failing for me right now anyway. I'd appreciate a second opinion!