all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* CUA mode C-c overridden by keymap text property
@ 2019-12-30 11:17 Yuri Khan
  0 siblings, 0 replies; only message in thread
From: Yuri Khan @ 2019-12-30 11:17 UTC (permalink / raw)
  To: help-gnu-emacs

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?)



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-12-30 11:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-30 11:17 CUA mode C-c overridden by keymap text property Yuri Khan

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.