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

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

[elpa] externals/diff-hl a625033 10/25: Update Magit bridge to use the r


From: Dmitry Gutov
Subject: [elpa] externals/diff-hl a625033 10/25: Update Magit bridge to use the recommended approach
Date: Sun, 20 Dec 2020 05:07:01 -0500 (EST)

branch: externals/diff-hl
commit a625033fb1dde83f6e4c2fc21f632b22ec34b609
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>

    Update Magit bridge to use the recommended approach
    
    Fixes #136
---
 README.md  |  1 +
 diff-hl.el | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index de07ffe..9bc4576 100644
--- a/README.md
+++ b/README.md
@@ -114,5 +114,6 @@ If you're using a version before 2.4.0, it defines 
`magit-revert-buffer-hook`
 When using Magit 2.4 or newer, add this to your init script:
 
 ```lisp
+(add-hook 'magit-pre-refresh-hook 'diff-hl-magit-pre-refresh)
 (add-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh)
 ```
diff --git a/diff-hl.el b/diff-hl.el
index d30c0a9..f504ddf 100644
--- a/diff-hl.el
+++ b/diff-hl.el
@@ -581,12 +581,22 @@ The value of this variable is a mode line template as in
 (declare-function magit-toplevel "magit-git")
 (declare-function magit-unstaged-files "magit-git")
 
+(defvar diff-hl--magit-unstaged-files nil)
+
+(defun diff-hl-magit-pre-refresh ()
+  (setq diff-hl--magit-unstaged-files (magit-unstaged-files t)))
+
 (defun diff-hl-magit-post-refresh ()
   (let* ((topdir (magit-toplevel))
          (modified-files
           (mapcar (lambda (file) (expand-file-name file topdir))
-                  (magit-unstaged-files t)))
+                  (delete-consecutive-dups
+                   (sort
+                    (nconc (magit-unstaged-files t)
+                           diff-hl--magit-unstaged-files)
+                    #'string<))))
          (unmodified-states '(up-to-date ignored unregistered)))
+    (setq diff-hl--magit-unstaged-files nil)
     (dolist (buf (buffer-list))
       (when (and (buffer-local-value 'diff-hl-mode buf)
                  (not (buffer-modified-p buf))



reply via email to

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