简体   繁体   中英

Emacs: why does keybinding with M-S-[letter] set mark?

I'm experimenting with new bindings for basic movement in Emacs. Borrowing from this page and ErgoEmacs , this remapping works as expected:

(global-set-key (kbd "M-i")   'previous-line)
(global-set-key (kbd "M-k")   'next-line)
(global-set-key (kbd "M-j")   'backward-char)
(global-set-key (kbd "M-l")   'forward-char)

But defining a Shift-Alt combination gives an unwanted side-effect.

(global-set-key (kbd "M-I")   'cua-scroll-down)
(global-set-key (kbd "M-K")   'cua-scroll-up)
(global-set-key (kbd "M-J")   'backward-word)
(global-set-key (kbd "M-L")   'forward-word)

Running describe-key ( Ch k ) shows that the bindings were successful. And these bindings move point as they should, but for some reason it sets the mark at my original position, and gives me a highlighted region as I move the point.

How do I correct this?

EDIT: This has something to do with cua-mode. When I disable cua-mode, the problem disappears. Unfortunately, disabling cua-mode is not a desirable solution.

EDIT: This is a bug in Emacs. It's tracked as bug#11221, title 'cua-mode activates the mark for shifted bindings'. From the discussion on the mailing list, it sounds like there will be a fix to cua-base.el.

It's indeed likely triggered by shift-select-mode , but it looks like a bug: shift-select-mode should pay attention to the fact that the command is bound to a shifted key. Try to reproduce the problem without using CUA and then please report it with Mx report-emacs-bug .

That's because of the shift selection . You can disable it by setting shift-select-mode to nil .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM