branch: externals/diff-hl
commit 39b8455c299e923da41a80f697c2f419c216d51a
Author: Dmitry Gutov <dgu...@yandex.ru>
Commit: Dmitry Gutov <dgu...@yandex.ru>

    Fold diff-hl-show-hunk-mode into the "main" mode
---
 README.md            |  2 +-
 diff-hl-show-hunk.el | 47 +++++++----------------------------------------
 diff-hl.el           |  4 ++++
 3 files changed, 12 insertions(+), 41 deletions(-)

diff --git a/README.md b/README.md
index 277e9c5..54eb6ca 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,7 @@ The package also contains auxiliary modes:
 * `diff-hl-flydiff-mode` implements highlighting changes on the fly.
 * `diff-hl-show-hunk-mouse-mode` makes fringe and margin react to
   mouse clicks to show the curresponding hunk. That's the alternative
-  to using the `diff-hl-show-hunk` family of commands.
+  to using `diff-hl-show-hunk` and friends.
 
 Usage
 =====
diff --git a/diff-hl-show-hunk.el b/diff-hl-show-hunk.el
index 8935044..6e23c77 100644
--- a/diff-hl-show-hunk.el
+++ b/diff-hl-show-hunk.el
@@ -21,28 +21,16 @@
 
 ;;; Commentary:
 
-;; `diff-hl-show-hunk' shows a popup with the modified hunk at point.
-;; `diff-hl-show-hunk-function' contains the backend used to show the
+;; `diff-hl-show-hunk' shows a popup with the modification hunk at point.
+;; `diff-hl-show-hunk-function' points to the backend used to show the
 ;; hunk.  Its default value is `diff-hl-show-hunk-inline-popup', that
 ;; shows diffs inline using overlay.  There is another built-in backend:
-;; `diff-hl-show-hunk-posframe' (based on posframe).  Other backends (for
-;; example based on `pos-tip') could also be implemented.
+;; `diff-hl-show-hunk-posframe' (based on posframe).
 ;;
-;; `diff-hl-show-hunk-mode' adds the following keybindings:
+;; `diff-hl-show-hunk-mouse-mode' adds interaction on clicking in the
+;; margin or the fringe (shows the current hunk as well).
 ;;
-;;   - `diff-hl-show-hunk': C-x v *
-;;   - `diff-hl-show-hunk-next': C-x v }
-;;   - `diff-hl-show-hunk-previous': C-x v {
-;;
-;; `diff-hl-show-hunk-mouse-mode' includes all the keybindings of
-;; `diff-hl-show-hunk-mode', and adds `diff-hl-show-hunk' when
-;; clicking in the margin or the fringe.
-;;
-;; To use one or both in all buffers:
-;;
-;;   (global-diff-hl-show-hunk-mode)
-;;
-;; and/or
+;; To use it in all buffers:
 ;;
 ;;   (global-diff-hl-show-hunk-mouse-mode)
 
@@ -51,21 +39,12 @@
 (require 'diff-hl-inline-popup)
 (require 'diff-hl)
 
-(defvar diff-hl-show-hunk-mode-map
-  (let ((map (make-sparse-keymap)))
-    (define-key map (concat diff-hl-command-prefix  "*") #'diff-hl-show-hunk)
-    (define-key map (concat diff-hl-command-prefix  "{") 
#'diff-hl-show-hunk-previous)
-    (define-key map (concat diff-hl-command-prefix  "}") 
#'diff-hl-show-hunk-next)
-    map)
-  "Keymap for command `diff-hl-show-hunk-mode'.")
-
 (defvar diff-hl-show-hunk-mouse-mode-map
   (let ((map (make-sparse-keymap)))
     (define-key map (kbd "<left-margin> <mouse-1>") 'diff-hl-show-hunk--click)
     (define-key map (kbd "<right-margin> <mouse-1>") 'diff-hl-show-hunk--click)
     (define-key map (kbd "<left-fringe> <mouse-1>") 'diff-hl-show-hunk--click)
     (define-key map (kbd "<right-fringe> <mouse-1>") 'diff-hl-show-hunk--click)
-    (set-keymap-parent map diff-hl-show-hunk-mode-map)
     map)
   "Keymap for command `diff-hl-show-hunk-mouse-mode'.")
 
@@ -409,7 +388,7 @@ The backend is determined by `diff-hl-show-hunk-function'."
 ;;;###autoload
 (define-minor-mode diff-hl-show-hunk-mouse-mode
   "Enables the margin and fringe to show a posframe/popup with vc diffs when 
clicked.
-By default, the posframe/popup shows only the current hunk, and
+By default, the popup shows only the current hunk, and
 the line of the hunk that matches the current position is
 highlighted.  The face, border and other visual preferences are
 customizable.  It can be also invoked with the command
@@ -423,17 +402,5 @@ customizable.  It can be also invoked with the command
   diff-hl-show-hunk-mouse-mode
   diff-hl-show-hunk-mouse-mode)
 
-;;;###autoload
-(define-minor-mode diff-hl-show-hunk-mode
-  "Enables a keymap with some commands of the `diff-hl-show-hunk' package
-\\{diff-hl-show-hunk-mode-map}"
-  :group 'diff-hl-show-hunk
-  :lighter "")
-
-;;;###autoload
-(define-globalized-minor-mode global-diff-hl-show-hunk-mode
-  diff-hl-show-hunk-mode
-  diff-hl-show-hunk-mode)
-
 (provide 'diff-hl-show-hunk)
 ;;; diff-hl-show-hunk.el ends here
diff --git a/diff-hl.el b/diff-hl.el
index d05e91e..dcedb95 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -35,6 +35,7 @@
 ;; `diff-hl-revert-hunk'     C-x v n
 ;; `diff-hl-previous-hunk'   C-x v [
 ;; `diff-hl-next-hunk'       C-x v ]
+;; `diff-hl-show-hunk'       C-x v *
 ;; `diff-hl-set-reference-rev'
 ;; `diff-hl-reset-reference-rev'
 ;;
@@ -603,6 +604,9 @@ in the source file, or the last line of the hunk above it."
     (define-key map "n" 'diff-hl-revert-hunk)
     (define-key map "[" 'diff-hl-previous-hunk)
     (define-key map "]" 'diff-hl-next-hunk)
+    (define-key map "*" 'diff-hl-show-hunk)
+    (define-key map "{" 'diff-hl-show-hunk-previous)
+    (define-key map "}" 'diff-hl-show-hunk-next)
     map))
 (fset 'diff-hl-command-map diff-hl-command-map)
 

Reply via email to