Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Diff could also show the changes within lines

Received: by 10.66.81.129 with SMTP id a1mr1181500pay.30.1352903512116;
        Wed, 14 Nov 2012 06:31:52 -0800 (PST)
Path: s9ni11150pbb.0!nntp.google.com!news.glorb.com!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From: "Sebastien Vauban" <wxhgmqzgw...@spammotel.com>
Newsgroups: gnu.emacs.help
Subject: Re: Diff could also show the changes within lines
Date: Wed, 14 Nov 2012 15:31:51 +0100
Organization: Sebastien Vauban
Lines: 82
Message-ID: <80vcd8l0h4.fsf@somewhere.org>
References: <loom.20121005T163605-672@post.gmane.org>
	<87txu9arc8.fsf@gmail.com> <loom.20121005T165541-721@post.gmane.org>
	<loom.20121005T182234-640@post.gmane.org>
	<mailman.10388.1349460693.855.help-gnu-emacs@gnu.org>
	<80d2zlvnos.fsf@somewhere.org>
	<mailman.12687.1352561429.855.help-gnu-emacs@gnu.org>
Mime-Version: 1.0
Injection-Info: mx04.eternal-september.org; posting-host="368fa3c7dc5c1bbe516391bd65bd1ab2";
	logging-data="12321"; mail-complaints-to="ab...@eternal-september.org";	posting-account="U2FsdGVkX1/hUT4B0qoqqWyl+8FlPXF2"
User-Agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.50 (windows-nt)
X-Archive: encrypt
Cancel-Lock: sha1:QgkpgAmzGa/kuwYjiBRygAw5ZyY=
	sha1:ipq4ApqZgst591Wb2jQqe/izIlQ=
X-Url: Under construction...
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hi Tom,

Tom wrote:
> Sebastien Vauban <wxhgmqzgwmuf@...> writes:
>> I'd like to get that feature as well. However, the above code causes me
>> 2=C2=A0problems:
>>=20
>> - 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;
>
> Currently I use this code added to the diff mode hook:
>
> (defun my-refine-all-diff-hunks ()
>   (interactive)
>   (condition-case nil=20=20=20=20=20=20
>       (save-excursion
>         (goto-char (point-min))
>         (while (not (eobp))
>           (diff-hunk-next)))
>     (error nil)))
>
> It works well for me, it highlights the changes in all hunks automaticall=
y.
> I use it only for diffing before checkin.
>
> But. It works only because the VC mercurial implementation calls the back=
end
> synchronously. In case of DVC it doesn't work for me, because DVC calls t=
he
> backend asynchronously, so when the diff hook is run the output is not th=
ere
> yet and I did not find a hook which is called when the async diff command=
 is
> finished
>
> You may want to check how the diff output is produced in your use cases. =
If
> it is done asynchronously then the diff hook is not a suitable place to c=
all
> the highlighting code from.

I'm not sure how to check for that, but I could reduce all my `.emacs' file=
 to
an example file which shows the problem on the current development snapshot=
 of
the future Emacs 24.3 (from 2012-10-22):

--8<---------------cut here---------------start------------->8---
;;; emacs-minimal.el

(setenv "LC_ALL" "C")

;; enable Diff Auto Refine mode (highlight the changes with better
;; granularity)
(defun my/diff-refine-all-hunks ()
  (interactive)
  (condition-case nil
      (save-excursion
        (goto-char (point-min))
        (while (not (eobp))
          (diff-hunk-next)))
    (error nil)))

(add-hook 'diff-mode-hook
          'my/diff-refine-all-hunks)

(message "%s" (emacs-version))
(sit-for 1)
--8<---------------cut here---------------end--------------->8---

You can see, in the screencast on http://screencast.com/t/JOlsyWHh, that:

- the cursor goes to the end of the diff

- only the last diff is refined (see the string " for Diff" which should be
  highlighted in the first hunk)

Best regards,
  Seb

--=20
Sebastien Vauban