diff-refine-hunk function to refine the highlighting of the current hunk. However, by default, only
diff-hunk-next or explicit
diff-refine-hunk calls will do this job -- hunks will not be refined by default. I wrote the following snippet to refine all hunks when I enter
(defun my-diff-hunks-highlight-all () "Highlight all hunks in diff-mode." (interactive) (save-excursion (goto-char (point-min)) (let ((last-point)) (while (not (equal (point) last-point)) (setq last-point (point)) (diff-refine-hunk) (diff-hunk-next))))) (add-hook 'diff-mode-hook 'my-diff-hunks-highlight-all)
However, it turns out that only the last hunk will be refined. Is there any reason that this approach fails? What should be the proper way to do it?
Related Emacs bug: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=18128