]> code.delx.au - gnu-emacs-elpa/commitdiff
Make prefix keys customizable
authorDmitry Gutov <dgutov@yandex.ru>
Wed, 12 Feb 2014 00:33:04 +0000 (02:33 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Wed, 12 Feb 2014 00:33:04 +0000 (02:33 +0200)
Closes #17

diff-hl.el

index 056d300ca766828212c4ec0bd0e88355ba3001ed..0494c0fd1ad5ac97b8963a893cef8133e4339d8f 100644 (file)
@@ -1,11 +1,11 @@
 ;;; diff-hl.el --- Highlight uncommitted changes -*- lexical-binding: t -*-\r
 \r
-;; Copyright (C) 2012-2013  Free Software Foundation, Inc.\r
+;; Copyright (C) 2012-2014  Free Software Foundation, Inc.\r
 \r
 ;; Author:   Dmitry Gutov <dgutov@yandex.ru>\r
 ;; URL:      https://github.com/dgutov/diff-hl\r
 ;; Keywords: vc, diff\r
-;; Version:  1.5.1\r
+;; Version:  1.5.2\r
 ;; Package-Requires: ((cl-lib "0.2"))\r
 \r
 ;; This file is part of GNU Emacs.\r
@@ -89,6 +89,9 @@
   '((default :inherit diff-header))\r
   "Face used to highlight unregistered files.")\r
 \r
+(defconst diff-hl-command-prefix (kbd "C-x v")\r
+  "The prefix for all `diff-hl' commands.")\r
+\r
 (defcustom diff-hl-draw-borders t\r
   "Non-nil to draw borders around fringe indicators."\r
   :group 'diff-hl\r
@@ -401,13 +404,19 @@ in the source file, or the last line of the hunk above it."
   (interactive)\r
   (diff-hl-next-hunk t))\r
 \r
+(define-prefix-command 'diff-hl-command-map)\r
+\r
+(let ((map diff-hl-command-map))\r
+  (define-key map "n" 'diff-hl-revert-hunk)\r
+  (define-key map "[" 'diff-hl-previous-hunk)\r
+  (define-key map "]" 'diff-hl-next-hunk)\r
+  map)\r
+\r
 ;;;###autoload\r
 (define-minor-mode diff-hl-mode\r
   "Toggle VC diff highlighting."\r
   :lighter "" :keymap `(([remap vc-diff] . diff-hl-diff-goto-hunk)\r
-                        (,(kbd "C-x v n") . diff-hl-revert-hunk)\r
-                        (,(kbd "C-x v [") . diff-hl-previous-hunk)\r
-                        (,(kbd "C-x v ]") . diff-hl-next-hunk))\r
+                        (,diff-hl-command-prefix . diff-hl-command-map))\r
   (if diff-hl-mode\r
       (progn\r
         (diff-hl-maybe-define-bitmaps)\r
@@ -437,8 +446,8 @@ in the source file, or the last line of the hunk above it."
                            (when (characterp event)\r
                              (push (cons (string event) binding) smart-keys))))\r
                        map)))\r
-      (scan diff-hl-mode-map)\r
-      (smartrep-define-key diff-hl-mode-map "C-x v" smart-keys))))\r
+      (scan diff-hl-command-map)\r
+      (smartrep-define-key diff-hl-mode-map diff-hl-command-prefix smart-keys))))\r
 \r
 (defun diff-hl-dir-update ()\r
   (dolist (pair (if (vc-dir-marked-files)\r