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

Add progress reporter when searching for difference.

This commit is contained in:
Andrey Kotlarski 2014-01-14 01:11:59 +02:00
parent 38e8f6c4e1
commit 117935db98

View File

@ -99,12 +99,12 @@ respectively of difference list, runs ediff over the adjacent chunks."
(defun vlf-next-chunk () (defun vlf-next-chunk ()
"Move to next chunk." "Move to next chunk."
(let ((new-start (+ vlf-start-pos vlf-batch-size))) (let ((new-start (+ vlf-start-pos vlf-batch-size)))
(vlf-move-to-chunk new-start (+ new-start vlf-batch-size)))) (vlf-move-to-chunk new-start (+ new-start vlf-batch-size) t)))
(defun vlf-prev-chunk () (defun vlf-prev-chunk ()
"Move to previous chunk." "Move to previous chunk."
(let ((new-start (- vlf-start-pos vlf-batch-size))) (let ((new-start (- vlf-start-pos vlf-batch-size)))
(vlf-move-to-chunk new-start (+ new-start vlf-batch-size)))) (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. "Activate ediff over the next difference in BUFFER-A and BUFFER-B.
@ -114,10 +114,18 @@ no difference at the current ones."
(setq buffer-A (current-buffer)) ;names change, so reference by buffer object (setq buffer-A (current-buffer)) ;names change, so reference by buffer object
(let ((end-A (= vlf-start-pos vlf-end-pos)) (let ((end-A (= vlf-start-pos vlf-end-pos))
(content (buffer-substring-no-properties (point-min) (content (buffer-substring-no-properties (point-min)
(point-max)))) (point-max)))
(min-file-size vlf-file-size)
(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))
(let ((end-B (= vlf-start-pos vlf-end-pos))) (setq min-file-size (min min-file-size vlf-file-size))
(let ((end-B (= vlf-start-pos vlf-end-pos))
(reporter (make-progress-reporter
"Searching for difference..."
(if is-forward vlf-start-pos
(- min-file-size vlf-end-pos))
min-file-size)))
(while (and (or (not end-A) (not end-B)) (while (and (or (not end-A) (not end-B))
(equal content (buffer-substring-no-properties (equal content (buffer-substring-no-properties
(point-min) (point-max)))) (point-min) (point-max))))
@ -127,27 +135,31 @@ no difference at the current ones."
(funcall next-func) (funcall next-func)
(setq content (buffer-substring-no-properties (point-min) (setq content (buffer-substring-no-properties (point-min)
(point-max)) (point-max))
end-A (= vlf-start-pos vlf-end-pos)))) end-A (= vlf-start-pos vlf-end-pos)))
(when (and end-A end-B) (progress-reporter-update reporter
(message "No (more) differences") (if is-forward vlf-end-pos
(set-buffer buffer-A) (- vlf-file-size vlf-start-pos))))
(if (eq next-func 'vlf-next-chunk) (progress-reporter-done reporter)
(let ((max-file-size vlf-file-size)) (cond ((or (not end-A) (not end-B))
(with-current-buffer buffer-B (vlf-update-buffer-name)
(setq max-file-size (max max-file-size vlf-file-size)) (set-buffer buffer-A)
(vlf-move-to-chunk (- max-file-size vlf-batch-size) (vlf-update-buffer-name))
max-file-size)) (is-forward ;end of both files
(vlf-move-to-chunk (- max-file-size vlf-batch-size) (let ((max-file-size vlf-file-size))
max-file-size)) (with-current-buffer buffer-A
(vlf-beginning-of-file) (setq max-file-size (max max-file-size vlf-file-size))
(set-buffer buffer-B) (vlf-move-to-chunk (- max-file-size vlf-batch-size)
(vlf-beginning-of-file)))) max-file-size))
(vlf-move-to-chunk (- max-file-size vlf-batch-size)
max-file-size)))
(t (vlf-beginning-of-file)
(set-buffer buffer-A)
(vlf-beginning-of-file))))
(ediff-buffers buffer-A buffer-B (ediff-buffers buffer-A buffer-B
`((lambda () (setq vlf-ediff-session t) `((lambda () (setq vlf-ediff-session t)
(if (< 0 ediff-number-of-differences) (if (< 0 ediff-number-of-differences)
(ediff-jump-to-difference (ediff-jump-to-difference
,(if (eq next-func 'vlf-next-chunk) 1 ,(if is-forward 1 -1))))))))
-1))))))))
(defadvice ediff-next-difference (around vlf-ediff-next-difference (defadvice ediff-next-difference (around vlf-ediff-next-difference
compile activate) compile activate)