Emacs shortcuts specific for a file type

后端 未结 2 1600
北恋
北恋 2021-01-06 11:41

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

相关标签:
2条回答
  • 2021-01-06 12:22

    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)))
    
    0 讨论(0)
  • 2021-01-06 12:43

    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 讨论(0)
提交回复
热议问题