From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Using incremental parsing in Emacs Date: Mon, 06 Jan 2020 08:47:31 -0500 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="22911"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Eli Zaretskii , alan@idiocy.org, arthur miller , emacs-devel@gnu.org To: HaiJun Zhang Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 06 14:48:19 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 1ioSjw-0005jf-O6 for ged-emacs-devel@m.gmane.org; Mon, 06 Jan 2020 14:48:17 +0100 Original-Received: from localhost ([::1]:52064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioSjv-0007qT-4r for ged-emacs-devel@m.gmane.org; Mon, 06 Jan 2020 08:48:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50241) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ioSjT-0007PS-61 for emacs-devel@gnu.org; Mon, 06 Jan 2020 08:47:48 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ioSjR-0002A5-K8 for emacs-devel@gnu.org; Mon, 06 Jan 2020 08:47:46 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:8041) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ioSjQ-000299-39; Mon, 06 Jan 2020 08:47:44 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B41BE100791; Mon, 6 Jan 2020 08:47:42 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 60C151003B1; Mon, 6 Jan 2020 08:47:41 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1578318461; bh=FqbZANxA3BrO7ep5FJolO7R1toD0PUWSn81O4xyfwUQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=UWNKniHnLi9GxoEdUjTuiyk7kKqMmb4FgCC3m9c+/ug+awHsN8wXPP8Kyh4OR2eSA 1Rf7lM/cUnPU6oHJ0uik1REXU43zhtp8fROIyOzwlgc70FpGIkiT+qKsdKCKVdw6t2 /JZKT8RutlI9l7LaHEieoATZgxz2B3Vwc8kHzPeSlN0ryqacJ7bkuaT6q4vZUgJzCO vv4kmbh1SYWVPl4lR4VC4v4V2i+QWeuBnLTXmxUOXB9aT+nuL5p4ZprWv3vdxMuNhK 7Xtqt7krYij7KZpzj4YZZIzsCt3FFggG/fnh0kQyXmoywnbj8Uf1/8wIcRPM2qNx2z xyOTYqHqih5iw== Original-Received: from pastel (unknown [45.72.147.220]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0631E120B82; Mon, 6 Jan 2020 08:47:41 -0500 (EST) In-Reply-To: (HaiJun Zhang's message of "Mon, 6 Jan 2020 12:39:02 +0800") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 132.204.25.50 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:244029 Archived-At: > I see the buffer is fontified correctly. Does it parse the whole buffer? We have different levels of parsing. At the bottom we have `syntax-ppss` (whose workhorse, implemented in C, is `parse-partial-sexp`) which only counts parentheses and looks for comment and string markers. In the above case, `syntax-ppss` indeed parses the whole buffer, but given its limited scope this parsing is usually fast (it can be slow in some cases, because `parse-partial-sexp` is supplemented by `syntax-propertize-function` to handle the "unusual" cases of "strings/comments" (a typical example would be here-documents in shell scripts) and this is all implemented in Elisp using regexp searches). After this parsing is done, font-lock looks at the few lines actually displayed using its Elisp/regexps rules to apply the actual highlighting. This may look at more parts of the buffer, tho, depending on the actual font-lock rules. Stefan