[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] scratch/add-vdiff e171b7c 140/258: Depend on hydra
From: |
Justin Burkett |
Subject: |
[elpa] scratch/add-vdiff e171b7c 140/258: Depend on hydra |
Date: |
Wed, 17 May 2017 08:13:39 -0400 (EDT) |
branch: scratch/add-vdiff
commit e171b7c06d24bf75f80904583a7979a84d39556d
Author: justbur <address@hidden>
Commit: justbur <address@hidden>
Depend on hydra
It's useful enough to warrant a hard dependency
Fixes #11
---
README.org | 22 ++++++-------
vdiff.el | 104 +++++++++++++++++++++++++++----------------------------------
2 files changed, 57 insertions(+), 69 deletions(-)
diff --git a/README.org b/README.org
index 48ec131..4cbe9c2 100644
--- a/README.org
+++ b/README.org
@@ -45,13 +45,13 @@ the commands would be
*** Basics
-| Key | Command | Description
|
-|---------+------------------------------------+-------------------------------------|
-| =C-c g= | =vdiff-switch-buffer= | Switch buffers at matching
line |
-| =C-c n= | =vdiff-next-hunk= | Move to next hunk in buffer
|
-| =C-c p= | =vdiff-previous-hunk= | Move to previous hunk in
buffer |
-| =C-c h= | =vdiff-maybe-hydra= | Enter vdiff-hydra if defined
|
-| =C-l= | =vdiff-sync-and-center= | Recenter both buffers at this
line |
+| Key | Command | Description |
+|---------+-------------------------+------------------------------------|
+| =C-c g= | =vdiff-switch-buffer= | Switch buffers at matching line |
+| =C-c n= | =vdiff-next-hunk= | Move to next hunk in buffer |
+| =C-c p= | =vdiff-previous-hunk= | Move to previous hunk in buffer |
+| =C-c h= | =vdiff-hydra/body= | Enter vdiff-hydra |
+| =C-l= | =vdiff-sync-and-center= | Recenter both buffers at this line |
*** Viewing and Transmitting Changes Between Buffers
@@ -107,11 +107,11 @@ prefix in normal state.
To start vdiff, use either =vdiff-files= to select two files or =vdiff-buffers=
to select two open buffers.
-** Hydra (optional)
+** Hydra
-If the [[https://github.com/abo-abo/hydra][hydra package]] is loaded,
=vdiff-hydra= is defined to allow quick movement
-and changes to be made in the buffer. By default it lives on the =h= command in
-the prefix map. Bind =vdiff-maybe-hydra= directly to customize this.
+Using the [[https://github.com/abo-abo/hydra][hydra package]], =vdiff-hydra=
allows quick movement and changes to be
+made in the buffer. By default it lives on the =h= command in the prefix
+map. Bind =vdiff-hydra/body= directly to customize this key binding.
[[file:img/hydra.png]]
diff --git a/vdiff.el b/vdiff.el
index df41f51..aa2ccef 100644
--- a/vdiff.el
+++ b/vdiff.el
@@ -6,7 +6,7 @@
;; URL: https://github.com/justbur/emacs-vdiff
;; Version: 0.1
;; Keywords: diff
-;; Package-Requires: ((emacs "24.4"))
+;; Package-Requires: ((emacs "24.4") (hydra "0.13.0"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -52,6 +52,7 @@
(require 'cl-lib)
(require 'subr-x)
(require 'diff-mode)
+(require 'hydra)
(defgroup vdiff nil
"Diff tool that is like vimdiff"
@@ -1349,7 +1350,7 @@ asked to select two buffers."
(define-key map "f" 'vdiff-refine-this-hunk)
(define-key map "F" 'vdiff-refine-all-hunks)
(define-key map "g" 'vdiff-switch-buffer)
- (define-key map "h" 'vdiff-maybe-hydra)
+ (define-key map "h" 'vdiff-hydra/body)
(define-key map "ic" 'vdiff-toggle-case)
(define-key map "iw" 'vdiff-toggle-whitespace)
(define-key map "n" 'vdiff-next-hunk)
@@ -1417,74 +1418,61 @@ enabled automatically if `vdiff-lock-scrolling' is
non-nil."
(remove-hook 'window-scroll-functions #'vdiff--scroll-function t))
(message "Scrolling unlocked"))))
-(defun vdiff--define-hydra ()
- "Define `vdiff-hydra'"
- (defun vdiff--current-case ()
- (if (string= "" vdiff--case-args) "off" "on (-i)"))
-
- (defun vdiff--current-whitespace ()
- (pcase vdiff--whitespace-args
- ("" "off")
- ("-w" "all (-w)")
- ("-b" "space changes (-b)")
- ("-B" "blank lines (-B)")))
-
- (defhydra vdiff-toggle-hydra (nil nil :hint nil)
- (concat (propertize
- "\
+(defun vdiff--current-case ()
+ (if (string= "" vdiff--case-args) "off" "on (-i)"))
+
+(defun vdiff--current-whitespace ()
+ (pcase vdiff--whitespace-args
+ ("" "off")
+ ("-w" "all (-w)")
+ ("-b" "space changes (-b)")
+ ("-B" "blank lines (-B)")))
+
+(defhydra vdiff-toggle-hydra (nil nil :hint nil)
+ (concat (propertize
+ "\
Toggles"
- 'face 'header-line)
- "
+ 'face 'header-line)
+ "
_c_ ignore case (current: %s(vdiff--current-case))
_w_ ignore whitespace (current: %s(vdiff--current-whitespace))
_q_ back to main hydra")
- ("c" vdiff-toggle-case)
- ("w" vdiff-toggle-whitespace)
- ("q" vdiff-hydra/body :exit t))
+ ("c" vdiff-toggle-case)
+ ("w" vdiff-toggle-whitespace)
+ ("q" vdiff-hydra/body :exit t))
- (defhydra vdiff-hydra (nil nil :hint nil :foreign-keys run)
- (concat (propertize
- "\
+(defhydra vdiff-hydra (nil nil :hint nil :foreign-keys run)
+ (concat (propertize
+ "\
Navigation^^^^ Refine^^ Transmit^^ Folds^^^^
Other^^^^ "
- 'face 'header-line)
- "
+ 'face 'header-line)
+ "
_n_/_N_ next hunk/fold _f_ this _s_ send _o_/_O_ open (all) _i_ ^ ^
toggles
_p_/_P_ prev hunk/fold _F_ all _r_ receive _c_/_C_ close (all) _u_ ^ ^
update diff
_g_^ ^ switch buffers _x_ clear ^ ^ _t_ ^ ^ close other _w_ ^ ^
save buffers
^ ^^ ^ ^ ^ ^ ^ ^ ^ ^ ^ _q_/_Q_
quit hydra/vdiff
ignore case: %s(vdiff--current-case) | ignore whitespace:
%s(vdiff--current-whitespace)")
- ("n" vdiff-next-hunk)
- ("p" vdiff-previous-hunk)
- ("N" vdiff-next-fold)
- ("P" vdiff-previous-fold)
- ("g" vdiff-switch-buffer)
- ("s" vdiff-send-changes)
- ("r" vdiff-receive-changes)
- ("o" vdiff-open-fold)
- ("O" vdiff-open-all-folds)
- ("c" vdiff-close-fold)
- ("C" vdiff-close-all-folds)
- ("t" vdiff-close-other-folds)
- ("u" vdiff-refresh)
- ("w" vdiff-save-buffers)
- ("f" vdiff-refine-this-hunk)
- ("F" vdiff-refine-all-hunks)
- ("x" vdiff-remove-refinements-in-hunk)
- ("i" vdiff-toggle-hydra/body :exit t)
- ("q" nil :exit t)
- ("Q" vdiff-quit :exit t)))
-
-(defun vdiff-maybe-hydra ()
- "Call `vdiff-hydra/body' if defined."
- (interactive)
- (cond ((fboundp 'vdiff-hydra/body)
- (call-interactively 'vdiff-hydra/body))
- ((require 'hydra nil t)
- (vdiff--define-hydra)
- (call-interactively 'vdiff-hydra/body))
- (t
- (message "hydra package not found."))))
+ ("n" vdiff-next-hunk)
+ ("p" vdiff-previous-hunk)
+ ("N" vdiff-next-fold)
+ ("P" vdiff-previous-fold)
+ ("g" vdiff-switch-buffer)
+ ("s" vdiff-send-changes)
+ ("r" vdiff-receive-changes)
+ ("o" vdiff-open-fold)
+ ("O" vdiff-open-all-folds)
+ ("c" vdiff-close-fold)
+ ("C" vdiff-close-all-folds)
+ ("t" vdiff-close-other-folds)
+ ("u" vdiff-refresh)
+ ("w" vdiff-save-buffers)
+ ("f" vdiff-refine-this-hunk)
+ ("F" vdiff-refine-all-hunks)
+ ("x" vdiff-remove-refinements-in-hunk)
+ ("i" vdiff-toggle-hydra/body :exit t)
+ ("q" nil :exit t)
+ ("Q" vdiff-quit :exit t))
(provide 'vdiff)
;;; vdiff.el ends here
- [elpa] scratch/add-vdiff f915562 047/258: Use customizable function to format closed fold strings, (continued)
- [elpa] scratch/add-vdiff f915562 047/258: Use customizable function to format closed fold strings, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff d8a4efb 023/258: Remove unused variable, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 23b3360 030/258: Fix compiler warnings, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff eeede0b 045/258: Reset open-fold-face, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 96258b1 046/258: Don't set open fold face, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff dc7a5e2 049/258: Add a comment on line-map structure, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff e9d0cc7 050/258: Define new bitmaps for open and close of folds, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 1c8dd1e 138/258: Default to nil for auto refinement, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 3d0678f 142/258: Make bitmaps nicer, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 53ee239 149/258: Fix bug in receive changes for 3way, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff e171b7c 140/258: Depend on hydra,
Justin Burkett <=
- [elpa] scratch/add-vdiff baed24a 148/258: Work on moving refresh to 3way, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 74ebab6 143/258: Don't move point when closing all folds, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 938cc55 155/258: Fix use of delq (wanted remq), Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 0cbaf6f 156/258: Fix point jumping after receive-changes, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 8f7a212 157/258: Remove with-other-window and sync-line, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff c2627f0 160/258: Fix recenter-all, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 78071df 147/258: Use a separate minor-mode for 3way, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff a373c6b 139/258: Fix line endings in README, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 7bc7f40 172/258: Add recent changes, Justin Burkett, 2017/05/17
- [elpa] scratch/add-vdiff 8842469 184/258: Allow point to leave overlay on target selection, Justin Burkett, 2017/05/17