From bd7187269373c4aa6a7fb9d17bb5fccbcb751308 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Wed, 1 Jan 2014 20:20:29 +0100 Subject: Simplify key bindings for transient-navigation Instead of binding each key in the global map, bind it in a map for the minor mode, so they automatically disappear when the mode is turned off. This should also prevent the key bindings from taking over in all buffers. --- transient-navigation.el | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'transient-navigation.el') diff --git a/transient-navigation.el b/transient-navigation.el index b11d7a2..7bbce4e 100644 --- a/transient-navigation.el +++ b/transient-navigation.el @@ -25,9 +25,9 @@ ;;; Code: +(defvar transient-navigation-mode-map (make-sparse-keymap)) (defvar transient-navigation-map (make-sparse-keymap)) (defvar transient-word-navigation-map (make-sparse-keymap)) -(defvar transient-function-map (make-hash-table)) (defmacro transnav-make-transient (key map func) "Bind KEY in MAP to FUNC with a transient map." @@ -40,7 +40,8 @@ (call-interactively #',func) (set-transient-map ,map t)) (define-key ,map (kbd ,key) #',func) - (setf (gethash ',func transient-function-map) ',funcname)))) + (define-key transient-navigation-mode-map + [remap ,func] #',funcname)))) (transnav-make-transient "f" transient-navigation-map forward-char) (transnav-make-transient "b" transient-navigation-map backward-char) @@ -57,15 +58,7 @@ ;;;###autoload (define-minor-mode transient-navigation-mode "Remap certain navigation commands to ones with a transient map." - nil nil nil - (if transient-navigation-mode - (maphash (lambda (k v) - (define-key global-map (vector 'remap k) v)) - transient-function-map) - (maphash (lambda (k v) - (ignore v) - (define-key global-map (vector 'remap k) nil)) - transient-function-map))) + nil nil transient-navigation-mode-map) (provide 'transient-navigation) ;;; transient-navigation.el ends here -- cgit v1.2.3-54-g00ecf