File-specific key-binding in emacs -
is possible define file specific key-bindings in emacs? suppose possible create minor mode , have loaded when particular file open 1 key-binding seems overkill.
if combine code local-set-key
, buffer-locally overriding minor-mode key bindings in emacs end this:
(defun my-buffer-local-set-key (key command) (interactive "kset key buffer-locally: \ncset key %s buffer-locally command: ") (let ((oldmap (current-local-map)) (newmap (make-sparse-keymap))) (when oldmap (set-keymap-parent newmap oldmap)) (define-key newmap key command) (use-local-map newmap)))
and then, per barmar's answer:
;; local variables: ;; eval: (my-buffer-local-set-key (kbd "c-c c-c") 'foo) ;; end:
note minor mode maps take precedence on local map.
Comments
Post a Comment