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: Fri, 14 Dec 2018 11:13:48 +0200 Message-ID: <834lbgh3n7.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> <837egpagko.fsf@gnu.org> <87k1koygvm.fsf@mail.linkov.net> <83r2ew8mfx.fsf@gnu.org> <87va475y1m.fsf@mail.linkov.net> <87mupafi73.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1544778856 2963 195.159.176.226 (14 Dec 2018 09:14:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 14 Dec 2018 09:14:16 +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 Fri Dec 14 10:14:11 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 1gXjXv-0000fa-Hb for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Dec 2018 10:14:11 +0100 Original-Received: from localhost ([::1]:60395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXja2-0008C8-5d for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Dec 2018 04:16:22 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXjYp-0007YJ-BN for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2018 04:15:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXjYk-0001IA-FD for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2018 04:15:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43044) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXjYk-0001I3-BI for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2018 04:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gXjYk-0006eg-3u for bug-gnu-emacs@gnu.org; Fri, 14 Dec 2018 04:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Dec 2018 09:15: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.154477884525502 (code B ref 33567); Fri, 14 Dec 2018 09:15:02 +0000 Original-Received: (at 33567) by debbugs.gnu.org; 14 Dec 2018 09:14:05 +0000 Original-Received: from localhost ([127.0.0.1]:47302 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gXjXn-0006dE-2Q for submit@debbugs.gnu.org; Fri, 14 Dec 2018 04:14:03 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:52759) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gXjXk-0006cc-Kp for 33567@debbugs.gnu.org; Fri, 14 Dec 2018 04:14:01 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXjXa-0008Qh-MU for 33567@debbugs.gnu.org; Fri, 14 Dec 2018 04:13:55 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:55587) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXjXa-0008QI-Gg; Fri, 14 Dec 2018 04:13:50 -0500 Original-Received: from [176.228.60.248] (port=4829 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1gXjXa-0001wa-3g; Fri, 14 Dec 2018 04:13:50 -0500 In-reply-to: <87mupafi73.fsf@mail.linkov.net> (message from Juri Linkov on Thu, 13 Dec 2018 01:17:52 +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:153440 Archived-At: > From: Juri Linkov > Cc: 33567@debbugs.gnu.org > Date: Thu, 13 Dec 2018 01:17:52 +0200 > > Here is a more less final version that I tested on many different diffs: Thanks, I have a few minor comments, mainly to the documentation parts. > diff --git a/etc/NEWS b/etc/NEWS > index decc5e3954..1024e9e9f5 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -273,6 +273,8 @@ To disable it, set the new defcustom 'diff-font-lock-refine' to nil. > *** File headers can be shortened, mimicking Magit's diff format > To enable it, set the new defcustom 'diff-font-lock-prettify to t. > > +*** Source language syntax is highlighted in diff hunks when 'diff-font-lock-syntax' is t. This line is too long, suggest to rephrase: *** Better syntax highlighting of Diff hunks. Fragments of source in Diff hunks are now by default highlighted according to the appropriate major mode. Customize the new option 'diff-font-lock-syntax' to nil to disable this. > +@vindex diff-font-lock-syntax > + If non-nil, diff hunk font-lock includes source language syntax highlighting. "nil" should be in @code. > diff --git a/lisp/vc/diff.el b/lisp/vc/diff.el > index ac94586cac..93fa54b1fb 100644 > --- a/lisp/vc/diff.el > +++ b/lisp/vc/diff.el > @@ -165,6 +167,7 @@ diff-no-select > (lambda (_ignore-auto _noconfirm) > (diff-no-select old new switches no-async (current-buffer)))) > (setq default-directory thisdir) > + (set (make-local-variable 'diff-default-directory) default-directory) Any reason not to use setq-local? > +(defun diff--font-lock-syntax (max) > + "Syntax highlighting from font-lock." Although an internal function, could it have a slightly more detailed do string, please? > +(defun diff-syntax-fontify-hunk (beg end old) > + "Highlight source language syntax in diff hunks." This is for a single hunk, not "hunks", right? Also, please mention the arguments in the doc string. > +(defun diff-syntax-fontify-props (file text line-nb &optional no-init hunk-only) > + "Get font-lock properties from the source code." Please mention the arguments ion the doc string.