[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CUA mode C-c overridden by keymap text property
From: |
Yuri Khan |
Subject: |
CUA mode C-c overridden by keymap text property |
Date: |
Mon, 30 Dec 2019 18:17:38 +0700 |
Hello,
I’m one of those heretics who dislike killing and yanking and insist
on cutting and pasting instead. In other words, I use ‘cua-mode’.
For some time, I’ve been noticing that, occasionally, C-c does not
work to copy the selected text to the clipboard. Instead, the
minibuffer shows the ‘C-c-’ prompt, as if ‘cua-mode’ were not active.
Most often I notice that when using Magit buffers. Sometimes I was
able to toggle ‘cua-mode’ off and on again and it fixed things. Other
times, it did not.
I looked into the source of ‘cua-mode’ and found a possible reason for that.
The mechanism that ‘cua-mode’ uses to allow C-x and C-c to be used for
cutting and copying is described in cua-base.el under the heading
‘Prefix key override mechanism’. Essentially, it depends on the
‘cua--prefix-override-keymap’ being active and pretty high in the
sequence of active keymaps. (In that map, C-c and C-x are bound to
‘cua--prefix-override-handler’, which allows ‘cua-mode’ to start a
timer and do its thing when it expires.)
The ‘cua--prefix-override-keymap’ is made active by means of the
‘emulation-mode-map-alists’ variable, which is second topmost source
of active keymaps. Above it, there is the ‘keymap’ text property.
So, if the current buffer text at point has a ‘keymap’ property, and
that property specifies a keymap where C-x and/or C-c are prefix keys,
then pressing C-x or C-c at that point will immediately go into prefix
key handling, waiting for the next key in sequence.
It so happens that Magit binds C-c C-e and C-c C-t in some of its maps
that are applied to diff sections. So, when I want to copy something
out of a diff section, I get the ‘C-c-’ prompt instead.
Could ‘cua-mode’ do better, to also work when a keymap property binds
C-c and/or C-x as prefix keys? Alternatively, does Magit (and all
other modes that use the keymap property) need to do something special
in order to not override ‘cua-mode’? Alternatively, am I on my own
here and do I have to unbind all C-c- bindings in any Magit keymaps I
find? (Also, how would I go about removing those bindings?)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- CUA mode C-c overridden by keymap text property,
Yuri Khan <=