help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Diff could also show the changes within lines


From: Sebastien Vauban
Subject: Re: Diff could also show the changes within lines
Date: Sat, 10 Nov 2012 09:58:59 +0100
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (windows-nt)

Hello Tom, Stefan and all,

Tom wrote:
> Tom <adatgyujto <at> gmail.com> writes:
>>
>>     (diff-auto-refine-mode 1)
>
> Turns out it only refines one hunk (the current) and the others only if you
> use hunk navigation commands (diff-auto-refine-mode does this which is on by
> default in Emacs 24). So to refine all hunks automatically, do this in the
> diff hook:
>
>   (save-excursion
>     (goto-char (point-min))
>     (while (not (eobp))
>       (diff-hunk-next))))

I'd like to get that feature as well. However, the above code causes me
2 problems:

- only the last hunk is getting refined, both in VC dir's buffer, or when
  reading (with Gnus) an email with a patch file in it;

- occasionally, an error message "no hunk found" when reading an email with a
  patch file in it.

I patched your code to try and avoid those problems, by:

- adding a condition-case nil... error construct
- using save-excursion
- using an explicit goto-char min
- ...

Here is my current code:

--8<---------------cut here---------------start------------->8---
  ;; enable Diff Auto Refine mode (highlight the changes with better
  ;; granularity)
  (add-hook 'diff-mode-hook
            (lambda ()
              ;; refine all hunks automatically
              (when (>= (diff-end-of-hunk) 1)
                ;; avoid "No hunk found" error
                (goto-char (point-min))
                (while (not (eobp))
                  (diff-hunk-next)))
              (goto-char (point-min))))
--8<---------------cut here---------------end--------------->8---

... but that does not help...

I still have the two above mentioned problems...

Any idea?

Best regards,
  Seb

--
Sebastien Vauban


reply via email to

[Prev in Thread] Current Thread [Next in Thread]