I'm running cua-mode, and I'm trying to override the cua binding for C-c so that I can insert a function somefunc before passing the baton to the original cua binding which is cua-prefix-override-handler.

However, I find I can't override the original cua binding. (And even if could, I'm still not sure it would work because cua-prefix-override-handler appears to be a tricky function based on timing in a loop.)

;; .emacs
(cua-mode t)
(defun somefunc--cua ()
  "Run `some-command' and `some-other-command' in sequence."

(global-set-key (kbd "C-c") 'somefunc--cua)

How can I achieve the desired effect of insert an extra function somefunct and then continuing on with the cua processing?

(Background information about the motivation for this question is here.)

2 Answers 2



(define-key cua--cua-keys-keymap (kbd "C-c <timeout>") 'somefunc)

(without wrapping somefunc) do what you want it to?


When in CUA mode, the usual method of investigating keybindings, describe-key did not work with C-c (at least with no selected text), as C-h k C-c continued waiting for further input (displaying C-c-). Hence, I tried C-c ? (if a certain key, say KEY, is a prefix-key, then KEY ? or KEY C-h, will display the keybindings starting with KEY (this also works for a sequence of keys — e.g. C-x n ?)).

This gave the following relevant information:

`cua--ena-cua-keys-keymap' Minor Mode Bindings Starting With C-c:
key             binding
---             -------

C-c <timeout>   copy-region-as-kill

which tells us that the relevant keybinding is C-c <timeout> and that the keymap in which it's bound is cua--ena-cua-keys-keymap (which overrides the global map, so just using (global-set-key (kbd ("C-c <timeout>")) 'somefunc) wouldn't work).

  • 1
    Worked perfectly! Nice job. Commented Mar 8, 2019 at 0:30


   (global-set-key [remap copy-region-to-clipboard--cua] 'your-replacement-function)
  • Thanks for your answer - I'm not sure what 'your-replacement-function represents in this context. Commented Mar 8, 2019 at 0:32
  • @CraigHicks: In your specific case, somefunc--cua . Commented Mar 8, 2019 at 1:29
  • What I called somefunc-cue in this question is a just a name substitution for 'copy-region-to-clipboard--cua` in the previous question (in which I selected your answer as correct). This question is leftover unanswered part of that question. I changed the name to make this question more clear. Commented Mar 8, 2019 at 2:31
  • @CraigHicks: So 'your-replacement-function would be your custom function to replace the emacs-standard cua funtion that you are remapping. Commented Mar 8, 2019 at 8:42
  • I read this documentation on remap : gnu.org/software/emacs/manual/html_node/elisp/… . "... Note that remapping only takes place through active keymaps; for example, putting a remapping in a prefix keymap like ctl-x-map typically has no effect, as such keymaps are not themselves active. In addition, remapping only works through a single level ... ". The problem is that cua-mode is not usually active, so perhaps cua mode's keytable wouldn't always be modified? Too hard to think about! Commented Mar 8, 2019 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.