branch: master
commit d6b7d82fb618d9ed59b31de1dc3846776f023fc5
Author: Dmitry Gutov <[email protected]>
Commit: Dmitry Gutov <[email protected]>
Support the "next" Magit version
Closes #41
---
README.md | 2 +-
diff-hl.el | 4 ++++
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/README.md b/README.md
index 325f53e..0f9fe64 100644
--- a/README.md
+++ b/README.md
@@ -87,4 +87,4 @@ Magit
-----
If you have a recent enough version installed, it defines
-`magit-revert-buffer-hook`, which we use.
+`magit-revert-buffer-hook` (or `magit-not-reverted-hook`), which we use.
diff --git a/diff-hl.el b/diff-hl.el
index 22a877a..a3e5447 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -453,6 +453,9 @@ in the source file, or the last line of the hunk above it."
;; doesn't care about changed VC state.
;; https://github.com/magit/magit/issues/603
(add-hook 'magit-revert-buffer-hook 'diff-hl-update nil t)
+ ;; Magit 2+ doesn't do the above and calls this instead,
+ ;; but only when it doesn't call `revert-buffer':
+ (add-hook 'magit-not-reverted-hook 'diff-hl-update nil t)
(add-hook 'auto-revert-mode-hook 'diff-hl-update nil t)
(add-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps nil t))
(remove-hook 'after-save-hook 'diff-hl-update t)
@@ -461,6 +464,7 @@ in the source file, or the last line of the hunk above it."
(remove-hook 'vc-checkin-hook 'diff-hl-update t)
(remove-hook 'after-revert-hook 'diff-hl-update t)
(remove-hook 'magit-revert-buffer-hook 'diff-hl-update t)
+ (remove-hook 'magit-not-reverted-hook 'diff-hl-update t)
(remove-hook 'auto-revert-mode-hook 'diff-hl-update t)
(remove-hook 'text-scale-mode-hook 'diff-hl-define-bitmaps t)
(diff-hl-remove-overlays)))