0

I recently got a new Chromebook and installed Ubuntu via crouton. I then installed Emacs 23 and transferred my .emacs file to the new machine. However, a few of my key rebindings have been overridden by definitions in the LaTeX major mode of the new installation. This did not happen on my previous computer (emacs 24.something). The three changes I would like to make are:

  1. When I press [, I want } to display.
  2. When I press (, I want { to display.
  3. When I press $, I want ^ to display.

I have the following lines in my .emacs file (along with other similar lines that work as intended):

(global-set-key (kbd "[") '(lambda () (interactive) (princ "{" (get-buffer (current-buffer)))))

(global-set-key (kbd "(") '(lambda () (interactive) (princ "[" (get-buffer (current-buffer)))))

(global-set-key (kbd "$") '(lambda () (interactive) (princ "^" (get-buffer (current-buffer)))))

I only use Emacs for LaTeX, so I am not concerned with the fact that I am defining everything globally. Currently, if I use C-h k [, I see that [ calls skeleton-pair-insert-maybe instead of self-insert-command, as expected (and similarly for the other two). All of my attempts to search on how to disable this returned only results talking about the usage of skeleton pairs and why one would want to use them, nothing about getting rid of them. Similarly, I have been unable to find a way to edit the LaTeX major mode to remove the lines that bind this function in the first place.

Any method which allows me to redefine these keys over the LaTeX major mode, or to change the LaTeX major mode, would be appreciated.

Zach
  • 103
  • 2

1 Answers1

1

If you are trying to move keys around, but only in emacs, then it is probably easier to use a translation keymap.

(define-key key-translation-map "[" "{")
(define-key key-translation-map "(" "[")

As far as the binding to skeleton-pair-insert-maybe, I don't see this being setup to any key. You can use the code How can I find out in which keymap a key is bound? to find the keymap,and then use (define-key keymap "[" nil) to unbind it from that keymap. When you want to unbind it depends on where it is being bound!

icarus
  • 1,904
  • 1
  • 10
  • 15
  • Perfect. It seems `define-key` is the correct way to do what I originally wanted, but I of course found a different hack first when I made the initial changes. Partially as expected, `skeleton-pair-insert-maybe` was not really the problem, just the part that I could see was different from before. Thanks. – Zach Oct 25 '16 at 03:57
  • 1
    As I said in http://emacs.stackexchange.com/questions/27811/key-bound-to-string-does-not-handle-some-chars-in-string-correctly/27813#27813 `set-global-key` is just a thin wrapper around `define-key`, providing the global keymap. – icarus Oct 25 '16 at 04:05