Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Key binding for § symbol in Emacs

I'm working in Ubuntu, but since the standard way of inserting unicode characters (Ctrl+Shift+U and, after that, the unicode code) doesn't work inside emacs, I've, in my .emacs, some keystrokes for different unicode symbols which I use frequently, for example:

(global-set-key (kbd "C-c b") "☛")

and every symbol works fine, except the symbol §, which is replaced by a simple dash ("-") when I use the corresponding keystroke:

(global-set-key (kbd "C-c y") "§")

The question is, what does it make this symbol different for other symbols and how can I solve my problem?

like image 932
Peregring-lk Avatar asked Feb 22 '14 19:02

Peregring-lk


People also ask

How do I set key bindings in Emacs?

First, Emacs checks if there's a minor mode key binding; If there isn't, then Emacs checks if there are any local keys set. Typically this local map is shared by the major mode of the current buffer. So if you want to add a key binding to python-mode , you can use local-set-key to do this.

What keys does Emacs use for special commands?

Although only the Control and Meta modifier keys are commonly used, Emacs supports three other modifier keys. These are called Super, Hyper, and Alt. Few terminals provide ways to use these modifiers; the key labeled Alt on most keyboards usually issues the Meta modifier, not Alt.

What is RET key in Emacs?

"RET" is the Return key while emacs runs in a terminal. and run emacs in terminal, your keybinding will have no effect. But the problem is, by binding (kbd "RET") , you are also binding (kbd "C-m") , regardless you run emacs in terminal or GUI.

How do you bind keystrokes?

To reassign a keyConnect the keyboard that you want to configure. Select the Start button, and then select Microsoft Mouse and Keyboard Center. From the displayed list of key names, select the key that you want to reassign. In the command list of the key that you want to reassign, select a command.


1 Answers

global-set-key usually expects a function, so this should work:

(global-set-key (kbd "C-c y") (lambda () (interactive) (insert "§")))

But you're better off using the excellent insert-char function:

(global-set-key (kbd "<f2> u") 'insert-char)

It understands hex Unicode as well as text description (with completion and all). Just press TAB to see the completions.

like image 110
abo-abo Avatar answered Oct 27 '22 17:10

abo-abo