From: Yuri Khan <yuri.v.khan@gmail.com>
To: help-gnu-emacs <help-gnu-emacs@gnu.org>
Subject: CUA mode C-c overridden by keymap text property
Date: Mon, 30 Dec 2019 18:17:38 +0700 [thread overview]
Message-ID: <CAP_d_8VYNvhm6Y6+r3wEyORPGY1f17M2_P_+NWzQct=cXgC=6A@mail.gmail.com> (raw)
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?)
reply other threads:[~2019-12-30 11:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP_d_8VYNvhm6Y6+r3wEyORPGY1f17M2_P_+NWzQct=cXgC=6A@mail.gmail.com' \
--to=yuri.v.khan@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.