3

I am not particularly satisfied how the viper mode works in Emacs. I am trying to write my own viper mode. I do not have any good programming experience in Elisp except for the number of customizations I have done using the .emacs file.

I would like to know if I can change the key-bindings in Emacs temporarily and return them back to their original state as and when needed.

2 Answers2

2

Well if I understand your question correctly one easy way to do this would be to create your own minor mode (in addition to your own specific mode I'd say), made only of your temporary key-bindings.

You give a name to that mode and then toggling all your temporary key-bindings on or off becomes as simple as calling your command:

M-x salsabear-minor-mode

You probably want to read scottfrazer's 45+ upvotes answer here on SO:

Globally override key binding in Emacs

where he explains how to create your own minor-mode containing your key-bindings.

Community
  • 1
  • 1
TacticalCoder
  • 6,275
  • 3
  • 31
  • 39
0

Given that you explicitly only mention viper, it's probably worth asking whether you're aware of the other vi/vim-based libraries which exist? See the list under:

http://www.emacswiki.org/emacs/CategoryEmulation

I would suspect that re-inventing this particular wheel is probably not worthwhile.

I believe that Evil is the most active project, but if it doesn't work the way you want, your efforts might be better-spent enhancing that (if practical)?

phils
  • 71,335
  • 11
  • 153
  • 198