Patrick Li
Patrick Li

Reputation: 672

How to I bind one character to a different control sequence?

My RSI is acting up, and I am trying to remap some keys in Emacs to help. Here's what I want to do:

  1. Be able to type the { character with the sequence M-j.
  2. Remove the ability to type the { character with the { key.

I've gotten 1 working by myself but not 2. Point 2 is important for me because the habit is pretty deeply ingrained in me, and I need a reminder to help me switch.

Is this possible? Thank you! -Patrick

Upvotes: 0

Views: 66

Answers (1)

lawlist
lawlist

Reputation: 13457

The original poster indicated that he remapped { to M-j, which caused Emacs to treat the latter as the former. In other words, the behavior for { was the same as M-j.

The following is a means of separating the two, and will serve to help remind the original poster that he wishes to train himself not to press the { key:

(global-set-key [?\M-j] (lambda () (interactive) (insert "{")))

(global-set-key "{" (lambda () (interactive) (message "Bad boy!")))
;;; OR use the following instead:
;; (global-set-key "{" nil)

Upvotes: 2

Related Questions