Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change Emacs key map (from C-c s to C-\)

Tags:

emacs

I'm trying to change the key maps in Emacs (for use with cscope). Cscope has bindings like

"C-c s s", "C-c s g", "C-c s G" ... etc

So I'm trying to change the map to C-\ s, C-\ g, C-\ G ... etc

I tried using

(define-key global-map "\C-\\-s"  'cscope-find-this-symbol)

It complains:

error: Key sequence C-\ - a starts with non-prefix key C-\

How do I correct this. I'm new to Emacs and Elisp. I tried using the define-prefix-command function as suggested in the Emacs Wiki. But it did not help may be I did not use it correctly. Can someone let me know of any resource that can help me make this change. An example snippet would also be of great help.

Thanks.

like image 579
yaami Avatar asked Jun 13 '11 03:06

yaami


1 Answers

You try to change the definition of C-\ s. However, C-\ is already bound to a different command. (You can find out what a key is bound to with C-h k.)

The basic explanation is: Your command would never be executed. That other command is already executed after the first key stroke. One way to solve this is to undefine the other key first. Then Emacs can turn it into a "prefix key".

(define-key global-map "\C-\\" nil)

You also said "\C-\\-s", but you meant "\C-\\s". The "-" means "at the same time".

(define-key global-map "\C-\\s" 'cscope-find-this-symbol)
like image 126
nschum Avatar answered Sep 28 '22 11:09

nschum