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: Tue, 04 Dec 2018 01:59:07 +0200 Organization: LINKOV.NET Message-ID: <875zwajh6c.fsf@mail.linkov.net> References: <878t18j4is.fsf@mail.linkov.net> <83a7lobemr.fsf@gnu.org> <87a7lnv6ex.fsf@mail.linkov.net> <83pnuj9kb8.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1543881955 1883 195.159.176.226 (4 Dec 2018 00:05:55 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 4 Dec 2018 00:05:55 +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 Tue Dec 04 01:05:50 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 1gTyDk-0000Kl-HX for geb-bug-gnu-emacs@m.gmane.org; Tue, 04 Dec 2018 01:05:48 +0100 Original-Received: from localhost ([::1]:53394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTyFq-00053r-WA for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Dec 2018 19:07:59 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTyF3-0004aX-CM for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 19:07:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTyEx-0000a7-Lz for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 19:07:09 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:55342) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gTyEx-0000Z9-3a for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 19:07:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gTyEw-0004r4-O8 for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2018 19:07:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 04 Dec 2018 00:07: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.154388201918646 (code B ref 33567); Tue, 04 Dec 2018 00:07:02 +0000 Original-Received: (at 33567) by debbugs.gnu.org; 4 Dec 2018 00:06:59 +0000 Original-Received: from localhost ([127.0.0.1]:59599 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTyEt-0004qg-9c for submit@debbugs.gnu.org; Mon, 03 Dec 2018 19:06:59 -0500 Original-Received: from ladybird.maple.relay.mailchannels.net ([23.83.214.98]:58358) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gTyEq-0004qW-RK for 33567@debbugs.gnu.org; Mon, 03 Dec 2018 19:06:58 -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 A0D48281FB0; Tue, 4 Dec 2018 00:06:55 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a54.g.dreamhost.com (unknown [100.96.19.78]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 3FA4C282398; Tue, 4 Dec 2018 00:06:55 +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); Tue, 04 Dec 2018 00:06:55 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Zesty-Quick: 708ca8e93611ddd9_1543882015472_3497246257 X-MC-Loop-Signature: 1543882015472:3709555546 X-MC-Ingress-Time: 1543882015471 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 F34007FE19; Mon, 3 Dec 2018 16:06:54 -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=ucJVH2bxzA+ianzQQsG1exV6U6U=; b= FBLAAyZMAfClUSBdt1M6z3MtYga+2M1FYr7SBoT+VFxMaCqPxqIMON+wv0Fu8nH5 bWdJSciRDQLWOUdceSk50+wxo/PienZQiiMVyV+x9bpq9j4Uk/Tlu0R4kYzHQnQp QsWGZOycKltuMaYMTBgd7aiRk3m3IvMwEQ//idg1P1I= 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 80EF07FDBA; Mon, 3 Dec 2018 16:06:34 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a54 In-Reply-To: <83pnuj9kb8.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 03 Dec 2018 08:49:15 +0200") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudefvddgudekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdefrdejnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtfedrjedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegvlhhiiiesghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedv 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:153045 Archived-At: >> 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: "..." -*- >> > 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. >> +(defcustom diff-font-lock-syntax 'vc >> + "If non-nil, diff hunk's font-lock includes language syntax highlighting. >> +This highlighting is the same as added by `font-lock-mode' when >> +corresponding source files are visited from the diff buffer. > > Thanks, this is much better than the original text, but there are > still unclear corners. One such corner is the "visited from the diff > buffer" part -- what is its significance? Can we just say "when the > corresponding source files are visited normally"? Changed, will send a patch with more changes later. >> +In diff hunks syntax highlighting is added over diff own >> +highlighted changes. > > What is the significance of the "In diff hunks" part here? Apart of > diff hunks, we have just headers, where this feature is irrelevant, > right? Removed "In diff hunks". >> +If `vc', highlight syntax only in Diff buffers created by a version control >> +system that provides all necessary context for reliable highlighting. > > I would use "in Diff buffers created by VC commands" instead. I would > also add this text (assuming it is correct): > > This value requires support from a VC backend to find the files > being compared. > > This should tell users that they could in principle set up things > manually even for buffers that were not created by VC commands. Changed. > Please also indicate that `vc' is the default. After adding another safe option that uses `diff-default-directory', we could combine it with `vc' for the safe default. >> +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. >> +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. > 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.