Emacs shortcuts specific to file type

Is there a way to get different shortcuts for different file types?
Tipically I use F12to compile. He is working make -f. I would like to have F12running

Mx org-export-as-html

when i'm in org mode.
How do I change the .emacs file? Currently it is simple:

(global key set [f12] 'compilation)

Thanks
hamen

+3
source share
2 answers

Add a mode cache for org-mode, which executes local-set-keyinsteadglobal-set-key

(add-hook 'org-mode-hook (lambda () (local-set-key [f12] 'org-export-as-html)))
+5
source

A clean way to add bindings based on the file type is to bind to the modes themselves:

(define-key org-mode-map (kbd "<f12>") 'org-export-as-html)

. , Keymaps

+4

All Articles