From: Eli Zaretskii <eliz@gnu.org>
To: Juri Linkov <juri@linkov.net>
Cc: 33567@debbugs.gnu.org
Subject: bug#33567: Syntactic fontification of diff hunks
Date: Tue, 04 Dec 2018 09:36:55 +0200 [thread overview]
Message-ID: <837egpagko.fsf@gnu.org> (raw)
In-Reply-To: <875zwajh6c.fsf@mail.linkov.net> (message from Juri Linkov on Tue, 04 Dec 2018 01:59:07 +0200)
> From: Juri Linkov <juri@linkov.net>
> Cc: 33567@debbugs.gnu.org
> Date: Tue, 04 Dec 2018 01:59:07 +0200
>
> >> As a general solution is should be possible to specify the default
> >> directory in the local variables at the first line of the diff files
> >> as currently already is used in compilation/grep buffers like
> >>
> >> -*- mode: diff-mode; default-directory: "..." -*-
> >
> > This is all fine, but I think we should document that files are
> > visited relative to default-directory of the buffer, so that users
> > could invoke "cd" to change that as needed.
>
> For more safety, I propose to set a new buffer-local variable
> `diff-default-directory' by such commands as diff, diff-backup,
> dired-diff, dired-backup-diff. The existence of such variable
> should guarantee that the referenced files really exist.
> This variable will be like `diff-vc-backend' that says that
> the diff-mode buffer is created by the VCS command.
> Then anyone who want to visit a diff file in another directory,
> could add it to the first line:
>
> -*- mode: diff-mode; diff-default-directory: "..." -*-
I'm not sure this is a step in the right direction. What is the
advantage of having a separate variable? How is it "safer"?
The advantage of default-directory is that it is well-known, and the
command to change it, 'cd', is easier to type and invoke than setting
diff-default-directory manually.
>
> >> > Also, if the diffs are from Git, they begin with a/, b/, etc. dummy
> >> > directories, which usually don't exist in the file system.
> >>
> >> This is not a problem because diff-find-file-name used in the patch
> >> strips such a/, b/ prefixes to get the existing file name.
> >
> > Not in my testing, but maybe I tried in the wrong Emacs version. Is
> > this feature new with Emacs 27?
>
> For testing better try to eval e.g. `(diff-find-file-name nil t)'
> on a hunk in a diff-mode buffer created by git.
I did, but I guess this must be done inside the repository to work,
does it? If I put the output of "git diff" on a file in some
arbitrary directory, then visit that file and evaluate
(diff-find-file-name nil t), I get nil.
> >> +For working revisions get highlighting according to the working
> >> +copy of the file.
> >
> > I don't understand the significance of this comment. If you want to
> > say that the produced highlighting might be wrong if the working
> > version has changed since it was compared, then let's say that
> > explicitly.
>
> This means that working revisions can't be extracted from the repository.
> Until committed, they reside in files that are visited with find-file.
We need to describe the implications of that to the users. Does the
following text capture the issue?
For diffs against the working-tree version of a file, the
highlighting is based on the current file contents, which could be
different from the contents when the diffs were taken. In such
cases, the produced highlighting might be wrong.
> >> +If t, additionally to trying to use a version control system to get
> >> +old revisions for fontification, also try to get fontification based
> >> +on existing files, and on failure get fontification from hunk alone."
> >
> > What is the difference between using a VCS to get old revisions, and
> > using existing files?
>
> This means that when a diff-mode buffer is not created by a VCS,
> then it tries to read files with find-file.
If so, I suggest the following wording:
If t, try to infer fontification from the compared files, if they
exist in the filesystem, when accessing their contents via VC
fails.
> > Also, does it mean `vc' will not fall back to `hunk-only'? Why not?
>
> Actually, it already falls back to `hunk-only', this is what
> "on failure get fontification from hunk alone." tries to say.
There's no such text in the description of 'vc', only in the
description of t, which is why I asked.
next prev parent reply other threads:[~2018-12-04 7:36 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-01 21:55 bug#33567: Syntactic fontification of diff hunks Juri Linkov
2018-12-02 6:56 ` Eli Zaretskii
2018-12-03 0:34 ` Juri Linkov
2018-12-03 6:49 ` Eli Zaretskii
2018-12-03 23:36 ` Juri Linkov
2018-12-04 7:01 ` Eli Zaretskii
2018-12-04 23:16 ` Juri Linkov
2018-12-05 7:19 ` Eli Zaretskii
2018-12-05 23:25 ` Juri Linkov
2018-12-06 6:53 ` Eli Zaretskii
2018-12-11 0:38 ` Juri Linkov
2018-12-11 6:23 ` Eli Zaretskii
2018-12-12 0:28 ` Juri Linkov
2018-12-12 17:11 ` Eli Zaretskii
2018-12-03 23:59 ` Juri Linkov
2018-12-04 7:36 ` Eli Zaretskii [this message]
2018-12-04 23:28 ` Juri Linkov
2018-12-05 7:25 ` Eli Zaretskii
2018-12-05 23:35 ` Juri Linkov
2018-12-12 23:17 ` Juri Linkov
2018-12-14 9:13 ` Eli Zaretskii
2018-12-16 23:27 ` Juri Linkov
2018-12-17 16:13 ` Eli Zaretskii
2018-12-17 23:11 ` Juri Linkov
2018-12-18 0:14 ` Juri Linkov
2018-12-18 15:55 ` Dmitry Gutov
2018-12-18 22:35 ` Juri Linkov
2018-12-18 23:33 ` Dmitry Gutov
2018-12-19 0:11 ` Juri Linkov
2018-12-19 0:48 ` Dmitry Gutov
2018-12-19 1:35 ` Dmitry Gutov
2018-12-19 21:49 ` Juri Linkov
2018-12-19 22:50 ` Dmitry Gutov
2018-12-20 22:00 ` Juri Linkov
2018-12-24 2:29 ` Dmitry Gutov
2018-12-25 20:35 ` Juri Linkov
2018-12-25 21:15 ` Dmitry Gutov
2018-12-26 22:49 ` Juri Linkov
2018-12-26 23:16 ` Dmitry Gutov
2018-12-27 0:18 ` Juri Linkov
2018-12-27 0:45 ` Dmitry Gutov
2018-12-27 3:34 ` Eli Zaretskii
2018-12-27 3:32 ` Eli Zaretskii
2018-12-19 21:51 ` Juri Linkov
2018-12-20 0:11 ` Dmitry Gutov
2018-12-20 21:50 ` Juri Linkov
2018-12-20 1:15 ` Dmitry Gutov
2018-12-20 22:17 ` Juri Linkov
2018-12-25 20:39 ` Juri Linkov
2018-12-26 1:40 ` Dmitry Gutov
2018-12-26 22:59 ` Juri Linkov
2018-12-26 23:56 ` Dmitry Gutov
2018-12-27 20:39 ` Juri Linkov
2018-12-29 23:07 ` Juri Linkov
2018-12-30 23:07 ` Dmitry Gutov
2018-12-26 0:43 ` Dmitry Gutov
2018-12-03 11:24 ` Dmitry Gutov
2018-12-03 23:24 ` Juri Linkov
2018-12-04 0:20 ` Dmitry Gutov
2018-12-04 6:46 ` Eli Zaretskii
2018-12-04 22:58 ` Juri Linkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=837egpagko.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=33567@debbugs.gnu.org \
--cc=juri@linkov.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.