From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#33567: Syntactic fontification of diff hunks Date: Tue, 04 Dec 2018 09:36:55 +0200 Message-ID: <837egpagko.fsf@gnu.org> References: <878t18j4is.fsf@mail.linkov.net> <83a7lobemr.fsf@gnu.org> <87a7lnv6ex.fsf@mail.linkov.net> <83pnuj9kb8.fsf@gnu.org> <875zwajh6c.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1543909181 3521 195.159.176.226 (4 Dec 2018 07:39:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Dec 2018 07:39:41 +0000 (UTC) Cc: 33567@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 04 08:39:37 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gU5Is-0000lg-GY for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Dec 2018 08:39:34 +0100 Original-Received: from localhost ([::1]:54345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gU5Kz-0005Do-3w for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Dec 2018 02:41:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gU5Hh-0001p1-3C for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2018 02:38:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gU5Hb-0002mQ-9D for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2018 02:38:20 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55490) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gU5HP-0002Yl-SL for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2018 02:38:07 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gU5HO-0002Zk-E5 for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2018 02:38:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Dec 2018 07:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33567 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 33567-submit@debbugs.gnu.org id=B33567.15439090359842 (code B ref 33567); Tue, 04 Dec 2018 07:38:02 +0000 Original-Received: (at 33567) by debbugs.gnu.org; 4 Dec 2018 07:37:15 +0000 Original-Received: from localhost ([127.0.0.1]:59748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gU5Gd-0002Yg-F6 for submit@debbugs.gnu.org; Tue, 04 Dec 2018 02:37:15 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:36969) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gU5Gb-0002YS-U6 for 33567@debbugs.gnu.org; Tue, 04 Dec 2018 02:37:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gU5GS-0000pf-S6 for 33567@debbugs.gnu.org; Tue, 04 Dec 2018 02:37:08 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:47736) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gU5GS-0000pS-OC; Tue, 04 Dec 2018 02:37:04 -0500 Original-Received: from [176.228.60.248] (port=4286 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gU5GQ-0006a9-Cy; Tue, 04 Dec 2018 02:37:03 -0500 In-reply-to: <875zwajh6c.fsf@mail.linkov.net> (message from Juri Linkov on Tue, 04 Dec 2018 01:59:07 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:153057 Archived-At: > From: Juri Linkov > 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.