Remapping C-c’s original functions?

31 views
Skip to first unread message

Tina Russell

unread,
Dec 27, 2017, 6:21:54 AM12/27/17
to ErgoEmacs
Hey, I’m new to Emacs and I’m very glad ErgoEmacs restores the commands I am used to, thank you very much :)

Instead of using the funky timeout stuff, I was hoping to keep the “Ctrl+C and Ctrl+X are Copy/Cut” option on and move the original utility of those keys to somewhere else. Alt+C and Alt+X seemed like good choices, since ErgoEmacs already moves ”M-x” (Alt+X) to Alt+A. I can remap Ctrl+X as seen here, and it seems to work fine:

(global-set-key (kbd "M-x") 'Control-X-prefix)

i.e., I can now switch windows with “Alt+X o,” evaluate an expression with “Alt+X Ctrl+E,” etc. I hoped the same would work for remapping Ctrl+C, but… it doesn’t.

(global-set-key (kbd "M-c") 'mode-specific-command-prefix)

For instance, if I go to org-mode, none of the commands that start with “C-c” will work with Alt+C… or at all, since I’ve already told ErgoEmacs to use Ctrl+C exclusively for copying. Instead of using the mode-specific-command-prefix map, or any other prefix keymap, the “C-c” bindings (at least in org-mode) seem to be hardwired in the mode’s main keymap.

So, is there any way to remap something to C-c to make it do what I need, here? I’ve heard ErgoEmacs has plans to make such a thing doable, is that true? Thank you!

Matthew Fidler

unread,
Dec 27, 2017, 10:11:10 PM12/27/17
to ergo...@googlegroups.com
Thank you for your kind words.

Ergoemacs indeed has a solution for this;  For QWERTY keyboards you can press the menu key followed by the "f" key to access the "C-c" keymap.  This access is a bit different since it makes the control key "sticky" so you don't have to press it again.  Hence, "C-c" could be typed as "menu" "f" and then "c".  This is also true of the "C-x" keymap, which can be accessed with the "menu" "d" key.  Note that pressing the menu key during any of the key-sequence can change the translation of the keys.

This is discussed at the following web-page:


However, I can't remember exactly how I set this up;  There is likely a way to set this up directly;  I think it would require:

1 -- disabling the components using M-c and M-x in ergoemacs-mode
2 -- changing the components to use the key-bindings that you prefer.

However, I would strongly recommend using the "apps/menu" key option since it is more ergonomic than the emacs keys, which notoriously give you RSI.

Hopefully this helps you a bit.


--
You received this message because you are subscribed to the Google Groups "ErgoEmacs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ergoemacs+...@googlegroups.com.
To post to this group, send email to ergo...@googlegroups.com.
Visit this group at https://groups.google.com/group/ergoemacs.
For more options, visit https://groups.google.com/d/optout.

tinakell...@gmail.com

unread,
Dec 28, 2017, 1:49:31 PM12/28/17
to ErgoEmacs
Thanks! I will give it a try. The main problem with using the “menu” key is that I already have it set up in Xkb to be the “compose” key (I also use the “Win” key as the AltGr/3rd-level selector key). But, this is an excellent starting point!

Matthew Fidler

unread,
Dec 29, 2017, 12:13:24 PM12/29/17
to ergo...@googlegroups.com
I'm not sure what you have compose do.  However, you can map compose to menu in emacs using a translation key map, so you could do both...? 

tinakell...@gmail.com

unread,
May 18, 2018, 2:37:00 PM5/18/18
to ErgoEmacs
By the way, I recently figured out a way to make this work:

 (global-set-key (kbd "M-x") '(lambda (&optional arg)
 (interactive "P")
 (let ((ergoemacs-handle-ctl-c-or-ctl-x '
only-C-c-and-C-x))
 
(ergoemacs-command-loop "C-x"))))
 
(global-set-key (kbd "M-c") '(lambda (&optional arg)
 (interactive "P")
 (let ((ergoemacs-handle-ctl-c-or-ctl-x '
only-C-c-and-C-x))
 
(ergoemacs-command-loop "C-c"))))

This way, Alt+c is the new C-c, and Alt+x is the new C-x (since ErgoEmacs already maps Alt+a to the original M-x function), irrespective of what I have set for ergoemacs-handle-ctl-c-or-ctl-x globally.

The only hiccups I’ve found with this are:

  • F1 or Ctrl+h, then Ctrl+c or Ctrl+x, loads the help for my lambda function, instead of acting as a prefix key (which I guess is a problem with ergoemacs-command-loop in general, as I know ErgoEmacs is a clever hack to make Emacs do things it should be doing by default).
  • The prompt will display “Ctrl+C” and “Ctrl+X” instead of “Alt+C” and “Alt+X”, naturally. Not sure how I would fix that (it’s a cosmetic issue, I know).
  • If I load ergoemacs-mode with use-package’s “after-init-hook”, or some other form of deferred loading, ErgoEmacs seems to redefine Alt+A to become like my custom Alt+X key (displaying “Ctrl+X” and everything), leaving me without access to “execute-extended-command”/“smex”. I don’t normally defer loading ErgoEmacs (it was an experiment to see if I could avoid a settings conflict), but the effects of it seemed interesting enough to note.
Also, I did end up rebinding xkb’s compose key to Win+Menu, leaving the menu key open for ErgoEmacs’s unchorded keybindings. They work very well! Thanks for the help :)

—Tina

Matthew Fidler

unread,
May 18, 2018, 11:49:16 PM5/18/18
to ergo...@googlegroups.com
Awesome, I'm glad it works.
Reply all
Reply to author
Forward
0 new messages