unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: arthur miller <arthur.miller@live.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: HaiJun Zhang <netjune@outlook.com>,
	"alan@idiocy.org" <alan@idiocy.org>,
	"monnier@iro.umontreal.ca" <monnier@iro.umontreal.ca>,
	"emacs-devel@gnu.org" <emacs-devel@gnu.org>
Subject: Re: Using incremental parsing in Emacs
Date: Mon, 6 Jan 2020 16:45:51 +0000	[thread overview]
Message-ID: <VI1P194MB0429FDF2153193E359481635963C0@VI1P194MB0429.EURP194.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <5CFA58D6-8A85-4636-AB0E-1548D235D681@gnu.org> (Eli Zaretskii's message of "Mon, 06 Jan 2020 07:33:27 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

> On January 6, 2020 6:39: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?
>> 
>> 
>> 在 2020年1月6日 +0800 AM11:42,Eli Zaretskii <eliz@gnu.org>,写道:
>> > > From: arthur miller <arthur.miller@live.com>
>> > > CC: "monnier@iro.umontreal.ca" <monnier@iro.umontreal.ca>,
>> "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. Same 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 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 for the
> buffer text it is about to display, whenever it finds a chunk of text whose
> 'fontified' text property is nil.

Thanks for the explanation.

Can I ask another related think: if I would to break the buffer
in chunks to send it to different threads, how can I find an
'edge' (in absence of better term) of an expression?

Say I happened to make a split in the middle of a comment, or some
expression, is there already something I can use to figure out
how to adjust split so I break on whole expressions, and not in
the middle?

About tree-sitter, I ment more in terms of RAM, it must cost to keep
all those AST nodes in RAM. In general it will keep entire file as an
AST copy in RAM.

But they are certainly more effective in terms of CPU then regular
expressions since tree-sitter seems to do only minimal work needed
when updating the AST, while regular expressions are more of a brute
force approach.

If you can use tree-sitter for other purposes then just syntax colouring
then tree-sitter might be definitely be a winner.

  parent reply	other threads:[~2020-01-06 16:45 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-03 10:05 Using incremental parsing in Emacs Eli Zaretskii
2020-01-03 13:36 ` phillip.lord
2020-01-03 14:24   ` Eli Zaretskii
2020-01-03 15:43     ` arthur miller
2020-01-03 16:00 ` Dmitry Gutov
2020-01-03 17:09   ` Pankaj Jangid
2020-01-03 19:39 ` Stephen Leake
2020-01-03 20:05   ` Eli Zaretskii
2020-01-03 22:21     ` arthur miller
2020-01-04  3:46       ` HaiJun Zhang
2020-01-04  8:23       ` Eli Zaretskii
2020-01-03 23:53     ` Stephen Leake
2020-01-04  8:45       ` Eli Zaretskii
2020-01-04 14:05         ` arthur miller
2020-01-04 19:26         ` Stephen Leake
2020-01-04 19:54           ` Eli Zaretskii
2020-01-05 17:05             ` Stephen Leake
2020-01-05 19:14               ` yyoncho
2020-01-05 22:44     ` Dmitry Gutov
2020-01-04  3:59 ` HaiJun Zhang
     [not found] ` <41b3e9a0-2866-4692-a35c-6d9541bc3aaa@Spark>
2020-01-04  4:57   ` HaiJun Zhang
2020-01-04  8:55     ` Eli Zaretskii
2020-01-04 12:50       ` VanL
2020-01-04 13:22         ` arthur miller
2020-01-04 23:47         ` Replacing all C code???? Richard Stallman
2020-01-05  3:35           ` VanL
2020-01-05 22:19             ` Richard Stallman
2020-01-05  5:01           ` Stefan Monnier
2020-01-05 16:58             ` Fangrui Song
2020-01-05 22:18             ` Richard Stallman
2020-01-05 22:25               ` Stefan Monnier
2020-01-07  2:34                 ` VanL
2020-01-04 13:30       ` Using incremental parsing in Emacs arthur miller
2020-01-04 13:42         ` Dmitry Gutov
2020-01-04 14:46 ` arthur miller
2020-01-05 14:50   ` Alan Third
2020-01-05 15:16     ` arthur miller
2020-01-05 15:29     ` Eli Zaretskii
2020-01-05 15:31     ` Eli Zaretskii
2020-01-05 17:11     ` Stephen Leake
2020-01-09 21:56   ` Dmitry Gutov
2020-01-10  7:41     ` Eli Zaretskii
2020-01-11  1:41       ` Dmitry Gutov
2020-01-11  7:53         ` Eli Zaretskii
2020-01-11 12:24           ` Dmitry Gutov
2020-01-11 12:29             ` Eli Zaretskii
2020-01-04 20:26 ` Yuan Fu
2020-01-04 20:43 ` Stefan Monnier
2020-01-05 14:19   ` Alan Third
2020-01-05 17:07     ` Stephen Leake
2020-01-05 19:16       ` Alan Third
2020-01-05 17:09     ` Stefan Monnier
2020-01-05 18:22       ` Eli Zaretskii
2020-01-05 19:18         ` Stefan Monnier
2020-01-05 19:36           ` Eli Zaretskii
2020-01-05 20:27             ` Stefan Monnier
2020-01-05 21:12               ` yyoncho
2020-01-05 22:10                 ` Stefan Monnier
2020-01-05 23:08                   ` yyoncho
2020-01-06  3:39                   ` Eli Zaretskii
2020-01-05 19:23         ` arthur miller
2020-01-05 19:40           ` Eli Zaretskii
2020-01-05 20:28             ` arthur miller
2020-01-06  3:42               ` Eli Zaretskii
2020-01-06  4:39                 ` HaiJun Zhang
2020-01-06  5:33                   ` Eli Zaretskii
2020-01-06  5:55                     ` HaiJun Zhang
2020-01-06  6:11                       ` Eli Zaretskii
2020-01-06 16:45                     ` arthur miller [this message]
2020-01-07 16:19                       ` Eli Zaretskii
2020-01-06 13:47                   ` Stefan Monnier
2020-01-06 16:36                     ` HaiJun Zhang
2020-01-06 16:48                     ` arthur miller
2020-01-06 16:14 ` Anand Tamariya
     [not found] <1504933445.581219.1569619792280.ref@mail.yahoo.com>
2019-09-27 21:29 ` Where to place third-party C source code? Jorge Araya Navarro
2019-09-28  6:31   ` Eli Zaretskii
2019-09-28  7:33     ` Jorge Javier Araya Navarro
2019-09-28 12:54       ` Stefan Monnier
2019-12-26 16:52         ` yyoncho
2020-01-04  3:25           ` Using incremental parsing in Emacs HaiJun Zhang
2020-01-04  5:21             ` Tobias Bading
2020-01-04 23:48             ` Richard Stallman
2020-01-05  3:36               ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=VI1P194MB0429FDF2153193E359481635963C0@VI1P194MB0429.EURP194.PROD.OUTLOOK.COM \
    --to=arthur.miller@live.com \
    --cc=alan@idiocy.org \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=netjune@outlook.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).