emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 7ea8159 16/42: Define diff-hl-command-map without destroyi


From: Dmitry Gutov
Subject: [elpa] master 7ea8159 16/42: Define diff-hl-command-map without destroying existing bindings
Date: Wed, 09 Sep 2015 19:03:33 +0000

branch: master
commit 7ea8159acb41adb743342bcab9d8a2efa50868b9
Author: Jonas Bernoulli <address@hidden>
Commit: Jonas Bernoulli <address@hidden>

    Define diff-hl-command-map without destroying existing bindings
    
    Keymaps are usually defined using `defvar' which has the advantage that
    it only sets a variables value if that is not defined yet.  As a result
    re-evaluating (i.e. during development) a buffer that contains such a
    definition does not reset the value, which would lose all user
    customization.
    
    Unfortunately `define-prefix-command' does not do that.  So use `defvar'
    to define the variable and then also store the in the function cell
    using `fset'.
---
 diff-hl.el |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/diff-hl.el b/diff-hl.el
index 8f2221a..18b92c7 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -437,13 +437,13 @@ in the source file, or the last line of the hunk above 
it."
   (interactive)
   (diff-hl-next-hunk t))
 
-(define-prefix-command 'diff-hl-command-map)
-
-(let ((map diff-hl-command-map))
-  (define-key map "n" 'diff-hl-revert-hunk)
-  (define-key map "[" 'diff-hl-previous-hunk)
-  (define-key map "]" 'diff-hl-next-hunk)
-  map)
+(defvar diff-hl-command-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "n" 'diff-hl-revert-hunk)
+    (define-key map "[" 'diff-hl-previous-hunk)
+    (define-key map "]" 'diff-hl-next-hunk)
+    map))
+(fset 'diff-hl-command-map diff-hl-command-map)
 
 ;;;###autoload
 (define-minor-mode diff-hl-mode



reply via email to

[Prev in Thread] Current Thread [Next in Thread]