1
0
mirror of https://github.com/m00natic/vlfi.git synced 2025-01-31 02:00:47 +00:00

Reuse initial ediff session for all chunks.

This commit is contained in:
Andrey Kotlarski 2014-01-15 02:17:33 +02:00
parent 117935db98
commit 27e3bbb320

View File

@ -59,7 +59,11 @@ respectively of difference list, runs ediff over the adjacent chunks."
(setq buffer-B (current-buffer)) (setq buffer-B (current-buffer))
(setq vlf-batch-size vlf-size)) (setq vlf-batch-size vlf-size))
(vlf-beginning-of-file) (vlf-beginning-of-file)
(vlf-ediff-next buffer-A buffer-B 'vlf-next-chunk)) (vlf-ediff-next buffer-A buffer-B 'vlf-next-chunk)
(ediff-buffers buffer-A buffer-B
'((lambda () (setq vlf-ediff-session t)
(if (< 0 ediff-number-of-differences)
(ediff-jump-to-difference 1))))))
;;;###autoload ;;;###autoload
(defun vlf-ediff-files (file-A file-B batch-size) (defun vlf-ediff-files (file-A file-B batch-size)
@ -107,7 +111,7 @@ respectively of difference list, runs ediff over the adjacent chunks."
(vlf-move-to-chunk new-start (+ new-start vlf-batch-size) t))) (vlf-move-to-chunk new-start (+ new-start vlf-batch-size) t)))
(defun vlf-ediff-next (buffer-A buffer-B &optional next-func) (defun vlf-ediff-next (buffer-A buffer-B &optional next-func)
"Activate ediff over the next difference in BUFFER-A and BUFFER-B. "Find next pair of chunks that differ in BUFFER-A and BUFFER-B.
NEXT-FUNC is used to jump to the next logical chunks in case there is NEXT-FUNC is used to jump to the next logical chunks in case there is
no difference at the current ones." no difference at the current ones."
(set-buffer buffer-A) (set-buffer buffer-A)
@ -118,8 +122,8 @@ no difference at the current ones."
(min-file-size vlf-file-size) (min-file-size vlf-file-size)
(is-forward (eq next-func 'vlf-next-chunk))) (is-forward (eq next-func 'vlf-next-chunk)))
(set-buffer buffer-B) (set-buffer buffer-B)
(setq buffer-B (current-buffer)) (setq buffer-B (current-buffer)
(setq min-file-size (min min-file-size vlf-file-size)) min-file-size (min min-file-size vlf-file-size))
(let ((end-B (= vlf-start-pos vlf-end-pos)) (let ((end-B (= vlf-start-pos vlf-end-pos))
(reporter (make-progress-reporter (reporter (make-progress-reporter
"Searching for difference..." "Searching for difference..."
@ -154,44 +158,45 @@ no difference at the current ones."
max-file-size))) max-file-size)))
(t (vlf-beginning-of-file) (t (vlf-beginning-of-file)
(set-buffer buffer-A) (set-buffer buffer-A)
(vlf-beginning-of-file)))) (vlf-beginning-of-file))))))
(ediff-buffers buffer-A buffer-B
`((lambda () (setq vlf-ediff-session t)
(if (< 0 ediff-number-of-differences)
(ediff-jump-to-difference
,(if is-forward 1 -1))))))))
(defadvice ediff-next-difference (around vlf-ediff-next-difference (defadvice ediff-next-difference (around vlf-ediff-next-difference
compile activate) compile activate)
"Quit ediff session, move to the next VLF chunk and search for\ "Move to the next VLF chunk and search for difference if at the end\
difference if at the end of difference list." of difference list."
(if (and vlf-ediff-session (if (and vlf-ediff-session
(<= (1- ediff-number-of-differences) (<= (1- ediff-number-of-differences)
ediff-current-difference)) ediff-current-difference))
(let ((buffer-A ediff-buffer-A) (let ((buffer-A ediff-buffer-A)
(buffer-B ediff-buffer-B)) (buffer-B ediff-buffer-B))
(ediff-really-quit nil) (save-excursion
(set-buffer buffer-A) (set-buffer buffer-A)
(vlf-next-chunk) (vlf-next-chunk)
(set-buffer buffer-B) (set-buffer buffer-B)
(vlf-next-chunk) (vlf-next-chunk)
(vlf-ediff-next buffer-A buffer-B 'vlf-next-chunk)) (vlf-ediff-next buffer-A buffer-B 'vlf-next-chunk))
(ediff-update-diffs)
(if (< 0 ediff-number-of-differences)
(ediff-jump-to-difference 1)))
ad-do-it)) ad-do-it))
(defadvice ediff-previous-difference (around vlf-ediff-prev-difference (defadvice ediff-previous-difference (around vlf-ediff-prev-difference
compile activate) compile activate)
"Quit ediff session, move to the previous VLF chunk and search for\ "Move to the previous VLF chunk and search for difference if at the\
difference if at the beginning of difference list." beginning of difference list."
(if (and vlf-ediff-session (if (and vlf-ediff-session
(<= ediff-current-difference 0)) (<= ediff-current-difference 0))
(let ((buffer-A ediff-buffer-A) (let ((buffer-A ediff-buffer-A)
(buffer-B ediff-buffer-B)) (buffer-B ediff-buffer-B))
(ediff-really-quit nil) (save-excursion
(set-buffer buffer-A) (set-buffer buffer-A)
(vlf-prev-chunk) (vlf-prev-chunk)
(set-buffer buffer-B) (set-buffer buffer-B)
(vlf-prev-chunk) (vlf-prev-chunk)
(vlf-ediff-next buffer-A buffer-B 'vlf-prev-chunk)) (vlf-ediff-next buffer-A buffer-B 'vlf-prev-chunk))
(ediff-update-diffs)
(if (< 0 ediff-number-of-differences)
(ediff-jump-to-difference -1)))
ad-do-it)) ad-do-it))
(provide 'vlf-ediff) (provide 'vlf-ediff)