From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: HaiJun Zhang Newsgroups: gmane.emacs.devel Subject: Re: Using incremental parsing in Emacs Date: Mon, 6 Jan 2020 13:55:02 +0800 Message-ID: References: <83blrkj1o1.fsf@gnu.org> <20200105141900.GA71296@breton.holly.idiocy.org> <83eewdg3vy.fsf@gnu.org> <834kx9g08y.fsf@gnu.org> <83v9ppdzed.fsf@gnu.org> <5CFA58D6-8A85-4636-AB0E-1548D235D681@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="5e12cbbc_235ba861_b145" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="147052"; mail-complaints-to="usenet@blaine.gmane.org" Cc: alan@idiocy.org, monnier@iro.umontreal.ca To: emacs-devel@gnu.org, arthur miller , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 06 06:55:36 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ioLMV-000c47-88 for ged-emacs-devel@m.gmane.org; Mon, 06 Jan 2020 06:55:35 +0100 Original-Received: from localhost ([::1]:48466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioLMS-0007G3-8T for ged-emacs-devel@m.gmane.org; Mon, 06 Jan 2020 00:55:33 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49714) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioLMI-0007D8-Pw for emacs-devel@gnu.org; Mon, 06 Jan 2020 00:55:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ioLMG-00076T-MV for emacs-devel@gnu.org; Mon, 06 Jan 2020 00:55:22 -0500 Original-Received: from mail-oln040092253026.outbound.protection.outlook.com ([40.92.253.26]:42475 helo=APC01-SG2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ioLMF-000723-PH; Mon, 06 Jan 2020 00:55:20 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NxxzbdPwRd7roBRJpF8WucNyaTVC0BPYfP8D+73nlviJ8AuQidjRAUHlXwYUmdNJ8rmaDb/W47RLxD779InWhVbSE46eXml1i9pyykWuoRYVKRqbniyuXlXF0q+01gbaYJlB4vVZJ+1AkAS0Ixqt54mPk4ostIJzX5RrVJkOPALKC5DCelT+mFE9mSNUoaa3ZhiomnVxgDu38uo2JV7hNpOuJvbU+PlVSI2lf0OKz3+DgQZ/Kf0oP1gLIXOqcO7lXhj498FytF9KNFgLQM+0AOTUK3tRufuGLX8w9eHuGBrpUERixcI6o+uxu5O3y4fm+VmWRl8naBZF2e6hkWOJ4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kicxh9+/nHvNpYUqv4zkC1+VEqcjZI+9GmwBmCSncYw=; b=YRydI5e+JwON2lh9Wl6NZPfSARAdVb28WHkEkCHM1NdomIkaR3o59YMv68DXr6EfnobmUv3tPf59Y8uZjyGrrDvAp3kvZhdtFBtWQ0bpol8qaXU3BwFz2ae2jc3xArlJ8FPom7sn2j6a9AJROiE7u3IVoomouzVAeWEVNNnFmSZ0rbNowYbydcVIw5AVrWDXLz7LkiNr1CEZnGNEG9RVAZpHxiznHxoXTagGJN+M5/GC1Bq1UD26o23m0C13UKe1hzKl1GabtMVGvLJjPbYwPZl3de3Tka5y/oHVzCwQq0XyjZ65QFoGBGyTAJ4t3erHv7ZWHQMTYgFuHYvGyv9Ctg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=outlook.com; dmarc=pass action=none header.from=outlook.com; dkim=pass header.d=outlook.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kicxh9+/nHvNpYUqv4zkC1+VEqcjZI+9GmwBmCSncYw=; b=EhoPOXcqmjgz9cpHCoUhj6KebQqyQ/C6jQFuf/KNshu7QyJDz1cNyYJA0IdrjNg6xIvfygwhqUJVXi3n2KN186RFSoof+WnuC59YsHEGfedVpCWoDoDsgwXReIt8XW5h3TkHFF6BV7aXl7DZ0oVHcwXJlWiFIqdUAIsFMwZ7L6rnZfv4Vkqqq1Fsp2Ze8OBFgMeG6AM8mKHwUrEszKjy8UuQk+XlDy7sY8lHMjSuxu6roKHpdd6EpNkqMxLBOP0HtXlLsTrgwErDEhV0/bD95iFS1n1yPi4r2LTNaQJI08uCeSbeTiIZTaM+DZzDSwV5IA4tr5YmLCn+QVpVWHDabA== Original-Received: from SG2APC01FT008.eop-APC01.prod.protection.outlook.com (10.152.250.58) by SG2APC01HT014.eop-APC01.prod.protection.outlook.com (10.152.250.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11; Mon, 6 Jan 2020 05:55:14 +0000 Original-Received: from PS1PR03MB3606.apcprd03.prod.outlook.com (10.152.250.59) by SG2APC01FT008.mail.protection.outlook.com (10.152.250.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.11 via Frontend Transport; Mon, 6 Jan 2020 05:55:14 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:DAC5C777AF2E66795762C22E850C10AD5AC268F4E32ECA860F4F0D0300E3153E; UpperCasedChecksum:CBBC00BDFEB1A0FFFCAAD7E0D117429837F474ADC07962234FECD6FFFE833754; SizeAsReceived:9260; Count:48 Original-Received: from PS1PR03MB3606.apcprd03.prod.outlook.com ([fe80::b470:80bc:efed:9117]) by PS1PR03MB3606.apcprd03.prod.outlook.com ([fe80::b470:80bc:efed:9117%7]) with mapi id 15.20.2623.008; Mon, 6 Jan 2020 05:55:14 +0000 In-Reply-To: <5CFA58D6-8A85-4636-AB0E-1548D235D681@gnu.org> X-Readdle-Message-ID: ac7f144c-77d3-4991-aeeb-cbecb695e04e@Spark X-ClientProxiedBy: HK2PR04CA0068.apcprd04.prod.outlook.com (2603:1096:202:15::12) To PS1PR03MB3606.apcprd03.prod.outlook.com (2603:1096:803:4e::17) X-Microsoft-Original-Message-ID: Original-Received: from [192.168.1.103] (1.199.245.197) by HK2PR04CA0068.apcprd04.prod.outlook.com (2603:1096:202:15::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12 via Frontend Transport; Mon, 6 Jan 2020 05:55:12 +0000 X-Readdle-Message-ID: ac7f144c-77d3-4991-aeeb-cbecb695e04e@Spark X-Microsoft-Original-Message-ID: X-TMN: [l7DucngByYP6OLQ+TP2FcX6nkGTaeKQR] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 13240dbd-2340-4867-bb9a-08d7926cffd0 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/ULD3VaDn2jKBvx0wkr11YTFf4dJtJY2VekhuYED3hC2prDqpM5HQPxn59OTAO3HPBPPbHK8T9sm0WtP4GpIp5ikaEhyRr3uCdq0K/Ji36JUYEPV80MXvHdYd/82qET38BxOloJxK1+GTabhHQBRoH20QLxi1f/0lelmGMUczbQmkbanDUMSOmU/qGfNfBy2N1kFc9gNop81zHtinp5h802ZLR2mEsoHJuxnyB8vBZFIT/1KutK8yWzisTX4sCXRdnT1Koh/ynrCkz7TlfzwGBRu8cZKz/ZSgPEQHqJe1A3yBTCfCwq/5KIuRBrMMYaeWrfLgNcRG27PY8VLpKM6iq8dfTSLYy/QwzSDY69UISvkCQV4RSFkjZU41mwOeJWEOQKXG2mf2yA55g6jA7NW6T2ZkLGgig3NHCmlvR4/IjbnAsNstN3I0JDY9FdK2WwxoYIAu/mBp4pgItxvqkGjnmGv6dQhx9oaSNS+HyGGy2aAspZXufICQJL6xDwNoH1ISq2hl67qoDJggT/84nH13IFjiwuTrDgrjgCsGmIHwBgApXq8ciKTFq1Bkc9RGYYuKWwQ8cSV+/XM59A9X2KeUwNBikV/V8XQVyI8uNhTkAj/iUZNiCoMrP3HW3ebn9x5oGJNEYww7sbbb9QgYjFmvcFDSCQB+1xVTw6hMRpv8jvNklr4Ka0+t0TrhS8oyJdR+DaLsQJBsbKMNQ== X-MS-TrafficTypeDiagnostic: SG2APC01HT014: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3MnzQS3QWMTlC9dq50vW6r7A50aygcWXDr8ENcmJq6FHe4ofwtzEl/CtWQvHBzyTDNZGzAA5+FHMKL9abqC4us1ljHzsIxrqC2hvBbWmj4KBRgHz/+mq2enJ7gwCD88IYTiaF57M9EMWWJgJhRlCFBMUykhVrKpwuCx+ABVZ0kyZzY6VLcOK16WIwdL+/E88 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 13240dbd-2340-4867-bb9a-08d7926cffd0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2020 05:55:14.4496 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2APC01HT014 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.92.253.26 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:244022 Archived-At: --5e12cbbc_235ba861_b145 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline In the test cpp file, there is a =C2=A0=E2=80=9C/*=E2=80=9D at the beginn= ing and no =E2=80=9C*/=E2=80=9C in the file. So all contents of the file = are comment. If it doesn=E2=80=99t parse from the beginning of the file, = how can it known they are comment when the point is at the end of buffer=3F= =E5=9C=A8 2020=E5=B9=B41=E6=9C=886=E6=97=A5 +0800 PM1:33=EF=BC=8CEli Zare= tskii =EF=BC=8C=E5=86=99=E9=81=93=EF=BC=9A > On January 6, 2020 6:39:02 AM GMT+02:00, HaiJun Zhang wrote: > > Could someone explain how the jit-lock in Emacs works in the followin= g > > case=3F > > > > 1. emacs -Q > > 2. open the attachment file and goto end of buffer > > 3. M-x desktop-save and quit emacs > > 4. emacs -Q > > 5. M-x desktop-read > > > > I see the buffer is fontified correctly. Does it parse the whole > > buffer=3F > > > > > > =E5=9C=A8 2020=E5=B9=B41=E6=9C=886=E6=97=A5 +0800 AM11:42=EF=BC=8CEli= Zaretskii =EF=BC=8C=E5=86=99=E9=81=93=EF=BC=9A > > > > =46rom: arthur miller > > > > CC: =22monnier=40iro.umontreal.ca=22 = , > > =22alan=40idiocy.org=22 > > > > , =22emacs-devel=40gnu.org=22 > > > > Date: Sun, 5 Jan 2020 20:28:43 +0000 > > > > > > > > When I said batch-processing I ment processing a file or chunk of= > > buffer (region) just before it is to be > > > > displayed to a user. Same for other =22insertions=22 from macro > > expansions or similar. > > > > > > Then we always do =22batch processing=22, because the display engin= e has > > > no good idea what exactly changed in the buffer. So it always > > > processes some minimal chunk of text that it can prove to itself > > that > > > the changes were all inside that chunk. > > > > > > > I also don't think teee-sitter is needed for syntax coloring. > > Tree-sitter seems to be very expensive regex engine > > > > in that case. > > > > > > They claim to be less expensive than regexp-based coloring, > > especially > > > with very long lines. > > > > > We never parse the whole buffer, only its chunk that is slightly larger= than what would be actually displayed in a window. > > This works by the display engine calling the fontification-functions fo= r the buffer text it is about to display, whenever it finds a chunk of te= xt whose 'fontified' text property is nil. > --5e12cbbc_235ba861_b145 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
In the test cpp file, there is a  =E2=80=9C/*=E2=80= =9D at the beginning and no =E2=80=9C*/=E2=80=9C in the file. So all conten= ts of the file are comment. If it doesn=E2=80=99t parse from the beginning = of the file, how can it known they are comment when the point is at the end= of buffer?

=E5=9C=A8 2020=E5=B9=B41=E6=9C=886=E6=97= =A5 +0800 PM1:33=EF=BC=8CEli Zaretskii <eliz@gnu.org>=EF=BC=8C=E5= =86=99=E9=81=93=EF=BC=9A
On January 6, 2020 6:3= 9:02 AM GMT+02:00, HaiJun Zhang <netjune@outlook.com> wrote:
Could someone explain = how the jit-lock in Emacs works in the following
case?

1. emacs -Q
2. open the attachment file and goto end of buffer
3. M-x desktop-save and quit emacs
4. emacs -Q
5. M-x desktop-read

I see the buffer is fontified correctly. Does it parse the whole
buffer?


=E5=9C=A8 2020=E5=B9=B41=E6=9C=886=E6=97=A5 +0800 AM11:42=EF=BC=8CEli Z= aretskii <eliz@gnu.org>=EF=BC=8C=E5=86=99=E9=81=93=EF=BC=9A
From: arthur miller &l= t;arthur.miller@live.com>
CC: "monnier@iro.umontreal.ca" <monnier@iro.umontreal.ca>,<= br>
"alan@idiocy.org"
<alan@idiocy.org>= ;, "emacs-devel@gnu.org" <emacs-devel@gnu.org>
Date: Sun, 5 Jan 2020 20:28:43 +0000

When I said batch-processing I ment processing a file or chunk of
buffer (region) just before it is to be
displayed to a user. S= ame for other "insertions" from macro
expansions or similar.

Then we always do "batch processing", because the display engine = has
no good idea what exactly changed in the buffer. So it always
processes some minimal chunk of text that it can prove to itself
that
the changes were all i= nside that chunk.

I also don't think tee= e-sitter is needed for syntax coloring.
Tree-sitter seems to be very expensive regex engine
in that case.

They claim to be less expensive than regexp-based coloring,
especially
with very long lines.<= br>

We never parse the whole buffer, only its chunk that is slightly larger tha= n what would be actually displayed in a window.

This works by the display engine calling the fontification-functions for th= e buffer text it is about to display, whenever it finds a chunk of text who= se 'fontified' text property is nil.

--5e12cbbc_235ba861_b145--