]> code.delx.au - gnu-emacs-elpa/blobdiff - diff-hl-flydiff.el
Prefer using /dev/shm for temporary files
[gnu-emacs-elpa] / diff-hl-flydiff.el
index b464ec6879aeae61f308cf73872476c903b3c9cb..0b7781e91af7df6edd93ece7d93221ad762feea3 100644 (file)
@@ -26,6 +26,7 @@
 ;;; Code:
 
 (require 'diff-hl)
+(require 'nadvice)
 
 (defvar diff-hl-flydiff-modified-tick 0)
 (defvar diff-hl-flydiff-timer)
@@ -108,14 +109,15 @@ This requires the external program `diff' to be in your `exec-path'."
   (interactive)
   (vc-ensure-vc-buffer)
   (with-current-buffer (get-buffer (current-buffer))
-    (let ((rev (diff-hl-flydiff-create-revision
-                 buffer-file-name
-                 (vc-working-revision buffer-file-name
-                   (vc-responsible-backend buffer-file-name))))
-           (temporary-file-directory
-             (if (file-directory-p "/dev/shm/")
-               "/dev/shm/"
-               temporary-file-directory)))
+    (let* ((file buffer-file-name)
+            (temporary-file-directory
+              (if (file-directory-p "/dev/shm/")
+                "/dev/shm/"
+                temporary-file-directory))
+            (rev (diff-hl-flydiff-create-revision
+                   file
+                   (vc-working-revision file
+                     (vc-responsible-backend file)))))
       (diff-no-select rev (current-buffer) "-U 0" 'noasync
         (get-buffer-create " *diff-hl-diff*")))))
 
@@ -170,8 +172,6 @@ This requires the external program `diff' to be in your `exec-path'."
           ((eq state 'removed)
             `((1 ,(line-number-at-pos (point-max)) delete))))))))
 
-(defun diff-hl-flydiff/overlay-modified (&rest args))
-
 ;;;###autoload
 (define-minor-mode diff-hl-flydiff-mode
   "Highlight diffs on-the-fly"
@@ -179,25 +179,17 @@ This requires the external program `diff' to be in your `exec-path'."
   :global t
   (if diff-hl-flydiff-mode
     (progn
-      (require 'nadvice)
-      (advice-add 'diff-hl-update :around
-        #'diff-hl-flydiff/update)
-      (advice-add 'diff-hl-changes :override
-        #'diff-hl-flydiff/changes)
-      (advice-add 'diff-hl-overlay-modified :override
-        #'diff-hl-flydiff/overlay-modified)
-
-      (remove-hook 'after-change-functions #'diff-hl-edit t)
+      (advice-add 'diff-hl-update :around #'diff-hl-flydiff/update)
+      (advice-add 'diff-hl-changes :override #'diff-hl-flydiff/changes)
+      (advice-add 'diff-hl-overlay-modified :override #'ignored)
+
       (setq diff-hl-flydiff-timer
         (run-with-idle-timer 0.3 t #'diff-hl-update t)))
 
     (advice-remove 'diff-hl-update #'diff-hl-flydiff/update)
     (advice-remove 'diff-hl-changes #'diff-hl-flydiff/changes)
-    (advice-remove 'diff-hl-overlay-modified
-      #'diff-hl-flydiff/overlay-modified)
+    (advice-remove 'diff-hl-overlay-modified #'ignored)
 
-    (cancel-timer diff-hl-flydiff-timer)
-    (when diff-hl-mode
-      (add-hook 'after-change-functions 'diff-hl-edit nil t))))
+    (cancel-timer diff-hl-flydiff-timer)))
 
 (provide 'diff-hl-flydiff)