diff options
author | Tom Willemse | 2014-01-01 20:20:29 +0100 |
---|---|---|
committer | Tom Willemse | 2014-01-01 20:20:29 +0100 |
commit | bd7187269373c4aa6a7fb9d17bb5fccbcb751308 (patch) | |
tree | 9199b435ab887a4443845c0f240b5c1a219adbe0 /transient-navigation.el | |
parent | 9ca2d33ab71c600cc8cba52af0b8bf087cdcb309 (diff) | |
download | transient-navigation-bd7187269373c4aa6a7fb9d17bb5fccbcb751308.tar.gz transient-navigation-bd7187269373c4aa6a7fb9d17bb5fccbcb751308.zip |
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.
Diffstat (limited to 'transient-navigation.el')
-rw-r--r-- | transient-navigation.el | 15 |
1 files changed, 4 insertions, 11 deletions
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 |