From d6b7d82fb618d9ed59b31de1dc3846776f023fc5 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 4 Apr 2015 19:01:13 +0300 Subject: [PATCH] Support the "next" Magit version Closes #41 --- README.md | 2 +- diff-hl.el | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 325f53ea5..0f9fe6481 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 22a877a64..a3e5447f6 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))) -- 2.39.2