emacs behaves a bit weird when killing regions with 'kill-region, i.e. it kills the region even if it's not really selected. it remembers somehow where the last selection was and if nothing is selected at the moment it kills previously remembered region.
that's really confusing because accidental C-w (with no selection) cuts somethi开发者_StackOverflow中文版ng that I definitely don't want to be cut.
is there any way to change this behaviour?
You can remap C-w
to work only when selected region currently exists:
(define-key global-map (kbd "C-w")
(lambda ()
(interactive)
(when mark-active
(call-interactively 'kill-region))))
精彩评论