1

In c mode, C-c C-c will put marked text in comment.

In python mode, C-c C-c will execute a python runtime.

Usually how do experienced emacs users resolve this inconsistency of key shortcut? Or we just accept it as is?

3
  • Using guide-key? Defining your own shortcuts?
    – Nsukami _
    May 15, 2015 at 1:58
  • 4
    In the days of Emacs-20, it was somewhat common for major modes to bind C-c C-c to something like comment-region, but with the advent of comment-dwim in Emacs-21, bound to M-; globally,these bindings were made redundant and disappeared. Nowadays C-c C-c is mostly used for a command you run where you're done editing and want to send the result for processing. IOW the CC-mode binding is a remnant of a distant past and should just be removed (or replaced with a binding to something like compile). I suggest you file a bug report about it.
    – Stefan
    May 15, 2015 at 2:10
  • Here's the manual page on rebinding keys, here's the elisp manual on rebinding keys, here's a tutorial on rebinding keys, and here's an Emacs.SE thread on rebinding keys.
    – Dan
    May 15, 2015 at 19:41

2 Answers 2

5

There is no recommended way to resolve such an "inconsistency". Major modes are free to define C-c C-c as they see fit. And users are free to bind it to whatever they like, overruling what a major mode defines.

Things between modes are often "inconsistent", because modes can differ dramatically.

Search for C-c C-c in the Emacs manual, and you will see that what it does varies widely from mode to mode - very widely. If such "inconsistency" bothers you, bind it to something that does the same thing or something similar in all modes.

The only convention in effect that applies to C-c C-c is this one, from the Elisp manual, node Key Binding Conventions:

Sequences consisting of `C-c' followed by a control character or a digit are reserved for major modes.

3

C-c C-c is generally used to run interpreted code, but as C is not interpreted, it was assigned to a different function. But one of the best features of emacs is to customize it to make it behave just like you want, so if you wish to you can change the shortcut for C modes with:

(define-key c-mode-map "\C-c\C-c" 'your-function-of-choice)

Your Answer

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

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