Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assign a keymap to a derived mode in emacs

How can I assign a keymap to a derived mode in emacs (I am using the define-derived-mode function). There is a derived-mode-set-keymap function but without examples or good documentation.

like image 332
Mathias Soeken Avatar asked Feb 07 '10 10:02

Mathias Soeken


1 Answers

define-derived-mode itself creates a keymap with the name MODE-map, where MODE is the name of the keymap you've just defined. I'm not sure what derive-mode-set-keymap does that is not already done with define-derived-mode; looking at the source, they do similar things, and I'm unsure of the very low-level differences between the two (e.g. define-derived-mode leaves the parent-mode's keymap as the parent of the new keymap while `derive-mode-set-keymap also merges the keymaps; what's the functional difference between the two?).

If you do the following:

(define-derived-mode foobar-mode text-mode "foo")

Then the following variables will be defined:

  • foobar-mode-abbrev-table
  • foobar-mode-hook
  • foobar-mode-map
  • foobar-mode-syntax-table

You can then start manipulating any of these as you like.

like image 172
Joe Casadonte Avatar answered Sep 24 '22 07:09

Joe Casadonte