From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#33567: Syntactic fontification of diff hunks Date: Wed, 05 Dec 2018 01:28:45 +0200 Organization: LINKOV.NET Message-ID: <87k1koygvm.fsf@mail.linkov.net> References: <878t18j4is.fsf@mail.linkov.net> <83a7lobemr.fsf@gnu.org> <87a7lnv6ex.fsf@mail.linkov.net> <83pnuj9kb8.fsf@gnu.org> <875zwajh6c.fsf@mail.linkov.net> <837egpagko.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1543968811 29165 195.159.176.226 (5 Dec 2018 00:13:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 5 Dec 2018 00:13:31 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: 33567@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 05 01:13:27 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 1gUKog-0007Sp-Kc for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Dec 2018 01:13:26 +0100 Original-Received: from localhost ([::1]:59459 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUKqn-0005Os-68 for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Dec 2018 19:15:37 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUKqP-0005I6-FP for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2018 19:15:18 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUKqF-0002JG-To for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2018 19:15:09 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56899) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gUKqF-0002IU-IF for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2018 19:15:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gUKqF-0001sI-Be for bug-gnu-emacs@gnu.org; Tue, 04 Dec 2018 19:15:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Dec 2018 00:15:03 +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.15439688757130 (code B ref 33567); Wed, 05 Dec 2018 00:15:03 +0000 Original-Received: (at 33567) by debbugs.gnu.org; 5 Dec 2018 00:14:35 +0000 Original-Received: from localhost ([127.0.0.1]:32921 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUKpm-0001qv-Lc for submit@debbugs.gnu.org; Tue, 04 Dec 2018 19:14:34 -0500 Original-Received: from common.maple.relay.mailchannels.net ([23.83.214.38]:18998) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUKpk-0001qm-4Y for 33567@debbugs.gnu.org; Tue, 04 Dec 2018 19:14:32 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 0F78A283009; Wed, 5 Dec 2018 00:14:31 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a54.g.dreamhost.com (unknown [100.96.20.98]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id AEFA928389D; Wed, 5 Dec 2018 00:14:30 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a54.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Wed, 05 Dec 2018 00:14:31 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Battle-Shoe: 472c245408275077_1543968870864_3767292175 X-MC-Loop-Signature: 1543968870864:2588285562 X-MC-Ingress-Time: 1543968870864 Original-Received: from pdx1-sub0-mail-a54.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a54.g.dreamhost.com (Postfix) with ESMTP id 47E3C7FF21; Tue, 4 Dec 2018 16:14:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=0JYt1MY6MCzdwVM9bsOZ+fZ1N2c=; b= WZtgH1wg+z4lTqpV+fifSYVaqjvIE5OJrc1nbo3mGtQTT0SwVA17yZsEwj5G8Ezz 3/1fsEOCfzPGEeXUf/XD/cUt2KywOXM0if3DJeSJ1JOWoV7orHUnOC/si0SNUevY XHKFiSdhnq1eZF3C0yM58bZJMCSWje2MFvvTXxEhwZE= Original-Received: from mail.jurta.org (m91-129-103-7.cust.tele2.ee [91.129.103.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a54.g.dreamhost.com (Postfix) with ESMTPSA id F35E77FF22; Tue, 4 Dec 2018 16:14:28 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a54 In-Reply-To: <837egpagko.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 04 Dec 2018 09:36:55 +0200") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudefgedgudelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdefrdejnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtfedrjedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegvlhhiiiesghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedv 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:153090 Archived-At: >> 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"? 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. >> >> > 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. Yes, it finds only the existing files inside the repository. >> >> +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. Such problem is very rare because highlighting is added usually immediately after creating a diff. When the file contents changes, there is no highlighting at all - it verifies if text of the hunk exist in the file, so highlighting never is 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. Will add in the final patch. >> > 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. Maybe then better to add text common for all cases, e.g. "If some method fails, get fontification from hunk alone."