# Emacs key bind on Mathematica Linux

This might not be Mathematica specific question but if there is anyone who can use Emacs keybind on Ubuntu Linux, would you share how you realize it?

I'm using Mathematica student edition both on Mac OS X (10.7.3) and Ubuntu (11.10), and Mac version allows basic Emacs keybind (Ctrl+a, Ctrl+e, Ctrl+d, Ctrl+f, Ctrl+b, etc.) In general, GUI programs on my Ubuntu doesn't allow Emacs keybind unless explicitly configured per program, so as I said I might have to look for general solution for Ubuntu/Linux. But I welcome whatever the solution to realise the keybind.

Update: Thanks to @sebhofer's answer, I manage to comfortably use Emacs keybind on Ubuntu. I had to modify both MenuSetup.tr and KeyEventTranslations.tr to enable my preferred keybind.

As a reference for other people who may want to enable Emacs keybind, I'm sharing those 2 files here: http://goo.gl/nJaXD and http://goo.gl/gZWS5, which allow following keybinds:

C-v "ScrollPageDown"
C-d "DeleteNext"
C-h "DeletePrevious"
C-p "MovePreviousLine"
C-n "MoveNextLine
C-b "MovePrevious"
C-f "MoveNext"
C-t "MoveNextWord"
C-i "MovePreviousWord"
C-e "MoveLineEnd"
C-a "MoveLineBeginning"


Some of the above might not be the standard Emacs keys. Also, more importantly, some default keybinds that use alt might not work due to the change (I haven't tested thoroughly). You can customize by modifying those .tr files.

-

I was never able to find a completely satisfying solution, but the following is what I use. The shortcuts for the Mathematica GUI are defined in [MathematicaDir]/SystemFiles/FrontEnd/TextResources/X/KeyEventTranslations.tr. You can also add your own shortcuts there, as long as the functionality you require already exists. (Actually you can also write your own functions and assign shortcuts there.) Of course the shortcuts need to be unique to work correctly, including the ones assigned to menu items, which normally have a Alt-... binding under Linux. These can be edited in the MenuSetup.tr file in the same directory. So you always have to make sure that there is no overlap between these two files. Just as an example, these are the custom shortcuts I defined:

(* My emacs shortcuts *)
Item[KeyEvent["I", Modifiers -> {Command}], "ScrollPageUp"],
Item[KeyEvent["K", Modifiers -> {Command}], "ScrollPageDown"],
Item[KeyEvent["d", Modifiers -> {Command}], "DeleteNext"],
Item[KeyEvent["D", Modifiers -> {Command}], "DeleteNextWord"],
Item[KeyEvent["i", Modifiers -> {Command}], "MovePreviousLine"],
Item[KeyEvent["k", Modifiers -> {Command}], "MoveNextLine"],
Item[KeyEvent["j", Modifiers -> {Command}], "MovePrevious"],
Item[KeyEvent["l", Modifiers -> {Command}], "MoveNext"],
Item[KeyEvent["o", Modifiers -> {Command}], "MoveNextWord"],
Item[KeyEvent["u", Modifiers -> {Command}], "MovePreviousWord"],
Item[KeyEvent["L", Modifiers -> {Command}], "MoveLineEnd"],
Item[KeyEvent["J", Modifiers -> {Command}], "MoveLineBeginning"],
Item[KeyEvent["O", Modifiers -> {Command}], "MoveNextCell"],
Item[KeyEvent["U", Modifiers -> {Command}], "MovePreviousCell"]

-