Subject: Re: bug#33567: Syntactic fontification of diff hunks

From: Juri Linkov <[email-masked]>
Date: Thu, 06 Dec 2018 01:35:17 +0200

>> When this special variable is set by a diff command, it's safe to assume
>> that the files referenced from the diff buffer really exist, so it's
>> safe to try reading them.  I don't want a patch in a mail attachment
>> to try reading files mentioned in the patch attachment.
>
> I think you lean heavily towards the use case where the diffs were
> produced by some Emacs command.  Whereas what I have in mind is the
> use case where the diffs came from some other source, like manual
> invocation of shell commands.  I'm saying that in the absence of
> diff-default-directory, using default-directory and 'cd' will be much
> easier for users.

Users still can use all diff-mode commands to visit source files from them.
Only language syntax fontification in diffs will fall back to hunk-only
when a diff buffer is not created by a diff command.  This is to avoid all
possible dangers of automatically visiting files in arbitrary diff buffers.

> The use case I have in mind is that some time passes between the
> generation of the diffs and the time the diffs are visited and
> fontified.  During that time, the working revision could have been
> changed.  Isn't that what this issue is about?  If so, we should
> explain why in that case, rare as it could be, the fontification might
> be wrong.

Fontification can't be wrong because code verifies if hunks from diff
still exist in the updated file, and doesn't highlight changed hunks.