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

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -