Quantcast
Channel: Super Nerdy Cool » LaTeX
Viewing all articles
Browse latest Browse all 20

Dissociate C-i, C-m, and C-[ in emacs

$
0
0

Every now and then, I bind functions to keys such as C-m, C-i, and C-[ , but run into issues as these keys are identical to RETURN, TAB, and ESC. See this and the named ascii list for more information. I tried many solutions before but never got them to work. I finally ran across a solution that works, namely Caio’s solution on this post. At the time of this writing, it shows as the last place answer on stacked overflow, so I (and many others) must have missed it. Note that this works only on GUI instances of Emacs and not terminal ones. I will reproduce the solution:

 <pre class="src src-sh">;; Translate the problematic keys to the <span style="color: #00ffff;">function</span> <span style="color: #87cefa;">key</span> Hyper:

(keyboard-translate ?C-i ?H-i) (keyboard-translate ?C-m ?H-m) ;; Rebind then accordantly: (global-set-key [?H-m] ‘delete-backward-char) (global-set-key [?H-i] ‘iswitchb-buffer)

Basically, translate the keys using the hyper, and define the new keybindings using the hyper key. For my use, I did

 <pre class="src src-sh">(global-set-key (kbd <span style="color: #ffa07a;">"C-]"</span>) <span style="color: #ffa07a;">'elscreen-next)</span>

(keyboard-translate ?C-[ ?H-[) (global-set-key (kbd “H-[“) ‘elscreen-previous)

Finally!


Viewing all articles
Browse latest Browse all 20

Trending Articles