HMM
HMM

Reputation: 3013

How to bind C-` (backquote) in emacs

I would like to bind C-` (control-backquote) but I could not do it.

The sexp

(global-set-key "\M-`" 'other-window)

works, whereas

(global-set-key "\C-`" 'other-window)

doesn't. It fails with the "Invalid modifier in string" error.

Upvotes: 7

Views: 1486

Answers (2)

Rémi
Rémi

Reputation: 8332

"\C-a" and similar do work because there is a ASCII code for them. There is none for C-`, simply use

(kbd "C-`")

By the way, this often more portable from one emacsen to another.

Upvotes: 7

HMM
HMM

Reputation: 3013

Since it is fair to answer my own question:

(global-set-key [?\C-`] 'other-window)

But I don't know the meaning of that extra question mark.

Upvotes: 2

Related Questions