0

I'm having a problem with putting vdiff-refine-all-hunks or ediff-update-diffs into --eval for startup. Take vdiff as example, I'm calling it using:

emacs --eval "(progn (vdiff-files file1 file2) (vdiff-refine-all-hunks))"

Note the functionvdiff-refine-all-hunks here acts just like ediff-update-diffs in ediff, which actually highlights the difference. Without running these two function the diffs are almost plain text.

According to diff-mode: refine all hunks when opening a diff file?, I added function sit-for before vdiff-refine-all-hunks:

emacs --eval "(progn (vdiff-files file1 file2) (sit-for 3) (vdiff-refine-all-hunks))"

Which works. However the loading time of vdiff really differs for different size of file. Setting 3 seconds works for a relatively large files but is too wasteful for two small one.

I do not understand why it takes so much time for ediff/vdiff to warm up, and is there an existing nice way to avoid the problem?

Update:

By using vdiff-auto-refine, it works if put (setq vdiff-auto-refine t) into init.el, or just implement it in eval:

emacs --eval "(progn (setq vdiff-auto-refine t) (vdiff-files file1 file2))

However, known issue is that it is still not working for emacsclient no matter I setq in init or include it in eval:

emacsclient -c --eval "(progn (setq vdiff-auto-refine t) (vdiff-files file1 file2))"

1 Answers1

2

vdiff processes the output of diff asynchronously which takes a nonzero amount of time. Instead of guessing when to run vdiff-refine-all-hunks just set vdiff-auto-refine to t to let vdiff run it at the right time.

If you're having a performance issue, first check how long diff takes on the command line, then see if refining all hunks is slow, and finally report it to me on github if something seems off.

For all of the above ediff does comparable operations in the background explaining the similarities.

justbur
  • 1,500
  • 8
  • 8