aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2013-12-31 14:17:33 +0100
committerGravatar Tom Willemse2013-12-31 14:17:33 +0100
commit515f65df7d90928c623ea43c8a7233621714c1a3 (patch)
tree00d4bfe8db1cba3732936972ca424b22ad3fa2ff
parent5624c6fa9b42ff94d19814a6879732a8468dc71b (diff)
downloadtransient-navigation-515f65df7d90928c623ea43c8a7233621714c1a3.tar.gz
transient-navigation-515f65df7d90928c623ea43c8a7233621714c1a3.zip
Add more keys, change macro for keymap management
Instead of having to keep track of the keys in the keymap, let the macro handle it. Add `beginning-of-line' and `end-of-line' key bindings.
-rw-r--r--transient-navigation.el42
1 files changed, 22 insertions, 20 deletions
diff --git a/transient-navigation.el b/transient-navigation.el
index 3e51a78..fb94ad2 100644
--- a/transient-navigation.el
+++ b/transient-navigation.el
@@ -25,27 +25,25 @@
;;; Code:
-(defvar transient-navigation-map
- (let ((map (make-sparse-keymap)))
- (define-key map (kbd "f") #'transient-forward-char)
- (define-key map (kbd "b") #'transient-backward-char)
- (define-key map (kbd "n") #'transient-next-line)
- (define-key map (kbd "p") #'transient-previous-line)
- map))
+(defvar transient-navigation-map (make-sparse-keymap))
-(defmacro transnav-make-transient (func)
- "Wrap FUNC with a transient map."
+(defmacro transnav-make-transient (key map func)
+ "Bind KEY in MAP to FUNC with a transient map."
(let ((funcname (intern (concat "transient-" (symbol-name func)))))
- `(defun ,funcname (&optional n)
- (interactive)
- (ignore n)
- (call-interactively #',func)
- (set-transient-map transient-navigation-map t))))
+ `(progn
+ (defun ,funcname (&optional n)
+ (interactive)
+ (ignore n)
+ (call-interactively #',func)
+ (set-transient-map transient-navigation-map t))
+ (define-key ,map (kbd ,key) #',funcname))))
-(transnav-make-transient forward-char)
-(transnav-make-transient backward-char)
-(transnav-make-transient next-line)
-(transnav-make-transient previous-line)
+(transnav-make-transient "f" transient-navigation-map forward-char)
+(transnav-make-transient "b" transient-navigation-map backward-char)
+(transnav-make-transient "n" transient-navigation-map next-line)
+(transnav-make-transient "p" transient-navigation-map previous-line)
+(transnav-make-transient "e" transient-navigation-map end-of-line)
+(transnav-make-transient "a" transient-navigation-map beginning-of-line)
;;;###autoload
(define-minor-mode transient-navigation-mode
@@ -56,11 +54,15 @@
(define-key global-map [remap forward-char] #'transient-forward-char)
(define-key global-map [remap backward-char] #'transient-backward-char)
(define-key global-map [remap next-line] #'transient-next-line)
- (define-key global-map [remap previous-line] #'transient-previous-line))
+ (define-key global-map [remap previous-line] #'transient-previous-line)
+ (define-key global-map [remap end-of-line] #'transient-end-of-line)
+ (define-key global-map [remap beginning-of-line] #'transient-beginning-of-line))
(define-key global-map [remap transient-forward-char] #'forward-char)
(define-key global-map [remap transient-backward-char] #'backward-char)
(define-key global-map [remap transient-next-line] #'next-line)
- (define-key global-map [remap transient-previous-line] #'previous-line)))
+ (define-key global-map [remap transient-previous-line] #'previous-line)
+ (define-key global-map [remap transient-end-of-line] #'end-of-line)
+ (define-key global-map [remap transient-beginning-of-line] #'beginning-of-line)))
(provide 'transient-navigation)
;;; transient-navigation.el ends here