]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/vlf/vlf-ediff.el
Merge commit 'ed44aa9bcebcc055551a2d018db9080ee0e9866f'
[gnu-emacs-elpa] / packages / vlf / vlf-ediff.el
index 51c8aecc1b8c2bc3e002d9b3d782fe43e3a9c436..ef9d5c7d95dca09824eccbd3b31e4a53ca5ea46a 100644 (file)
@@ -1,4 +1,4 @@
-;;; vlf-ediff.el --- VLF ediff functionality
+;;; vlf-ediff.el --- VLF ediff functionality  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2014 Free Software Foundation, Inc.
 
@@ -34,7 +34,6 @@
   "If non nil, specifies that ediff is done over VLF buffers.")
 (make-variable-buffer-local 'vlf-ediff-session)
 
-;;;###autoload
 (defun vlf-ediff-buffers (buffer-A buffer-B)
   "Run batch by batch ediff over VLF buffers BUFFER-A and BUFFER-B.
 Batch size is determined by the size in BUFFER-A.
@@ -93,10 +92,10 @@ respectively of difference list, runs ediff over the adjacent chunks."
                                       dir-B)))
                                    (ediff-get-default-file-name f 1)))
            (read-number "Batch size (in bytes): " vlf-batch-size))))
-  (let ((buffer-A (vlf file-A)))
+  (let ((buffer-A (vlf file-A t)))
     (set-buffer buffer-A)
     (vlf-set-batch-size batch-size)
-    (let ((buffer-B (vlf file-B)))
+    (let ((buffer-B (vlf file-B t)))
       (vlf-ediff-buffers buffer-A buffer-B))))
 
 (defadvice ediff-next-difference (around vlf-ediff-next-difference
@@ -154,18 +153,23 @@ beginning of difference list."
 governed by EDIFF-BUFFER.  NEXT-FUNC is used to jump to the next
 logical chunks in case there is no difference at the current ones."
   (set-buffer buffer-A)
+  (run-hook-with-args 'vlf-before-batch-functions 'ediff)
   (setq buffer-A (current-buffer)) ;names change, so reference by buffer object
   (let ((end-A (= vlf-start-pos vlf-end-pos))
         (chunk-A (cons vlf-start-pos vlf-end-pos))
         (point-max-A (point-max))
         (font-lock-A font-lock-mode)
         (min-file-size vlf-file-size)
-        (forward-p (eq next-func 'vlf-next-chunk)))
+        (forward-p (eq next-func 'vlf-next-chunk))
+        (is-hexl (derived-mode-p 'hexl-mode)))
     (font-lock-mode 0)
     (set-buffer buffer-B)
+    (run-hook-with-args 'vlf-before-batch-functions 'ediff)
     (setq buffer-B (current-buffer)
-          min-file-size (min min-file-size vlf-file-size))
-    (let ((tramp-verbose (min 2 tramp-verbose))
+          min-file-size (min min-file-size vlf-file-size)
+          is-hexl (or is-hexl (derived-mode-p 'hexl-mode)))
+    (let ((tramp-verbose (if (boundp 'tramp-verbose)
+                             (min tramp-verbose 2)))
           (end-B (= vlf-start-pos vlf-end-pos))
           (chunk-B (cons vlf-start-pos vlf-end-pos))
           (font-lock-B font-lock-mode)
@@ -184,7 +188,7 @@ logical chunks in case there is no difference at the current ones."
                                     buffer-B (point-min) (point-max)))
                             (with-current-buffer ediff-buffer
                               (ediff-update-diffs)
-                              (and (not end-A) (not end-B)
+                              (and (not end-A) (not end-B) (not is-hexl)
                                    (vlf-ediff-refine buffer-A
                                                      buffer-B))
                               (zerop ediff-number-of-differences))))
@@ -218,16 +222,11 @@ logical chunks in case there is no difference at the current ones."
                 (vlf-beginning-of-file))
               (set-buffer ediff-buffer)
               (ediff-update-diffs)
-              (if (or (not forward-p)
-                      (and (not end-A) (not end-B)))
-                  (vlf-ediff-refine buffer-A buffer-B)))
+              (or is-hexl
+                  (if (or (not forward-p)
+                          (and (not end-A) (not end-B)))
+                      (vlf-ediff-refine buffer-A buffer-B))))
             (setq done t))
-        (when font-lock-A
-          (set-buffer buffer-A)
-          (font-lock-mode 1))
-        (when font-lock-B
-          (set-buffer buffer-B)
-          (font-lock-mode 1))
         (unless done
           (set-buffer buffer-A)
           (set-buffer-modified-p nil)
@@ -237,7 +236,14 @@ logical chunks in case there is no difference at the current ones."
           (vlf-move-to-chunk (car chunk-B) (cdr chunk-B))
           (set-buffer ediff-buffer)
           (ediff-update-diffs)
-          (vlf-ediff-refine buffer-A buffer-B))))))
+          (or is-hexl
+              (vlf-ediff-refine buffer-A buffer-B)))
+        (set-buffer buffer-A)
+        (if font-lock-A (font-lock-mode 1))
+        (run-hook-with-args 'vlf-after-batch-functions 'ediff)
+        (set-buffer buffer-B)
+        (if font-lock-B (font-lock-mode 1))
+        (run-hook-with-args 'vlf-after-batch-functions 'ediff)))))
 
 (defun vlf-ediff-refine (buffer-A buffer-B)
   "Try to minimize differences between BUFFER-A and BUFFER-B.