In my .emacs
file, I want to add a key binding for a specific major mode (setting coffee-compile-file
to C-c C-c in coffee-mode).
I've found a lot of instructions on using local-set-key
and global-set-key
, so I can easily add this binding once I've opened a file in coffee-mode, but it would be nice for this to be handled by .emacs
.
Answer
Use the mode hook. C-h m
shows information about the major mode, usually including what hook(s) it supports; then you do something like
(add-hook 'coffee-mode-hook ;; guessing
'(lambda ()
(local-set-key "\C-cc" 'coffee-compile-file)))
No comments:
Post a Comment