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: Thu, 06 Dec 2018 01:25:46 +0200 Organization: LINKOV.NET Message-ID: <87a7lj8rmd.fsf@mail.linkov.net> References: <878t18j4is.fsf@mail.linkov.net> <83a7lobemr.fsf@gnu.org> <87a7lnv6ex.fsf@mail.linkov.net> <83pnuj9kb8.fsf@gnu.org> <87bm62npwr.fsf@mail.linkov.net> <83a7llai7v.fsf@gnu.org> <87va4826tz.fsf@mail.linkov.net> <83sgzc8mp0.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1544057714 934 195.159.176.226 (6 Dec 2018 00:55:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 6 Dec 2018 00:55:14 +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 Thu Dec 06 01:55:10 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 1gUhwb-00007Q-Mz for geb-bug-gnu-emacs@m.gmane.org; Thu, 06 Dec 2018 01:55:10 +0100 Original-Received: from localhost ([::1]:38288 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUhyh-00040m-Vv for geb-bug-gnu-emacs@m.gmane.org; Wed, 05 Dec 2018 19:57:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gUhyV-0003yN-OJ for bug-gnu-emacs@gnu.org; Wed, 05 Dec 2018 19:57:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gUhyR-00041F-Ip for bug-gnu-emacs@gnu.org; Wed, 05 Dec 2018 19:57:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58792) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gUhyR-000412-C6 for bug-gnu-emacs@gnu.org; Wed, 05 Dec 2018 19:57:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gUhyR-0004XE-AH for bug-gnu-emacs@gnu.org; Wed, 05 Dec 2018 19:57: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: Thu, 06 Dec 2018 00:57: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.154405781017375 (code B ref 33567); Thu, 06 Dec 2018 00:57:03 +0000 Original-Received: (at 33567) by debbugs.gnu.org; 6 Dec 2018 00:56:50 +0000 Original-Received: from localhost ([127.0.0.1]:34809 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUhyA-0004W8-KE for submit@debbugs.gnu.org; Wed, 05 Dec 2018 19:56:50 -0500 Original-Received: from catfish.maple.relay.mailchannels.net ([23.83.214.32]:1469) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gUhy5-0004Vv-Nl for 33567@debbugs.gnu.org; Wed, 05 Dec 2018 19:56:45 -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 661383E320B; Thu, 6 Dec 2018 00:56:40 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a54.g.dreamhost.com (unknown [100.96.19.74]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id ED03F3E3114; Thu, 6 Dec 2018 00:56:39 +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); Thu, 06 Dec 2018 00:56:40 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Trail-Reign: 763d61904ee59aa8_1544057800224_561714276 X-MC-Loop-Signature: 1544057800224:4127925711 X-MC-Ingress-Time: 1544057800224 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 97D0580077; Wed, 5 Dec 2018 16:56:39 -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=RXFoDimClPTh2ivkET98sJ2z9w4=; b= Je+4tBIx/AoG6160dTcTI3jOMYavmN7OSxh6sxM4mJP2UOB/m6r/+igl3Mwe26tx OOuMeRkYC1nuUa6vKgfQdmdYX4xj5ds0O2fI8OtQ4Z40gX9iMHNi2bGKyepHualu ox1Q3TlQF69MJkVgnkGFBrNCP52ga/8m5xJo2S6HTa4= 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 B795D8007F; Wed, 5 Dec 2018 16:56:33 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a54 In-Reply-To: <83sgzc8mp0.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 05 Dec 2018 09:19:55 +0200") X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: -100 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrudefiedgvdekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufhofhffjgfkfgggtgesthdtredttdertdenucfhrhhomheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqeenucfkphepledurdduvdelrddutdefrdejnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopehmrghilhdrjhhurhhtrgdrohhrghdpihhnvghtpeeluddruddvledruddtfedrjedprhgvthhurhhnqdhprghthheplfhurhhiucfnihhnkhhovhcuoehjuhhriheslhhinhhkohhvrdhnvghtqedpmhgrihhlfhhrohhmpehjuhhriheslhhinhhkohhvrdhnvghtpdhnrhgtphhtthhopegvlhhiiiesghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt 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:153131 Archived-At: >> vc-git-find-revision binds coding-system-for-read to `binary'. > > I see that vc-hg-find-revision does the same. Sigh. I guess the > find-revision API was never meant to process the resulting buffer > normally. My advice would be to reimplement your > vc-find-revision-no-save function differently, without trying to > piggy-back the fact that vc-find-revision inserts the contents into a > buffer. That is, let the code write the contents to a temporary file, > like vc-find-revision does, then call insert-file-contents to re-read > that file normally. It would be slightly less efficient, but I think > the result will be much simpler, so a net win. The whole purpose of creating vc-find-revision-no-save function was to improve the performance of vc-find-revision-save to avoid the need to write files. It would significantly degrade performance of diff syntax fontification if it will write files for every hunk. > If you still want to reuse the literal contents of the file, as > inserted by vc-git-find-revision etc., then you will have to duplicate > what insert-file-contents does internally. I suggest to look at how > this is done in archive-set-buffer-as-visiting-file. I see it does something like I was trying to do. I will use it when failing to use the third possible solution I proposed below. >> > How do you know vc-git-find-revision doesn't have a subtle bug as >> > well, e.g. when file names in the repository are encoded in some >> > non-trivial, non-UTF-8 encoding? >> >> This is why vc-git-find-revision does nothing with its output >> when it binds coding-system-for-read to `binary', >> and doesn't try to encode/decode the git output. > > vc-git-find-revision does _something_ with Git's output: it uses the > file name returned by Git. That file name could have a non-trivial > encoding. I'm thinking about overriding coding in vc-git-find-revision like diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index f317400530..e5f44524df 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -838,8 +838,8 @@ vc-git-checkin (defun vc-git-find-revision (file rev buffer) (let* (process-file-side-effects - (coding-system-for-read 'binary) - (coding-system-for-write 'binary) + (coding-system-for-read (or coding-system-for-read 'binary)) + (coding-system-for-write (or coding-system-for-write 'binary)) (fullname (let ((fn (vc-git--run-command-string file "ls-files" "-z" "--full-name" "--"))) then a caller function could set its own value of this dynamic binding. But I haven't tested yet if it works with UTF-8 file names.