]> code.delx.au - gnu-emacs-elpa/blobdiff - diff-hl-flydiff.el
Add diff-hl-dired-ignored-backends
[gnu-emacs-elpa] / diff-hl-flydiff.el
index e5a6111f45d66fd49653719da2deccf389f7b774..94dbbd7f6d9e89f68536d9a37ccd86884d18e3b3 100644 (file)
@@ -1,4 +1,4 @@
-;; Copyright (C) 2015 Free Software Foundation, Inc.
+;; Copyright (C) 2015, 2016 Free Software Foundation, Inc.
 
 ;; Author:   Jonathan Hayase <PythonNut@gmail.com>
 ;; URL:      https://github.com/dgutov/diff-hl
@@ -125,7 +125,7 @@ This requires the external program `diff' to be in your `exec-path'."
   (interactive)
   (vc-ensure-vc-buffer)
   (setq diff-hl-flydiff-modified-tick (buffer-modified-tick))
-  (with-current-buffer (get-buffer (current-buffer))
+  (save-current-buffer
     (let* ((temporary-file-directory
             (if (file-directory-p "/dev/shm/")
                 "/dev/shm/"
@@ -136,12 +136,12 @@ This requires the external program `diff' to be in your `exec-path'."
       (diff-no-select rev (current-buffer) "-U 0 --strip-trailing-cr" 'noasync
                       (get-buffer-create " *diff-hl-diff*")))))
 
-(defun diff-hl-flydiff/update (old-fun &optional auto)
-  (unless (and auto
-               (or
-                (= diff-hl-flydiff-modified-tick (buffer-modified-tick))
-                (file-remote-p default-directory)))
-    (funcall old-fun)))
+(defun diff-hl-flydiff-update ()
+  (unless (or
+           (not diff-hl-mode)
+           (= diff-hl-flydiff-modified-tick (buffer-modified-tick))
+           (file-remote-p default-directory))
+    (diff-hl-update)))
 
 (defun diff-hl-flydiff/modified-p (state)
   (buffer-modified-p))
@@ -153,7 +153,6 @@ This requires the external program `diff' to be in your `exec-path'."
   :global t
   (if diff-hl-flydiff-mode
       (progn
-        (advice-add 'diff-hl-update :around #'diff-hl-flydiff/update)
         (advice-add 'diff-hl-overlay-modified :override #'ignore)
 
         (advice-add 'diff-hl-modified-p :before-until
@@ -161,9 +160,8 @@ This requires the external program `diff' to be in your `exec-path'."
         (advice-add 'diff-hl-changes-buffer :override
                     #'diff-hl-flydiff-buffer-with-head)
         (setq diff-hl-flydiff-timer
-              (run-with-idle-timer diff-hl-flydiff-delay t #'diff-hl-update t)))
+              (run-with-idle-timer diff-hl-flydiff-delay t #'diff-hl-flydiff-update)))
 
-    (advice-remove 'diff-hl-update #'diff-hl-flydiff/update)
     (advice-remove 'diff-hl-overlay-modified #'ignore)
 
     (advice-remove 'diff-hl-modified-p #'diff-hl-flydiff/modified-p)