开发者

Emacs shortcuts specific for a file type

开发者 https://www.devze.com 2023-01-17 09:26 出处:网络
is there a way to get different shortcut for different file types? 开发者_开发技巧Tipically I use F12 to compile. It runs make -f. I\'d like to have F12 running

is there a way to get different shortcut for different file types?

开发者_开发技巧Tipically I use F12 to compile. It runs make -f. I'd like to have F12 running

M-x org-export-as-html

when I'm on Org-mode.

How should I edit my .emacs file? Currently it's just:

(global-set-key [f12] 'compile)

Thanks,

hamen


Add a mode hook for org-mode that does a local-set-key instead of a global-set-key

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


The clean way to add bindings on a file type basis is to the bindings to the modes themselves:

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

See Changing Key Bindings, Keymaps, and Major Mode Conventions

0

精彩评论

暂无评论...
验证码 换一张
取 消