frinkr
frinkr

Reputation: 664

How to define emacs keybinding 'C-c C-c'?

I want to bind the 'C-c C-c' to a custom command, don't know how to.

I tried (global-set-key (kbd "C-c C-c") 'suspend-emacs), but it seams not work.

Any idea will be appreciated.

Thanks.

Upvotes: 2

Views: 957

Answers (1)

dkim
dkim

Reputation: 3970

It is very likely that the local binding of C-c C-c in the current buffer is shadowing the global binding that you make with global-set-key. Conventionally, key sequences consisting of C-c followed by a control character are reserved for major modes. For instance, CC Mode gives C-c C-c a local binding as comment-region. Key sequences consisting of C-c and a letter (either upper or lower case) are set aside for users:

(global-set-key (kbd "C-c c") 'suspend-emacs)

And you may not want to bind suspend-emacs to a new key sequece. suspend-frame, which is bound to C-z and C-x C-z by default, calls suspend-emacs for us when it is invoked from the (controlling) tty device.

Upvotes: 6

Related Questions